Special case menu items to pop down on motion. (#75961)

Wed May 15 17:12:50 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktooltips.c: Special case menu items to
        pop down on motion. (#75961)

        * tests/testgtk.c (create_item_factory): Add tooltips
        to the File menu.

        * gtk/gtkentry.c (update_im_cursor_location): Fix
        cursor locations passed to the IM context.
        (#80027, Yao Zhang)
This commit is contained in:
Owen Taylor 2002-05-15 21:46:42 +00:00 committed by Owen Taylor
parent 030ac8095a
commit 70d78734c5
9 changed files with 133 additions and 24 deletions

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -1,3 +1,15 @@
Wed May 15 17:12:50 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtktooltips.c: Special case menu items to
pop down on motion. (#75961)
* tests/testgtk.c (create_item_factory): Add tooltips
to the File menu.
* gtk/gtkentry.c (update_im_cursor_location): Fix
cursor locations passed to the IM context.
(#80027, Yao Zhang)
Wed May 15 16:52:57 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkfontsel.c: Update from contents of size entry

View File

@ -2367,11 +2367,11 @@ update_im_cursor_location (GtkEntry *entry)
GdkRectangle area;
gint strong_x;
gint strong_xoffset;
gint x, y, area_width, area_height;
gint area_width, area_height;
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL)
;
get_text_area_size (entry, &x, &y, &area_width, &area_height);
get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
strong_xoffset = strong_x - entry->scroll_offset;
if (strong_xoffset < 0)
@ -2382,9 +2382,9 @@ update_im_cursor_location (GtkEntry *entry)
{
strong_xoffset = area_width;
}
area.x = x + strong_xoffset;
area.y = y + area_height;
area.width = area_width;
area.x = strong_xoffset;
area.y = 0;
area.width = 0;
area.height = area_height;
gtk_im_context_set_cursor_location (entry->im_context, &area);

View File

@ -30,6 +30,7 @@
#include "gtklabel.h"
#include "gtkmain.h"
#include "gtkmenuitem.h"
#include "gtkwidget.h"
#include "gtkwindow.h"
#include "gtksignal.h"
@ -518,6 +519,31 @@ stop_keyboard_mode (GtkWidget *widget)
}
}
static void
gtk_tooltips_start_delay (GtkTooltips *tooltips,
GtkWidget *widget)
{
GtkTooltipsData *old_tips_data;
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);
}
}
static void
gtk_tooltips_event_handler (GtkWidget *widget,
GdkEvent *event)
@ -559,29 +585,11 @@ gtk_tooltips_event_handler (GtkWidget *widget,
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);
}
gtk_tooltips_start_delay (tooltips, widget);
break;
case GDK_LEAVE_NOTIFY:
@ -595,6 +603,17 @@ gtk_tooltips_event_handler (GtkWidget *widget,
}
break;
case GDK_MOTION_NOTIFY:
/* Handle menu items specially ... pend popup for each motion
* on other widgets, we ignore motion.
*/
if (GTK_IS_MENU_ITEM (widget))
{
gtk_tooltips_set_active_widget (tooltips, NULL);
gtk_tooltips_start_delay (tooltips, widget);
break;
}
break; /* ignore */
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_KEY_PRESS:

View File

@ -3598,6 +3598,7 @@ create_item_factory (GtkWidget *widget)
GtkWidget *button;
GtkAccelGroup *accel_group;
GtkItemFactory *item_factory;
GtkTooltips *tooltips;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -3628,6 +3629,23 @@ create_item_factory (GtkWidget *widget)
"/Preferences/Shape/Oval")),
TRUE);
/* Test how tooltips (ugh) work on menu items
*/
tooltips = gtk_tooltips_new ();
g_object_ref (tooltips);
gtk_object_sink (GTK_OBJECT (tooltips));
g_object_set_data_full (G_OBJECT (window), "testgtk-tooltips",
tooltips, (GDestroyNotify)g_object_unref);
gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/New"),
"Create a new file", NULL);
gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Open"),
"Open a file", NULL);
gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Save"),
"Safe file", NULL);
gtk_tooltips_set_tip (tooltips, gtk_item_factory_get_item (item_factory, "/File/Save As..."),
"Save under a new name", NULL);
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);