Hi.

Sorry it's taken so long to get back to you on this.

On Wed, Sep 24, 17:21:33 +0200, Carlos Martín Nieto wrote:
>  The tooltip of the tray icon shows the battery charge and disk space
> usage of the PDA. This tooltip is however not updated (at least the
> battery charge) and so it always displays the charge at plug-in time.
> 
>  The tooltip should be updated so as to show the actual charge.

I attach a patch that I think will fix this bug. Unfortunately I can't
test it now, but it appears to build fine. It removes the old deprecated
GtkTooltips code and replaced it with the sane GTK+ 2.12 GtkTooltip API.

I've CC'd the maintainer for his comments; what do you think Mark?

Many thanks,

-- 
Jonny Lamb, UK
jo...@debian.org
diff -Nruad -Nruad synce-trayicon-0.11.old/src/synce-trayicon.c 
synce-trayicon-0.11/src/synce-trayicon.c
--- synce-trayicon-0.11.old/src/synce-trayicon.c        2008-04-15 
20:17:47.000000000 +0100
+++ synce-trayicon-0.11/src/synce-trayicon.c    2009-01-10 03:07:06.000000000 
+0000
@@ -61,7 +61,6 @@
   GConfClient *conf_client;
   DccmClient *comms_client;
   WmDeviceManager *device_list;
-  GtkTooltips* tooltips;
   GtkWidget *icon;
   GtkWidget *menu;
 
@@ -95,12 +94,14 @@
 static void device_disconnected_cb(DccmClient *comms_client, gchar *pdaname, 
gpointer user_data);
 static void service_stopping_cb(DccmClient *comms_client, gpointer user_data);
 static gboolean is_connected(SynceTrayIcon *self);
-static void set_status_tooltips(SynceTrayIcon *self);
+static void set_status_tooltip(SynceTrayIcon *self);
 static void set_icon(SynceTrayIcon *self);
 static gboolean update(gpointer data);
 static void device_added_cb(GObject *obj, gpointer user_data);
 static void device_removed_cb(GObject *obj, gpointer user_data);
 static void trayicon_clicked(GtkWidget *button, GdkEventButton *event, 
gpointer user_data);
+static gboolean query_tooltip_cb(GtkWidget *widget, gint x, gint y,
+    gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data);
 
 #ifdef ENABLE_NOTIFY
 static void event_notification(SynceTrayIcon *self, const gchar *summary, 
const gchar *body);
@@ -122,7 +123,7 @@
 }
 
 static void
-set_status_tooltips(SynceTrayIcon *self)
+set_status_tooltip(SynceTrayIcon *self)
 {
   SynceTrayIconPrivate *priv = SYNCE_TRAYICON_GET_PRIVATE (self);
 
@@ -135,7 +136,7 @@
   WmDevice *device;
 
   if (!(is_connected(self))) {
-    gtk_tooltips_set_tip(priv->tooltips, GTK_WIDGET(self), _("Not connected"), 
NULL);
+    gtk_widget_set_tooltip_text(GTK_WIDGET(self), _("Not connected"));
     return;
   }
 
@@ -161,7 +162,7 @@
     tooltip_str = tmpstr;
   }
 
-  gtk_tooltips_set_tip(priv->tooltips, GTK_WIDGET(self), tooltip_str, NULL);
+  gtk_widget_set_tooltip_text(GTK_WIDGET(self), tooltip_str);
   g_free(tooltip_str);
   return;
 }
@@ -186,7 +187,7 @@
   SynceTrayIcon *self = SYNCE_TRAYICON(data);
 
   set_icon(self);
-  set_status_tooltips(self);
+  set_status_tooltip(self);
 
   /* prevent function from running again when
    set with g_idle_add */
@@ -827,9 +828,6 @@
   g_signal_connect (G_OBJECT (priv->device_list), "device-removed",
                    (GCallback)device_removed_cb, self);
 
-  /* tooltip */
-  priv->tooltips = gtk_tooltips_new();
-
   /* visible icon */
   priv->icon = gtk_image_new();
   GtkWidget *box = gtk_event_box_new();
@@ -838,6 +836,9 @@
   gtk_widget_show_all(GTK_WIDGET(self));
   g_signal_connect(G_OBJECT(box), "button-press-event", 
G_CALLBACK(trayicon_clicked), self);
 
+  /* tooltip */
+  g_signal_connect(G_OBJECT (self), "query-tooltip",
+      (GCallback)query_tooltip_cb, self);
 
   /* dccm comms */
   priv->comms_client = init_client_comms(self);
@@ -849,6 +850,16 @@
   update(self);
 }
 
+static gboolean
+query_tooltip_cb(GtkWidget *widget, gint x, gint y,
+    gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
+{
+  set_status_tooltip(user_data);
+
+  /* show the tooltip */
+  return TRUE;
+}
+
 static void
 synce_trayicon_dispose (GObject *obj)
 {
@@ -885,7 +896,6 @@
   notify_uninit();
 #endif /* ENABLE_NOTIFY */
 
-  g_object_unref(priv->tooltips);
   g_object_unref(priv->icon);
 
   module_unload_all();

Attachment: signature.asc
Description: Digital signature

Reply via email to