[Xfce4-commits] <xfce4-diskperf-plugin:master> Use newer tooltip API (bug #8730).

Landry Breuil noreply at xfce.org
Sun May 13 21:12:01 CEST 2012


Updating branch refs/heads/master
         to c8d14b580ca2d580984439be9d9eb6180d027376 (commit)
       from 6ab7dbf56c8ce498164a3c6f9eca56dea83d8dc1 (commit)

commit c8d14b580ca2d580984439be9d9eb6180d027376
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun May 13 21:08:59 2012 +0200

    Use newer tooltip API (bug #8730).
    
    This updates the plugin to use the newer tooltip API
    (requires >=GTK-2.12) and fixes tooltips not showing for
    update intervals smaller then 500ms.

 panel-plugin/main.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index eea4f8a..7efbc7e 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -168,8 +168,6 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
  /* Get the last disk perfomance data, compute the statistics and update
     the panel-docked monitor bars */
 {
-    static GtkTooltips *s_poToolTips = 0;
-
     struct devperf_t oPerf;
     struct param_t *poConf = &(p_poPlugin->oConf.oParam);
     struct monitor_t *poMonitor = &(p_poPlugin->oMonitor);
@@ -184,9 +182,6 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
     char            acToolTips[256];
     int             status, i;
 
-    if (!s_poToolTips)
-	s_poToolTips = gtk_tooltips_new ();
-
     rbytes = wbytes = iRBusy_ns = iWBusy_ns = -1;
     memset (&oPerf, 0, sizeof (oPerf));
     oPerf.qlen = -1;
@@ -201,8 +196,8 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
     snprintf (acToolTips, sizeof(acToolTips), _("%s: Device statistics unavailable."),
               poConf->acTitle);
     UpdateProgressBars(p_poPlugin, 0, 0, 0);
-    gtk_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox),
-			  acToolTips, 0);
+    gtk_widget_set_tooltip_text(GTK_WIDGET(poMonitor->wEventBox), acToolTips);
+
 	return (-1);
     }
     if (poMonitor->oPrevPerf.timestamp_ns) {
@@ -262,8 +257,7 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
 	     (int) round(arBusy[W_DATA]) : -1,
 #endif
 	     (oPerf.qlen >= 0) ? (int) round(arBusy[RW_DATA]) : -1);
-    gtk_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox),
-			  acToolTips, 0);
+    gtk_widget_set_tooltip_text(GTK_WIDGET(poMonitor->wEventBox), acToolTips);
 
     switch (poConf->eStatistics) {
 	case BUSY_TIME:
@@ -307,6 +301,14 @@ static gboolean SetTimer (void *p_pvPlugin)
         timerNeedsUpdate = 0;
     }
 
+    /* reduce the default tooltip timeout to be smaller than the update interval otherwise
+     * we won't see tooltips on GTK 2.16 or newer */
+    GtkSettings *settings;
+    settings = gtk_settings_get_default();
+    if (g_object_class_find_property(G_OBJECT_GET_CLASS(settings), "gtk-tooltip-timeout"))
+        g_object_set(settings, "gtk-tooltip-timeout",
+                     poConf->iPeriod_ms - 10, NULL);
+
     if (!poPlugin->iTimerId)
         poPlugin->iTimerId = g_timeout_add (poConf->iPeriod_ms,
 					    (GSourceFunc) SetTimer, poPlugin);


More information about the Xfce4-commits mailing list