[gnome-contacts] contact-list: Add longpress gesture for selecting contacts
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] contact-list: Add longpress gesture for selecting contacts
- Date: Sun, 17 Jan 2021 17:51:27 +0000 (UTC)
commit 1e30e5b82a8e5d10862a116a869271edd10a1f4a
Author: Julian Sparber <julian sparber net>
Date: Wed Jul 24 11:25:31 2019 +0200
contact-list: Add longpress gesture for selecting contacts
src/contacts-contact-list.vala | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index 07103af2..8bc9c76c 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -103,6 +103,9 @@ public class Contacts.ContactList : Gtk.ListBox {
private bool sort_on_surname = false; // keep in sync with the setting
+ private Gtk.GestureLongPress long_press;
+ private bool got_long_press = false;
+
public UiState state { get; set; }
public ContactList (Settings settings, Store store, Query query) {
@@ -114,6 +117,16 @@ public class Contacts.ContactList : Gtk.ListBox {
this.notify["state"].connect (on_ui_state_changed);
+ // Connect long press gesture
+ this.long_press = new Gtk.GestureLongPress (this);
+ this.long_press.pressed.connect ((g, x, y) => {
+ this.got_long_press = true;
+ var row = (ContactDataRow) get_row_at_y ((int) Math.round (y));
+ if (row != null) {
+ row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
+ }
+ });
+
this.sort_on_surname = settings.sort_on_surname;
settings.changed["sort-on-surname"].connect(() => {
this.sort_on_surname = settings.sort_on_surname;
@@ -235,14 +248,26 @@ public class Contacts.ContactList : Gtk.ListBox {
row.destroy ();
}
+ public override void row_activated (Gtk.ListBoxRow row) {
+ if (!this.got_long_press) {
+ var data = row as ContactDataRow;
+ if (data != null && this.state == UiState.SELECTING)
+ data.selector_button.active = !data.selector_button.active;
+ } else {
+ this.got_long_press = false;
+ }
+ }
+
public override void row_selected (Gtk.ListBoxRow? row) {
- var data = (ContactDataRow?) row as ContactDataRow;
- var individual = data != null ? data.individual : null;
- selection_changed (individual);
+ if (this.state != UiState.SELECTING) {
+ var data = row as ContactDataRow;
+ var individual = data != null ? data.individual : null;
+ selection_changed (individual);
#if HAVE_TELEPATHY
- if (individual != null)
- Utils.fetch_contact_info (individual);
+ if (individual != null)
+ Contact.fetch_contact_info (individual);
#endif
+ }
}
private bool filter_row (Gtk.ListBoxRow row) {
@@ -306,7 +331,6 @@ public class Contacts.ContactList : Gtk.ListBox {
if (event.button == Gdk.BUTTON_SECONDARY) {
unowned var row = (ContactDataRow) get_row_at_y ((int) Math.round (event.y));
if (row != null) {
- select_row (row);
row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]