empathy r2043 - trunk/src



Author: xclaesse
Date: Tue Jan  6 16:46:57 2009
New Revision: 2043
URL: http://svn.gnome.org/viewvc/empathy?rev=2043&view=rev

Log:
Port EmpathyStatusIcon to the new API.

Modified:
   trunk/src/empathy-status-icon.c

Modified: trunk/src/empathy-status-icon.c
==============================================================================
--- trunk/src/empathy-status-icon.c	(original)
+++ trunk/src/empathy-status-icon.c	Tue Jan  6 16:46:57 2009
@@ -29,6 +29,7 @@
 
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-idle.h>
+#include <libempathy/empathy-account-manager.h>
 
 #include <libempathy-gtk/empathy-presence-chooser.h>
 #include <libempathy-gtk/empathy-conf.h>
@@ -51,10 +52,9 @@
 typedef struct {
 	GtkStatusIcon       *icon;
 	EmpathyIdle         *idle;
-	MissionControl      *mc;
+	EmpathyAccountManager *account_manager;
 	gboolean             showing_event_icon;
 	guint                blink_timeout;
-	gpointer             token;
 	EmpathyEventManager *event_manager;
 	EmpathyEvent        *event;
 
@@ -342,6 +342,23 @@
 }
 
 static void
+status_icon_connection_changed_cb (EmpathyAccountManager *manager,
+				   McAccount *account,
+				   TpConnectionStatusReason reason,
+				   TpConnectionStatus current,
+				   TpConnectionStatus previous,
+				   EmpathyStatusIcon *icon)
+{
+	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+	int connected_accounts;
+
+	/* Check for a connected account */
+	connected_accounts = empathy_account_manager_get_connected_accounts (manager);
+
+	gtk_widget_set_sensitive (priv->message_item, connected_accounts > 0);
+}
+
+static void
 status_icon_finalize (GObject *object)
 {
 	EmpathyStatusIconPriv *priv = GET_PRIV (object);
@@ -350,11 +367,13 @@
 		g_source_remove (priv->blink_timeout);
 	}
 
-	empathy_disconnect_account_status_changed (priv->token);
+	g_signal_handlers_disconnect_by_func (priv->account_manager,
+					      status_icon_connection_changed_cb,
+					      object);
 
 	g_object_unref (priv->icon);
 	g_object_unref (priv->idle);
-	g_object_unref (priv->mc);
+	g_object_unref (priv->account_manager);
 	g_object_unref (priv->event_manager);
 }
 
@@ -369,33 +388,6 @@
 }
 
 static void
-status_icon_status_changed_cb (MissionControl           *mc,
-			       TpConnectionStatus        status,
-			       McPresence                presence,
-			       TpConnectionStatusReason  reason,
-			       const gchar              *unique_name,
-			       EmpathyStatusIcon        *icon)
-{
-	EmpathyStatusIconPriv *priv = GET_PRIV (icon);
-	GList                 *accounts, *l;
-	guint                  connection_status = 1;
-
-	/* Check for a connected account */
-	accounts = mc_accounts_list_by_enabled (TRUE);
-	for (l = accounts; l; l = l->next) {
-		connection_status = mission_control_get_connection_status (priv->mc,
-									   l->data,
-									   NULL);
-		if (connection_status == 0) {
-			break;
-		}
-	}
-	mc_accounts_list_free (accounts);
-
-	gtk_widget_set_sensitive (priv->message_item, connection_status == 0);
-}
-
-static void
 empathy_status_icon_init (EmpathyStatusIcon *icon)
 {
 	EmpathyStatusIconPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (icon,
@@ -403,12 +395,13 @@
 
 	icon->priv = priv;
 	priv->icon = gtk_status_icon_new ();
-	priv->mc = empathy_mission_control_new ();
+	priv->account_manager = empathy_account_manager_new ();
 	priv->idle = empathy_idle_new ();
 	priv->event_manager = empathy_event_manager_new ();
-	priv->token = empathy_connect_to_account_status_changed (priv->mc,
-			G_CALLBACK (status_icon_status_changed_cb),
-			icon, NULL);
+
+	g_signal_connect (priv->account_manager,
+			  "account-connection-changed",
+			  G_CALLBACK (status_icon_connection_changed_cb), icon);
 
 	/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
 	empathy_conf_notify_add (empathy_conf_get (),



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