[empathy: 33/35] Update the wording of the contact blocking dialog



commit 355a558cfa919b1fa91f7c430c738b6d762239fb
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Fri Mar 11 11:08:06 2011 +1100

    Update the wording of the contact blocking dialog
    
    Include the list of personas which will not be blocked.

 libempathy-gtk/empathy-individual-dialogs.c |   71 +++++++++++++++++++++------
 1 files changed, 56 insertions(+), 15 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c
index e141182..67ec221 100644
--- a/libempathy-gtk/empathy-individual-dialogs.c
+++ b/libempathy-gtk/empathy-individual-dialogs.c
@@ -161,6 +161,18 @@ empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
   tp_clear_object (&contact);
 }
 
+static char *
+contact_pretty_name (TpContact *contact)
+{
+  const char *alias = tp_contact_get_alias (contact);
+  const char *identifier = tp_contact_get_identifier (contact);
+
+  if (tp_strdiff (alias, identifier))
+    return g_strdup_printf ("%s (%s)", alias, identifier);
+  else
+    return g_strdup (alias);
+}
+
 /*
  * Block contact dialog
  */
@@ -174,8 +186,10 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
   GtkWidget *dialog;
   GtkWidget *abusive_check = NULL;
   GList *personas, *l;
-  GString *str = g_string_new ("");
-  guint npersonas = 0;
+  GString *text = g_string_new ("");
+  GString *blocked_str = g_string_new ("");
+  GString *notblocked_str = g_string_new ("");
+  guint npersonas_blocked = 0, npersonas_notblocked = 0;
   gboolean can_report_abuse = FALSE;
   int res;
 
@@ -192,6 +206,8 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       TpfPersona *persona = l->data;
       TpContact *contact;
       EmpathyContactListFlags flags;
+      GString *s;
+      char *str;
 
       if (!TPF_IS_PERSONA (persona))
           continue;
@@ -200,22 +216,45 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       flags = empathy_contact_manager_get_flags_for_connection (
           contact_manager, tp_contact_get_connection (contact));
 
-      if (!(flags & EMPATHY_CONTACT_LIST_CAN_BLOCK))
-        continue;
-      else if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
+      if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
+        {
+          s = blocked_str;
+          npersonas_blocked++;
+        }
+      else
+        {
+          s = notblocked_str;
+          npersonas_notblocked++;
+        }
+
+      if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
         can_report_abuse = TRUE;
 
-      g_string_append_printf (str, "\n " BULLET_POINT " %s",
-          tp_contact_get_identifier (contact));
-      npersonas++;
+      str = contact_pretty_name (contact);
+      g_string_append_printf (s, "\n " BULLET_POINT " %s", str);
+      g_free (str);
     }
 
+  g_string_append_printf (text,
+      _("Are you sure you want to block '%s' from contacting you again?"),
+      folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)));
+
+  if (npersonas_blocked > 0)
+    g_string_append_printf (text, "\n\n%s\n%s",
+        ngettext ("The following identity will be blocked:",
+                  "The following identities will be blocked:",
+                  npersonas_blocked),
+        blocked_str->str);
+
+  if (npersonas_notblocked > 0)
+    g_string_append_printf (text, "\n\n%s\n%s",
+        ngettext ("The following identity can not be blocked:",
+                  "The following identities can not be blocked:",
+                  npersonas_notblocked),
+        notblocked_str->str);
+
   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);
+    "%s", text->str);
 
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -230,14 +269,16 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       abusive_check = gtk_check_button_new_with_mnemonic (
           ngettext ("_Report this contact as abusive",
                     "_Report these contacts as abusive",
-                    npersonas));
+                    npersonas_blocked));
 
       gtk_box_pack_start (GTK_BOX (vbox), abusive_check, FALSE, TRUE, 0);
       gtk_widget_show (abusive_check);
     }
 
   g_object_unref (contact_manager);
-  g_string_free (str, TRUE);
+  g_string_free (text, TRUE);
+  g_string_free (blocked_str, TRUE);
+  g_string_free (notblocked_str, TRUE);
 
   res = gtk_dialog_run (GTK_DIALOG (dialog));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]