[gnome-contacts] ContactsWindow: use a Cancel button when selecting.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ContactsWindow: use a Cancel button when selecting.
- Date: Sat, 23 Dec 2017 10:33:39 +0000 (UTC)
commit 8b900d405355840af54535eddbabbf0e17ee5303
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sat Dec 23 11:19:46 2017 +0100
ContactsWindow: use a Cancel button when selecting.
See [bug 764179](https://bugzilla.gnome.org/show_bug.cgi?id=764179).
data/ui/contacts-window.ui | 19 ++++++++++++-------
src/contacts-window.vala | 40 ++++++++++++++++------------------------
2 files changed, 28 insertions(+), 31 deletions(-)
---
diff --git a/data/ui/contacts-window.ui b/data/ui/contacts-window.ui
index a799d8d..30432a8 100644
--- a/data/ui/contacts-window.ui
+++ b/data/ui/contacts-window.ui
@@ -176,26 +176,20 @@
</packing>
</child>
<child>
- <object class="GtkToggleButton" id="select_button">
+ <object class="GtkButton" id="select_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
<child internal-child="accessible">
<object class="AtkObject" id="select_button_atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Selection mode</property>
</object>
</child>
- <style>
- <class name="image-button"/>
- </style>
<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_size">1</property>
</object>
</child>
</object>
@@ -203,6 +197,17 @@
<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-window.vala b/src/contacts-window.vala
index 4076e96..9d103e6 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -38,7 +38,9 @@ public class Contacts.Window : Gtk.ApplicationWindow {
[GtkChild]
private Button add_button;
[GtkChild]
- private ToggleButton select_button;
+ private Button select_button;
+ [GtkChild]
+ private Button select_cancel_button;
[GtkChild]
private Button edit_button;
[GtkChild]
@@ -235,9 +237,11 @@ public class Contacts.Window : Gtk.ApplicationWindow {
}
public void activate_selection_mode (bool active) {
- if (active) {
- selection_mode = true;
+ this.selection_mode = active;
+ this.select_button.visible = !active;
+ this.select_cancel_button.visible = active;
+ if (active) {
left_toolbar.get_style_context ().add_class ("selection-mode");
right_toolbar.get_style_context ().add_class ("selection-mode");
@@ -245,8 +249,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
list_pane.show_selection ();
} else {
- selection_mode = false;
-
left_toolbar.get_style_context ().remove_class ("selection-mode");
right_toolbar.get_style_context ().remove_class ("selection-mode");
@@ -322,7 +324,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
else
right_title = "";
- edit_button.visible = (c != null) && !select_button.active;
+ edit_button.visible = (c != null) && !this.selection_mode;
}
[GtkCallback]
@@ -358,21 +360,11 @@ public class Contacts.Window : Gtk.ApplicationWindow {
left_toolbar.decoration_layout = tokens[0];
}
- select_button.toggled.connect (() => {
- activate_selection_mode (select_button.active);
- });
-
- edit_button.clicked.connect (() => {
- enter_edit_mode ();
- });
-
- done_button.clicked.connect (() => {
- leave_edit_mode ();
- });
-
- cancel_button.clicked.connect (() => {
- leave_edit_mode (true);
- });
+ this.select_button.clicked.connect (() => activate_selection_mode (true));
+ this.select_cancel_button.clicked.connect (() => activate_selection_mode (false));
+ this.edit_button.clicked.connect (() => enter_edit_mode ());
+ this.done_button.clicked.connect (() => leave_edit_mode ());
+ this.cancel_button.clicked.connect (() => leave_edit_mode (true));
}
[GtkCallback]
@@ -414,7 +406,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
void list_pane_link_contacts_cb (LinkedList<Contact> contact_list) {
/* getting out of selection mode */
set_shown_contact (null);
- select_button.set_active (false);
+ activate_selection_mode (false);
LinkOperation2 operation = null;
link_contacts_list.begin (contact_list, this.store, (obj, result) => {
@@ -441,7 +433,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
void list_pane_delete_contacts_cb (LinkedList<Contact> contact_list) {
/* getting out of selection mode */
set_shown_contact (null);
- select_button.set_active (false);
+ activate_selection_mode (false);
string msg = ngettext ("%d contact deleted",
"%d contacts deleted",
@@ -474,7 +466,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
private void contact_pane_delete_contact_cb (Contact contact) {
/* unsetting edit-mode */
set_shown_contact (null);
- this.select_button.active = false;
+ activate_selection_mode (false);
var msg = _("Contact deleted: ā%sā").printf (contact.display_name);
var b = new Button.with_mnemonic (_("_Undo"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]