diff options
author | Krifa75 <yahiaoui.fakhri@gmail.com> | 2021-06-30 18:48:19 +0200 |
---|---|---|
committer | Krifa75 <yahiaoui.fakhri@gmail.com> | 2021-06-30 18:48:19 +0200 |
commit | b7f432fc3ec236ab12c0fbed0ff3036005a5358f (patch) | |
tree | d68645ab0c8181770cca2a991c1ed2647f544cc0 /src | |
parent | 9ac82192623dc7688506fdbe4417831ece33803c (diff) | |
download | gnome-contacts-b7f432fc3ec236ab12c0fbed0ff3036005a5358f.tar.gz |
Scroll to contact when adding/updating contact
Diffstat (limited to 'src')
-rw-r--r-- | src/contacts-contact-list.vala | 19 | ||||
-rw-r--r-- | src/contacts-list-pane.vala | 4 | ||||
-rw-r--r-- | src/contacts-main-window.vala | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala index 63d90e4..3ac0c70 100644 --- a/src/contacts-contact-list.vala +++ b/src/contacts-contact-list.vala @@ -287,7 +287,24 @@ public class Contacts.ContactList : Gtk.ListBox { return; } - select_row (find_row_for_contact (individual)); + ContactDataRow? row = find_row_for_contact (individual); + select_row (row); + scroll_to_contact (row); + } + + public void scroll_to_contact (Gtk.ListBoxRow? row = null) { + unowned ContactDataRow? selected_row = null; + + if (row == null) + selected_row = get_selected_row () as ContactDataRow; + else + selected_row = row as ContactDataRow; + + GLib.Timeout.add (100, () => { + if (selected_row != null) + selected_row.grab_focus (); + return GLib.Source.REMOVE; + }); } public void hide_contact (Individual? individual) { diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala index 1cf62d5..5439b36 100644 --- a/src/contacts-list-pane.vala +++ b/src/contacts-list-pane.vala @@ -94,6 +94,10 @@ public class Contacts.ListPane : Gtk.Frame { this.contacts_list.select_contact (individual); } + public void scroll_to_contact () { + this.contacts_list.scroll_to_contact (); + } + public void hide_contact (Individual? individual) { this.contacts_list.hide_contact (individual); } diff --git a/src/contacts-main-window.vala b/src/contacts-main-window.vala index f8a46d6..486c16a 100644 --- a/src/contacts-main-window.vala +++ b/src/contacts-main-window.vala @@ -338,6 +338,7 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow { this.state = UiState.SHOWING; } this.contact_pane.stop_editing (cancel); + this.list_pane.scroll_to_contact (); if (this.contact_pane.individual != null) { this.right_header.title = this.contact_pane.individual.display_name; |