]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-individual-dialogs.c
Center the 'smiley images' inside the menu items
[empathy.git] / libempathy-gtk / empathy-individual-dialogs.c
index b5f41db13e82d0332f526f2fdc516bb7c1745f0d..2e388bd578897b1aa5595b8daf2dc111d03e2807 100644 (file)
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  */
 
-#include <config.h>
-
-#include <string.h>
-#include <stdlib.h>
+#include "config.h"
+#include "empathy-individual-dialogs.h"
 
-#include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
 
-#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>
-#include <libempathy/empathy-contact-manager.h>
-
-#include "empathy-individual-dialogs.h"
 #include "empathy-contact-widget.h"
-#include "empathy-ui-utils.h"
+#include "empathy-individual-manager.h"
+#include "empathy-utils.h"
 
 #define BULLET_POINT "\342\200\242"
 
@@ -135,11 +125,7 @@ empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
   if (individual != NULL)
     contact = empathy_contact_dup_from_folks_individual (individual);
 
-  contact_widget = empathy_contact_widget_new (contact,
-      EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
-      EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT |
-      EMPATHY_CONTACT_WIDGET_EDIT_ID |
-      EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
+  contact_widget = empathy_contact_widget_new (contact);
   gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8);
   gtk_box_pack_start (
       GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
@@ -179,13 +165,13 @@ contact_pretty_name (TpContact *contact)
 gboolean
 empathy_block_individual_dialog_show (GtkWindow *parent,
     FolksIndividual *individual,
+    GdkPixbuf *avatar,
     gboolean *abusive)
 {
-  EmpathyContactManager *contact_manager =
-    empathy_contact_manager_dup_singleton ();
   GtkWidget *dialog;
   GtkWidget *abusive_check = NULL;
-  GList *personas, *l;
+  GeeSet *personas;
+  GeeIterator *iter;
   GString *text = g_string_new ("");
   GString *blocked_str = g_string_new ("");
   GString *notblocked_str = g_string_new ("");
@@ -198,25 +184,35 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       _("Block %s?"),
       folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
 
+  if (avatar != NULL)
+    {
+      GtkWidget *image = gtk_image_new_from_pixbuf (avatar);
+      gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);
+      gtk_widget_show (image);
+    }
+
   /* build a list of personas that support blocking */
   personas = folks_individual_get_personas (individual);
-
-  for (l = personas; l != NULL; l = l->next)
+  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+  while (gee_iterator_next (iter))
     {
-      TpfPersona *persona = l->data;
+      TpfPersona *persona = gee_iterator_get (iter);
       TpContact *contact;
-      EmpathyContactListFlags flags;
       GString *s;
       char *str;
+      TpConnection *conn;
 
       if (!TPF_IS_PERSONA (persona))
-          continue;
+          goto while_finish;
 
       contact = tpf_persona_get_contact (persona);
-      flags = empathy_contact_manager_get_flags_for_connection (
-          contact_manager, tp_contact_get_connection (contact));
+      if (contact == NULL)
+        goto while_finish;
 
-      if (flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
+      conn = tp_contact_get_connection (contact);
+
+      if (tp_proxy_has_interface_by_id (conn,
+            TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_BLOCKING))
         {
           s = blocked_str;
           npersonas_blocked++;
@@ -227,13 +223,17 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
           npersonas_notblocked++;
         }
 
-      if (flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
+      if (tp_connection_can_report_abusive (conn))
         can_report_abuse = TRUE;
 
       str = contact_pretty_name (contact);
       g_string_append_printf (s, "\n " BULLET_POINT " %s", str);
       g_free (str);
+
+while_finish:
+      g_clear_object (&persona);
     }
+  g_clear_object (&iter);
 
   g_string_append_printf (text,
       _("Are you sure you want to block '%s' from contacting you again?"),
@@ -275,7 +275,6 @@ empathy_block_individual_dialog_show (GtkWindow *parent,
       gtk_widget_show (abusive_check);
     }
 
-  g_object_unref (contact_manager);
   g_string_free (text, TRUE);
   g_string_free (blocked_str, TRUE);
   g_string_free (notblocked_str, TRUE);