]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-individual-menu.c
Reorder header inclusions accordingly to the Telepathy coding style
[empathy.git] / libempathy-gtk / empathy-individual-menu.c
index 5b83b2931b7d2f2bb47beb64331350cceadf6834..e70146bf76349a439ad271875781687954da4d2e 100644 (file)
  */
 
 #include "config.h"
-
-#include <string.h>
+#include "empathy-individual-menu.h"
 
 #include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-
-#include <telepathy-glib/util.h>
-
-#include <folks/folks.h>
-#include <folks/folks-telepathy.h>
-
-#include <libempathy/empathy-camera-monitor.h>
-#include <libempathy/empathy-request-util.h>
-#include <libempathy/empathy-individual-manager.h>
-#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-utils.h>
 
 #include "empathy-account-selector-dialog.h"
-#include "empathy-individual-menu.h"
-#include "empathy-images.h"
-#include "empathy-log-window.h"
-#include "empathy-contact-dialogs.h"
+#include "empathy-call-utils.h"
+#include "empathy-camera-monitor.h"
+#include "empathy-chatroom-manager.h"
 #include "empathy-gtk-enum-types.h"
+#include "empathy-images.h"
+#include "empathy-individual-dialogs.h"
 #include "empathy-individual-dialogs.h"
 #include "empathy-individual-edit-dialog.h"
-#include "empathy-ui-utils.h"
-#include "empathy-share-my-desktop.h"
-#include "empathy-call-utils.h"
-#include "empathy-individual-store-channel.h"
 #include "empathy-individual-information-dialog.h"
+#include "empathy-individual-manager.h"
+#include "empathy-individual-store-channel.h"
+#include "empathy-log-window.h"
+#include "empathy-request-util.h"
+#include "empathy-share-my-desktop.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndividualMenu)
 
@@ -107,7 +98,6 @@ individual_menu_add_personas (GtkMenuShell *menu,
   GeeSet *personas;
   GeeIterator *iter;
   guint persona_count = 0;
-  gboolean c;
 
   g_return_if_fail (GTK_IS_MENU (menu));
   g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual));
@@ -130,14 +120,15 @@ individual_menu_add_personas (GtkMenuShell *menu,
 
   /* return early if these entries would add nothing beyond the "quick" items */
   if (persona_count <= 1)
-    return;
+    goto out;
 
   /* add a separator before the list of personas */
   item = gtk_separator_menu_item_new ();
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
   gtk_widget_show (item);
 
-  for (c = gee_iterator_first (iter); c; c = gee_iterator_next (iter))
+  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+  while (gee_iterator_next (iter))
     {
       GtkWidget *image;
       GtkWidget *contact_item;
@@ -163,6 +154,11 @@ individual_menu_add_personas (GtkMenuShell *menu,
       single_individual = empathy_create_individual_from_tp_contact (
           tp_contact);
 
+      /* Pretty hacky. Creating single_individual had a side effect to change
+       * persona.individual from individual to single_individual which is not
+       * what we want so we set it back. See bgo#684971 for details. */
+      g_object_set (persona, "individual", individual, NULL);
+
       store = folks_persona_get_store (FOLKS_PERSONA (persona));
       account = folks_persona_store_get_display_name (store);
 
@@ -266,6 +262,7 @@ while_finish:
       g_clear_object (&persona);
     }
 
+out:
   g_clear_object (&iter);
 }
 
@@ -288,7 +285,7 @@ find_phone_accounts (void)
   am = tp_account_manager_dup ();
   g_return_val_if_fail (am != NULL, NULL);
 
-  accounts = tp_account_manager_get_valid_accounts (am);
+  accounts = tp_account_manager_dup_valid_accounts (am);
   for (l = accounts; l != NULL; l = g_list_next (l))
     {
       TpAccount *account = l->data;
@@ -303,7 +300,7 @@ find_phone_accounts (void)
       found = g_list_prepend (found, g_object_ref (account));
     }
 
-  g_list_free (accounts);
+  g_list_free_full (accounts, g_object_unref);
   g_object_unref (am);
 
   return found;
@@ -475,6 +472,8 @@ add_phone_numbers (EmpathyIndividualMenu *self)
       gtk_menu_shell_append (GTK_MENU_SHELL (self), item);
       gtk_widget_show (item);
     }
+
+  g_object_unref (iter);
 }
 
 /* return a list of TpContact supporting the blocking iface */
@@ -1795,18 +1794,18 @@ add_menu_item_activated (GtkMenuItem *item,
     TpContact *tp_contact)
 {
   GtkWidget *toplevel;
-  EmpathyContact *contact;
+  FolksIndividual *individual;
 
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item));
   if (!gtk_widget_is_toplevel (toplevel) || !GTK_IS_WINDOW (toplevel))
     toplevel = NULL;
 
-  contact = empathy_contact_dup_from_tp_contact (tp_contact);
+  individual = empathy_ensure_individual_from_tp_contact (tp_contact);
 
-  empathy_new_contact_dialog_show_with_contact (GTK_WINDOW (toplevel),
-      contact);
+  empathy_new_individual_dialog_show_with_individual (GTK_WINDOW (toplevel),
+      individual);
 
-  g_object_unref (contact);
+  g_object_unref (individual);
 }
 
 static GtkWidget *