forked from AuroraMiddleware/gtk
Implement Control-F1 as toggle-tooltips-mode.
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1 as toggle-tooltips-mode. * gtk/gtktooltips.c: Remove parsing of tooltips style string from here ... now in gtkrc.c.
This commit is contained in:
parent
6b838a22d1
commit
803a1f6fbc
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -1,3 +1,11 @@
|
||||
Wed Feb 13 15:42:42 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtktooltips.[ch] gtkwidget.c: Implement Control-F1
|
||||
as toggle-tooltips-mode.
|
||||
|
||||
* gtk/gtktooltips.c: Remove parsing of tooltips style
|
||||
string from here ... now in gtkrc.c.
|
||||
|
||||
Wed Feb 13 12:41:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkmain.c (gtk_init_check): g_warning() if setting
|
||||
|
@ -49,7 +49,7 @@ static void gtk_tooltips_class_init (GtkTooltipsClass *klass);
|
||||
static void gtk_tooltips_init (GtkTooltips *tooltips);
|
||||
static void gtk_tooltips_destroy (GtkObject *object);
|
||||
|
||||
static gint gtk_tooltips_event_handler (GtkWidget *widget,
|
||||
static void gtk_tooltips_event_handler (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
static void gtk_tooltips_widget_unmap (GtkWidget *widget,
|
||||
gpointer data);
|
||||
@ -62,6 +62,8 @@ static gint gtk_tooltips_timeout (gpointer data);
|
||||
static gint gtk_tooltips_paint_window (GtkTooltips *tooltips);
|
||||
static void gtk_tooltips_draw_tips (GtkTooltips *tooltips);
|
||||
|
||||
static gboolean get_keyboard_mode (GtkWidget *widget);
|
||||
|
||||
static GtkObjectClass *parent_class;
|
||||
static const gchar *tooltips_data_key = "_GtkTooltipsData";
|
||||
|
||||
@ -104,19 +106,6 @@ gtk_tooltips_class_init (GtkTooltipsClass *class)
|
||||
static void
|
||||
gtk_tooltips_init (GtkTooltips *tooltips)
|
||||
{
|
||||
static gboolean have_rc = FALSE;
|
||||
if (!have_rc)
|
||||
{
|
||||
have_rc = TRUE;
|
||||
|
||||
gtk_rc_parse_string ("style \"gtk-default-tooltips-style\" {\n"
|
||||
" bg[NORMAL] = \"#ffffc0\"\n"
|
||||
" fg[NORMAL] = \"#000000\"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"widget \"gtk-tooltips*\" style : gtk \"gtk-default-tooltips-style\"\n");
|
||||
}
|
||||
|
||||
tooltips->tip_window = NULL;
|
||||
tooltips->active_tips_data = NULL;
|
||||
tooltips->tips_data_list = NULL;
|
||||
@ -293,7 +282,7 @@ gtk_tooltips_set_tip (GtkTooltips *tooltips,
|
||||
|
||||
tooltips->tips_data_list = g_list_append (tooltips->tips_data_list,
|
||||
tooltipsdata);
|
||||
gtk_signal_connect_after (GTK_OBJECT (widget), "event",
|
||||
gtk_signal_connect_after (GTK_OBJECT (widget), "event-after",
|
||||
(GtkSignalFunc) gtk_tooltips_event_handler,
|
||||
tooltipsdata);
|
||||
|
||||
@ -326,13 +315,14 @@ gtk_tooltips_paint_window (GtkTooltips *tooltips)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tooltips_draw_tips (GtkTooltips * tooltips)
|
||||
gtk_tooltips_draw_tips (GtkTooltips *tooltips)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
GtkWidget *widget;
|
||||
GtkStyle *style;
|
||||
gint x, y, w, h, scr_w, scr_h;
|
||||
GtkTooltipsData *data;
|
||||
gboolean keyboard_mode;
|
||||
|
||||
if (!tooltips->tip_window)
|
||||
gtk_tooltips_force_window (tooltips);
|
||||
@ -344,6 +334,8 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips)
|
||||
|
||||
widget = tooltips->active_tips_data->widget;
|
||||
|
||||
keyboard_mode = get_keyboard_mode (widget);
|
||||
|
||||
scr_w = gdk_screen_width ();
|
||||
scr_h = gdk_screen_height ();
|
||||
|
||||
@ -355,10 +347,17 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips)
|
||||
w = requisition.width;
|
||||
h = requisition.height;
|
||||
|
||||
gdk_window_get_pointer (NULL, &x, NULL, NULL);
|
||||
gdk_window_get_origin (widget->window, NULL, &y);
|
||||
gdk_window_get_origin (widget->window, &x, &y);
|
||||
if (GTK_WIDGET_NO_WINDOW (widget))
|
||||
y += widget->allocation.y;
|
||||
{
|
||||
x += widget->allocation.x;
|
||||
y += widget->allocation.y;
|
||||
}
|
||||
|
||||
x += widget->allocation.width / 2;
|
||||
|
||||
if (!keyboard_mode)
|
||||
gdk_window_get_pointer (NULL, &x, NULL, NULL);
|
||||
|
||||
x -= (w / 2 + 4);
|
||||
|
||||
@ -434,6 +433,35 @@ gtk_tooltips_set_active_widget (GtkTooltips *tooltips,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tooltips_show_tip (GtkWidget *widget)
|
||||
{
|
||||
GtkTooltipsData *tooltipsdata;
|
||||
|
||||
tooltipsdata = gtk_tooltips_data_get (widget);
|
||||
|
||||
if (tooltipsdata &&
|
||||
(!tooltipsdata->tooltips->active_tips_data ||
|
||||
tooltipsdata->tooltips->active_tips_data->widget != widget))
|
||||
{
|
||||
gtk_tooltips_set_active_widget (tooltipsdata->tooltips, widget);
|
||||
gtk_tooltips_draw_tips (tooltipsdata->tooltips);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tooltips_hide_tip (GtkWidget *widget)
|
||||
{
|
||||
GtkTooltipsData *tooltipsdata;
|
||||
|
||||
tooltipsdata = gtk_tooltips_data_get (widget);
|
||||
|
||||
if (tooltipsdata &&
|
||||
(tooltipsdata->tooltips->active_tips_data &&
|
||||
tooltipsdata->tooltips->active_tips_data->widget == widget))
|
||||
gtk_tooltips_set_active_widget (tooltipsdata->tooltips, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_tooltips_recently_shown (GtkTooltips *tooltips)
|
||||
{
|
||||
@ -446,67 +474,122 @@ gtk_tooltips_recently_shown (GtkTooltips *tooltips)
|
||||
return (msec < STICKY_REVERT_DELAY);
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
get_keyboard_mode (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
return GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode"));
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
start_keyboard_mode (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
GtkWidget *focus = GTK_WINDOW (toplevel)->focus_widget;
|
||||
if (focus)
|
||||
gtk_tooltips_show_tip (focus);
|
||||
|
||||
g_object_set_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode", GUINT_TO_POINTER (TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
stop_keyboard_mode (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
|
||||
if (GTK_IS_WINDOW (toplevel))
|
||||
{
|
||||
GtkWidget *focus = GTK_WINDOW (toplevel)->focus_widget;
|
||||
if (focus)
|
||||
gtk_tooltips_hide_tip (focus);
|
||||
|
||||
g_object_set_data (G_OBJECT (toplevel), "gtk-tooltips-keyboard-mode", GUINT_TO_POINTER (FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tooltips_event_handler (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkTooltips *tooltips;
|
||||
GtkTooltipsData *old_tips_data;
|
||||
GtkWidget *event_widget;
|
||||
gboolean keyboard_mode = get_keyboard_mode (widget);
|
||||
|
||||
if ((event->type == GDK_LEAVE_NOTIFY || event->type == GDK_ENTER_NOTIFY) &&
|
||||
event->crossing.detail == GDK_NOTIFY_INFERIOR)
|
||||
return FALSE;
|
||||
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
if (event_widget != widget)
|
||||
return FALSE;
|
||||
|
||||
old_tips_data = gtk_tooltips_data_get (widget);
|
||||
tooltips = old_tips_data->tooltips;
|
||||
|
||||
switch (event->type)
|
||||
if (keyboard_mode)
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
case GDK_EXPOSE:
|
||||
/* do nothing */
|
||||
break;
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
old_tips_data = tooltips->active_tips_data;
|
||||
if (tooltips->enabled &&
|
||||
(!old_tips_data || old_tips_data->widget != widget))
|
||||
switch (event->type)
|
||||
{
|
||||
guint delay;
|
||||
|
||||
gtk_tooltips_set_active_widget (tooltips, widget);
|
||||
|
||||
if (tooltips->use_sticky_delay &&
|
||||
gtk_tooltips_recently_shown (tooltips))
|
||||
delay = STICKY_DELAY;
|
||||
case GDK_FOCUS_CHANGE:
|
||||
if (event->focus_change.in)
|
||||
gtk_tooltips_show_tip (widget);
|
||||
else
|
||||
delay = tooltips->delay;
|
||||
tooltips->timer_tag = gtk_timeout_add (delay,
|
||||
gtk_tooltips_timeout,
|
||||
(gpointer) tooltips);
|
||||
gtk_tooltips_hide_tip (widget);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
if (event_widget != widget)
|
||||
return FALSE;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_MOTION_NOTIFY:
|
||||
case GDK_EXPOSE:
|
||||
/* do nothing */
|
||||
break;
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
old_tips_data = tooltips->active_tips_data;
|
||||
if (tooltips->enabled &&
|
||||
(!old_tips_data || old_tips_data->widget != widget))
|
||||
{
|
||||
guint delay;
|
||||
|
||||
gtk_tooltips_set_active_widget (tooltips, widget);
|
||||
|
||||
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;
|
||||
}
|
||||
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);
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -537,25 +620,12 @@ gtk_tooltips_widget_remove (GtkWidget *widget,
|
||||
gtk_tooltips_destroy_data (tooltipsdata);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_tooltips_show_tip (GtkWidget *widget)
|
||||
void
|
||||
_gtk_tooltips_toggle_keyboard_mode (GtkWidget *widget)
|
||||
{
|
||||
/* Showing the tip from the keyboard */
|
||||
|
||||
/* FIXME this function is completely broken right now,
|
||||
* popdown doesn't occur when it should.
|
||||
*/
|
||||
|
||||
GtkTooltipsData *tooltipsdata;
|
||||
|
||||
tooltipsdata = gtk_tooltips_data_get (widget);
|
||||
|
||||
if (tooltipsdata == NULL)
|
||||
return FALSE;
|
||||
|
||||
gtk_tooltips_set_active_widget (tooltipsdata->tooltips,
|
||||
widget);
|
||||
|
||||
gtk_tooltips_timeout (tooltipsdata->tooltips);
|
||||
return TRUE;
|
||||
if (get_keyboard_mode (widget))
|
||||
stop_keyboard_mode (widget);
|
||||
else
|
||||
start_keyboard_mode (widget);
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ struct _GtkTooltips
|
||||
guint delay : 30;
|
||||
guint enabled : 1;
|
||||
guint have_grab : 1;
|
||||
guint use_sticky_delay : 1;
|
||||
gint timer_tag;
|
||||
gboolean use_sticky_delay;
|
||||
GTimeVal last_popdown;
|
||||
};
|
||||
|
||||
@ -94,7 +94,7 @@ GtkTooltipsData* gtk_tooltips_data_get (GtkWidget *widget);
|
||||
void gtk_tooltips_force_window (GtkTooltips *tooltips);
|
||||
|
||||
|
||||
gboolean _gtk_tooltips_show_tip (GtkWidget *widget);
|
||||
void _gtk_tooltips_toggle_keyboard_mode (GtkWidget *widget);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -3400,9 +3400,12 @@ gtk_widget_real_show_help (GtkWidget *widget,
|
||||
GtkWidgetHelpType help_type)
|
||||
{
|
||||
if (help_type == GTK_WIDGET_HELP_TOOLTIP)
|
||||
return _gtk_tooltips_show_tip (widget);
|
||||
{
|
||||
_gtk_tooltips_toggle_keyboard_mode (widget);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user