aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-individual-dialogs.c
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-02-11 13:17:48 +0800
committerChandni Verma <chandniverma2112@gmail.com>2011-03-08 12:04:57 +0800
commit95bbacd1eda4500ef9cef0f998ebb485861a3a3d (patch)
tree4c70d900678f5474ae99104bae7e45c1f8d72fd6 /libempathy-gtk/empathy-individual-dialogs.c
parent1e15d1b253163c98064997aabe6b127acbecc64b (diff)
downloadgsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar.gz
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar.bz2
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar.lz
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar.xz
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.tar.zst
gsoc2013-empathy-95bbacd1eda4500ef9cef0f998ebb485861a3a3d.zip
Add confirmation dialog to Remove
Also includes the future Report Abusive check box, so that all the strings are in place now.
Diffstat (limited to 'libempathy-gtk/empathy-individual-dialogs.c')
-rw-r--r--libempathy-gtk/empathy-individual-dialogs.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c
index 2c9801059..f7ca788c1 100644
--- a/libempathy-gtk/empathy-individual-dialogs.c
+++ b/libempathy-gtk/empathy-individual-dialogs.c
@@ -29,6 +29,7 @@
#include <telepathy-glib/util.h>
#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
#include <libempathy/empathy-individual-manager.h>
#include <libempathy/empathy-utils.h>
@@ -156,3 +157,96 @@ empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
tp_clear_object (&contact);
}
+
+/*
+ * Block contact dialog
+ */
+gboolean
+empathy_block_individual_dialog_show (GtkWindow *parent,
+ FolksIndividual *individual,
+ gboolean *abusive)
+{
+ EmpathyIndividualManager *manager =
+ empathy_individual_manager_dup_singleton ();
+ GtkWidget *dialog;
+ GtkWidget *abusive_check = NULL;
+ GList *personas, *l;
+ GString *str = g_string_new ("");
+ guint npersonas = 0;
+ gboolean can_report_abuse = FALSE;
+ int res;
+
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ _("Block %s?"),
+ folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)));
+
+ /* build a list of personas that support blocking */
+ personas = folks_individual_get_personas (individual);
+
+ for (l = personas; l != NULL; l = l->next)
+ {
+ TpfPersona *persona = l->data;
+ TpContact *contact;
+ EmpathyIndividualManagerFlags flags;
+
+ if (!TPF_IS_PERSONA (persona))
+ continue;
+
+ contact = tpf_persona_get_contact (persona);
+ flags = empathy_individual_manager_get_flags_for_connection (manager,
+ tp_contact_get_connection (contact));
+
+ if (!(flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK))
+ continue;
+ else if (flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE)
+ can_report_abuse = TRUE;
+
+ g_string_append_printf (str, "\n \342\200\242 %s",
+ tp_contact_get_identifier (contact));
+ npersonas++;
+ }
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s\n%s",
+ ngettext ("Are you sure you want to block the following contact?",
+ "Are you sure you want to block the following contacts?",
+ npersonas),
+ str->str);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Block"), GTK_RESPONSE_REJECT,
+ NULL);
+
+ if (can_report_abuse)
+ {
+ GtkWidget *vbox;
+
+ vbox = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
+ abusive_check = gtk_check_button_new_with_mnemonic (
+ ngettext ("_Report this contact as abusive",
+ "_Report these contacts as abusive",
+ npersonas));
+
+ gtk_box_pack_start (GTK_BOX (vbox), abusive_check, FALSE, TRUE, 0);
+ gtk_widget_show (abusive_check);
+ }
+
+ g_object_unref (manager);
+ g_string_free (str, TRUE);
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (abusive != NULL)
+ {
+ if (abusive_check != NULL)
+ *abusive = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (abusive_check));
+ else
+ *abusive = FALSE;
+ }
+
+ return res == GTK_RESPONSE_REJECT;
+}