[gnome-contacts] Hooked ::delete_contacts signal.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Hooked ::delete_contacts signal.
- Date: Thu, 7 Feb 2013 13:10:06 +0000 (UTC)
commit be78782626bb1aac6d4de108be59b585438c18df
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Tue Feb 5 11:44:46 2013 -0500
Hooked ::delete_contacts signal.
Added notification for undo support.
Fixed ::select_contact method on Contacts.ListPane and
Contacts.View for getting null parameter.
src/contacts-app.vala | 39 +++++++++++++++++++++++++++++++++++++++
src/contacts-list-pane.vala | 6 +++---
src/contacts-view.vala | 8 +++++++-
3 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 0ec71ec..9a63483 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+using Gee;
using Gtk;
using Folks;
@@ -338,6 +339,7 @@ public class Contacts.App : Gtk.Application {
list_pane = new ListPane (contacts_store);
list_pane.selection_changed.connect (selection_changed);
+ list_pane.delete_contacts.connect (delete_contacts);
grid.attach (list_pane, 0, 1, 1, 1);
@@ -463,6 +465,43 @@ public class Contacts.App : Gtk.Application {
dialog.show_all ();
}
+ private void delete_contacts (LinkedList<Contact> contacts_list) {
+ /* getting out of selection mode */
+ show_contact (null);
+ select_button.set_active (false);
+
+ var notification = new Gd.Notification ();
+
+ var g = new Grid ();
+ g.set_column_spacing (8);
+ notification.add (g);
+
+ string msg = _("%d contacts deleted").printf (contacts_list.size);
+ var b = new Button.from_stock (Stock.UNDO);
+ g.add (new Label (msg));
+ g.add (b);
+
+ notification.show_all ();
+ overlay.add_overlay (notification);
+
+ /* signal handlers */
+ bool really_delete = true;
+ notification.dismissed.connect ( () => {
+ if (really_delete) {
+ foreach (var c in contacts_list) {
+ c.remove_personas.begin ();
+ }
+ }
+ });
+ b.clicked.connect ( () => {
+ really_delete = false;
+ notification.dismiss ();
+ foreach (var c in contacts_list) {
+ c.show ();
+ }
+ });
+ }
+
private void delete_contact (Contact contact) {
/* unsetting edit-mode */
contact_name.set_text (null);
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index f01364b..3c65788 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -111,8 +111,8 @@ public class Contacts.ListPane : Frame {
this.add (grid);
contacts_view.selection_changed.connect( (l, contact) => {
- if (!ignore_selection_change)
- selection_changed (contact);
+ if (!ignore_selection_change)
+ selection_changed (contact);
});
contacts_view.add_to_scrolled (scrolled);
@@ -165,7 +165,7 @@ public class Contacts.ListPane : Frame {
});
}
- public void select_contact (Contact contact, bool ignore_change = false) {
+ public void select_contact (Contact? contact, bool ignore_change = false) {
if (ignore_change)
ignore_selection_change = true;
contacts_view.select_contact (contact);
diff --git a/src/contacts-view.vala b/src/contacts-view.vala
index 211078d..a4f842e 100644
--- a/src/contacts-view.vala
+++ b/src/contacts-view.vala
@@ -330,7 +330,13 @@ public class Contacts.View : Egg.ListBox {
separator = null;
}
- public void select_contact (Contact contact) {
+ public void select_contact (Contact? contact) {
+ if (contact == null) {
+ /* deselect */
+ select_child (null);
+ return;
+ }
+
var data = contacts.get (contact);
select_child (data.grid);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]