summaryrefslogtreecommitdiff
path: root/gtk/gtkvolumebutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-07-09 20:32:35 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-07-09 20:32:35 +0000
commit4397046785b4e425f1ad8c5b4c0155ddb5424482 (patch)
tree71d334cc88dcc9dd686a23d385951fca7d879afd /gtk/gtkvolumebutton.c
parent5450603225779045e1dc04e8d5874d930a18a2b3 (diff)
downloadgtk+-4397046785b4e425f1ad8c5b4c0155ddb5424482.tar.gz
Remove deprecated tooltips, use new tooltips API. (#449311, Jan Arne
2007-07-09 Matthias Clasen <mclasen@redhat.com> * gtk/gtkvolumebutton.c: Remove deprecated tooltips, use new tooltips API. (#449311, Jan Arne Petersen) svn path=/trunk/; revision=18424
Diffstat (limited to 'gtk/gtkvolumebutton.c')
-rw-r--r--gtk/gtkvolumebutton.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/gtk/gtkvolumebutton.c b/gtk/gtkvolumebutton.c
index 41a7373fba..a77f71b2c1 100644
--- a/gtk/gtkvolumebutton.c
+++ b/gtk/gtkvolumebutton.c
@@ -33,8 +33,8 @@
#include <atk/atk.h>
#include "gtkvolumebutton.h"
-#include "gtktooltips.h"
#include "gtkstock.h"
+#include "gtktooltip.h"
#include "gtkalias.h"
@@ -43,13 +43,16 @@
struct _GtkVolumeButton
{
GtkScaleButton parent;
- GtkTooltips *tooltips;
};
static void gtk_volume_button_class_init (GtkVolumeButtonClass *klass);
static void gtk_volume_button_init (GtkVolumeButton *button);
-static void gtk_volume_button_dispose (GObject *object);
-static void gtk_volume_button_update_tooltip(GtkVolumeButton *button);
+static gboolean cb_query_tooltip (GtkWidget *button,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data);
static void cb_value_changed (GtkVolumeButton *button,
gdouble value,
gpointer user_data);
@@ -59,9 +62,6 @@ G_DEFINE_TYPE (GtkVolumeButton, gtk_volume_button, GTK_TYPE_SCALE_BUTTON)
static void
gtk_volume_button_class_init (GtkVolumeButtonClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->dispose = gtk_volume_button_dispose;
}
static void
@@ -90,30 +90,15 @@ gtk_volume_button_init (GtkVolumeButton *button)
g_object_set (G_OBJECT (button),
"adjustment", adj,
"size", GTK_ICON_SIZE_SMALL_TOOLBAR,
+ "has-tooltip", TRUE,
NULL);
- button->tooltips = gtk_tooltips_new ();
- g_object_ref_sink (button->tooltips);
- gtk_volume_button_update_tooltip (button);
-
+ g_signal_connect (G_OBJECT (button), "query-tooltip",
+ G_CALLBACK (cb_query_tooltip), NULL);
g_signal_connect (G_OBJECT (button), "value-changed",
G_CALLBACK (cb_value_changed), NULL);
}
-static void
-gtk_volume_button_dispose (GObject *object)
-{
- GtkVolumeButton *button;
-
- button = GTK_VOLUME_BUTTON (object);
-
- if (button->tooltips)
- g_object_unref (button->tooltips);
- button->tooltips = NULL;
-
- G_OBJECT_CLASS (gtk_volume_button_parent_class)->dispose (object);
-}
-
/**
* gtk_volume_button_new
*
@@ -133,8 +118,13 @@ gtk_volume_button_new (void)
return GTK_WIDGET (button);
}
-static void
-gtk_volume_button_update_tooltip (GtkVolumeButton *button)
+static gboolean
+cb_query_tooltip (GtkWidget *button,
+ gint x,
+ gint y,
+ gboolean keyboard_mode,
+ GtkTooltip *tooltip,
+ gpointer user_data)
{
GtkScaleButton *scale_button = GTK_SCALE_BUTTON (button);
GtkAdjustment *adj;
@@ -168,16 +158,16 @@ gtk_volume_button_update_tooltip (GtkVolumeButton *button)
str = g_strdup_printf (Q_("volume percentage|%d %%"), percent);
}
- gtk_tooltips_set_tip (button->tooltips,
- GTK_WIDGET (button),
- str, NULL);
+ gtk_tooltip_set_text (tooltip, str);
g_free (str);
+
+ return TRUE;
}
static void
cb_value_changed (GtkVolumeButton *button, gdouble value, gpointer user_data)
{
- gtk_volume_button_update_tooltip (button);
+ gtk_widget_trigger_tooltip_query (GTK_WIDGET (button));
}