]> git.0d.be Git - empathy.git/commitdiff
Add confirmation dialog to Remove
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 11 Feb 2011 05:17:48 +0000 (16:17 +1100)
committerChandni Verma <chandniverma2112@gmail.com>
Tue, 8 Mar 2011 04:04:57 +0000 (09:34 +0530)
Also includes the future Report Abusive check box, so that all the strings
are in place now.

libempathy-gtk/empathy-individual-dialogs.c
libempathy-gtk/empathy-individual-dialogs.h
libempathy-gtk/empathy-individual-view.c
libempathy/empathy-individual-manager.c
libempathy/empathy-individual-manager.h

index 2c9801059349a16c5ca702309232d849ba459f07..f7ca788c1fe71d028bde8de8eb559786d9f608ac 100644 (file)
@@ -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;
+}
index b34a7ab181cfe687548151e704abdb52c9c7dd67..f6c402014b5675960202eb7eeee3e4f92d8be31f 100644 (file)
@@ -32,6 +32,8 @@ G_BEGIN_DECLS
 void empathy_new_individual_dialog_show (GtkWindow *parent);
 void empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
     FolksIndividual *individual);
+gboolean empathy_block_individual_dialog_show (GtkWindow *parent,
+    FolksIndividual *individual, gboolean *abusive);
 
 G_END_DECLS
 
index 4cb8a76f48e20e79dd6d0d562805572ac6e00d8e..cea55a2002b5f9bf35696bf5937d9526ca730c4b 100644 (file)
@@ -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"
@@ -2447,12 +2448,21 @@ individual_view_remove_activate_cb (GtkMenuItem *menuitem,
 
       if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_REJECT)
         {
-          empathy_individual_manager_remove (manager, individual, "");
+          if (res == GTK_RESPONSE_REJECT &&
+              empathy_block_individual_dialog_show (parent, individual, NULL))
+            {
+              empathy_individual_manager_set_blocked (manager, individual,
+                  TRUE);
+            }
+          else
+            {
+              goto finally;
+            }
 
-          if (res == GTK_RESPONSE_REJECT)
-            empathy_individual_manager_set_blocked (manager, individual, TRUE);
+          empathy_individual_manager_remove (manager, individual, "");
         }
 
+finally:
       g_free (text);
       g_object_unref (individual);
       g_object_unref (manager);
index 01eb51951d1cd3eb70bd8e3d978ce5eab715c512..fd74e4bbea7e2deb20deb4356f2665d3abd3e8af 100644 (file)
@@ -628,6 +628,8 @@ empathy_individual_manager_get_flags_for_connection (
     flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
   if (list_flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
     flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK;
+  if (list_flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
+    flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE;
 
   return flags;
 }
index daa7ec86ab772fc503d2d5f521e5311a8729c831..12f8ccdb0df5f0d7cd4b20aa3420d5aaa925af48 100644 (file)
@@ -44,6 +44,7 @@ typedef enum
   EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS = 1 << 2,
   EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP = 1 << 3,
   EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK = 1 << 4,
+  EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE = 1 << 5,
 } EmpathyIndividualManagerFlags;
 
 typedef struct _EmpathyIndividualManager EmpathyIndividualManager;