diff options
author | Havoc Pennington <hp@pobox.com> | 2001-02-17 17:21:21 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-02-17 17:21:21 +0000 |
commit | e90d8357a9d9bedba20ac2b6feb67294fb232e28 (patch) | |
tree | f8e820165a9452afbb68b59e831634a7edd6a641 /gtk/gtktooltips.c | |
parent | ca26902c651c7868c3e9880c0b2864d7ad42554f (diff) | |
download | gtk+-e90d8357a9d9bedba20ac2b6feb67294fb232e28.tar.gz |
fix screwup with shadowed variables that had broken size request in some
2001-02-17 Havoc Pennington <hp@pobox.com>
* gtk/gtklabel.c (gtk_label_ensure_layout): fix screwup with
shadowed variables that had broken size request in some cases,
leading to bogus tooltips (#50996)
2001-02-06 Jon K Hellan <hellan@acm.org>
Implement fast browsing of tooltips, bug #50619
* gtk/gtktooltips.h (struct _GtkTooltips): Add use_sticky_delay
and last_popdown
* gtk/gtktooltips.c (gtk_tooltips_init): Initialize sticky_delay,
use_sticky_delay and last_popdown.
(gtk_tooltips_draw_tips, gtk_tooltips_set_active_widget): Record
time of popdown.
(gtk_tooltips_set_active_widget): Unset sticky behaviour if widget
is NULL.
(gtk_tooltips_recently_shown): New static function. Return true
if < sticky_delay has elapsed since last popdown.
(gtk_tooltips_event_handler): Display window after sticky_delay
(presumably < normal delay) if < STICKY_REVERT_DELAY has elapsed
since last popdown.
2001-02-17 Havoc Pennington <hp@pobox.com>
* gtk/gtktypeutils.h (GtkSignalFunc): change it to take (void)
instead of (). #6394
* gtk/gtkprogressbar.c (gtk_progress_bar_get_text): Add
G_CONST_RETURN, make it return by reference, #50473
Diffstat (limited to 'gtk/gtktooltips.c')
-rw-r--r-- | gtk/gtktooltips.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index 5de565ada5..faf7254340 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -38,6 +38,12 @@ #define DEFAULT_DELAY 500 /* Default delay in ms */ +#define STICKY_DELAY 0 /* Delay before popping up next tip + * if we're sticky + */ +#define STICKY_REVERT_DELAY 1000 /* Delay before sticky tooltips revert + * to normal + */ static void gtk_tooltips_class_init (GtkTooltipsClass *klass); static void gtk_tooltips_init (GtkTooltips *tooltips); @@ -105,6 +111,9 @@ gtk_tooltips_init (GtkTooltips *tooltips) tooltips->delay = DEFAULT_DELAY; tooltips->enabled = TRUE; tooltips->timer_tag = 0; + tooltips->use_sticky_delay = FALSE; + tooltips->last_popdown.tv_sec = -1; + tooltips->last_popdown.tv_usec = -1; } GtkTooltips * @@ -310,7 +319,10 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips) if (!tooltips->tip_window) gtk_tooltips_force_window (tooltips); else if (GTK_WIDGET_VISIBLE (tooltips->tip_window)) - gtk_widget_hide (tooltips->tip_window); + { + gtk_widget_hide (tooltips->tip_window); + g_get_current_time (&tooltips->last_popdown); + } gtk_widget_ensure_style (tooltips->tip_window); style = tooltips->tip_window->style; @@ -369,7 +381,11 @@ gtk_tooltips_set_active_widget (GtkTooltips *tooltips, GtkWidget *widget) { if (tooltips->tip_window) - gtk_widget_hide (tooltips->tip_window); + { + if (GTK_WIDGET_VISIBLE (tooltips->tip_window)) + g_get_current_time (&tooltips->last_popdown); + gtk_widget_hide (tooltips->tip_window); + } if (tooltips->timer_tag) { gtk_timeout_remove (tooltips->timer_tag); @@ -396,6 +412,22 @@ gtk_tooltips_set_active_widget (GtkTooltips *tooltips, } } } + else + { + tooltips->use_sticky_delay = FALSE; + } +} + +static gboolean +gtk_tooltips_recently_shown (GtkTooltips *tooltips) +{ + GTimeVal now; + glong msec; + + g_get_current_time (&now); + msec = (now.tv_sec - tooltips->last_popdown.tv_sec) * 1000 + + (now.tv_usec - tooltips->last_popdown.tv_usec) / 1000; + return (msec < STICKY_REVERT_DELAY); } static gint @@ -429,14 +461,31 @@ gtk_tooltips_event_handler (GtkWidget *widget, if (tooltips->enabled && (!old_tips_data || old_tips_data->widget != widget)) { + guint delay; + gtk_tooltips_set_active_widget (tooltips, widget); - tooltips->timer_tag = gtk_timeout_add (tooltips->delay, + if (tooltips->use_sticky_delay && + gtk_tooltips_recently_shown (tooltips)) + delay = STICKY_DELAY; + else + delay = tooltips->delay; + tooltips->timer_tag = gtk_timeout_add (delay, gtk_tooltips_timeout, (gpointer) tooltips); } break; + case GDK_LEAVE_NOTIFY: + { + gboolean use_sticky_delay; + + use_sticky_delay = tooltips->tip_window && + GTK_WIDGET_VISIBLE (tooltips->tip_window); + gtk_tooltips_set_active_widget (tooltips, NULL); + tooltips->use_sticky_delay = use_sticky_delay; + } + break; default: gtk_tooltips_set_active_widget (tooltips, NULL); break; |