Commit e90d8357 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

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
parent ca26902c
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
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
Sat Feb 17 06:47:27 2001 Tim Janik <timj@gtk.org>
* gtk/gtkmenu.c (gtk_menu_motion_notify): default initialize the
......
......@@ -525,7 +525,7 @@ gtk_label_ensure_layout (GtkLabel *label,
{
GtkWidget *widget;
PangoRectangle logical_rect;
gint width, height;
gint rwidth, rheight;
widget = GTK_WIDGET (label);
......@@ -550,8 +550,8 @@ gtk_label_ensure_layout (GtkLabel *label,
* don't think it's really that slow.
*/
width = label->misc.xpad * 2;
height = label->misc.ypad * 2;
rwidth = label->misc.xpad * 2;
rheight = label->misc.ypad * 2;
if (!label->layout)
{
......@@ -613,8 +613,8 @@ gtk_label_ensure_layout (GtkLabel *label,
pango_layout_set_width (label->layout, aux_info->width * PANGO_SCALE);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
width += aux_info->width;
height += PANGO_PIXELS (logical_rect.height);
rwidth += aux_info->width;
rheight += PANGO_PIXELS (logical_rect.height);
}
else
{
......@@ -681,8 +681,8 @@ gtk_label_ensure_layout (GtkLabel *label,
}
pango_layout_set_width (label->layout, width);
width += PANGO_PIXELS (real_width);
height += PANGO_PIXELS (height);
rwidth += PANGO_PIXELS (real_width);
rheight += PANGO_PIXELS (height);
}
}
else /* !label->wrap */
......@@ -690,15 +690,15 @@ gtk_label_ensure_layout (GtkLabel *label,
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
width += PANGO_PIXELS (logical_rect.width);
height += PANGO_PIXELS (logical_rect.height);
rwidth += PANGO_PIXELS (logical_rect.width);
rheight += PANGO_PIXELS (logical_rect.height);
}
if (widthp)
*widthp = width;
*widthp = rwidth;
if (heightp)
*heightp = height;
*heightp = rheight;
}
static void
......
......@@ -253,7 +253,7 @@ gtk_progress_bar_get_arg (GtkObject *object,
GTK_VALUE_FLOAT (*arg) = pbar->pulse_fraction;
break;
case ARG_TEXT:
GTK_VALUE_STRING (*arg) = gtk_progress_bar_get_text (pbar);
GTK_VALUE_STRING (*arg) = g_strdup (gtk_progress_bar_get_text (pbar));
break;
default:
arg->type = GTK_TYPE_INVALID;
......@@ -939,11 +939,14 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
* gtk_progress_bar_get_text:
* @pbar: a #GtkProgressBar
*
* Retrieves the text displayed superimposed on the progress bar.
* Retrieves the text displayed superimposed on the progress bar,
* if any, otherwise %NULL. The return value is a reference
* to the text, not a copy of it, so will become invalid
* if you change the text in the progress bar.
*
* Return value: a string which must be freed, or %NULL
* Return value: text, or %NULL; don't free the string
**/
gchar*
G_CONST_RETURN gchar*
gtk_progress_bar_get_text (GtkProgressBar *pbar)
{
g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), NULL);
......@@ -951,7 +954,7 @@ gtk_progress_bar_get_text (GtkProgressBar *pbar)
if (GTK_PROGRESS (pbar)->use_text_format)
return NULL;
else
return g_strdup (GTK_PROGRESS (pbar)->format);
return GTK_PROGRESS (pbar)->format;
}
/**
......
......@@ -128,9 +128,9 @@ void gtk_progress_bar_set_pulse_step (GtkProgressBar *pbar,
void gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
GtkProgressBarOrientation orientation);
gchar* gtk_progress_bar_get_text (GtkProgressBar *pbar);
gfloat gtk_progress_bar_get_fraction (GtkProgressBar *pbar);
gfloat gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar);
G_CONST_RETURN gchar* gtk_progress_bar_get_text (GtkProgressBar *pbar);
gfloat gtk_progress_bar_get_fraction (GtkProgressBar *pbar);
gfloat gtk_progress_bar_get_pulse_step (GtkProgressBar *pbar);
GtkProgressBarOrientation gtk_progress_bar_get_orientation (GtkProgressBar *pbar);
......
......@@ -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;
......
......@@ -68,6 +68,8 @@ struct _GtkTooltips
guint delay : 30;
guint enabled : 1;
gint timer_tag;
gboolean use_sticky_delay;
GTimeVal last_popdown;
};
struct _GtkTooltipsClass
......
......@@ -121,7 +121,7 @@ typedef void (*GtkCallbackMarshal) (GtkObject *object,
gpointer data,
guint n_args,
GtkArg *args);
typedef void (*GtkSignalFunc) ();
typedef void (*GtkSignalFunc) (void);
typedef GSignalCMarshaller GtkSignalMarshaller;
#define GTK_SIGNAL_FUNC(f) ((GtkSignalFunc) (f))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment