[Xfce4-commits] <xfce4-netload-plugin:master> Upgrade from GtkTooltips to GtkTooltip
Florian Rivoal
noreply at xfce.org
Fri Nov 12 02:52:01 CET 2010
Updating branch refs/heads/master
to 343303d7eab8b7d9464d32eff9134b024581daf4 (commit)
from 5454e32347d681e4f2398b9f10d87542dd81ed74 (commit)
commit 343303d7eab8b7d9464d32eff9134b024581daf4
Author: Florian Rivoal <frivoal at xfce.org>
Date: Fri Nov 12 10:32:47 2010 +0900
Upgrade from GtkTooltips to GtkTooltip
The former was deprecated, and caused problems in some cases.
Fixes bug #5177.
panel-plugin/netload.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c
index c1fa4d2..e0d4550 100644
--- a/panel-plugin/netload.c
+++ b/panel-plugin/netload.c
@@ -30,8 +30,6 @@
#include <libxfce4panel/xfce-panel-plugin.h>
-static GtkTooltips *tooltips = NULL;
-
#define BORDER 8
/* Defaults */
@@ -119,6 +117,7 @@ typedef struct
GtkWidget *ebox;
GtkWidget *box;
+ GtkWidget *tooltip_text;
guint timeout_id;
t_monitor *monitor;
@@ -143,7 +142,7 @@ static gboolean update_monitors(t_global_monitor *global)
g_snprintf(caption, sizeof(caption),
_("<< %s >> (Interface down)"),
get_name(&(global->monitor->data)));
- gtk_tooltips_set_tip(tooltips, GTK_WIDGET(global->ebox), caption, NULL);
+ gtk_label_set_text(GTK_LABEL(global->tooltip_text), caption);
return TRUE;
}
@@ -229,7 +228,7 @@ static gboolean update_monitors(t_global_monitor *global)
"Incoming: %s kByte/s\nOutgoing: %s kByte/s\nTotal: %s kByte/s"),
get_name(&(global->monitor->data)), ip ? ip : _("no IP address"),
HISTSIZE_CALCULATE, buffer[IN], buffer[OUT], buffer[TOT]);
- gtk_tooltips_set_tip(tooltips, GTK_WIDGET(global->ebox), caption, NULL);
+ gtk_label_set_text(GTK_LABEL(global->tooltip_text), caption);
}
return TRUE;
@@ -340,6 +339,12 @@ static void monitor_set_orientation (XfcePanelPlugin *plugin, GtkOrientation ori
run_update( global );
}
+/* ---------------------------------------------------------------------------------------------- */
+static gboolean tooltip_cb(GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip, t_global_monitor *global)
+{
+ gtk_tooltip_set_custom(tooltip, global->tooltip_text);
+ return TRUE;
+}
/* ---------------------------------------------------------------------------------------------- */
static void monitor_free(XfcePanelPlugin *plugin, t_global_monitor *global)
@@ -353,6 +358,9 @@ static void monitor_free(XfcePanelPlugin *plugin, t_global_monitor *global)
{
g_free(global->monitor->options.label_text);
}
+
+ gtk_widget_destroy(global->tooltip_text);
+
g_free(global);
close_netload( &(global->monitor->data) );
@@ -368,17 +376,17 @@ static t_global_monitor * monitor_new(XfcePanelPlugin *plugin)
global = g_new(t_global_monitor, 1);
global->timeout_id = 0;
global->ebox = gtk_event_box_new();
+ gtk_widget_set_has_tooltip(global->ebox, TRUE);
+ g_signal_connect(global->ebox, "query-tooltip", G_CALLBACK(tooltip_cb), global);
gtk_widget_show(global->ebox);
global->box = NULL;
+ global->tooltip_text = gtk_label_new(NULL);
+ g_object_ref(global->tooltip_text);
+
global->plugin = plugin;
xfce_panel_plugin_add_action_widget (plugin, global->ebox);
- if (!tooltips)
- {
- tooltips = gtk_tooltips_new();
- }
-
global->monitor = g_new(t_monitor, 1);
global->monitor->options.label_text = g_strdup(DEFAULT_TEXT);
global->monitor->options.network_device = g_strdup("");
More information about the Xfce4-commits
mailing list