[gnome-contacts] ContactList: use and sync the UiState.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ContactList: use and sync the UiState.
- Date: Sun, 21 Jan 2018 09:27:23 +0000 (UTC)
commit 2a101835a127b1722fb37b022249f4f26c5e1af1
Author: Niels De Graef <nielsdegraef gmail com>
Date: Wed Jan 17 15:12:58 2018 +0100
ContactList: use and sync the UiState.
src/contacts-contact-list.vala | 38 ++++++++++++++++++--------------------
src/contacts-list-pane.vala | 6 +-----
src/contacts-window.vala | 4 ++--
3 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index d692b2c..80cf036 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -78,14 +78,17 @@ public class Contacts.ContactList : ListBox {
int nr_contacts_marked = 0;
string []? filter_values;
- bool selectors_visible = false;
private Store store;
+ public UiState state { get; set; }
+
public ContactList (Store store) {
this.selection_mode = Gtk.SelectionMode.BROWSE;
this.store = store;
+ this.notify["state"].connect ( () => { on_ui_state_changed(); });
+
this.store.added.connect (contact_added_cb);
this.store.removed.connect (contact_removed_cb);
this.store.changed.connect (contact_changed_cb);
@@ -101,6 +104,19 @@ public class Contacts.ContactList : ListBox {
show ();
}
+ 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);
+
+ if (this.state != UiState.SELECTING)
+ row.selector_button.active = false;
+ }
+
+ if (this.state != UiState.SELECTING)
+ this.nr_contacts_marked = 0;
+ }
+
private int compare_data (ContactDataRow a_data, ContactDataRow b_data) {
var a = a_data.contact.individual;
var b = b_data.contact.individual;
@@ -208,7 +224,7 @@ public class Contacts.ContactList : ListBox {
contacts_marked (this.nr_contacts_marked);
});
- if (! selectors_visible)
+ if (this.state != UiState.SELECTING)
data.selector_button.hide ();
contacts.set (c, data);
this.add (data);
@@ -246,24 +262,6 @@ public class Contacts.ContactList : ListBox {
select_row (data);
}
- public void show_selectors () {
- foreach (var widget in get_children ()) {
- var row = widget as ContactDataRow;
- row.selector_button.show ();
- }
- selectors_visible = true;
- }
-
- public void hide_selectors () {
- foreach (var widget in get_children ()) {
- var row = widget as ContactDataRow;
- row.selector_button.hide ();
- row.selector_button.set_active (false);
- }
- selectors_visible = false;
- nr_contacts_marked = 0;
- }
-
public LinkedList<Contact> get_marked_contacts () {
var cs = new LinkedList<Contact> ();
foreach (var widget in get_children ()) {
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index 333c1dd..59582a9 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -54,6 +54,7 @@ public class Contacts.ListPane : Frame {
// Load the ContactsView and connect the necessary signals
this.contacts_list = new ContactList (contacts_store);
+ bind_property ("state", this.contacts_list, "state", BindingFlags.BIDIRECTIONAL |
BindingFlags.SYNC_CREATE);
this.contacts_list_container.add (this.contacts_list);
this.contacts_list.selection_changed.connect( (l, contact) => {
@@ -73,11 +74,6 @@ public class Contacts.ListPane : Frame {
= this.contacts_list.sensitive
= !this.state.editing ();
- if (this.state == UiState.SELECTING)
- this.contacts_list.show_selectors ();
- else
- this.contacts_list.hide_selectors ();
-
this.actions_bar.visible = (this.state == UiState.SELECTING);
}
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index b0372b3..2b842b8 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -126,12 +126,12 @@ public class Contacts.Window : Gtk.ApplicationWindow {
// UI when showing a contact
this.edit_button.visible
= this.favorite_button.visible
- = (new_state == UiState.SHOWING);
+ = (this.state == UiState.SHOWING);
// Selecting UI
this.select_cancel_button.visible = (this.state == UiState.SELECTING);
- this.left_header.title = (new_state == UiState.SELECTING)? _("Select") : _("Contacts");
+ this.left_header.title = (this.state == UiState.SELECTING)? _("Select") : _("Contacts");
// Editing UI
this.cancel_button.visible
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]