From 5b3e2c6c0fdde21ffc79de3b14a6cce626034eb7 Mon Sep 17 00:00:00 2001 From: Andrea Villa Date: Wed, 18 Apr 2012 20:02:15 +0200 Subject: [PATCH] tooltip bug quick fix --- panel-plugin/main.c | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/panel-plugin/main.c b/panel-plugin/main.c index 05ce707..2ae06d1 100644 --- a/panel-plugin/main.c +++ b/panel-plugin/main.c @@ -137,6 +137,8 @@ typedef struct diskperf_t { struct conf_t oConf; struct monitor_t oMonitor; + GtkWidget *tooltip_text; + } diskperf_t; /**************************************************************/ @@ -147,7 +149,7 @@ 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; +// static GtkTooltips *s_poToolTips = 0; struct devperf_t oPerf; struct param_t *poConf = &(p_poPlugin->oConf.oParam); @@ -160,8 +162,8 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin) char acToolTips[256]; int status, i; - if (!s_poToolTips) - s_poToolTips = gtk_tooltips_new (); +// if (!s_poToolTips) +// s_poToolTips = gtk_tooltips_new (); rbytes = wbytes = iRBusy_ns = iWBusy_ns = -1; memset (&oPerf, 0, sizeof (oPerf)); @@ -230,8 +232,9 @@ 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_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox), +// acToolTips, 0); + gtk_label_set_text(GTK_LABEL(p_poPlugin->tooltip_text), acToolTips); switch (poConf->eStatistics) { case BUSY_TIME: @@ -460,11 +463,26 @@ static diskperf_t *diskperf_create_control (XfcePanelPlugin *plugin) /**************************************************************/ + + + +/* ---------------------------------------------------------------------------------------------- */ +static gboolean tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip, struct diskperf_t *poPlugin) +{ + gtk_tooltip_set_custom(tooltip, poPlugin->tooltip_text); + return TRUE; +} + + + + + static void diskperf_free (XfcePanelPlugin *plugin, diskperf_t *poPlugin) /* Plugin API */ { if (poPlugin->iTimerId) g_source_remove (poPlugin->iTimerId); + gtk_widget_destroy(poPlugin->tooltip_text); g_free (poPlugin); } /* diskperf_free() */ @@ -1148,7 +1166,7 @@ static void diskperf_construct (XfcePanelPlugin *plugin) g_signal_connect (plugin, "save", G_CALLBACK (diskperf_write_config), diskperf); - + g_signal_connect (plugin, "size-changed", G_CALLBACK (diskperf_set_size), diskperf); @@ -1168,6 +1186,11 @@ static void diskperf_construct (XfcePanelPlugin *plugin) G_CALLBACK (diskperf_create_options), diskperf); gtk_container_add (GTK_CONTAINER (plugin), diskperf->oMonitor.wEventBox); + + gtk_widget_set_has_tooltip(diskperf->oMonitor.wEventBox, TRUE); + g_signal_connect(diskperf->oMonitor.wEventBox, "query-tooltip", G_CALLBACK(tooltip_cb), diskperf); + diskperf->tooltip_text = gtk_label_new(NULL); + g_object_ref(diskperf->tooltip_text); CreateMonitorBars (diskperf, xfce_panel_plugin_get_orientation (plugin)); -- 1.7.5.4