[gnome-contacts] contact-list: Rework and simplify scroll_to_contact()
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] contact-list: Rework and simplify scroll_to_contact()
- Date: Sun, 17 Apr 2022 06:29:50 +0000 (UTC)
commit 7d1b553a39f2bffe2bed281876169504ac9819d6
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Apr 17 08:28:55 2022 +0200
contact-list: Rework and simplify scroll_to_contact()
We're only using this method to scroll to the selected contact, so
remove the optional argument and rename for clarity.
src/contacts-contact-list.vala | 11 ++++-------
src/contacts-main-window.vala | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index fe27a73e..45129980 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -146,16 +146,13 @@ public class Contacts.ContactList : Adw.Bin {
}
}
- public void scroll_to_contact (Gtk.ListBoxRow? row = null) {
- unowned ContactDataRow? selected_row = null;
+ public void scroll_to_selected () {
+ unowned var row = this.listbox.get_selected_row ();
if (row == null)
- selected_row = (ContactDataRow?) this.listbox.get_selected_row ();
- else
- selected_row = (ContactDataRow) row;
+ return;
GLib.Timeout.add (100, () => {
- if (selected_row != null)
- selected_row.grab_focus ();
+ row.grab_focus ();
return GLib.Source.REMOVE;
});
}
diff --git a/src/contacts-main-window.vala b/src/contacts-main-window.vala
index 89cbe3f3..14126c31 100644
--- a/src/contacts-main-window.vala
+++ b/src/contacts-main-window.vala
@@ -339,7 +339,7 @@ public class Contacts.MainWindow : Adw.ApplicationWindow {
this.state = UiState.SHOWING;
}
this.contact_pane.stop_editing (cancel);
- this.contacts_list.scroll_to_contact ();
+ this.contacts_list.scroll_to_selected ();
this.right_header.title_widget = new Adw.WindowTitle ("", "");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]