]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-presence-chooser.c
sort contacts by most recent event
[empathy.git] / libempathy-gtk / empathy-presence-chooser.c
index 33637d48362fccb7c2ac2830c07f6be5bc537082..da08718cbd49d0bb88e1cb0f398a7669545b4be0 100644 (file)
  */
 
 #include "config.h"
-
-#include <string.h>
-#include <stdlib.h>
+#include "empathy-presence-chooser.h"
 
 #include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
+#include <tp-account-widgets/tpaw-utils.h>
 
-#include <libempathy/empathy-presence-manager.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-status-presets.h>
+#include "empathy-presence-manager.h"
+#include "empathy-status-presets.h"
+#include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 #include "empathy-ui-utils.h"
-#include "empathy-images.h"
 #include "empathy-presence-chooser.h"
 #include "empathy-status-preset-dialog.h"
 
@@ -107,7 +100,6 @@ typedef struct {
        PresenceChooserEntryType previous_type;
 
        TpAccountManager *account_manager;
-       GdkPixbuf *not_favorite_pixbuf;
 } EmpathyPresenceChooserPriv;
 
 /* States to be listed in the menu.
@@ -281,7 +273,7 @@ get_state_and_status (EmpathyPresenceChooser *self,
 
        state = tp_account_manager_get_most_available_presence (
                priv->account_manager, NULL, &tmp);
-       if (EMP_STR_EMPTY (tmp)) {
+       if (TPAW_STR_EMPTY (tmp)) {
                /* no message, use the default message */
                g_free (tmp);
                tmp = g_strdup (empathy_presence_get_default_message (state));
@@ -326,7 +318,6 @@ presence_chooser_is_preset (EmpathyPresenceChooser *self)
 static void
 presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self)
 {
-       EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
        GtkWidget *entry;
        PresenceChooserEntryType type;
 
@@ -338,16 +329,16 @@ presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self)
                        /* saved entries can be removed from the list */
                        gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
                                           GTK_ENTRY_ICON_SECONDARY,
-                                          "emblem-favorite");
+                                          "starred-symbolic");
                        gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
                                         GTK_ENTRY_ICON_SECONDARY,
                                         _("Click to remove this status as a favorite"));
                }
-               else if (priv->not_favorite_pixbuf != NULL) {
+               else {
                        /* custom entries can be favorited */
-                       gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry),
+                       gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
                                           GTK_ENTRY_ICON_SECONDARY,
-                                          priv->not_favorite_pixbuf);
+                                          "non-starred-symbolic");
                        gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
                                         GTK_ENTRY_ICON_SECONDARY,
                                         _("Click to make this status a favorite"));
@@ -761,7 +752,7 @@ update_sensitivity_am_prepared_cb (GObject *source_object,
                return;
        }
 
-       accounts = tp_account_manager_get_valid_accounts (manager);
+       accounts = tp_account_manager_dup_valid_accounts (manager);
 
        for (l = accounts ; l != NULL ; l = g_list_next (l)) {
                TpAccount *a = TP_ACCOUNT (l->data);
@@ -772,7 +763,7 @@ update_sensitivity_am_prepared_cb (GObject *source_object,
                }
        }
 
-       g_list_free (accounts);
+       g_list_free_full (accounts, g_object_unref);
 
        if (!g_network_monitor_get_network_available (priv->connectivity))
                sensitive = FALSE;
@@ -819,40 +810,6 @@ presence_chooser_network_change (GNetworkMonitor *connectivity,
        presence_chooser_update_sensitivity (chooser);
 }
 
-/* Create a greyed version of the 'favorite' icon */
-static GdkPixbuf *
-create_not_favorite_pixbuf (void)
-{
-       GdkPixbuf *favorite, *result;
-
-       favorite = empathy_pixbuf_from_icon_name ("emblem-favorite",
-                                                 GTK_ICON_SIZE_MENU);
-
-       if (favorite == NULL)
-               return NULL;
-
-       result = gdk_pixbuf_copy (favorite);
-       gdk_pixbuf_saturate_and_pixelate (favorite, result, 1.0, TRUE);
-
-       g_object_unref (favorite);
-       return result;
-}
-
-static void
-icon_theme_changed_cb (GtkIconTheme *icon_theme,
-                      EmpathyPresenceChooser *self)
-{
-       EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
-
-       /* Theme has changed, recreate the not-favorite icon */
-       if (priv->not_favorite_pixbuf != NULL)
-               g_object_unref (priv->not_favorite_pixbuf);
-       priv->not_favorite_pixbuf = create_not_favorite_pixbuf ();
-
-       /* Update the icon */
-       presence_chooser_set_favorite_icon (self);
-}
-
 static void
 empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
 {
@@ -860,9 +817,6 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
                EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
 
        chooser->priv = priv;
-
-       /* Create the not-favorite icon */
-       priv->not_favorite_pixbuf = create_not_favorite_pixbuf ();
 }
 
 static void
@@ -874,9 +828,8 @@ presence_chooser_constructed (GObject *object)
        GtkCellRenderer *renderer;
        const gchar *status_tooltip;
 
-       tp_g_signal_connect_object (gtk_icon_theme_get_default (), "changed",
-                                    G_CALLBACK (icon_theme_changed_cb),
-                                    chooser, 0);
+       if (G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->constructed)
+               G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->constructed (object);
 
        presence_chooser_create_model (chooser);
 
@@ -986,8 +939,6 @@ presence_chooser_finalize (GObject *object)
        g_object_unref (priv->presence_mgr);
 
        g_object_unref (priv->connectivity);
-       if (priv->not_favorite_pixbuf != NULL)
-               g_object_unref (priv->not_favorite_pixbuf);
 
        G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object);
 }