[gnome-contacts] Added link operation to selection-mode.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Added link operation to selection-mode.
- Date: Thu, 14 Feb 2013 14:15:04 +0000 (UTC)
commit 325fd8feb1e6b78f189483feeb4fc937a5758479
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Thu Feb 14 00:01:35 2013 -0500
Added link operation to selection-mode.
No unlink on [Undo] yet.
I will keep the old link implementation for this cycle at least.
It's necessary to improve link/unlink behavior for the next cycle,
make it more robust. I'm thinking even at folks level.
src/contacts-app.vala | 38 ++++++++++++++++++++++++++++++++++----
src/contacts-linking.vala | 15 +++++++++++++++
src/contacts-list-pane.vala | 8 ++++++++
3 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 9ef674a..71232c4 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -339,6 +339,7 @@ public class Contacts.App : Gtk.Application {
list_pane = new ListPane (contacts_store);
list_pane.selection_changed.connect (selection_changed);
+ list_pane.link_contacts.connect (link_contacts);
list_pane.delete_contacts.connect (delete_contacts);
grid.attach (list_pane, 0, 1, 1, 1);
@@ -465,7 +466,36 @@ public class Contacts.App : Gtk.Application {
dialog.show_all ();
}
- private void delete_contacts (LinkedList<Contact> contacts_list) {
+ private void link_contacts (LinkedList<Contact> contact_list) {
+ /* getting out of selection mode */
+ show_contact (null);
+ select_button.set_active (false);
+
+ link_contacts_list.begin (contact_list, (obj, result) => {
+ link_contacts_list.end (result);
+ });
+
+ var notification = new Gd.Notification ();
+
+ var g = new Grid ();
+ g.set_column_spacing (8);
+ notification.add (g);
+
+ string msg = _("%d contact%s linked").printf (contact_list.size, contact_list.size > 1 ? "s" : "");
+ 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 */
+ b.clicked.connect ( () => {
+ /* here, we will unlink the thing in question */
+ });
+ }
+
+ private void delete_contacts (LinkedList<Contact> contact_list) {
/* getting out of selection mode */
show_contact (null);
select_button.set_active (false);
@@ -476,7 +506,7 @@ public class Contacts.App : Gtk.Application {
g.set_column_spacing (8);
notification.add (g);
- string msg = _("%d contacts deleted").printf (contacts_list.size);
+ string msg = _("%d contact%s deleted").printf (contact_list.size, contact_list.size > 1 ? "s" : "");
var b = new Button.from_stock (Stock.UNDO);
g.add (new Label (msg));
g.add (b);
@@ -488,7 +518,7 @@ public class Contacts.App : Gtk.Application {
bool really_delete = true;
notification.dismissed.connect ( () => {
if (really_delete) {
- foreach (var c in contacts_list) {
+ foreach (var c in contact_list) {
c.remove_personas.begin ();
}
}
@@ -496,7 +526,7 @@ public class Contacts.App : Gtk.Application {
b.clicked.connect ( () => {
really_delete = false;
notification.dismiss ();
- foreach (var c in contacts_list) {
+ foreach (var c in contact_list) {
c.show ();
}
});
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index 8bb310b..4f210a2 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -713,4 +713,19 @@ namespace Contacts {
return operation;
}
+
+ public class LinkOperation2 : Object {
+ }
+
+ public async LinkOperation2 link_contacts_list (LinkedList<Contact> contact_list) {
+ var operation = new LinkOperation2 ();
+
+ var all_personas = new HashSet<Persona> ();
+ foreach (var c in contact_list) {
+ all_personas.add_all (c.individual.personas);
+ }
+
+ yield App.app.contacts_store.aggregator.link_personas (all_personas);
+ return operation;
+ }
}
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index 3c65788..abb330c 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -32,6 +32,8 @@ public class Contacts.ListPane : Frame {
private bool search_visible;
public signal void selection_changed (Contact? contact);
+
+ public signal void link_contacts (LinkedList<Contact> contacts_list);
public signal void delete_contacts (LinkedList<Contact> contacts_list);
private void refilter () {
@@ -155,6 +157,12 @@ public class Contacts.ListPane : Frame {
link_selected_button.set_sensitive (false);
});
+ link_selected_button.clicked.connect (() => {
+ var marked_contacts = contacts_view.get_marked_contacts ();
+
+ link_contacts (marked_contacts);
+ });
+
delete_selected_button.clicked.connect (() => {
var marked_contacts = contacts_view.get_marked_contacts ();
foreach (var c in marked_contacts) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]