r7228 - in dumbhippo/trunk/client/linux: engine-dbus src



Author: otaylor
Date: 2008-01-17 14:39:10 -0600 (Thu, 17 Jan 2008)
New Revision: 7228

Modified:
   dumbhippo/trunk/client/linux/engine-dbus/hippo-dbus-server.c
   dumbhippo/trunk/client/linux/engine-dbus/json.c
   dumbhippo/trunk/client/linux/src/hippo-dbus-client.c
   dumbhippo/trunk/client/linux/src/hippo-status-icon.c
Log:
- Fix programs with GetChatWindowState() call
- Fix a wrong include causing a warning
- Reflect the data-model online state with the status icon


Modified: dumbhippo/trunk/client/linux/engine-dbus/hippo-dbus-server.c
===================================================================
--- dumbhippo/trunk/client/linux/engine-dbus/hippo-dbus-server.c	2008-01-17 20:38:31 UTC (rev 7227)
+++ dumbhippo/trunk/client/linux/engine-dbus/hippo-dbus-server.c	2008-01-17 20:39:10 UTC (rev 7228)
@@ -1036,11 +1036,12 @@
     state = hippo_engine_app_get_chat_state(hippo_get_engine_app(), chat_id);
     dbus_state = (dbus_int32_t)state;
 
-    dbus_message_append_args(message,
-			     DBUS_TYPE_INT64, &dbus_state,
+    reply = dbus_message_new_method_return(message);
+    
+    dbus_message_append_args(reply,
+			     DBUS_TYPE_INT32, &dbus_state,
 			     DBUS_TYPE_INVALID);
     
-    reply = dbus_message_new_method_return(message);
     return reply;
 }
 

Modified: dumbhippo/trunk/client/linux/engine-dbus/json.c
===================================================================
--- dumbhippo/trunk/client/linux/engine-dbus/json.c	2008-01-17 20:38:31 UTC (rev 7227)
+++ dumbhippo/trunk/client/linux/engine-dbus/json.c	2008-01-17 20:39:10 UTC (rev 7228)
@@ -44,7 +44,7 @@
     return TRUE;
 }
 #else /* !BUILD_TESTS */
-#include <hippo/hippo-basics.h>
+#include <engine/hippo-engine-basics.h>
 #endif
 
 

Modified: dumbhippo/trunk/client/linux/src/hippo-dbus-client.c
===================================================================
--- dumbhippo/trunk/client/linux/src/hippo-dbus-client.c	2008-01-17 20:38:31 UTC (rev 7227)
+++ dumbhippo/trunk/client/linux/src/hippo-dbus-client.c	2008-01-17 20:39:10 UTC (rev 7228)
@@ -156,9 +156,9 @@
         goto out;
     }
 
-    if (dbus_message_get_args(message, &derror,
-                              DBUS_TYPE_INT32, &dbus_state,
-                              DBUS_TYPE_INVALID)) {
+    if (!dbus_message_get_args(reply, &derror,
+                               DBUS_TYPE_INT32, &dbus_state,
+                               DBUS_TYPE_INVALID)) {
         propagate_dbus_error(error, &derror);
         goto out;
     }

Modified: dumbhippo/trunk/client/linux/src/hippo-status-icon.c
===================================================================
--- dumbhippo/trunk/client/linux/src/hippo-status-icon.c	2008-01-17 20:38:31 UTC (rev 7227)
+++ dumbhippo/trunk/client/linux/src/hippo-status-icon.c	2008-01-17 20:39:10 UTC (rev 7228)
@@ -18,6 +18,7 @@
 struct _HippoStatusIcon {
     GtkStatusIcon parent;
     DDMDataModel *model;
+    DDMDataResource *global_resource;
     GtkWidget *popup_menu;
 };
 
@@ -50,15 +51,62 @@
 static const char *
 get_icon_name(DDMDataModel *model)
 {
-#if 0
-    if (hippo_connection_get_connected(connection))
+    if (ddm_data_model_is_online(model))
         return "mugshot_notification";
     else
         return "mugshot_notification_disabled";
-#endif    
-    return "mugshot_notification";
 }
 
+static const char *
+get_icon_tooltip(DDMDataModel *model)
+{
+    return "Mugshot";
+}
+
+static void
+on_online_changed(DDMDataResource *global_resource,
+                  GSList          *changed_properties,
+                  gpointer         data)
+{
+    HippoStatusIcon *icon = data;
+    
+    g_object_set(G_OBJECT(icon), 
+                 "icon-name", get_icon_name(icon->model),
+                 NULL);
+}
+
+static void
+set_global_resource(HippoStatusIcon *icon,
+                    DDMDataResource *global_resource)
+{
+    if (icon->global_resource) {
+        ddm_data_resource_disconnect(icon->global_resource,
+                                     on_online_changed,
+                                     icon);
+        ddm_data_resource_unref(icon->global_resource);
+        icon->global_resource = NULL;
+    }
+
+    icon->global_resource = global_resource;
+
+    if (icon->global_resource) {
+        ddm_data_resource_ref(icon->global_resource);
+        ddm_data_resource_connect(icon->global_resource, "online",
+                                  on_online_changed,
+                                  icon);
+    }
+
+    on_online_changed(icon->global_resource, NULL, icon);
+}
+
+static void
+on_ready(DDMDataModel    *model,
+         HippoStatusIcon *icon)
+{
+    set_global_resource(icon,
+                        ddm_data_model_get_global_resource(model));
+}
+
 HippoStatusIcon*
 hippo_status_icon_new(DDMDataModel *model)
 {
@@ -70,14 +118,11 @@
     
     icon->model = g_object_ref(model);
 
-#if 0
-    /* FIXME: get via data model */
-    g_signal_connect(connection, "state-changed",
-                     G_CALLBACK(on_state_changed), icon);
+    g_signal_connect(icon->model, "ready",
+                     G_CALLBACK(on_ready), icon);
 
     gtk_status_icon_set_tooltip(GTK_STATUS_ICON(icon),
-                                hippo_connection_get_tooltip(connection));
-#endif    
+                                get_icon_tooltip(model));
 
     return HIPPO_STATUS_ICON(icon);
 }
@@ -96,7 +141,12 @@
 {
     HippoStatusIcon *icon = HIPPO_STATUS_ICON(object);
 
+    set_global_resource(icon, NULL);
     destroy_menu(icon);
+
+    g_signal_handlers_disconnect_by_func(icon->model,
+                                         (gpointer)on_ready,
+                                         icon);
     
     g_object_unref(icon->model);
     
@@ -189,17 +239,3 @@
                     button, activate_time);
     gtk_menu_shell_select_first(GTK_MENU_SHELL(icon->popup_menu), FALSE);                    
 }                             
-
-#if 0
-static void
-on_state_changed(HippoConnection         *connection,
-                 HippoStatusIcon         *icon)
-{
-    g_object_set(G_OBJECT(icon), 
-                 "icon-name", get_icon_name(connection), 
-                 NULL);
-    
-    gtk_status_icon_set_tooltip(GTK_STATUS_ICON(icon),
-                                hippo_connection_get_tooltip(connection));
-}
-#endif



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