summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2018-01-21 11:23:12 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2018-01-21 11:23:12 +0100
commitf36cc8e5fa1b867fe3181f6cf30505fdfedfce56 (patch)
tree307cb01d9a0600d81cfab4664436a420818315aa
parent2a101835a127b1722fb37b022249f4f26c5e1af1 (diff)
downloadgnome-contacts-f36cc8e5fa1b867fe3181f6cf30505fdfedfce56.tar.gz
ContactList: only show checkbox on hover.
* Removed the select_button in ContactWindow (as selection_mode is implicitly started by selecting a checkbox). * Updated the cancel_select_button with a new icon (complying with the new mockups).
-rw-r--r--data/ui/contacts-window.ui23
-rw-r--r--src/contacts-contact-list.vala51
-rw-r--r--src/contacts-window.vala4
3 files changed, 41 insertions, 37 deletions
diff --git a/data/ui/contacts-window.ui b/data/ui/contacts-window.ui
index 2294701..7571709 100644
--- a/data/ui/contacts-window.ui
+++ b/data/ui/contacts-window.ui
@@ -53,20 +53,16 @@
</packing>
</child>
<child>
- <object class="GtkButton" id="select_button">
- <property name="visible">True</property>
+ <object class="GtkButton" id="select_cancel_button">
+ <property name="visible">False</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="select_button_atkobject">
- <property name="AtkObject::accessible-name" translatable="yes">Selection mode</property>
- </object>
- </child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">object-select-symbolic</property>
+ <property name="icon_name">edit-clear-symbolic</property>
+ <property name="icon_size">1</property>
</object>
</child>
</object>
@@ -74,17 +70,6 @@
<property name="pack_type">end</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="select_cancel_button">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="focus_on_click">False</property>
- <property name="label" translatable="yes">Cancel</property>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
</object>
</child>
<child>
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index 80cf036..99efa95 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -32,6 +32,8 @@ public class Contacts.ContactList : ListBox {
public Label label;
private Avatar avatar;
public CheckButton selector_button;
+ // Whether the selector should always be visible (or only on hover)
+ private bool checkbox_exposed = false;
public bool filtered;
public ContactDataRow(Contact c) {
@@ -69,6 +71,22 @@ public class Contacts.ContactList : ListBox {
this.label.set_text (this.contact.display_name);
this.avatar.set_image.begin (this.contact.individual, this.contact);
}
+
+ // Sets whether the checbox should always be shown (and not only on hover)
+ public void expose_checkbox (bool expose) {
+ this.checkbox_exposed = expose;
+ this.selector_button.visible = expose;
+ }
+
+ // Normally, we would use the (enter/leave)_notify_event here, but since ListBoxRow
+ // doesn't have its own Gdk.Window, this won't work (at least in GTK+3).
+ public override void state_flags_changed (StateFlags previous_state) {
+ var hovering_now = StateFlags.PRELIGHT in get_state_flags ();
+ var was_hovering = StateFlags.PRELIGHT in previous_state;
+
+ if (hovering_now != was_hovering) // If hovering changed
+ this.selector_button.visible = checkbox_exposed || hovering_now;
+ }
}
public signal void selection_changed (Contact? contact);
@@ -107,7 +125,7 @@ public class Contacts.ContactList : ListBox {
private void on_ui_state_changed () {
foreach (var widget in get_children ()) {
var row = widget as ContactDataRow;
- row.selector_button.visible = (this.state == UiState.SELECTING);
+ row.expose_checkbox (this.state == UiState.SELECTING);
if (this.state != UiState.SELECTING)
row.selector_button.active = false;
@@ -211,23 +229,28 @@ public class Contacts.ContactList : ListBox {
}
private void contact_added_cb (Store store, Contact c) {
- var data = new ContactDataRow(c);
+ var row = new ContactDataRow(c);
+ row.update_data (calculate_filtered (c));
+ row.selector_button.toggled.connect ( () => { on_row_checkbox_toggled (row); });
+ row.selector_button.visible = (this.state == UiState.SELECTING);
- data.update_data (calculate_filtered (c));
+ contacts[c] = row;
+ add (row);
+ }
- data.selector_button.toggled.connect (() => {
- if (data.selector_button.active)
- this.nr_contacts_marked++;
- else
- this.nr_contacts_marked--;
+ private void on_row_checkbox_toggled (ContactDataRow row) {
+ this.nr_contacts_marked += (row.selector_button.active)? 1 : -1;
- contacts_marked (this.nr_contacts_marked);
- });
+ // User selected a first checkbox: enter selection mode
+ if (row.selector_button.active && this.nr_contacts_marked == 1)
+ this.state = UiState.SELECTING;
- if (this.state != UiState.SELECTING)
- data.selector_button.hide ();
- contacts.set (c, data);
- this.add (data);
+
+ // User deselected the last checkbox: leave selection mode
+ if (!row.selector_button.active && this.nr_contacts_marked == 0)
+ this.state = UiState.SHOWING;
+
+ contacts_marked (this.nr_contacts_marked);
}
private void contact_removed_cb (Store store, Contact c) {
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 2b842b8..25ce666 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -38,8 +38,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
[GtkChild]
private Button add_button;
[GtkChild]
- private Button select_button;
- [GtkChild]
private Button select_cancel_button;
[GtkChild]
private ToggleButton favorite_button;
@@ -120,7 +118,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
// UI when we're not editing of selecting stuff
this.add_button.visible
= this.right_header.show_close_button
- = this.select_button.visible
= (this.state == UiState.NORMAL || this.state == UiState.SHOWING);
// UI when showing a contact
@@ -242,7 +239,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
}
private void connect_button_signals () {
- this.select_button.clicked.connect (() => { this.state = UiState.SELECTING; });
this.select_cancel_button.clicked.connect (() => { this.state = UiState.NORMAL; });
this.done_button.clicked.connect (() => stop_editing ());
this.cancel_button.clicked.connect (() => stop_editing (true));