[gnome-contacts] Window: ContactPane instance made internal widget
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Window: ContactPane instance made internal widget
- Date: Thu, 29 May 2014 20:26:05 +0000 (UTC)
commit c43a56e97c09aef8c321efc0a8b1126e5689f843
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Sat Apr 26 15:43:53 2014 -0400
Window: ContactPane instance made internal widget
Instance renamed to contact_pane
src/contacts-app.vala | 68 -----------------------------------
src/contacts-window.ui | 4 ++-
src/contacts-window.vala | 89 +++++++++++++++++++++++++++++++++++++++-------
3 files changed, 79 insertions(+), 82 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 3f0beba..0dd5968 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -30,8 +30,6 @@ public class Contacts.App : Gtk.Application {
public Contacts.Window window;
- private weak ContactPane contacts_pane;
-
private bool app_menu_created;
public void show_contact (Contact? contact) {
@@ -186,11 +184,6 @@ public class Contacts.App : Gtk.Application {
contacts_store = window.contacts_store;
- contacts_pane = window.contacts_pane;
-
- contacts_pane.will_delete.connect (delete_contact);
- contacts_pane.contacts_linked.connect (contacts_linked);
-
window.add_button.clicked.connect (app.new_contact);
}
@@ -284,41 +277,6 @@ public class Contacts.App : Gtk.Application {
dialog.show_all ();
}
- private void delete_contact (Contact contact) {
- /* unsetting edit-mode */
- window.set_shown_contact (null);
-
- var notification = new Gd.Notification ();
- notification.timeout = 5;
-
- var g = new Grid ();
- g.set_column_spacing (8);
- notification.add (g);
-
- var label = new Label (_("Contact deleted: \"%s\"").printf (contact.display_name));
- label.set_max_width_chars (45);
- label.set_ellipsize (Pango.EllipsizeMode.END);
- var b = new Button.with_mnemonic (_("_Undo"));
- g.add (label);
- g.add (b);
-
- bool really_delete = true;
- notification.show_all ();
- notification.dismissed.connect ( () => {
- if (really_delete)
- contact.remove_personas.begin ( () => {
- contact.show ();
- });
- });
- b.clicked.connect ( () => {
- really_delete = false;
- notification.dismiss ();
- contact.show ();
- show_contact (contact);
- });
- window.add_notification (notification);
- }
-
private static string individual_id = null;
private static string email_address = null;
private static const OptionEntry[] options = {
@@ -329,32 +287,6 @@ public class Contacts.App : Gtk.Application {
{ null }
};
- private void contacts_linked (string? main_contact, string linked_contact, LinkOperation operation) {
- var notification = new Gd.Notification ();
- notification.timeout = 5;
-
- var g = new Grid ();
- g.set_column_spacing (8);
- notification.add (g);
-
- string msg;
- if (main_contact != null)
- msg = _("%s linked to %s").printf (main_contact, linked_contact);
- else
- msg = _("%s linked to the contact").printf (linked_contact);
-
- var b = new Button.with_mnemonic (_("_Undo"));
- g.add (new Label (msg));
- g.add (b);
-
- notification.show_all ();
- b.clicked.connect ( () => {
- notification.dismiss ();
- operation.undo.begin ();
- });
- window.add_notification (notification);
- }
-
public override int command_line (ApplicationCommandLine command_line) {
var args = command_line.get_arguments ();
unowned string[] _args = args;
diff --git a/src/contacts-window.ui b/src/contacts-window.ui
index 7ee6039..772a368 100644
--- a/src/contacts-window.ui
+++ b/src/contacts-window.ui
@@ -140,11 +140,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="ContactsContactPane" id="contacts_pane">
+ <object class="ContactsContactPane" id="contact_pane">
<property name="store">contacts_store</property>
<property name="show_tabs">False</property>
<property name="visible">True</property>
<property name="hexpand">True</property>
+ <signal name="will-delete" handler="contact_pane_delete_contact_cb"
object="ContactsWindow" after="no" swapped="no"/>
+ <signal name="contacts-linked" handler="contact_pane_contacts_linked_cb"
object="ContactsWindow" after="no" swapped="no"/>
</object>
</child>
</object>
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 3f16c48..bf8c62a 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -31,6 +31,8 @@ public class Contacts.Window : Gtk.ApplicationWindow {
[GtkChild]
private ListPane list_pane;
[GtkChild]
+ private ContactPane contact_pane;
+ [GtkChild]
private Button edit_button;
[GtkChild]
private Button done_button;
@@ -38,8 +40,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
[GtkChild]
public Store contacts_store;
- [GtkChild]
- public ContactPane contacts_pane;
/* FIXME: remove from public what it is not needed */
[GtkChild]
@@ -105,14 +105,14 @@ public class Contacts.Window : Gtk.ApplicationWindow {
public void set_shown_contact (Contact? c) {
/* FIXME: ask the user to leave edit-mode and act accordingly */
- if (contacts_pane.on_edit_mode) {
- contacts_pane.set_edit_mode (false);
+ if (contact_pane.on_edit_mode) {
+ contact_pane.set_edit_mode (false);
right_title = "";
}
done_button.hide ();
- contacts_pane.show_contact (c, false);
+ contact_pane.show_contact (c, false);
/* clearing right_toolbar */
if (c != null) {
@@ -147,27 +147,27 @@ public class Contacts.Window : Gtk.ApplicationWindow {
});
edit_button.clicked.connect (() => {
- if (contacts_pane.contact == null)
+ if (contact_pane.contact == null)
return;
if (select_button.active)
select_button.set_active (false);
- var name = contacts_pane.contact.display_name;
+ var name = contact_pane.contact.display_name;
right_title = _("Editing %s").printf (name);
edit_button.hide ();
done_button.show ();
- contacts_pane.set_edit_mode (true);
+ contact_pane.set_edit_mode (true);
});
done_button.clicked.connect (() => {
done_button.hide ();
edit_button.show ();
- contacts_pane.set_edit_mode (false);
+ contact_pane.set_edit_mode (false);
- if (contacts_pane.contact != null) {
- right_title = contacts_pane.contact.display_name;
+ if (contact_pane.contact != null) {
+ right_title = contact_pane.contact.display_name;
}
});
}
@@ -177,7 +177,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
if ((event.keyval == Gdk.keyval_from_name ("q")) &&
((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
// Clear the contacts so any changed information is stored
- contacts_pane.show_contact (null);
+ contact_pane.show_contact (null);
destroy ();
} else if (((event.keyval == Gdk.Key.s) ||
(event.keyval == Gdk.Key.f)) &&
@@ -200,7 +200,7 @@ public class Contacts.Window : Gtk.ApplicationWindow {
[GtkCallback]
bool delete_event_cb (Gdk.EventAny event) {
// Clear the contacts so any changed information is stored
- contacts_pane.show_contact (null);
+ contact_pane.show_contact (null);
return false;
}
@@ -289,4 +289,67 @@ public class Contacts.Window : Gtk.ApplicationWindow {
set_shown_contact (contact_list.last ());
});
}
+
+ [GtkCallback]
+ void contact_pane_delete_contact_cb (Contact contact) {
+ /* unsetting edit-mode */
+ set_shown_contact (null);
+
+ var notification = new Gd.Notification ();
+ notification.timeout = 5;
+
+ var g = new Grid ();
+ g.set_column_spacing (8);
+ notification.add (g);
+
+ var label = new Label (_("Contact deleted: \"%s\"").printf (contact.display_name));
+ label.set_max_width_chars (45);
+ label.set_ellipsize (Pango.EllipsizeMode.END);
+ var b = new Button.with_mnemonic (_("_Undo"));
+ g.add (label);
+ g.add (b);
+
+ bool really_delete = true;
+ notification.show_all ();
+ notification.dismissed.connect ( () => {
+ if (really_delete)
+ contact.remove_personas.begin ( () => {
+ contact.show ();
+ });
+ });
+ b.clicked.connect ( () => {
+ really_delete = false;
+ notification.dismiss ();
+ contact.show ();
+ set_shown_contact (contact);
+ });
+ add_notification (notification);
+ }
+
+ [GtkCallback]
+ void contact_pane_contacts_linked_cb (string? main_contact, string linked_contact, LinkOperation
operation) {
+ var notification = new Gd.Notification ();
+ notification.timeout = 5;
+
+ var g = new Grid ();
+ g.set_column_spacing (8);
+ notification.add (g);
+
+ string msg;
+ if (main_contact != null)
+ msg = _("%s linked to %s").printf (main_contact, linked_contact);
+ else
+ msg = _("%s linked to the contact").printf (linked_contact);
+
+ var b = new Button.with_mnemonic (_("_Undo"));
+ g.add (new Label (msg));
+ g.add (b);
+
+ notification.show_all ();
+ b.clicked.connect ( () => {
+ notification.dismiss ();
+ operation.undo.begin ();
+ });
+ add_notification (notification);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]