diff options
author | Alexander Larsson <alexl@redhat.com> | 2000-11-08 17:34:52 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2000-11-08 17:34:52 +0000 |
commit | 814957b46e16fbaf8999190c2052edbc347c71fe (patch) | |
tree | 0554a3123f5c6f7115db4ecbe4e7cacc00a7cccc /gtk/gtkoptionmenu.c | |
parent | b440118aa4644e30ef6d7d44f607f67f05536285 (diff) | |
download | gdk-pixbuf-814957b46e16fbaf8999190c2052edbc347c71fe.tar.gz |
Add note about GtkMenuPositionFunc API changes.
2000-11-08 Alexander Larsson <alexl@redhat.com>
* docs/Changes-2.0.txt: Add note about GtkMenuPositionFunc
API changes.
* gtk/gtkmenu.c: Add support for scrolling menus.
Remove gtk_menu_append/prepend/insert, these have been moved to
gtkcompat.h as #defines.
* gtk/gtkcompat.h.in:
Add compatibility #defines for gtk_menu_append/prepend/insert
* gtk/gtkmenu.h: Add data needed for scrolling menus.
GtkMenuPositionFunc gets an extra argument push_in.
gtk_menu_append/prepend/insert removed.
* gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Change menu
positioning behaviour to fit to scrolling menus.
* gtk/gtkmenuitem.c (gtk_menu_item_forall): Don't recurse
into menuitem->submeny. That is wrong, and broke torn
off submenus of torn off menus, since they were unrealized
when the first menu was unrealized.
* gtk/gtkmenushell.[ch]: Virtualize gtk_menu_shell_insert() and
gtk_menu_shell_select_item() since these need to be overridden in
GtkMenu.
* gtk/gtkoptionmenu.c (gtk_opttion_menu_position): Change menu
positioning behaviour to fit to scrolling menus.
(gtk_option_menu_key_press, gtk_option_menu_button_press): Select
the current item so that it is prelighted when the menu pops up.
This is a workaround to the fact that the menu doesn't get the
initial enter event (due to grabs).
* gtk/gtkfilesel.c, gtk/gtkinputdialog.c, gtk/testgtk.c:
s/gtk_menu_append/gtk_menu_shell_append/
* gtk/gtknotebook.c:
s/gtk_menu_insert/gtk_menu_shell_insert/
* gtk/testgtk.c (create_menu, create_menus):
Create the first menu with 50 items so that menu scrolling
can be tested.
Patch from Jonathan Blandford <jrb@redhat.com>
* gtk/gtkmenuitem.[ch] (gtk_menu_item_toggle_size_request): new
system to handle size requests. First, we ask what the size of
the toggle is. Then, when allocating the size, we allocate the
toggle_size first. This way we can have multiple menu-item
classes w/o needing a seperate class for each.
* gtk/gtkmenu.c (gtk_menu_size_request): Actually use the new system.
* gtk/gtkmenu.c (gtk_menu_size_allocate): Use the new system.
* gtk/gtkcheckmenuitem.c
(gtk_check_menu_item_toggle_size_request): New function to handle
the toggle size-request.
Diffstat (limited to 'gtk/gtkoptionmenu.c')
-rw-r--r-- | gtk/gtkoptionmenu.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index cca763d1a..db1a4f4b6 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -65,6 +65,7 @@ static void gtk_option_menu_calc_size (GtkOptionMenu *option_menu); static void gtk_option_menu_position (GtkMenu *menu, gint *x, gint *y, + gint *scroll_offet, gpointer user_data); static void gtk_option_menu_show_all (GtkWidget *widget); static void gtk_option_menu_hide_all (GtkWidget *widget); @@ -498,6 +499,7 @@ gtk_option_menu_button_press (GtkWidget *widget, GdkEventButton *event) { GtkOptionMenu *option_menu; + GtkWidget *menu_item; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), FALSE); @@ -512,6 +514,9 @@ gtk_option_menu_button_press (GtkWidget *widget, gtk_menu_popup (GTK_MENU (option_menu->menu), NULL, NULL, gtk_option_menu_position, option_menu, event->button, event->time); + menu_item = gtk_menu_get_active (GTK_MENU (option_menu->menu)); + if (menu_item) + gtk_menu_shell_select_item (GTK_MENU_SHELL (option_menu->menu), menu_item); return TRUE; } @@ -523,6 +528,7 @@ gtk_option_menu_key_press (GtkWidget *widget, GdkEventKey *event) { GtkOptionMenu *option_menu; + GtkWidget *menu_item; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), FALSE); @@ -537,6 +543,9 @@ gtk_option_menu_key_press (GtkWidget *widget, gtk_menu_popup (GTK_MENU (option_menu->menu), NULL, NULL, gtk_option_menu_position, option_menu, 0, event->time); + menu_item = gtk_menu_get_active (GTK_MENU (option_menu->menu)); + if (menu_item) + gtk_menu_shell_select_item (GTK_MENU_SHELL (option_menu->menu), menu_item); return TRUE; } @@ -650,6 +659,7 @@ static void gtk_option_menu_position (GtkMenu *menu, gint *x, gint *y, + gboolean *push_in, gpointer user_data) { GtkOptionMenu *option_menu; @@ -657,13 +667,10 @@ gtk_option_menu_position (GtkMenu *menu, GtkWidget *child; GtkRequisition requisition; GList *children; - gint shift_menu; gint screen_width; - gint screen_height; gint menu_xpos; gint menu_ypos; - gint width; - gint height; + gint menu_width; g_return_if_fail (user_data != NULL); g_return_if_fail (GTK_IS_OPTION_MENU (user_data)); @@ -671,11 +678,9 @@ gtk_option_menu_position (GtkMenu *menu, option_menu = GTK_OPTION_MENU (user_data); gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); - width = requisition.width; - height = requisition.height; + menu_width = requisition.width; active = gtk_menu_get_active (GTK_MENU (option_menu->menu)); - children = GTK_MENU_SHELL (option_menu->menu)->children; gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos); menu_ypos += GTK_WIDGET (option_menu)->allocation.height / 2 - 2; @@ -686,6 +691,7 @@ gtk_option_menu_position (GtkMenu *menu, menu_ypos -= requisition.height / 2; } + children = GTK_MENU_SHELL (option_menu->menu)->children; while (children) { child = children->data; @@ -703,35 +709,15 @@ gtk_option_menu_position (GtkMenu *menu, } screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - shift_menu = FALSE; - if (menu_ypos < 0) - { - menu_ypos = 0; - shift_menu = TRUE; - } - else if ((menu_ypos + height) > screen_height) - { - menu_ypos -= ((menu_ypos + height) - screen_height); - shift_menu = TRUE; - } - - if (shift_menu) - { - if ((menu_xpos + GTK_WIDGET (option_menu)->allocation.width + width) <= screen_width) - menu_xpos += GTK_WIDGET (option_menu)->allocation.width; - else - menu_xpos -= width; - } - + if (menu_xpos < 0) menu_xpos = 0; - else if ((menu_xpos + width) > screen_width) - menu_xpos -= ((menu_xpos + width) - screen_width); + else if ((menu_xpos + menu_width) > screen_width) + menu_xpos -= ((menu_xpos + menu_width) - screen_width); *x = menu_xpos; *y = menu_ypos; + *push_in = TRUE; } |