From 814957b46e16fbaf8999190c2052edbc347c71fe Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 8 Nov 2000 17:34:52 +0000 Subject: Add note about GtkMenuPositionFunc API changes. 2000-11-08 Alexander Larsson * 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 * 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. --- gtk/gtkmenu.h | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'gtk/gtkmenu.h') diff --git a/gtk/gtkmenu.h b/gtk/gtkmenu.h index 741a37ea54..1d478c30dd 100644 --- a/gtk/gtkmenu.h +++ b/gtk/gtkmenu.h @@ -37,7 +37,6 @@ extern "C" { #endif /* __cplusplus */ - #define GTK_TYPE_MENU (gtk_menu_get_type ()) #define GTK_MENU(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MENU, GtkMenu)) #define GTK_MENU_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass)) @@ -52,6 +51,7 @@ typedef struct _GtkMenuClass GtkMenuClass; typedef void (*GtkMenuPositionFunc) (GtkMenu *menu, gint *x, gint *y, + gboolean *push_in, gpointer user_data); typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget, GtkMenu *menu); @@ -62,18 +62,31 @@ struct _GtkMenu GtkWidget *parent_menu_item; GtkWidget *old_active_menu_item; - + GtkAccelGroup *accel_group; GtkMenuPositionFunc position_func; gpointer position_func_data; + guint toggle_size; /* Do _not_ touch these widgets directly. We hide the reference * count from the toplevel to the menu, so it must be restored * before operating on these widgets */ GtkWidget *toplevel; + GtkWidget *tearoff_window; + GtkWidget *tearoff_hbox; + GtkWidget *tearoff_scrollbar; + GtkAdjustment *tearoff_adjustment; + + GdkWindow *view_window; + GdkWindow *bin_window; + gint scroll_offset; + gint saved_scroll_offset; + gint scroll_step; + guint timeout_id; + /* When a submenu of this menu is popped up, motion in this * region is ignored */ @@ -82,6 +95,17 @@ struct _GtkMenu guint needs_destruction_ref_count : 1; guint torn_off : 1; + /* The tearoff is active when it is torn off and the not-torn-off + * menu is not popped up. + */ + guint tearoff_active : 1; + + guint scroll_fast : 1; + + guint upper_arrow_visible : 1; + guint lower_arrow_visible : 1; + guint upper_arrow_prelight : 1; + guint lower_arrow_prelight : 1; }; struct _GtkMenuClass @@ -93,15 +117,6 @@ struct _GtkMenuClass GtkType gtk_menu_get_type (void) G_GNUC_CONST; GtkWidget* gtk_menu_new (void); -/* Wrappers for the Menu Shell operations */ -void gtk_menu_append (GtkMenu *menu, - GtkWidget *child); -void gtk_menu_prepend (GtkMenu *menu, - GtkWidget *child); -void gtk_menu_insert (GtkMenu *menu, - GtkWidget *child, - gint position); - /* Display the menu onscreen */ void gtk_menu_popup (GtkMenu *menu, GtkWidget *parent_menu_shell, -- cgit v1.2.1