aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-11 10:31:26 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-11 10:37:11 +0800
commit7311c2623170a0271d14da46d5b2ee0163ed46e5 (patch)
treee6d4858a50dc9ba1595ca967ea841380dc295b17
parent2327d4810445c2e3975cc69fae61bddf471abda2 (diff)
downloadgsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar.gz
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar.bz2
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar.lz
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar.xz
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.tar.zst
gsoc2013-empathy-7311c2623170a0271d14da46d5b2ee0163ed46e5.zip
Factor out common blocking confirmation dialog
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.c43
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.h3
-rw-r--r--libempathy-gtk/empathy-contact-menu.c33
3 files changed, 53 insertions, 26 deletions
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index b51ce18c8..ddd870aa4 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors: Xavier Claessens <xclaesse@gmail.com>
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
*/
#include <config.h>
@@ -463,3 +464,45 @@ empathy_new_contact_dialog_show_with_contact (GtkWindow *parent,
gtk_widget_show (dialog);
}
+/**
+ * empathy_block_contact_dialog_show:
+ * @parent: the parent of this dialog (or %NULL)
+ * @contact: the contact for this dialog
+ * @abusive: a pointer to store the value of the abusive contact check box
+ * (or %NULL)
+ *
+ * Returns: %TRUE if the user wishes to block the contact
+ */
+gboolean
+empathy_block_contact_dialog_show (GtkWindow *parent,
+ EmpathyContact *contact,
+ gboolean *abusive)
+{
+ GtkWidget *dialog;
+ int res;
+
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ _("Block %s?"),
+ empathy_contact_get_id (contact));
+
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("Are you sure you want to block the contact %s?"),
+ empathy_contact_get_id (contact));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Block"), GTK_RESPONSE_REJECT,
+ NULL);
+
+ /* FIXME: support reporting abusive contacts */
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (abusive != NULL)
+ *abusive = FALSE;
+
+ return res == GTK_RESPONSE_REJECT;
+}
diff --git a/libempathy-gtk/empathy-contact-dialogs.h b/libempathy-gtk/empathy-contact-dialogs.h
index 21aa5ce73..33e2cf054 100644
--- a/libempathy-gtk/empathy-contact-dialogs.h
+++ b/libempathy-gtk/empathy-contact-dialogs.h
@@ -38,6 +38,9 @@ void empathy_contact_personal_dialog_show (GtkWindow *parent);
void empathy_new_contact_dialog_show (GtkWindow *parent);
void empathy_new_contact_dialog_show_with_contact (GtkWindow *parent,
EmpathyContact *contact);
+gboolean empathy_block_contact_dialog_show (GtkWindow *parent,
+ EmpathyContact *contact,
+ gboolean *abusive);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c
index 156d82e3c..6f83fbe98 100644
--- a/libempathy-gtk/empathy-contact-menu.c
+++ b/libempathy-gtk/empathy-contact-menu.c
@@ -238,51 +238,32 @@ empathy_contact_block_menu_item_toggled (GtkCheckMenuItem *item,
if (block_signal > 0)
return;
- manager = empathy_contact_manager_dup_singleton ();
blocked = gtk_check_menu_item_get_active (item);
if (blocked) {
/* confirm the user really wishes to block the contact */
- int res;
- GtkWidget *parent, *dialog;
+ GtkWidget *parent;
/* gtk_menu_get_attach_widget() doesn't behave properly here
* for some reason */
parent = g_object_get_data (
G_OBJECT (gtk_widget_get_parent (GTK_WIDGET (item))),
"window");
- dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
- _("Block %s?"),
- empathy_contact_get_id (contact));
-
- gtk_message_dialog_format_secondary_text (
- GTK_MESSAGE_DIALOG (dialog),
- _("Are you sure you want to block the contact %s?"),
- empathy_contact_get_id (contact));
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("Block"), GTK_RESPONSE_REJECT,
- NULL);
-
- res = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- if (res != GTK_RESPONSE_REJECT)
- goto finally;
+
+ if (!empathy_block_contact_dialog_show (GTK_WINDOW (parent),
+ contact, NULL))
+ return;
}
+ manager = empathy_contact_manager_dup_singleton ();
empathy_contact_list_set_blocked (EMPATHY_CONTACT_LIST (manager),
contact, blocked);
+ g_object_unref (manager);
/* update the toggle with the blocked status */
block_signal++;
gtk_check_menu_item_set_active (item, blocked);
block_signal--;
-
-finally:
- g_object_unref (manager);
}
static GtkWidget *