diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-02-11 17:31:32 +0800 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2011-02-11 17:31:32 +0800 |
commit | 17e69195176edfa854e1d62cc3e6bd322128ce37 (patch) | |
tree | a185577dea98d680827db4ab4021b50e16bf1b58 /libempathy-gtk/empathy-individual-view.c | |
parent | d23ec3dc8820592c390adec4de712a570a3c06c7 (diff) | |
parent | 49a44a405f845bdb1cb76c6d0b073c257342bf53 (diff) | |
download | gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar.gz gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar.bz2 gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar.lz gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar.xz gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.tar.zst gsoc2013-empathy-17e69195176edfa854e1d62cc3e6bd322128ce37.zip |
Merge branch 'contact-blocking-3' into gnome-2-34
Diffstat (limited to 'libempathy-gtk/empathy-individual-view.c')
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 63c5a8d90..55d25f801 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -47,6 +47,7 @@ #include "empathy-individual-menu.h" #include "empathy-individual-store.h" #include "empathy-contact-dialogs.h" +#include "empathy-individual-dialogs.h" #include "empathy-images.h" #include "empathy-linking-dialog.h" #include "empathy-cell-renderer-expander.h" @@ -2206,16 +2207,22 @@ empathy_individual_view_get_selected_group (EmpathyIndividualView *view, return name; } -static gboolean +static int individual_view_remove_dialog_show (GtkWindow *parent, const gchar *message, - const gchar *secondary_text) + const gchar *secondary_text, + gboolean block_button) { GtkWidget *dialog; gboolean res; dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", message); + + if (block_button) + gtk_dialog_add_button (GTK_DIALOG (dialog), + _("Delete and Block"), GTK_RESPONSE_REJECT); + gtk_dialog_add_buttons (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_NO, GTK_STOCK_DELETE, GTK_RESPONSE_YES, NULL); @@ -2227,7 +2234,7 @@ individual_view_remove_dialog_show (GtkWindow *parent, res = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - return (res == GTK_RESPONSE_YES); + return res; } static void @@ -2247,7 +2254,7 @@ individual_view_group_remove_activate_cb (GtkMenuItem *menuitem, group); parent = empathy_get_toplevel_window (GTK_WIDGET (view)); if (individual_view_remove_dialog_show (parent, _("Removing group"), - text)) + text, FALSE) == GTK_RESPONSE_YES) { EmpathyIndividualManager *manager = empathy_individual_manager_dup_singleton (); @@ -2326,26 +2333,43 @@ individual_view_remove_activate_cb (GtkMenuItem *menuitem, if (individual != NULL) { + EmpathyIndividualManager *manager; gchar *text; GtkWindow *parent; + gboolean can_block; + int res; + + manager = empathy_individual_manager_dup_singleton (); + can_block = empathy_individual_manager_supports_blocking (manager, + individual); parent = empathy_get_toplevel_window (GTK_WIDGET (view)); text = - g_strdup_printf (_ - ("Do you really want to remove the contact '%s'?"), + g_strdup_printf ( + _("Do you really want to remove the contact '%s'?"), folks_aliasable_get_alias (FOLKS_ALIASABLE (individual))); - if (individual_view_remove_dialog_show (parent, _("Removing contact"), - text)) + res = individual_view_remove_dialog_show (parent, _("Removing contact"), + text, can_block); + if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_REJECT) { - EmpathyIndividualManager *manager; + if (res == GTK_RESPONSE_REJECT && + empathy_block_individual_dialog_show (parent, individual, NULL)) + { + empathy_individual_manager_set_blocked (manager, individual, + TRUE); + } + else + { + goto finally; + } - manager = empathy_individual_manager_dup_singleton (); empathy_individual_manager_remove (manager, individual, ""); - g_object_unref (G_OBJECT (manager)); } +finally: g_free (text); g_object_unref (individual); + g_object_unref (manager); } } |