[Goodies-commits] r4911 - in xfce4-datetime-plugin/trunk: . panel-plugin

Diego Ongaro ongardie at xfce.org
Sun Jun 8 02:17:44 CEST 2008


Author: ongardie
Date: 2008-06-08 00:17:43 +0000 (Sun, 08 Jun 2008)
New Revision: 4911

Modified:
   xfce4-datetime-plugin/trunk/ChangeLog
   xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
   xfce4-datetime-plugin/trunk/panel-plugin/datetime.h
Log:
Fix Bug #4110: time is not updated in tooltip while it is displayed.


Modified: xfce4-datetime-plugin/trunk/ChangeLog
===================================================================
--- xfce4-datetime-plugin/trunk/ChangeLog	2008-06-07 23:16:14 UTC (rev 4910)
+++ xfce4-datetime-plugin/trunk/ChangeLog	2008-06-08 00:17:43 UTC (rev 4911)
@@ -1,5 +1,7 @@
 2008-06-08	Diego Ongaro <ongardie at gmail.com>
 
+	* panel-plugin/datetime.{c,h}: Fix Bug #4110: time is not updated in
+	tooltip while it is displayed.
 	* panel-plugin/datetime.{c,h}, panel-plugin/datetime-dialog.c: New
 	tooltips implementation (only enabled on GTK >= 2.12).
 

Modified: xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
===================================================================
--- xfce4-datetime-plugin/trunk/panel-plugin/datetime.c	2008-06-07 23:16:14 UTC (rev 4910)
+++ xfce4-datetime-plugin/trunk/panel-plugin/datetime.c	2008-06-08 00:17:43 UTC (rev 4911)
@@ -158,6 +158,23 @@
 }
 
 #if USE_GTK_TOOLTIP_API
+static gboolean datetime_tooltip_timer(t_datetime *datetime)
+{
+
+  /* flag to datetime_query_tooltip that there is no longer an active timeout */
+  datetime->tooltip_timeout_id = 0;
+
+  /*
+   * Run datetime_query_tooltip if the mouse is still there.
+   * If it is run, it'll register *this* function to be called after another
+   * timeout. If not, *this* function won't run again.
+   */
+  gtk_widget_trigger_tooltip_query(GTK_WIDGET(datetime->button));
+
+  /* we don't want to automatically run again */
+  return FALSE;
+}
+
 static gboolean datetime_query_tooltip(GtkWidget *widget,
                                        gint x, gint y,
                                        gboolean keyboard_mode,
@@ -191,6 +208,17 @@
   gtk_tooltip_set_text(tooltip, utf8str);
   g_free(utf8str);
 
+  /* if there is no active timeout to update the tooltip, register one */
+  if (!datetime->tooltip_timeout_id)
+  {
+    /*
+     * I think we can afford to inefficiently poll every
+     * second while the user keeps the mouse here.
+     */
+    datetime->tooltip_timeout_id = g_timeout_add(1000,
+      (GSourceFunc) datetime_tooltip_timer, datetime);
+  }
+
   return TRUE;
 }
 #endif
@@ -425,19 +453,20 @@
 
 #if USE_GTK_TOOLTIP_API
   /* update tooltip handler */
-  if (datetime->tooltip_id)
+  if (datetime->tooltip_handler_id)
   {
     g_signal_handler_disconnect(datetime->button,
-                                datetime->tooltip_id);
-    datetime->tooltip_id = 0;
+                                datetime->tooltip_handler_id);
+    datetime->tooltip_handler_id = 0;
   }
   switch(datetime->layout)
   {
     case LAYOUT_DATE:
     case LAYOUT_TIME:
       gtk_widget_set_has_tooltip(GTK_WIDGET(datetime->button), TRUE);
-      datetime->tooltip_id = g_signal_connect(datetime->button, "query-tooltip",
-                                 G_CALLBACK(datetime_query_tooltip), datetime);
+      datetime->tooltip_handler_id = g_signal_connect(datetime->button,
+                             "query-tooltip",
+                             G_CALLBACK(datetime_query_tooltip), datetime);
       break;
 
     default:
@@ -640,27 +669,19 @@
 
   DBG("Starting datetime panel plugin");
 
-  /* alloc mem */
+  /* alloc and clear mem */
   datetime = panel_slice_new0 (t_datetime);
 
-  /* set variables */
+  /* store plugin reference */
   datetime->plugin = plugin;
-  datetime->date_font = NULL;
-  datetime->date_format = NULL;
-  datetime->time_font = NULL;
-  datetime->time_format = NULL;
 
   /* call widget-create function */
   datetime_create_widget(datetime);
 
-  /* set calendar variables */
-  datetime->cal = NULL;
-
   /* load settings (default values if non-av) */
   datetime_read_rc_file(plugin, datetime);
 
   /* set date and time labels */
-  datetime->timeout_id = 0;
   datetime_update(datetime);
 
   return datetime;
@@ -671,8 +692,9 @@
  */
 static void datetime_free(XfcePanelPlugin *plugin, t_datetime *datetime)
 {
-  /* stop timeout */
+  /* stop timeouts */
   g_source_remove(datetime->timeout_id);
+  g_source_remove(datetime->tooltip_timeout_id);
 
   /* destroy widget */
   gtk_widget_destroy(datetime->button);

Modified: xfce4-datetime-plugin/trunk/panel-plugin/datetime.h
===================================================================
--- xfce4-datetime-plugin/trunk/panel-plugin/datetime.h	2008-06-07 23:16:14 UTC (rev 4910)
+++ xfce4-datetime-plugin/trunk/panel-plugin/datetime.h	2008-06-08 00:17:43 UTC (rev 4911)
@@ -46,11 +46,11 @@
   GtkWidget *vbox;
   GtkWidget *date_label;
   GtkWidget *time_label;
-  GtkTooltips *tips;
   guint update_interval;  /* time between updates in milliseconds */
   guint timeout_id;
 #if USE_GTK_TOOLTIP_API
-  gulong tooltip_id;
+  guint tooltip_timeout_id;
+  gulong tooltip_handler_id;
 #endif
 
   /* settings */




More information about the Goodies-commits mailing list