gtk2/gtk/gtkmenu.c

5786 lines
182 KiB
C
Raw Normal View History

/* GTK - The GIMP Toolkit
1997-11-24 22:37:52 +00:00
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
1997-11-24 22:37:52 +00:00
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2010-12-23 20:50:18 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
1997-11-24 22:37:52 +00:00
*
* You should have received a copy of the GNU Lesser General Public
2012-02-27 13:01:10 +00:00
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
1997-11-24 22:37:52 +00:00
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
2011-01-15 13:51:11 +00:00
/**
* SECTION:gtkmenu
* @Short_description: A menu widget
* @Title: GtkMenu
*
* A #GtkMenu is a #GtkMenuShell that implements a drop down menu
* consisting of a list of #GtkMenuItem objects which can be navigated
* and activated by the user to perform application functions.
*
* A #GtkMenu is most commonly dropped down by activating a
* #GtkMenuItem in a #GtkMenuBar or popped up by activating a
* #GtkMenuItem in another #GtkMenu.
*
* A #GtkMenu can also be popped up by activating a #GtkComboBox.
2011-01-15 13:51:11 +00:00
* Other composite widgets such as the #GtkNotebook can pop up a
* #GtkMenu as well.
*
* Applications can display a #GtkMenu as a popup menu by calling the
* gtk_menu_popup() function. The example below shows how an application
* can pop up a menu when the 3rd mouse button is pressed.
*
* <example>
* <title>Connecting the popup signal handler.</title>
* <programlisting>
* /<!---->* connect our handler which will popup the menu *<!---->/
* g_signal_connect_swapped (window, "button_press_event",
* G_CALLBACK (my_popup_handler), menu);
* </programlisting>
* </example>
*
* <example>
* <title>Signal handler which displays a popup menu.</title>
* <programlisting>
* static gint
* my_popup_handler (GtkWidget *widget, GdkEvent *event)
* {
* GtkMenu *menu;
* GdkEventButton *event_button;
*
* g_return_val_if_fail (widget != NULL, FALSE);
* g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
* g_return_val_if_fail (event != NULL, FALSE);
*
* /<!---->* The "widget" is the menu that was supplied when
* * g_signal_connect_swapped() was called.
* *<!---->/
* menu = GTK_MENU (widget);
*
* if (event->type == GDK_BUTTON_PRESS)
* {
* event_button = (GdkEventButton *) event;
* if (event_button->button == GDK_BUTTON_SECONDARY)
2011-01-15 13:51:11 +00:00
* {
* gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
* event_button->button, event_button->time);
* return TRUE;
* }
* }
*
* return FALSE;
* }
* </programlisting>
* </example>
*/
#include "config.h"
#include <string.h>
#include <gobject/gvaluecollector.h>
#include "gtkaccellabel.h"
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
#include "gtkaccelmap.h"
#include "gtkadjustment.h"
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
#include "gtkbindings.h"
#include "gtkcheckmenuitem.h"
1997-11-24 22:37:52 +00:00
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkmenuprivate.h"
#include "gtkmenuitemprivate.h"
#include "gtkmenushellprivate.h"
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
#include "gtkwindow.h"
2011-08-28 05:54:55 +00:00
#include "gtkbox.h"
2011-06-08 14:23:53 +00:00
#include "gtkscrollbar.h"
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
#include "gtksettings.h"
#include "gtkprivate.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkdnd.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
2011-10-01 03:49:48 +00:00
#include "deprecated/gtktearoffmenuitem.h"
2011-10-01 03:49:48 +00:00
2011-07-02 02:30:54 +00:00
#include "a11y/gtkmenuaccessible.h"
1997-11-24 22:37:52 +00:00
#define NAVIGATION_REGION_OVERSHOOT 50 /* How much the navigation region
2010-12-23 20:50:18 +00:00
* extends below the submenu
*/
#define MENU_SCROLL_STEP1 8
#define MENU_SCROLL_STEP2 15
#define MENU_SCROLL_FAST_ZONE 8
#define MENU_SCROLL_TIMEOUT1 50
#define MENU_SCROLL_TIMEOUT2 20
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.
2000-11-08 17:34:52 +00:00
#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
#define ATTACHED_MENUS "gtk-attached-menus"
2010-12-23 20:50:18 +00:00
typedef struct _GtkMenuAttachData GtkMenuAttachData;
typedef struct _GtkMenuPopdownData GtkMenuPopdownData;
struct _GtkMenuAttachData
{
GtkWidget *attach_widget;
GtkMenuDetachFunc detacher;
};
2010-05-25 22:38:44 +00:00
struct _GtkMenuPopdownData
{
GtkMenu *menu;
GdkDevice *device;
};
typedef struct
{
gint left_attach;
gint right_attach;
gint top_attach;
gint bottom_attach;
gint effective_left_attach;
gint effective_right_attach;
gint effective_top_attach;
gint effective_bottom_attach;
} AttachInfo;
enum {
MOVE_SCROLL,
LAST_SIGNAL
};
enum {
PROP_0,
PROP_ACTIVE,
PROP_ACCEL_GROUP,
PROP_ACCEL_PATH,
PROP_ATTACH_WIDGET,
PROP_TEAROFF_STATE,
PROP_TEAROFF_TITLE,
PROP_MONITOR,
PROP_RESERVE_TOGGLE_SIZE
};
enum {
CHILD_PROP_0,
CHILD_PROP_LEFT_ATTACH,
CHILD_PROP_RIGHT_ATTACH,
CHILD_PROP_TOP_ATTACH,
CHILD_PROP_BOTTOM_ATTACH
};
static void gtk_menu_set_property (GObject *object,
2010-12-23 20:50:18 +00:00
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_menu_get_property (GObject *object,
2010-12-23 20:50:18 +00:00
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_menu_set_child_property(GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_menu_get_child_property(GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_menu_destroy (GtkWidget *widget);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_realize (GtkWidget *widget);
static void gtk_menu_unrealize (GtkWidget *widget);
static void gtk_menu_size_allocate (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GtkAllocation *allocation);
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
static void gtk_menu_show (GtkWidget *widget);
2010-09-06 15:32:30 +00:00
static gboolean gtk_menu_draw (GtkWidget *widget,
cairo_t *cr);
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.
2000-11-08 17:34:52 +00:00
static gboolean gtk_menu_key_press (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventKey *event);
static gboolean gtk_menu_scroll (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventScroll *event);
static gboolean gtk_menu_button_press (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventButton *event);
static gboolean gtk_menu_button_release (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventButton *event);
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.
2000-11-08 17:34:52 +00:00
static gboolean gtk_menu_motion_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventMotion *event);
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.
2000-11-08 17:34:52 +00:00
static gboolean gtk_menu_enter_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventCrossing *event);
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.
2000-11-08 17:34:52 +00:00
static gboolean gtk_menu_leave_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventCrossing *event);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_scroll_to (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint offset);
static void gtk_menu_grab_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
gboolean was_grabbed);
static gboolean gtk_menu_captured_event (GtkWidget *widget,
GdkEvent *event);
static void gtk_menu_stop_scrolling (GtkMenu *menu);
static void gtk_menu_remove_scroll_timeout (GtkMenu *menu);
static gboolean gtk_menu_scroll_timeout (gpointer data);
static void gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *menu_item);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_select_item (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *menu_item);
static void gtk_menu_real_insert (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *child,
gint position);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_scrollbar_changed (GtkAdjustment *adjustment,
2010-12-23 20:50:18 +00:00
GtkMenu *menu);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_handle_scrolling (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint event_x,
gint event_y,
gboolean enter,
gboolean motion);
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.
2000-11-08 17:34:52 +00:00
static void gtk_menu_set_tearoff_hints (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint width);
static void gtk_menu_style_updated (GtkWidget *widget);
static gboolean gtk_menu_focus (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GtkDirectionType direction);
static gint gtk_menu_get_popup_delay (GtkMenuShell *menu_shell);
static void gtk_menu_move_current (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction);
static void gtk_menu_real_move_scroll (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GtkScrollType type);
static void gtk_menu_stop_navigating_submenu (GtkMenu *menu);
static gboolean gtk_menu_stop_navigating_submenu_cb (gpointer user_data);
static gboolean gtk_menu_navigating_submenu (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint event_x,
gint event_y);
static void gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GtkMenuItem *menu_item,
GdkEventCrossing *event);
2010-12-23 20:50:18 +00:00
static void gtk_menu_deactivate (GtkMenuShell *menu_shell);
GTK_MENU_DIR_CHILD: check for the existance of Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_real_menu_shell_move_current): GTK_MENU_DIR_CHILD: check for the existance of menu_shell->active_menu_item before accessing its child. GTK_MENU_DIR_PREV: GTK_MENU_DIR_NEXT: if we haven't had an active item and still don't, make a default selection. Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_propagate_state): iterate the children with _forall for sensitivity changes and with _foreach on pure state changes. this fixes a lot of the old inclusions of internal widgets into _foreach calls. * gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall do the work. don't walk the subtrees of first level children. * gtk/gtktreeitem.c: provide a _forall implementation, which walks the subtrees as well for include_internals. * gtk/gtkmenuitem.c: provide a _forall implementation, which walks the submenus as well for include_internals. * gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and implemented gtk_scrolled_window_forall, which will iterate over the viewport and the scrollbars for gtk_container_forall or iterate over the viewports children for gtk_container_foreach. * gtk/gtktoolbar.c: * gtk/gtktable.c: * gtk/gtkpaned.c: * gtk/gtkpacker.c: * gtk/gtkmenushell.c: * gtk/gtklist.c: * gtk/gtkfixed.c: * gtk/gtkclist.c: * gtk/gtkbox.c: * gtk/gtkbin.c: * gtk/gtknotebook.c: removed the old gtk_*_foreach functions and provided gtk_*_forall. * gtk/gtknotebook.c: (gtk_notebook_real_switch_page): expose tabs. (gtk_notebook_page_num): new function to return the page number of a distinct child. (gtk_notebook_focus): minor fixups. foxus handling is still screwed under some circumstances. * gtk/gtktreeitem.c: (gtk_real_tree_item_select): (gtk_real_tree_item_deselect): major fixes. some general fixups wrt queue_redraw, and tree items not being NO_WINDOW widgets. * gtk/gtklistitem.c: (gtk_real_list_item_select): (gtk_real_list_item_deselect): (gtk_real_list_item_toggle): removed unneccessary queue_redraw calls. Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: allow optionmenus to have the focus and automatically popup the menu on space bar. Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class method), which acts similar to gtk_container_foreach(), but iterates over internal children. the GtkContainer::foreach signal vanished in favour of a new class method ->forall() that optionally includes internal widgets. * gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation but a _forall implementation, since all child widgets we have are internal ones. (column_button_create): set the parent window prior to gtk_widget_set_parent(). * gtk/gtkwidget.c: exchanged all calls to gtk_container_foreach() with gtk_container_forall(). * gtk/gtkwidget.h: * gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through the GtkWidget::composite_child argument. to have a widget created with the flag initially, two new functions got added to wrap a widgets creation: gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag(). Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktooltips.h: * gtk/gtktooltips.c: exported gtk_tooltips_create_window() as gtk_tooltips_force_window(), so tooltips->tip_window can be accessed prior to the first tip being set. don't put an extra reference on the window, since it is a toplevel, it wont get destroyed from anywhere else. * overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
static void gtk_menu_show_all (GtkWidget *widget);
static void gtk_menu_position (GtkMenu *menu,
gboolean set_scroll_offset);
2010-12-23 20:50:18 +00:00
static void gtk_menu_reparent (GtkMenu *menu,
GtkWidget *new_parent,
gboolean unrealize);
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
static void gtk_menu_remove (GtkContainer *menu,
2010-12-23 20:50:18 +00:00
GtkWidget *widget);
1997-11-24 22:37:52 +00:00
static void gtk_menu_update_title (GtkMenu *menu);
static void menu_grab_transfer_window_destroy (GtkMenu *menu);
static GdkWindow *menu_grab_transfer_window_get (GtkMenu *menu);
static gboolean gtk_menu_real_can_activate_accel (GtkWidget *widget,
guint signal_id);
applied patch from owen to get rid of accel map notifiers. changed things Tue Nov 20 21:25:08 2001 Tim Janik <timj@gtk.org> * applied patch from owen to get rid of accel map notifiers. changed things to fix reentrancy and API as discussed on gtk-devel. * gtk/gtkaccelgroup.[hc]: (gtk_accel_group_finalize): unregister this accel group from all accel map paths. (accel_closure_invalidate): handle invalidation of closures by disconnecting their accelerators. (quick_accel_add): move closure connection and changed notification into this function to reduce code duplication. don't emit change notification on closurers without accelerators. (quick_accel_remove): rewrite, do the exact opposite of quick_accel_add for a GtkAccelGroupEntry. (gtk_accel_group_connect): get rid of the accel_path_quark argument. (gtk_accel_group_connect_by_path): new function to add accelerators with an accel path. (gtk_accel_group_disconnect_closure): new function, disconnect a closure from of an accel group. (gtk_accel_group_disconnect): loop over all closure for a accel_ley, accel_mods pair and remove them. (_gtk_accel_group_reconnect): new function that basically does gtk_accel_group_disconnect_closure() and gtk_accel_group_connect_by_path() once an accel path changed. (gtk_accel_groups_disconnect_closure): remove this, there's gtk_accel_group_disconnect_closure(). * gtk/gtkaccelmap.[hc]: keep list of accel groups per entry now, nuke notifiers. (_gtk_accel_path_is_valid): make this non-static for gtkwidget.c and gtkaccelgroup.c assertions. (gtk_accel_map_add_notifer): removed this function. (gtk_accel_map_remove_notifer): same. (_gtk_accel_map_add_group): (_gtk_accel_map_remove_group): (un-)register accel groups, with accel paths for correct propagation. (gtk_accel_map_add_entry): return void. (gtk_accel_map_lookup): return gboolean instead of GQuark. * gtk/gtkitemfactory.c (gtk_item_factory_add_foreign): always set accel_path on widgets. * gtk/gtkwidget.[hc]: (accel_path_changed): got rid of this, changes are handled by accel maps internally now. (_gtk_widget_set_accel_path): get things to work without notifiers. (gtk_widget_list_accel_closures): list accel closures of a widget. * gtk/gtkwindow.[hc]: rename ::accels_changed, to ::keys_changed.
2001-11-20 23:43:03 +00:00
static void _gtk_menu_refresh_accel_paths (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gboolean group_changed);
applied patch from owen to get rid of accel map notifiers. changed things Tue Nov 20 21:25:08 2001 Tim Janik <timj@gtk.org> * applied patch from owen to get rid of accel map notifiers. changed things to fix reentrancy and API as discussed on gtk-devel. * gtk/gtkaccelgroup.[hc]: (gtk_accel_group_finalize): unregister this accel group from all accel map paths. (accel_closure_invalidate): handle invalidation of closures by disconnecting their accelerators. (quick_accel_add): move closure connection and changed notification into this function to reduce code duplication. don't emit change notification on closurers without accelerators. (quick_accel_remove): rewrite, do the exact opposite of quick_accel_add for a GtkAccelGroupEntry. (gtk_accel_group_connect): get rid of the accel_path_quark argument. (gtk_accel_group_connect_by_path): new function to add accelerators with an accel path. (gtk_accel_group_disconnect_closure): new function, disconnect a closure from of an accel group. (gtk_accel_group_disconnect): loop over all closure for a accel_ley, accel_mods pair and remove them. (_gtk_accel_group_reconnect): new function that basically does gtk_accel_group_disconnect_closure() and gtk_accel_group_connect_by_path() once an accel path changed. (gtk_accel_groups_disconnect_closure): remove this, there's gtk_accel_group_disconnect_closure(). * gtk/gtkaccelmap.[hc]: keep list of accel groups per entry now, nuke notifiers. (_gtk_accel_path_is_valid): make this non-static for gtkwidget.c and gtkaccelgroup.c assertions. (gtk_accel_map_add_notifer): removed this function. (gtk_accel_map_remove_notifer): same. (_gtk_accel_map_add_group): (_gtk_accel_map_remove_group): (un-)register accel groups, with accel paths for correct propagation. (gtk_accel_map_add_entry): return void. (gtk_accel_map_lookup): return gboolean instead of GQuark. * gtk/gtkitemfactory.c (gtk_item_factory_add_foreign): always set accel_path on widgets. * gtk/gtkwidget.[hc]: (accel_path_changed): got rid of this, changes are handled by accel maps internally now. (_gtk_widget_set_accel_path): get things to work without notifiers. (gtk_widget_list_accel_closures): list accel closures of a widget. * gtk/gtkwindow.[hc]: rename ::accels_changed, to ::keys_changed.
2001-11-20 23:43:03 +00:00
static void gtk_menu_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_menu_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size);
static void gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
gint for_size,
gint *minimum_size,
gint *natural_size);
static const gchar attach_data_key[] = "gtk-menu-attach-data";
static guint menu_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL)
1997-11-24 22:37:52 +00:00
static void
menu_queue_resize (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
priv->have_layout = FALSE;
gtk_widget_queue_resize (GTK_WIDGET (menu));
}
static void
attach_info_free (AttachInfo *info)
{
g_slice_free (AttachInfo, info);
}
static AttachInfo *
get_attach_info (GtkWidget *child)
{
GObject *object = G_OBJECT (child);
AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
if (!ai)
{
ai = g_slice_new0 (AttachInfo);
g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai,
(GDestroyNotify) attach_info_free);
}
return ai;
}
static gboolean
is_grid_attached (AttachInfo *ai)
{
return (ai->left_attach >= 0 &&
2010-12-23 20:50:18 +00:00
ai->right_attach >= 0 &&
ai->top_attach >= 0 &&
ai->bottom_attach >= 0);
}
static void
menu_ensure_layout (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
if (!priv->have_layout)
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
GList *l;
gchar *row_occupied;
gint current_row;
gint max_right_attach;
gint max_bottom_attach;
/* Find extents of gridded portion
*/
max_right_attach = 1;
max_bottom_attach = 0;
for (l = menu_shell->priv->children; l; l = l->next)
2010-12-23 20:50:18 +00:00
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
if (is_grid_attached (ai))
{
max_bottom_attach = MAX (max_bottom_attach, ai->bottom_attach);
max_right_attach = MAX (max_right_attach, ai->right_attach);
}
}
/* Find empty rows */
row_occupied = g_malloc0 (max_bottom_attach);
for (l = menu_shell->priv->children; l; l = l->next)
2010-12-23 20:50:18 +00:00
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
2010-12-23 20:50:18 +00:00
if (is_grid_attached (ai))
{
gint i;
2010-12-23 20:50:18 +00:00
for (i = ai->top_attach; i < ai->bottom_attach; i++)
row_occupied[i] = TRUE;
}
}
/* Lay non-grid-items out in those rows
*/
current_row = 0;
for (l = menu_shell->priv->children; l; l = l->next)
2010-12-23 20:50:18 +00:00
{
GtkWidget *child = l->data;
AttachInfo *ai = get_attach_info (child);
if (!is_grid_attached (ai))
{
while (current_row < max_bottom_attach && row_occupied[current_row])
current_row++;
ai->effective_left_attach = 0;
ai->effective_right_attach = max_right_attach;
ai->effective_top_attach = current_row;
ai->effective_bottom_attach = current_row + 1;
current_row++;
}
else
{
ai->effective_left_attach = ai->left_attach;
ai->effective_right_attach = ai->right_attach;
ai->effective_top_attach = ai->top_attach;
ai->effective_bottom_attach = ai->bottom_attach;
}
}
g_free (row_occupied);
priv->n_rows = MAX (current_row, max_bottom_attach);
priv->n_columns = max_right_attach;
priv->have_layout = TRUE;
}
}
static gint
gtk_menu_get_n_columns (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
menu_ensure_layout (menu);
return priv->n_columns;
}
static gint
gtk_menu_get_n_rows (GtkMenu *menu)
{
GtkMenuPrivate *priv = menu->priv;
menu_ensure_layout (menu);
return priv->n_rows;
}
static void
get_effective_child_attach (GtkWidget *child,
2010-12-23 20:50:18 +00:00
int *l,
int *r,
int *t,
int *b)
{
GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (child));
AttachInfo *ai;
menu_ensure_layout (menu);
ai = get_attach_info (child);
if (l)
*l = ai->effective_left_attach;
if (r)
*r = ai->effective_right_attach;
if (t)
*t = ai->effective_top_attach;
if (b)
*b = ai->effective_bottom_attach;
}
1997-11-24 22:37:52 +00:00
static void
gtk_menu_class_init (GtkMenuClass *class)
{
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_CLASS (class);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
GtkBindingSet *binding_set;
fixed an assertment. Sat Jun 6 06:01:24 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_emitv): fixed an assertment. * gtk/makeenums.awk: a script to generate the GtkEnumValue arrays from, this should eventually be done by gentypeinfo.el somewhen. * gtk/gtkenumvalues.c: new generated file to hold GtkEnumValue arrays. * gtk/gtktypeutils.h: new function gtk_enum_values() to retrive all the enum values of an enum type. * gtk/gtk.defs: * gtk/gtkcurve.h: * gtk/gtkobject.h: * gtk/gtkprivate.h: * gtk/gtkwidget.h: * gtk/gtkenums.h: brought enum/flags definitions in sync, added a few more enum definitions for bindings and pattern matching. * some more macro and GtkType fixups in various places. * gdk/gdktypes.h (enum): added a new value GDK_AFTER_MASK, which is used as a key-release modifier for the binding system. Fri Jun 5 06:06:06 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenu.h (struct _GtkMenu): removed GList*children, since it was a stale list pointer that is already present in GtkMenuShell. * gtk/gtkmenushell.h (struct _GtkMenuShellClass): added a signal GtkMenuShell::selection_done which is emitted after the menu shell poped down again and all possible menu items have been activated. Thu Jun 4 02:20:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_menu_shell_button_release): flush the x-queue before activation of the menuitem, so the menu is actually taken off the screen prior to any menu item activation. * gtk/gtkctree.c (gtk_ctree_get_row_data): allow function invokation for NULL nodes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: new function gtk_widget_stop_accelerator to stop the emission of the "add-accelerator" signal on a widget. this is usefull to prevent accelerator installation on certain widgets. * gtk/gtknotebook.c (gtk_notebook_menu_item_create): keep the menu labels left justified, by setting their alignment. stop accelerator installation for the menu items, since we use dynamic menus. Wed Jun 3 06:41:22 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenufactory.c: adaptions to use the new accel groups. people should *really* use GtkItemFactory. this is only for preserving source compatibility where possible, use of GtkMenuFactory is deprecated as of now. * gtk/gtkobject.h (gtk_object_class_add_user_signal): new function to create user signals of type GTK_RUN_NO_RECURSE. don't know why i missed this possibility when i added gtk_object_class_add_user_signal in late january. * gtk/gtkmain.c (gtk_init): ignore subsequent function calls. Sun May 31 07:31:09 1998 Tim Janik <timj@gtk.org> * gtk/gtkaccelgroup.h: * gtk/gtkaccelgroup.c: new implementation of the accelerator concept. * gtk/gtkaccellabel.h: * gtk/gtkaccellabel.c: new widget derived from GtkLabel whitch features display of the accelerators associated with a certain widget. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: new widget, item factory with automatic rc parsing and accelerator handling. * gtk/gtkmenu.c (gtk_menu_reposition): new function to care for positioning a menu. (gtk_menu_map): removed the allocation code. (gtk_menu_size_allocate): care for redrawing of children and resize our widget->window correctly. (gtk_menu_key_press): feature the new accelerator groups. * gtk/gtkmenuitem.c (gtk_menu_item_size_allocate): reposition the submenu if neccessary. * gtk/gtkmenuitem.c: * gtk/gtkcheckmenuitem.c: * gtk/gtkradiomenuitem.c: use GtkAccelLabel in the *_new_with_label() function variants. * gdk/gdk.c: (gdk_keyval_from_name): (gdk_keyval_name): new functions for keyval<->key-name associations. (gdk_keyval_to_upper): (gdk_keyval_to_lower): (gdk_keyval_is_upper): (gdk_keyval_is_lower): new functions to check/translate keyvalues with regards to their cases. Wed May 27 00:48:10 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_class_path): new function to calculate a widget's class path. (gtk_widget_path): new function to calculate a widget's name path. * gtk/gtkrc.c: newly introduced GtkPatternSpec structures to speed up pattern matching, features reversed pattern matches.
1998-06-07 06:48:56 +00:00
gobject_class->set_property = gtk_menu_set_property;
gobject_class->get_property = gtk_menu_get_property;
widget_class->destroy = gtk_menu_destroy;
widget_class->realize = gtk_menu_realize;
widget_class->unrealize = gtk_menu_unrealize;
widget_class->size_allocate = gtk_menu_size_allocate;
widget_class->show = gtk_menu_show;
2010-09-06 15:32:30 +00:00
widget_class->draw = gtk_menu_draw;
widget_class->scroll_event = gtk_menu_scroll;
widget_class->key_press_event = gtk_menu_key_press;
widget_class->button_press_event = gtk_menu_button_press;
widget_class->button_release_event = gtk_menu_button_release;
widget_class->motion_notify_event = gtk_menu_motion_notify;
widget_class->show_all = gtk_menu_show_all;
widget_class->enter_notify_event = gtk_menu_enter_notify;
widget_class->leave_notify_event = gtk_menu_leave_notify;
widget_class->style_updated = gtk_menu_style_updated;
widget_class->focus = gtk_menu_focus;
widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
widget_class->grab_notify = gtk_menu_grab_notify;
widget_class->get_preferred_width = gtk_menu_get_preferred_width;
widget_class->get_preferred_height = gtk_menu_get_preferred_height;
widget_class->get_preferred_height_for_width = gtk_menu_get_preferred_height_for_width;
container_class->remove = gtk_menu_remove;
container_class->get_child_property = gtk_menu_get_child_property;
container_class->set_child_property = gtk_menu_set_child_property;
menu_shell_class->submenu_placement = GTK_LEFT_RIGHT;
menu_shell_class->deactivate = gtk_menu_deactivate;
menu_shell_class->select_item = gtk_menu_select_item;
menu_shell_class->insert = gtk_menu_real_insert;
menu_shell_class->get_popup_delay = gtk_menu_get_popup_delay;
menu_shell_class->move_current = gtk_menu_move_current;
2011-01-15 13:51:11 +00:00
/**
* GtkMenu::move-scroll:
* @menu: a #GtkMenu
* @scroll_type: a #GtkScrollType
*/
menu_signals[MOVE_SCROLL] =
g_signal_new_class_handler (I_("move-scroll"),
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (gtk_menu_real_move_scroll),
NULL, NULL,
_gtk_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
GTK_TYPE_SCROLL_TYPE);
/**
* GtkMenu:active:
*
* The index of the currently selected menu item, or -1 if no
* menu item is selected.
*
* Since: 2.14
**/
g_object_class_install_property (gobject_class,
PROP_ACTIVE,
g_param_spec_int ("active",
2010-12-23 20:50:18 +00:00
P_("Active"),
P_("The currently selected menu item"),
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE));
/**
* GtkMenu:accel-group:
*
* The accel group holding accelerators for the menu.
*
* Since: 2.14
**/
g_object_class_install_property (gobject_class,
PROP_ACCEL_GROUP,
g_param_spec_object ("accel-group",
2010-12-23 20:50:18 +00:00
P_("Accel Group"),
P_("The accel group holding accelerators for the menu"),
GTK_TYPE_ACCEL_GROUP,
GTK_PARAM_READWRITE));
/**
* GtkMenu:accel-path:
*
* An accel path used to conveniently construct accel paths of child items.
*
* Since: 2.14
**/
g_object_class_install_property (gobject_class,
PROP_ACCEL_PATH,
g_param_spec_string ("accel-path",
2010-12-23 20:50:18 +00:00
P_("Accel Path"),
P_("An accel path used to conveniently construct accel paths of child items"),
NULL,
GTK_PARAM_READWRITE));
/**
* GtkMenu:attach-widget:
*
* The widget the menu is attached to. Setting this property attaches
* the menu without a #GtkMenuDetachFunc. If you need to use a detacher,
* use gtk_menu_attach_to_widget() directly.
*
* Since: 2.14
**/
g_object_class_install_property (gobject_class,
PROP_ATTACH_WIDGET,
g_param_spec_object ("attach-widget",
2010-12-23 20:50:18 +00:00
P_("Attach Widget"),
P_("The widget the menu is attached to"),
GTK_TYPE_WIDGET,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TEAROFF_TITLE,
g_param_spec_string ("tearoff-title",
P_("Tearoff Title"),
P_("A title that may be displayed by the window manager when this menu is torn-off"),
NULL,
GTK_PARAM_READWRITE));
/**
* GtkMenu:tearoff-state:
*
* A boolean that indicates whether the menu is torn-off.
*
* Since: 2.6
**/
g_object_class_install_property (gobject_class,
PROP_TEAROFF_STATE,
g_param_spec_boolean ("tearoff-state",
2010-12-23 20:50:18 +00:00
P_("Tearoff State"),
P_("A boolean that indicates whether the menu is torn-off"),
FALSE,
GTK_PARAM_READWRITE));
/**
* GtkMenu:monitor:
*
* The monitor the menu will be popped up on.
*
* Since: 2.14
**/
g_object_class_install_property (gobject_class,
PROP_MONITOR,
g_param_spec_int ("monitor",
2010-12-23 20:50:18 +00:00
P_("Monitor"),
P_("The monitor the menu will be popped up on"),
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE));
/**
* GtkMenu:reserve-toggle-size:
*
* A boolean that indicates whether the menu reserves space for
* toggles and icons, regardless of their actual presence.
*
* This property should only be changed from its default value
* for special-purposes such as tabular menus. Regular menus that
* are connected to a menu bar or context menus should reserve
* toggle space for consistency.
*
* Since: 2.18
*/
g_object_class_install_property (gobject_class,
PROP_RESERVE_TOGGLE_SIZE,
g_param_spec_boolean ("reserve-toggle-size",
2010-12-23 20:50:18 +00:00
P_("Reserve Toggle Size"),
P_("A boolean that indicates whether the menu reserves space for toggles and icons"),
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkMenu:horizontal-padding:
*
* Extra space at the left and right edges of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
P_("Horizontal Padding"),
P_("Extra space at the left and right edges of the menu"),
0,
G_MAXINT,
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
/**
* GtkMenu:vertical-padding:
*
* Extra space at the top and bottom of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
P_("Vertical Padding"),
P_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
gtk_widget_class_install_style_property (widget_class,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("vertical-offset",
P_("Vertical Offset"),
P_("When the menu is a submenu, position it this number of pixels offset vertically"),
G_MININT,
G_MAXINT,
0,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("horizontal-offset",
P_("Horizontal Offset"),
P_("When the menu is a submenu, position it this number of pixels offset horizontally"),
G_MININT,
G_MAXINT,
-2,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("double-arrows",
P_("Double Arrows"),
P_("When scrolling, always show both arrows."),
TRUE,
GTK_PARAM_READABLE));
/**
* GtkMenu:arrow-placement:
*
* Indicates where scroll arrows should be placed.
*
* Since: 2.16
**/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("arrow-placement",
P_("Arrow Placement"),
P_("Indicates where scroll arrows should be placed"),
GTK_TYPE_ARROW_PLACEMENT,
GTK_ARROWS_BOTH,
GTK_PARAM_READABLE));
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
gtk_container_class_install_child_property (container_class,
CHILD_PROP_LEFT_ATTACH,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("left-attach",
P_("Left Attach"),
P_("The column number to attach the left side of the child to"),
2010-12-23 20:50:18 +00:00
-1, INT_MAX, -1,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_RIGHT_ATTACH,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("right-attach",
P_("Right Attach"),
P_("The column number to attach the right side of the child to"),
2010-12-23 20:50:18 +00:00
-1, INT_MAX, -1,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TOP_ATTACH,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("top-attach",
P_("Top Attach"),
P_("The row number to attach the top of the child to"),
2010-12-23 20:50:18 +00:00
-1, INT_MAX, -1,
GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_BOTTOM_ATTACH,
2010-12-23 20:50:18 +00:00
g_param_spec_int ("bottom-attach",
P_("Bottom Attach"),
P_("The row number to attach the bottom of the child to"),
2010-12-23 20:50:18 +00:00
-1, INT_MAX, -1,
GTK_PARAM_READWRITE));
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
/**
* GtkMenu:arrow-scaling:
*
* Arbitrary constant to scale down the size of the scroll arrow.
*
* Since: 2.16
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_float ("arrow-scaling",
P_("Arrow Scaling"),
P_("Arbitrary constant to scale down the size of the scroll arrow"),
0.0, 1.0, 0.7,
GTK_PARAM_READABLE));
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Up, 0,
I_("move-current"), 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PREV);
Clip the retrieved image data to the screen, using a server grab to avoid 2001-06-28 Havoc Pennington <hp@pobox.com> * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved image data to the screen, using a server grab to avoid race conditions. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove check for NULL return from gtk_image_new_from_stock(), it never returns NULL. (gtk_item_factory_create_item): fix bug where we parsed the stock ID as an inline pixbuf * gtk/gtktext.c (gtk_text_key_press): numeric keypad support * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad support (should be using binding set here) * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad support (should be using binding set here) * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad support * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad * gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress): keypad * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, should be binding-setted) * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes * gtk/gtkcalendar.c: numeric keypad fixes * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad support * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop screwup * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): clip the render area to the drawable's clip region in advance, so we don't get data from the server that we don't need. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): check return value of gdk_pixbuf_get_from_drawable(), fall back to bilevel alpha if we can't get the pixbuf to composite against. * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap * gdk/gdkimage.c (gdk_image_get_colormap): add gdk_image_set_colormap, gdk_image_get_colormap * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to take a region of the image, instead of converting the entire image. * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help keybinding signal. Add default bindings for it. Add default handler for show_help that shows the tooltip for the widget. * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and "close" keybinding signal, remove key press handler. * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, it's not our usual practice to leave a deprecated function around with a runtime warning, plus we don't want it to appear in docs, plus if we make them yellow no one will want to change them anyhow.
2001-06-29 01:59:02 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Up, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PREV);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Down, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_NEXT);
Clip the retrieved image data to the screen, using a server grab to avoid 2001-06-28 Havoc Pennington <hp@pobox.com> * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved image data to the screen, using a server grab to avoid race conditions. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove check for NULL return from gtk_image_new_from_stock(), it never returns NULL. (gtk_item_factory_create_item): fix bug where we parsed the stock ID as an inline pixbuf * gtk/gtktext.c (gtk_text_key_press): numeric keypad support * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad support (should be using binding set here) * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad support (should be using binding set here) * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad support * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad * gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress): keypad * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, should be binding-setted) * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes * gtk/gtkcalendar.c: numeric keypad fixes * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad support * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop screwup * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): clip the render area to the drawable's clip region in advance, so we don't get data from the server that we don't need. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): check return value of gdk_pixbuf_get_from_drawable(), fall back to bilevel alpha if we can't get the pixbuf to composite against. * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap * gdk/gdkimage.c (gdk_image_get_colormap): add gdk_image_set_colormap, gdk_image_get_colormap * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to take a region of the image, instead of converting the entire image. * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help keybinding signal. Add default bindings for it. Add default handler for show_help that shows the tooltip for the widget. * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and "close" keybinding signal, remove key press handler. * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, it's not our usual practice to leave a deprecated function around with a runtime warning, plus we don't want it to appear in docs, plus if we make them yellow no one will want to change them anyhow.
2001-06-29 01:59:02 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Down, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_NEXT);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Left, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PARENT);
Clip the retrieved image data to the screen, using a server grab to avoid 2001-06-28 Havoc Pennington <hp@pobox.com> * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved image data to the screen, using a server grab to avoid race conditions. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove check for NULL return from gtk_image_new_from_stock(), it never returns NULL. (gtk_item_factory_create_item): fix bug where we parsed the stock ID as an inline pixbuf * gtk/gtktext.c (gtk_text_key_press): numeric keypad support * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad support (should be using binding set here) * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad support (should be using binding set here) * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad support * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad * gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress): keypad * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, should be binding-setted) * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes * gtk/gtkcalendar.c: numeric keypad fixes * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad support * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop screwup * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): clip the render area to the drawable's clip region in advance, so we don't get data from the server that we don't need. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): check return value of gdk_pixbuf_get_from_drawable(), fall back to bilevel alpha if we can't get the pixbuf to composite against. * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap * gdk/gdkimage.c (gdk_image_get_colormap): add gdk_image_set_colormap, gdk_image_get_colormap * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to take a region of the image, instead of converting the entire image. * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help keybinding signal. Add default bindings for it. Add default handler for show_help that shows the tooltip for the widget. * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and "close" keybinding signal, remove key press handler. * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, it's not our usual practice to leave a deprecated function around with a runtime warning, plus we don't want it to appear in docs, plus if we make them yellow no one will want to change them anyhow.
2001-06-29 01:59:02 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Left, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PARENT);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Right, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_CHILD);
Clip the retrieved image data to the screen, using a server grab to avoid 2001-06-28 Havoc Pennington <hp@pobox.com> * gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved image data to the screen, using a server grab to avoid race conditions. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove check for NULL return from gtk_image_new_from_stock(), it never returns NULL. (gtk_item_factory_create_item): fix bug where we parsed the stock ID as an inline pixbuf * gtk/gtktext.c (gtk_text_key_press): numeric keypad support * gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad support (should be using binding set here) * gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad support (should be using binding set here) * gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad support * gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support * gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad * gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad * gtk/gtkimcontextsimple.c (gtk_im_context_simple_filter_keypress): keypad * gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad * gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes * gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support * gtk/gtkcolorsel.c (palette_activate): keypad support (of course, should be binding-setted) * gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes * gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes * gtk/gtkcalendar.c: numeric keypad fixes * gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad support * gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop screwup * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): clip the render area to the drawable's clip region in advance, so we don't get data from the server that we don't need. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha): check return value of gdk_pixbuf_get_from_drawable(), fall back to bilevel alpha if we can't get the pixbuf to composite against. * gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap * gdk/gdkimage.c (gdk_image_get_colormap): add gdk_image_set_colormap, gdk_image_get_colormap * gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to take a region of the image, instead of converting the entire image. * gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help keybinding signal. Add default bindings for it. Add default handler for show_help that shows the tooltip for the widget. * gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and "close" keybinding signal, remove key press handler. * gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this, it's not our usual practice to leave a deprecated function around with a runtime warning, plus we don't want it to appear in docs, plus if we make them yellow no one will want to change them anyhow.
2001-06-29 01:59:02 +00:00
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Right, 0,
"move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_CHILD);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Home, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_START);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Home, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_START);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_End, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_END);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_End, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_END);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Page_Up, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_PAGE_UP);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Page_Up, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_PAGE_UP);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_Page_Down, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_PAGE_DOWN);
gtk_binding_entry_add_signal (binding_set,
2010-12-23 20:50:18 +00:00
GDK_KEY_KP_Page_Down, 0,
"move-scroll", 1,
GTK_TYPE_SCROLL_TYPE,
GTK_SCROLL_PAGE_DOWN);
g_type_class_add_private (gobject_class, sizeof (GtkMenuPrivate));
2011-07-02 02:30:54 +00:00
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_ACCESSIBLE);
1997-11-24 22:37:52 +00:00
}
static void
gtk_menu_set_property (GObject *object,
2010-12-23 20:50:18 +00:00
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkMenu *menu = GTK_MENU (object);
switch (prop_id)
{
case PROP_ACTIVE:
gtk_menu_set_active (menu, g_value_get_int (value));
break;
case PROP_ACCEL_GROUP:
gtk_menu_set_accel_group (menu, g_value_get_object (value));
break;
case PROP_ACCEL_PATH:
gtk_menu_set_accel_path (menu, g_value_get_string (value));
break;
case PROP_ATTACH_WIDGET:
{
GtkWidget *widget;
widget = gtk_menu_get_attach_widget (menu);
if (widget)
gtk_menu_detach (menu);
widget = (GtkWidget*) g_value_get_object (value);
if (widget)
gtk_menu_attach_to_widget (menu, widget, NULL);
}
break;
case PROP_TEAROFF_STATE:
gtk_menu_set_tearoff_state (menu, g_value_get_boolean (value));
break;
case PROP_TEAROFF_TITLE:
gtk_menu_set_title (menu, g_value_get_string (value));
break;
case PROP_MONITOR:
gtk_menu_set_monitor (menu, g_value_get_int (value));
break;
case PROP_RESERVE_TOGGLE_SIZE:
gtk_menu_set_reserve_toggle_size (menu, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_menu_get_property (GObject *object,
2010-12-23 20:50:18 +00:00
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkMenu *menu = GTK_MENU (object);
switch (prop_id)
{
case PROP_ACTIVE:
g_value_set_int (value, g_list_index (GTK_MENU_SHELL (menu)->priv->children, gtk_menu_get_active (menu)));
break;
case PROP_ACCEL_GROUP:
g_value_set_object (value, gtk_menu_get_accel_group (menu));
break;
case PROP_ACCEL_PATH:
g_value_set_string (value, gtk_menu_get_accel_path (menu));
break;
case PROP_ATTACH_WIDGET:
g_value_set_object (value, gtk_menu_get_attach_widget (menu));
break;
case PROP_TEAROFF_STATE:
g_value_set_boolean (value, gtk_menu_get_tearoff_state (menu));
break;
case PROP_TEAROFF_TITLE:
g_value_set_string (value, gtk_menu_get_title (menu));
break;
case PROP_MONITOR:
g_value_set_int (value, gtk_menu_get_monitor (menu));
break;
case PROP_RESERVE_TOGGLE_SIZE:
g_value_set_boolean (value, gtk_menu_get_reserve_toggle_size (menu));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_menu_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkMenu *menu = GTK_MENU (container);
AttachInfo *ai = get_attach_info (child);
switch (property_id)
{
case CHILD_PROP_LEFT_ATTACH:
ai->left_attach = g_value_get_int (value);
break;
case CHILD_PROP_RIGHT_ATTACH:
ai->right_attach = g_value_get_int (value);
break;
case CHILD_PROP_TOP_ATTACH:
2010-12-23 20:50:18 +00:00
ai->top_attach = g_value_get_int (value);
break;
case CHILD_PROP_BOTTOM_ATTACH:
ai->bottom_attach = g_value_get_int (value);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
return;
}
menu_queue_resize (menu);
}
static void
gtk_menu_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
AttachInfo *ai = get_attach_info (child);
switch (property_id)
{
case CHILD_PROP_LEFT_ATTACH:
g_value_set_int (value, ai->left_attach);
break;
case CHILD_PROP_RIGHT_ATTACH:
g_value_set_int (value, ai->right_attach);
break;
case CHILD_PROP_TOP_ATTACH:
g_value_set_int (value, ai->top_attach);
break;
case CHILD_PROP_BOTTOM_ATTACH:
g_value_set_int (value, ai->bottom_attach);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
return;
}
}
static gboolean
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
gtk_menu_window_event (GtkWidget *window,
2010-12-23 20:50:18 +00:00
GdkEvent *event,
GtkWidget *menu)
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
{
gboolean handled = FALSE;
g_object_ref (window);
g_object_ref (menu);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
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.
2000-11-08 17:34:52 +00:00
handled = gtk_widget_event (menu, event);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
break;
case GDK_WINDOW_STATE:
/* Window for the menu has been closed by the display server or by GDK.
* Update the internal state as if the user had clicked outside the
* menu
*/
if (event->window_state.new_window_state & GDK_WINDOW_STATE_WITHDRAWN &&
event->window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
gtk_menu_shell_deactivate (GTK_MENU_SHELL(menu));
break;
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
default:
break;
}
g_object_unref (window);
g_object_unref (menu);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
return handled;
}
1997-11-24 22:37:52 +00:00
static void
gtk_menu_init (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv;
GtkStyleContext *context;
2010-12-23 20:50:18 +00:00
priv = G_TYPE_INSTANCE_GET_PRIVATE (menu, GTK_TYPE_MENU, GtkMenuPrivate);
menu->priv = priv;
priv->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
"type", GTK_WINDOW_POPUP,
"child", menu,
NULL),
"signal::event", gtk_menu_window_event, menu,
"signal::destroy", gtk_widget_destroyed, &priv->toplevel,
NULL);
gtk_window_set_resizable (GTK_WINDOW (priv->toplevel), FALSE);
gtk_window_set_mnemonic_modifier (GTK_WINDOW (priv->toplevel), 0);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
/* Refloat the menu, so that reference counting for the menu isn't
* affected by it being a child of the toplevel
*/
g_object_force_floating (G_OBJECT (menu));
2010-12-23 20:50:18 +00:00
priv->needs_destruction_ref = TRUE;
priv->monitor_num = -1;
priv->drag_start_y = -1;
context = gtk_widget_get_style_context (GTK_WIDGET (menu));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENU);
_gtk_widget_set_captured_event_handler (GTK_WIDGET (menu), gtk_menu_captured_event);
GTK_RESIZE_NEEDED is a private flag now. Mon Feb 2 04:15:08 1998 Tim Janik <timj@gimp.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: GTK_RESIZE_NEEDED is a private flag now. (gtk_container_register_toplevel): new function. (gtk_container_unregister_toplevel): new function. * gtk/gtkmain.c: GTK_LEAVE_PENDING is a private flag now. * gtk/gtkmenu.c: call gtk_container_register_toplevel in gtk_menu_class_init instead of this dirty gtk_widget_set_parent(,NULL) hack. new default handler gtk_menu_destroy for calling gtk_container_unregister_toplevel. removed GTK_ANCHORED, GTK_UNMAPPED. * gtk/gtkobject.h: macro cleanups, added GTK_DESTROYED flag. * gtk/gtkobject.c: only emit DESTROY signal if !GTK_OBJECT_DESTROYED (object). * gtk/gtkprivate.h: new file that will not be automatically included. it holds the private flags for GtkWidget along with it's SET/UNSET and examination macros. * gtk/gtkwidget.c: private flags: GTK_RESIZE_NEEDED, GTK_REDRAW_PENDING, GTK_RESIZE_PENDING, GTK_IN_REPARENT, GTK_USER_STYLE. GTK_ANCHORED is replaced by GTK_TOPLEVEL. added missing UNSET for GTK_IN_REPARENT. removed the gtk_widget_set_parent(, NULL) hack for toplevels. upon destroy free memory for widgets with GTK_WIDGET_HAS_SHAPE_MASK. * gtk/gtkwidget.h: split up the widget flags into a public and a private portion. added an extra field private_flags to GtkWidget without making it bigger by using an alignment gap of 16 bit. macro cleanups. * gtk/gtkwindow.c: removed GTK_ANCHORED. new function gtk_window_destroy for calling gtk_container_unregister_toplevel. removed the gtk_widget_set_parent(,NULL), call gtk_container_register_toplevel instead. remove GTK_UNMAPPED. GTK_RESIZE_NEEDED is private now. * gtk/gtksignal.c (gtk_signal_disconnect): removed a bug on removal that cut off the handler list -> living_objects == 0 with testgtk. made some warnings more descriptive. new function gtk_signal_connect_object_while_alive, which will automatically destroy the connection once one of the objects is destroyed. didn't include this before removal of the above mentioned bug. * reflected refcounting revolution in ChangeLog
1998-02-02 04:54:25 +00:00
}
static void
gtk_menu_destroy (GtkWidget *widget)
GTK_RESIZE_NEEDED is a private flag now. Mon Feb 2 04:15:08 1998 Tim Janik <timj@gimp.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: GTK_RESIZE_NEEDED is a private flag now. (gtk_container_register_toplevel): new function. (gtk_container_unregister_toplevel): new function. * gtk/gtkmain.c: GTK_LEAVE_PENDING is a private flag now. * gtk/gtkmenu.c: call gtk_container_register_toplevel in gtk_menu_class_init instead of this dirty gtk_widget_set_parent(,NULL) hack. new default handler gtk_menu_destroy for calling gtk_container_unregister_toplevel. removed GTK_ANCHORED, GTK_UNMAPPED. * gtk/gtkobject.h: macro cleanups, added GTK_DESTROYED flag. * gtk/gtkobject.c: only emit DESTROY signal if !GTK_OBJECT_DESTROYED (object). * gtk/gtkprivate.h: new file that will not be automatically included. it holds the private flags for GtkWidget along with it's SET/UNSET and examination macros. * gtk/gtkwidget.c: private flags: GTK_RESIZE_NEEDED, GTK_REDRAW_PENDING, GTK_RESIZE_PENDING, GTK_IN_REPARENT, GTK_USER_STYLE. GTK_ANCHORED is replaced by GTK_TOPLEVEL. added missing UNSET for GTK_IN_REPARENT. removed the gtk_widget_set_parent(, NULL) hack for toplevels. upon destroy free memory for widgets with GTK_WIDGET_HAS_SHAPE_MASK. * gtk/gtkwidget.h: split up the widget flags into a public and a private portion. added an extra field private_flags to GtkWidget without making it bigger by using an alignment gap of 16 bit. macro cleanups. * gtk/gtkwindow.c: removed GTK_ANCHORED. new function gtk_window_destroy for calling gtk_container_unregister_toplevel. removed the gtk_widget_set_parent(,NULL), call gtk_container_register_toplevel instead. remove GTK_UNMAPPED. GTK_RESIZE_NEEDED is private now. * gtk/gtksignal.c (gtk_signal_disconnect): removed a bug on removal that cut off the handler list -> living_objects == 0 with testgtk. made some warnings more descriptive. new function gtk_signal_connect_object_while_alive, which will automatically destroy the connection once one of the objects is destroyed. didn't include this before removal of the above mentioned bug. * reflected refcounting revolution in ChangeLog
1998-02-02 04:54:25 +00:00
{
GtkMenu *menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkMenuAttachData *data;
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.
2000-11-08 17:34:52 +00:00
gtk_menu_remove_scroll_timeout (menu);
2010-12-23 20:50:18 +00:00
data = g_object_get_data (G_OBJECT (widget), attach_data_key);
if (data)
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gtk_menu_detach (menu);
2010-12-23 20:50:18 +00:00
gtk_menu_stop_navigating_submenu (menu);
2010-12-23 20:50:18 +00:00
if (priv->old_active_menu_item)
g_clear_object (&priv->old_active_menu_item);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
/* Add back the reference count for being a child */
2010-12-23 20:50:18 +00:00
if (priv->needs_destruction_ref)
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
{
2010-12-23 20:50:18 +00:00
priv->needs_destruction_ref = FALSE;
g_object_ref (widget);
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
}
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
2010-12-23 20:50:18 +00:00
if (priv->accel_group)
g_clear_object (&priv->accel_group);
2010-12-23 20:50:18 +00:00
if (priv->toplevel)
gtk_widget_destroy (priv->toplevel);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
2010-12-23 20:50:18 +00:00
if (priv->tearoff_window)
gtk_widget_destroy (priv->tearoff_window);
if (priv->heights)
{
g_free (priv->heights);
priv->heights = NULL;
}
if (priv->title)
{
g_free (priv->title);
priv->title = NULL;
}
if (priv->position_func_data_destroy)
{
2010-12-23 20:50:18 +00:00
priv->position_func_data_destroy (priv->position_func_data);
priv->position_func_data = NULL;
priv->position_func_data_destroy = NULL;
}
GTK_WIDGET_CLASS (gtk_menu_parent_class)->destroy (widget);
}
static void
menu_change_screen (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GdkScreen *new_screen)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
if (gtk_widget_has_screen (GTK_WIDGET (menu)))
{
if (new_screen == gtk_widget_get_screen (GTK_WIDGET (menu)))
2010-12-23 20:50:18 +00:00
return;
}
2010-12-23 20:50:18 +00:00
if (priv->torn_off)
{
2010-12-23 20:50:18 +00:00
gtk_window_set_screen (GTK_WINDOW (priv->tearoff_window), new_screen);
gtk_menu_position (menu, TRUE);
}
2010-12-23 20:50:18 +00:00
gtk_window_set_screen (GTK_WINDOW (priv->toplevel), new_screen);
priv->monitor_num = -1;
}
static void
attach_widget_screen_changed (GtkWidget *attach_widget,
2010-12-23 20:50:18 +00:00
GdkScreen *previous_screen,
GtkMenu *menu)
{
if (gtk_widget_has_screen (attach_widget) &&
!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
2010-12-23 20:50:18 +00:00
menu_change_screen (menu, gtk_widget_get_screen (attach_widget));
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_attach_to_widget:
2011-01-15 13:51:11 +00:00
* @menu: a #GtkMenu
* @attach_widget: the #GtkWidget that the menu will be attached to
* @detacher: (scope async)(allow-none): the user supplied callback function
* that will be called when the menu calls gtk_menu_detach()
2011-01-15 13:51:11 +00:00
*
* Attaches the menu to the widget and provides a callback function
* that will be invoked when the menu calls gtk_menu_detach() during
* its destruction.
*/
void
2010-12-23 20:50:18 +00:00
gtk_menu_attach_to_widget (GtkMenu *menu,
GtkWidget *attach_widget,
GtkMenuDetachFunc detacher)
{
GtkMenuAttachData *data;
GList *list;
2010-12-23 20:50:18 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_WIDGET (attach_widget));
2010-12-23 20:50:18 +00:00
/* keep this function in sync with gtk_widget_set_parent() */
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
if (data)
{
g_warning ("gtk_menu_attach_to_widget(): menu already attached to %s",
2010-12-23 20:50:18 +00:00
g_type_name (G_TYPE_FROM_INSTANCE (data->attach_widget)));
return;
}
2010-12-23 20:50:18 +00:00
g_object_ref_sink (menu);
2010-12-23 20:50:18 +00:00
data = g_slice_new (GtkMenuAttachData);
data->attach_widget = attach_widget;
2010-12-23 20:50:18 +00:00
g_signal_connect (attach_widget, "screen-changed",
2010-12-23 20:50:18 +00:00
G_CALLBACK (attach_widget_screen_changed), menu);
attach_widget_screen_changed (attach_widget, NULL, menu);
2010-12-23 20:50:18 +00:00
data->detacher = detacher;
g_object_set_data (G_OBJECT (menu), I_(attach_data_key), data);
list = g_object_steal_data (G_OBJECT (attach_widget), ATTACHED_MENUS);
if (!g_list_find (list, menu))
2010-12-23 20:50:18 +00:00
list = g_list_prepend (list, menu);
g_object_set_data_full (G_OBJECT (attach_widget), I_(ATTACHED_MENUS), list,
(GDestroyNotify) g_list_free);
/* Attach the widget to the toplevel window. */
gtk_window_set_attached_to (GTK_WINDOW (menu->priv->toplevel), attach_widget);
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
/* Fallback title for menu comes from attach widget */
gtk_menu_update_title (menu);
g_object_notify (G_OBJECT (menu), "attach-widget");
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_get_attach_widget:
* @menu: a #GtkMenu
*
* Returns the #GtkWidget that the menu is attached to.
*
* Returns: (transfer none): the #GtkWidget that the menu is attached to
2011-01-15 13:51:11 +00:00
*/
GtkWidget*
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
gtk_menu_get_attach_widget (GtkMenu *menu)
{
GtkMenuAttachData *data;
2010-12-23 20:50:18 +00:00
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
2010-12-23 20:50:18 +00:00
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
if (data)
return data->attach_widget;
return NULL;
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_detach:
* @menu: a #GtkMenu
*
* Detaches the menu from the widget to which it had been attached.
* This function will call the callback function, @detacher, provided
* when the gtk_menu_attach_to_widget() function was called.
*/
void
documented necessary changes for 1.4 transition. Fri May 12 17:13:32 2000 Tim Janik <timj@gtk.org> * docs/Changes-1.4.txt: documented necessary changes for 1.4 transition. * gtk/gtktext.c: made the adjustments no-construct args, simply provide default adjustments. (gtk_text_destroy): release adjustments. * gtk/gtkprogressbar.c (gtk_progress_bar_class_init): made the adjustment argument non-construct. * gtk/gtkprogress.c (gtk_progress_destroy): release adjustment here, instead of in finalize. (gtk_progress_get_text_from_value): (gtk_progress_get_current_text): (gtk_progress_set_value): (gtk_progress_get_percentage_from_value): (gtk_progress_get_current_percentage): (gtk_progress_set_percentage): (gtk_progress_configure): ensure an adjustment is present. Thu May 11 01:24:08 2000 Tim Janik <timj@gtk.org> * gtk/gtkcolorsel.[hc]: * gtk/gtkcolorseldialog.[hc]: * gtk/gtkhsv.[hc]: major code cleanups, destroy handlers need to chain their parent implementation, use bit fields for boolean values, don't create unused widgets, usage of glib types, braces go on their own lines, function argument alignment, #include directives etc. etc. etc.. * gtk/Makefile.am (gtk_public_h_sources): install gtkhsv.h. Wed May 10 23:29:52 2000 Tim Janik <timj@gtk.org> * gtk/gtktoolbar.c (gtk_toolbar_destroy): don't unref a NULL tooltips. * gtk/gtkfilesel.c (gtk_file_selection_destroy): don't free a cmpl_state of NULL. * gtk/gtkcombo.c (gtk_combo_item_destroy): don#t keep references to freed data. (gtk_combo_destroy): don't keep a pointer to a destroyed window. * gtk/gtkmenu.c (gtk_menu_init): reset the menu's toplevel pointer to NULL when the toplevel is getting destroyed. (gtk_menu_set_tearoff_state): same here for the tearoff_window. (gtk_menu_destroy): (gtk_menu_init): store the information of whether we have to readd the initial child ref_count during destruction in a new GtkMenu field needs_destruction_ref_count. * gtk/gtkviewport.c: SHAME! ok this one is tricky, so i note it here, those reading: learn from my mistake! ;) in order for set_?adjustment to support a default adjustemnt if invoked with an adjustment pointer of NULL, the code read (pseudo): if (v->adjustment) unref (v->adjustment); if (!adjustment) adjustment = adjustment_new (); if (v->adjustment != adjustment) v->adjustment = ref (adjustment); now imagine the first unref to actually free the old adjustment and adjustment_new() creating a new adjustment from the very same memory portion. here, the latter comparision will unintendedly fail, and all hell breaks loose. (gtk_viewport_set_hadjustment): (gtk_viewport_set_vadjustment): reset viewport->?adjustment to NULL after unreferencing it. * gtk/gtkcontainer.[hc]: removed toplevel registration functions: gtk_container_register_toplevel(), gtk_container_unregister_toplevel() and gtk_container_get_toplevels() which had wrong semantics anyways: it didn't reference and copy the list. * gtk/gtkwindow.c: we take over the container toplevel registration bussiness now. windows are registered across multiple destructions, untill they are finalized. the initial implicit reference count users are holding on windows is removed with the first destruction though. (gtk_window_init): ref & sink and set has_user_ref_count, got rid of gtk_container_register_toplevel() call. add window to toplevel_list. (gtk_window_destroy): unref the window if has_user_ref_count is still set, got rid of call to gtk_container_unregister_toplevel(). (gtk_window_finalize): remove window from toplevel list. (gtk_window_list_toplevels): new function to return a newly created list with referenced toplevels. (gtk_window_read_rcfiles): use gtk_window_list_toplevels(). * gtk/gtkhscale.c (gtk_hscale_class_init): made the GtkRange adjustment a non-construct arg. * gtk/gtkvscale.c (gtk_vscale_class_init): likewise. * gtk/gtkhscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkvscrollbar.c (gtk_vscrollbar_class_init): likewise. * gtk/gtkrange.c: added some realized checks. (gtk_range_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. remove timer. (gtk_range_get_adjustment): demand create adjustment. * gtk/gtkviewport.c: made h/v adjustment non-construct args. we simply create them on demand now and get rid of them in the destroy handler. (gtk_viewport_destroy): get rid of the h/v adjustments in the destroy handler instead of finalize. (gtk_viewport_get_hadjustment): (gtk_viewport_get_vadjustment): (gtk_viewport_size_allocate): demand create h/v adjustment if required. * gtk/gtkwidget.c (gtk_widget_finalize): duplicate part of the gtk_widget_real_destroy () functionality. (gtk_widget_real_destroy): reinitialize with a new style, instead of setting widget->style to NULL. Fri May 5 13:02:09 2000 Tim Janik <timj@gtk.org> * gtk/gtkcalendar.c: * gtk/gtkbutton.c: ported _get_type() implementation over to GType, either to preserve memchunks allocation facilities, or because Gtk+ 1.0 GtkTypeInfo was still being used. * gtk/gtkobject.[hc]: derive from GObject. ported various functions over. prepare for ::destroy to be emitted multiple times. removed reference tracer magic. chain into GObjectClass.shutdown() to emit ::destroy signal. * gtk/gtksignal.c: removed assumptions about GTK_TYPE_OBJECT being fundamental. * gtk/gtkmain.c: removed gtk_object_post_arg_parsing_init() cludge. * gtk/gtksocket.c: * gtk/gtkplug.c: * gtk/gtklayout.c: * gtk/gtklabel.c: * gtk/gtkargcollector.c: * gtk/gtkarg.c: various fixups to work with GTK_TYPE_OBJECT not being a fundamental anymore, and to work with the new type system (nuked fundamental type varargs clutter). * gtk/*.c: install finalize handlers in the GObjectClass part of the class structure. changed direct GTK_OBJECT()->klass accesses to GTK_*_GET_CLASS(). changed direct object_class->type accesses to GTK_CLASS_TYPE(). * gtktypeutils.[hc]: use the reserved fundamental ids provided by GType. made most of the GTK_*() type macros and Gtk* typedefs simple wrappers around macros and types provided by GType. most notably, a significant portion of the old API vanished: GTK_TYPE_MAKE(), GTK_TYPE_SEQNO(), GTK_TYPE_FLAT_FIRST, GTK_TYPE_FLAT_LAST, GTK_TYPE_STRUCTURED_FIRST, GTK_TYPE_STRUCTURED_LAST, GTK_TYPE_ARGS, GTK_TYPE_CALLBACK, GTK_TYPE_C_CALLBACK, GTK_TYPE_FOREIGN, GtkTypeQuery, gtk_type_query(), gtk_type_set_varargs_type(), gtk_type_get_varargs_type(), gtk_type_check_object_cast(), gtk_type_check_class_cast(), gtk_type_describe_tree(), gtk_type_describe_heritage(), gtk_type_free(), gtk_type_children_types(), gtk_type_set_chunk_alloc(), gtk_type_register_enum(), gtk_type_register_flags(), gtk_type_parent_class(). replacements, where available are described in ../docs/Changes-1.4.txt. implemented compatibility functions for the remaining API. * configure.in: depend on glib 1.3.1, use gobject module.
2000-05-12 15:25:50 +00:00
gtk_menu_detach (GtkMenu *menu)
{
GtkMenuAttachData *data;
GList *list;
2010-12-23 20:50:18 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
/* keep this function in sync with gtk_widget_unparent() */
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
if (!data)
{
g_warning ("gtk_menu_detach(): menu is not attached");
return;
}
g_object_set_data (G_OBJECT (menu), I_(attach_data_key), NULL);
2010-12-23 20:50:18 +00:00
/* Detach the toplevel window. */
gtk_window_set_attached_to (GTK_WINDOW (menu->priv->toplevel), NULL);
g_signal_handlers_disconnect_by_func (data->attach_widget,
2010-12-23 20:50:18 +00:00
(gpointer) attach_widget_screen_changed,
menu);
if (data->detacher)
data->detacher (data->attach_widget, menu);
list = g_object_steal_data (G_OBJECT (data->attach_widget), ATTACHED_MENUS);
list = g_list_remove (list, menu);
if (list)
g_object_set_data_full (G_OBJECT (data->attach_widget), I_(ATTACHED_MENUS), list,
(GDestroyNotify) g_list_free);
else
g_object_set_data (G_OBJECT (data->attach_widget), I_(ATTACHED_MENUS), NULL);
2010-12-23 20:50:18 +00:00
if (gtk_widget_get_realized (GTK_WIDGET (menu)))
gtk_widget_unrealize (GTK_WIDGET (menu));
2010-12-23 20:50:18 +00:00
g_slice_free (GtkMenuAttachData, data);
2010-12-23 20:50:18 +00:00
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
/* Fallback title for menu comes from attach widget */
gtk_menu_update_title (menu);
g_object_notify (G_OBJECT (menu), "attach-widget");
g_object_unref (menu);
1997-11-24 22:37:52 +00:00
}
static void
gtk_menu_remove (GtkContainer *container,
2010-12-23 20:50:18 +00:00
GtkWidget *widget)
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
{
GtkMenu *menu = GTK_MENU (container);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
2010-12-23 20:50:18 +00:00
/* Clear out old_active_menu_item if it matches the item we are removing */
if (priv->old_active_menu_item == widget)
g_clear_object (&priv->old_active_menu_item);
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
2006-05-02 23:56:43 +00:00
GTK_CONTAINER_CLASS (gtk_menu_parent_class)->remove (container, widget);
2010-12-23 20:50:18 +00:00
g_object_set_data (G_OBJECT (widget), I_(ATTACH_INFO_KEY), NULL);
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
menu_queue_resize (menu);
}
Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). Fri Feb 2 12:26:50 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Get rid of a bunch of g_strdup_printf("%s%s") in favor of g_strconcat(). * gtk/gtkrc.c Makefile.am: Use $(libdir), not $(exe_prefix), since some people set $(libdir) separately. (#1290, David Kaelbling) Thu Feb 1 18:25:46 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c: If PATH_MAX and MAXPATHLEN are not defined, define MAXPATHLEN to 2048. (The Hurd doesn't have MAXPATHLEN, but the code here depends on a fixed value.) (#4524) Wed Jan 31 22:01:04 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkhandlebox.c (gtk_handle_box_button_changed): Handle the case where child == NULL and handle_position == RIGHT or BOTTOM. (#8041g) Wed Jan 31 21:20:39 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (real_tree_move): If the node being moved isn't viewable there is no way that moving the node will cause the focus row to become not viewable, so omit check on the visibility of new_sibling, which is irrelevant. (Fixes #8002, David Helder) Wed Jan 31 20:38:17 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_commit_cb): Delete the current selection before inserting new text. Wed Jan 31 18:49:33 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkoptionmenu.c (gtk_option_menu_item_state_changed_cb): Make the sensitivity of the reparented child track that of the original parent menu item. (#34218, David Hodson) * gtk/gtkoptionmenu.c (gtk_option_menu_item_destroy_cb): Handle the case where the current item is destroyed properly. * gtk/gtkoptionmenu.c: Some additional code cleanups and fix some edge cases with child-less menuitems. Wed Jan 31 17:16:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkcombo.c (gtk_combo_window_key_press): Make Return key pop down window. (#12074, Jon K Hellan) Wed Jan 31 16:21:42 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklist.c (gtk_list_signal_item_toggle): Don't allow toggling of rows off in BROWSE or EXTENDED mode. (#12072, Jon K Hellan) The solution here isn't perfect - you get an extraneous emission of "toggle", which could conceivably confuse an app, but better than the current situation. LXR search seems to indicate that no apps in GNOME CVS connect to "toggle". Wed Jan 31 15:46:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (libgtkinclude_HEADERS): Move gtkcompat.h from gtk_public_h_sources to directly here to avoid warning when building srcdir != builddir. (#9656) Tue Jan 30 19:49:02 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkrange.c: Patch from Kipp Hickman to make the event handlers in gtkrange.c return the proper values (TRUE == handled) (#10316). This is just the tip of the iceberg, but gtkrange.c is the most common place where the propagation is problematical, and also a place where it is almost certainly safe to change this in the stable branch. (You don't want right click popups on a range control or anything...) Tue Jan 30 18:57:59 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_focus_area): We need to clear the focus area on focus out, even if a background pixmap isn't set. (#13941) Tue Jan 30 18:24:10 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_shape): Fix from Sean Cunningham to deal with setting the shape properly when scrolling arrows are turned on, but not visible because there is sufficient space. (#13432) Tue Jan 30 16:39:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_delete_item): For menu items with submenus, destroy the item along with the submenu. (#7841, Brian Masney(?)) Also, handle paths of the form '<foo>/abcd...' properly. * gtk/testgtk.c (menu_items): Add a dummy branch that we delete later. Tue Jan 30 15:51:25 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_real_set_focus): Fix a problem where the focus widget sometimes wasn't drawn with the default if there was no default widget. * gtk/gtkstyle.c (gtk_style_real_unrealize): free colors, unreference pixmaps. * gtk/gtkstyle.c (gtk_style_realize): Reference colormap for some extra safety. Mon Jan 29 19:00:01 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtk{ctree.c,clist.c} (set_cell_contents): Handle setting the text of a cell to the old pointer value better, by copying the new text before freeing the old text. Some code cleanup. (#8079, Karl Nelson) Mon Jan 29 16:50:19 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtklabel.[ch] gtk/gtkframe.[ch]: Make gtk_label_get_text() gtk_frame_get_label() non strdup'ing, and G_CONST_RETURN. Mon Jan 29 15:22:51 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenu.c (gtk_menu_remove): When removing an item from a menu, check to see if it matches menu->old_active_menu_item, and if so, unref and clear old_active_menu_item (Patch from Pavel Cisler) * gtk/gtkmenushell.c (gtk_menu_shell_remove): Unset menu_shell->active_menu_item, if it is the child being removed. (Patch based on that of Gene Ragan, #50337)
2001-02-02 17:53:29 +00:00
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_new:
*
* Creates a new #GtkMenu
2011-01-15 13:51:11 +00:00
*
* Returns: a new #GtkMenu
2011-01-15 13:51:11 +00:00
*/
1997-11-24 22:37:52 +00:00
GtkWidget*
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
1998-05-03 22:41:32 +00:00
gtk_menu_new (void)
1997-11-24 22:37:52 +00:00
{
return g_object_new (GTK_TYPE_MENU, NULL);
1997-11-24 22:37:52 +00:00
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_real_insert (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *child,
gint position)
1997-11-24 22:37:52 +00:00
{
GtkMenu *menu = GTK_MENU (menu_shell);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
AttachInfo *ai = get_attach_info (child);
ai->left_attach = -1;
ai->right_attach = -1;
ai->top_attach = -1;
ai->bottom_attach = -1;
if (gtk_widget_get_realized (GTK_WIDGET (menu_shell)))
2010-12-23 20:50:18 +00:00
gtk_widget_set_parent_window (child, priv->bin_window);
2006-05-02 23:56:43 +00:00
GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->insert (menu_shell, child, position);
menu_queue_resize (menu);
}
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
static void
gtk_menu_tearoff_bg_copy (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
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.
2000-11-08 17:34:52 +00:00
gint width, height;
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
2010-12-23 20:50:18 +00:00
if (priv->torn_off)
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
{
GdkWindow *window;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr;
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
priv->tearoff_active = FALSE;
priv->saved_scroll_offset = priv->scroll_offset;
2010-12-23 20:50:18 +00:00
window = gtk_widget_get_window (priv->tearoff_window);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
surface = gdk_window_create_similar_surface (window,
CAIRO_CONTENT_COLOR,
width,
height);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
cr = cairo_create (surface);
2010-12-23 20:50:18 +00:00
gdk_cairo_set_source_window (cr, window, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
gtk_widget_set_size_request (priv->tearoff_window, width, height);
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.
2000-11-08 17:34:52 +00:00
pattern = cairo_pattern_create_for_surface (surface);
gdk_window_set_background_pattern (window, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (surface);
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
}
}
static gboolean
popup_grab_on_window (GdkWindow *window,
2010-05-25 22:38:44 +00:00
GdkDevice *keyboard,
GdkDevice *pointer,
2010-12-23 20:50:18 +00:00
guint32 activate_time)
{
2010-05-25 22:38:44 +00:00
if (keyboard &&
gdk_device_grab (keyboard, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, activate_time) != GDK_GRAB_SUCCESS)
return FALSE;
if (pointer &&
gdk_device_grab (pointer, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_SMOOTH_SCROLL_MASK |
2010-05-25 22:38:44 +00:00
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK,
NULL, activate_time) != GDK_GRAB_SUCCESS)
{
2010-05-25 22:38:44 +00:00
if (keyboard)
gdk_device_ungrab (keyboard, activate_time);
return FALSE;
}
2010-05-25 22:38:44 +00:00
return TRUE;
}
/**
2010-05-25 22:38:44 +00:00
* gtk_menu_popup_for_device:
* @menu: a #GtkMenu
2010-05-25 22:38:44 +00:00
* @device: (allow-none): a #GdkDevice
* @parent_menu_shell: (allow-none): the menu shell containing the triggering
* menu item, or %NULL
* @parent_menu_item: (allow-none): the menu item whose activation triggered
* the popup, or %NULL
* @func: (allow-none): a user supplied function used to position the menu,
* or %NULL
* @data: (allow-none): user supplied data to be passed to @func
* @destroy: (allow-none): destroy notify for @data
* @button: the mouse button which was pressed to initiate the event
* @activate_time: the time at which the activation event occurred
*
* Displays a menu and makes it available for selection.
*
* Applications can use this function to display context-sensitive menus,
* and will typically supply %NULL for the @parent_menu_shell,
* @parent_menu_item, @func, @data and @destroy parameters. The default
* menu positioning function will position the menu at the current position
* of @device (or its corresponding pointer).
*
* The @button parameter should be the mouse button pressed to initiate
* the menu popup. If the menu popup was initiated by something other than
* a mouse button press, such as a mouse button release or a keypress,
* @button should be 0.
*
* The @activate_time parameter is used to conflict-resolve initiation of
* concurrent requests for mouse/keyboard grab requests. To function
* properly, this needs to be the time stamp of the user event (such as
* a mouse click or key press) that caused the initiation of the popup.
* Only if no such event is available, gtk_get_current_event_time() can
* be used instead.
2010-05-25 22:38:44 +00:00
*
* Since: 3.0
*/
1997-11-24 22:37:52 +00:00
void
2010-05-25 22:38:44 +00:00
gtk_menu_popup_for_device (GtkMenu *menu,
GdkDevice *device,
GtkWidget *parent_menu_shell,
GtkWidget *parent_menu_item,
GtkMenuPositionFunc func,
gpointer data,
GDestroyNotify destroy,
2010-05-25 22:38:44 +00:00
guint button,
guint32 activate_time)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
GtkWidget *widget;
1998-03-24 01:43:21 +00:00
GtkWidget *xgrab_shell;
GtkWidget *parent;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
GdkEvent *current_event;
GtkMenuShell *menu_shell;
gboolean grab_keyboard;
GtkWidget *parent_toplevel;
GdkDevice *keyboard, *pointer, *source_device = NULL;
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.
2000-11-08 17:34:52 +00:00
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (device == NULL || GDK_IS_DEVICE (device));
if (device == NULL)
device = gtk_get_current_event_device ();
if (device == NULL)
{
GdkDisplay *display;
GdkDeviceManager *device_manager;
GList *devices;
display = gtk_widget_get_display (GTK_WIDGET (menu));
device_manager = gdk_display_get_device_manager (display);
devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
device = devices->data;
g_list_free (devices);
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
widget = GTK_WIDGET (menu);
menu_shell = GTK_MENU_SHELL (menu);
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
2010-05-25 22:38:44 +00:00
{
keyboard = device;
pointer = gdk_device_get_associated_device (device);
}
else
{
pointer = device;
keyboard = gdk_device_get_associated_device (device);
}
menu_shell->priv->parent_menu_shell = parent_menu_shell;
priv->seen_item_enter = FALSE;
2010-12-23 20:50:18 +00:00
/* Find the last viewable ancestor, and make an X grab on it
*/
parent = GTK_WIDGET (menu);
xgrab_shell = NULL;
while (parent)
{
gboolean viewable = TRUE;
GtkWidget *tmp = parent;
2010-12-23 20:50:18 +00:00
while (tmp)
2010-12-23 20:50:18 +00:00
{
if (!gtk_widget_get_mapped (tmp))
{
viewable = FALSE;
break;
}
tmp = gtk_widget_get_parent (tmp);
}
if (viewable)
2010-12-23 20:50:18 +00:00
xgrab_shell = parent;
parent = GTK_MENU_SHELL (parent)->priv->parent_menu_shell;
}
2010-12-23 20:50:18 +00:00
/* We want to receive events generated when we map the menu;
* unfortunately, since there is probably already an implicit
* grab in place from the button that the user used to pop up
* the menu, we won't receive then -- in particular, the EnterNotify
* when the menu pops up under the pointer.
*
2010-12-23 20:50:18 +00:00
* If we are grabbing on a parent menu shell, no problem; just grab
* on that menu shell first before popping up the window with
* owner_events = TRUE.
*
2010-12-23 20:50:18 +00:00
* When grabbing on the menu itself, things get more convoluted --
* we do an explicit grab on a specially created window with
2010-12-23 20:50:18 +00:00
* owner_events = TRUE, which we override further down with a
* grab on the menu. (We can't grab on the menu until it is mapped;
* we probably could just leave the grab on the other window,
* with a little reorganization of the code in gtkmenu*).
*/
grab_keyboard = gtk_menu_shell_get_take_focus (menu_shell);
2010-12-23 20:50:18 +00:00
gtk_window_set_accept_focus (GTK_WINDOW (priv->toplevel), grab_keyboard);
2010-05-25 22:38:44 +00:00
if (!grab_keyboard)
keyboard = NULL;
if (xgrab_shell && xgrab_shell != widget)
{
if (popup_grab_on_window (gtk_widget_get_window (xgrab_shell), keyboard, pointer, activate_time))
2010-05-25 22:38:44 +00:00
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
2010-05-25 22:38:44 +00:00
}
}
else
{
GdkWindow *transfer_window;
xgrab_shell = widget;
transfer_window = menu_grab_transfer_window_get (menu);
2010-05-25 22:38:44 +00:00
if (popup_grab_on_window (transfer_window, keyboard, pointer, activate_time))
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
2010-05-25 22:38:44 +00:00
}
}
if (!GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab)
{
2010-12-23 20:50:18 +00:00
/* We failed to make our pointer/keyboard grab.
* Rather than leaving the user with a stuck up window,
* we just abort here. Presumably the user will try again.
*/
menu_shell->priv->parent_menu_shell = NULL;
menu_grab_transfer_window_destroy (menu);
return;
}
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (menu), pointer);
menu_shell->priv->active = TRUE;
menu_shell->priv->button = button;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
/* If we are popping up the menu from something other than, a button
* press then, as a heuristic, we ignore enter events for the menu
2010-12-23 20:50:18 +00:00
* until we get a MOTION_NOTIFY.
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
*/
current_event = gtk_get_current_event ();
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
if (current_event)
{
if ((current_event->type != GDK_BUTTON_PRESS) &&
2010-12-23 20:50:18 +00:00
(current_event->type != GDK_ENTER_NOTIFY))
menu_shell->priv->ignore_enter = TRUE;
source_device = gdk_event_get_source_device (current_event);
gdk_event_free (current_event);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
else
menu_shell->priv->ignore_enter = TRUE;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
2010-12-23 20:50:18 +00:00
if (priv->torn_off)
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
{
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
gtk_menu_tearoff_bg_copy (menu);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
2010-12-23 20:50:18 +00:00
gtk_menu_reparent (menu, priv->toplevel, FALSE);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
parent_toplevel = NULL;
2010-12-23 20:50:18 +00:00
if (parent_menu_shell)
parent_toplevel = gtk_widget_get_toplevel (parent_menu_shell);
else if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
{
GtkWidget *attach_widget = gtk_menu_get_attach_widget (menu);
if (attach_widget)
2010-12-23 20:50:18 +00:00
parent_toplevel = gtk_widget_get_toplevel (attach_widget);
}
2010-12-23 20:50:18 +00:00
/* Set transient for to get the right window group and parent */
if (GTK_IS_WINDOW (parent_toplevel))
2010-12-23 20:50:18 +00:00
gtk_window_set_transient_for (GTK_WINDOW (priv->toplevel),
GTK_WINDOW (parent_toplevel));
priv->parent_menu_item = parent_menu_item;
priv->position_func = func;
priv->position_func_data = data;
priv->position_func_data_destroy = destroy;
menu_shell->priv->activate_time = activate_time;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
2010-12-23 20:50:18 +00:00
/* We need to show the menu here rather in the init function
* because code expects to be able to tell if the menu is onscreen
* by looking at gtk_widget_get_visible (menu)
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
*/
1997-11-24 22:37:52 +00:00
gtk_widget_show (GTK_WIDGET (menu));
/* Position the menu, possibly changing the size request
*/
gtk_menu_position (menu, TRUE);
/* Compute the size of the toplevel and realize it so we
* can scroll correctly.
*/
if (!gtk_widget_get_realized (GTK_WIDGET (menu)))
{
GtkRequisition tmp_request;
GtkAllocation tmp_allocation = { 0, };
2010-12-23 20:50:18 +00:00
/* Instead of trusting the menu position function to queue a
* resize when the menu goes out of bounds, invalidate the cached
* size here.
*/
gtk_widget_queue_resize (GTK_WIDGET (menu));
2010-12-23 20:50:18 +00:00
gtk_widget_get_preferred_size (priv->toplevel, &tmp_request, NULL);
tmp_allocation.width = tmp_request.width;
tmp_allocation.height = tmp_request.height;
2010-12-23 20:50:18 +00:00
gtk_widget_size_allocate (priv->toplevel, &tmp_allocation);
gtk_widget_realize (priv->toplevel);
}
2010-12-23 20:50:18 +00:00
gtk_menu_scroll_to (menu, priv->scroll_offset);
Merged heavily modified patch from maemo-gtk which enables opening and 2007-04-27 Michael Natterer <mitch@imendio.com> Merged heavily modified patch from maemo-gtk which enables opening and closing submenus on click, and introduces some usability changes when gtk-touchscreen-mode is enabled (bug #128968): * gtk/gtkmenushell.c (struct GtkMenuShellPrivate): added boolean "activated_submenu" to indicate that the current mouse operation (click or drag) has opened a submenu. (gtk_menu_shell_button_press): pop up submenus without delay and record the fact in "activated_submenu". (gtk_menu_shell_button_release): if a submenu was explicitely opened, or not opened by this release's button_press, or enough time has passed since timeout-opening it, close the submenu here. (gtk_menu_shell_enter_notify): when entering a menu item with any mouse button pressed, open its submenu. (gtk_real_menu_shell_move_current): in touchsreen mode, close the submenu when moving the focus away from it via keyboard-navigation. * gtk/gtkmenuitem.[ch] (_gtk_menu_item_popup_submenu): added parameter "gboolean with_delay" so GtkMenuShell can control this for the different scenarios of submenu showing. (_gtk_menu_item_popdown_submenu): new function. also needed by GtkMenuShell for closing submenus on click. Renamed internal function gtk_menu_item_select_timeout() to gtk_menu_item_popup_timeout(). (gtk_menu_item_real_popup_submenu): new utility function which does the actual popup and records the exact time of the popup when the menu was timeout-opened (using g_get_current_time()). (gtk_real_menu_item_select): don't add the popup timeout when in touchscreen mode. * gtk/gtkmenu.c (gtk_menu_popup): in touchscreen mode, select the first item of every opened menu. svn path=/trunk/; revision=17659
2007-04-27 14:49:37 +00:00
/* if no item is selected, select the first one */
if (!menu_shell->priv->active_menu_item &&
source_device && gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN)
gtk_menu_shell_select_first (menu_shell, TRUE);
Merged heavily modified patch from maemo-gtk which enables opening and 2007-04-27 Michael Natterer <mitch@imendio.com> Merged heavily modified patch from maemo-gtk which enables opening and closing submenus on click, and introduces some usability changes when gtk-touchscreen-mode is enabled (bug #128968): * gtk/gtkmenushell.c (struct GtkMenuShellPrivate): added boolean "activated_submenu" to indicate that the current mouse operation (click or drag) has opened a submenu. (gtk_menu_shell_button_press): pop up submenus without delay and record the fact in "activated_submenu". (gtk_menu_shell_button_release): if a submenu was explicitely opened, or not opened by this release's button_press, or enough time has passed since timeout-opening it, close the submenu here. (gtk_menu_shell_enter_notify): when entering a menu item with any mouse button pressed, open its submenu. (gtk_real_menu_shell_move_current): in touchsreen mode, close the submenu when moving the focus away from it via keyboard-navigation. * gtk/gtkmenuitem.[ch] (_gtk_menu_item_popup_submenu): added parameter "gboolean with_delay" so GtkMenuShell can control this for the different scenarios of submenu showing. (_gtk_menu_item_popdown_submenu): new function. also needed by GtkMenuShell for closing submenus on click. Renamed internal function gtk_menu_item_select_timeout() to gtk_menu_item_popup_timeout(). (gtk_menu_item_real_popup_submenu): new utility function which does the actual popup and records the exact time of the popup when the menu was timeout-opened (using g_get_current_time()). (gtk_real_menu_item_select): don't add the popup timeout when in touchscreen mode. * gtk/gtkmenu.c (gtk_menu_popup): in touchscreen mode, select the first item of every opened menu. svn path=/trunk/; revision=17659
2007-04-27 14:49:37 +00:00
2010-12-23 20:50:18 +00:00
/* Once everything is set up correctly, map the toplevel */
gtk_widget_show (priv->toplevel);
if (xgrab_shell == widget)
popup_grab_on_window (gtk_widget_get_window (widget), keyboard, pointer, activate_time); /* Should always succeed */
2010-05-25 22:38:44 +00:00
gtk_device_grab_add (GTK_WIDGET (menu), pointer, TRUE);
if (parent_menu_shell)
{
gboolean keyboard_mode;
keyboard_mode = _gtk_menu_shell_get_keyboard_mode (GTK_MENU_SHELL (parent_menu_shell));
_gtk_menu_shell_set_keyboard_mode (menu_shell, keyboard_mode);
}
else if (menu_shell->priv->button == 0) /* a keynav-activated context menu */
_gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
_gtk_menu_shell_update_mnemonics (menu_shell);
1997-11-24 22:37:52 +00:00
}
2010-05-25 22:38:44 +00:00
/**
* gtk_menu_popup:
* @menu: a #GtkMenu
2010-12-23 20:50:18 +00:00
* @parent_menu_shell: (allow-none): the menu shell containing the
* triggering menu item, or %NULL
* @parent_menu_item: (allow-none): the menu item whose activation
* triggered the popup, or %NULL
* @func: (scope async) (allow-none): a user supplied function used to position
2010-12-23 20:50:18 +00:00
* the menu, or %NULL
* @data: user supplied data to be passed to @func.
2010-05-25 22:38:44 +00:00
* @button: the mouse button which was pressed to initiate the event.
* @activate_time: the time at which the activation event occurred.
*
2010-12-23 20:50:18 +00:00
* Displays a menu and makes it available for selection.
*
* Applications can use this function to display context-sensitive
* menus, and will typically supply %NULL for the @parent_menu_shell,
* @parent_menu_item, @func and @data parameters. The default menu
* positioning function will position the menu at the current mouse
* cursor position.
2010-05-25 22:38:44 +00:00
*
* The @button parameter should be the mouse button pressed to initiate
2010-12-23 20:50:18 +00:00
* the menu popup. If the menu popup was initiated by something other
* than a mouse button press, such as a mouse button release or a keypress,
2010-05-25 22:38:44 +00:00
* @button should be 0.
*
2010-12-23 20:50:18 +00:00
* The @activate_time parameter is used to conflict-resolve initiation
* of concurrent requests for mouse/keyboard grab requests. To function
* properly, this needs to be the timestamp of the user event (such as
2010-05-25 22:38:44 +00:00
* a mouse click or key press) that caused the initiation of the popup.
* Only if no such event is available, gtk_get_current_event_time() can
* be used instead.
*/
void
2010-12-23 20:50:18 +00:00
gtk_menu_popup (GtkMenu *menu,
GtkWidget *parent_menu_shell,
GtkWidget *parent_menu_item,
GtkMenuPositionFunc func,
gpointer data,
guint button,
guint32 activate_time)
2010-05-25 22:38:44 +00:00
{
g_return_if_fail (GTK_IS_MENU (menu));
gtk_menu_popup_for_device (menu,
NULL,
2010-05-25 22:38:44 +00:00
parent_menu_shell,
parent_menu_item,
func, data, NULL,
2010-05-25 22:38:44 +00:00
button, activate_time);
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_popdown:
* @menu: a #GtkMenu
*
* Removes the menu from the screen.
*/
1997-11-24 22:37:52 +00:00
void
gtk_menu_popdown (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv;
1997-11-24 22:37:52 +00:00
GtkMenuShell *menu_shell;
2010-05-25 22:38:44 +00:00
GdkDevice *pointer;
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.
2000-11-08 17:34:52 +00:00
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
menu_shell = GTK_MENU_SHELL (menu);
2010-12-23 20:50:18 +00:00
priv = menu->priv;
menu_shell->priv->parent_menu_shell = NULL;
menu_shell->priv->active = FALSE;
menu_shell->priv->ignore_enter = FALSE;
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
priv->have_position = FALSE;
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.
2000-11-08 17:34:52 +00:00
gtk_menu_stop_scrolling (menu);
gtk_menu_stop_navigating_submenu (menu);
2010-12-23 20:50:18 +00:00
if (menu_shell->priv->active_menu_item)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
if (priv->old_active_menu_item)
g_object_unref (priv->old_active_menu_item);
priv->old_active_menu_item = menu_shell->priv->active_menu_item;
2010-12-23 20:50:18 +00:00
g_object_ref (priv->old_active_menu_item);
1997-11-24 22:37:52 +00:00
}
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
gtk_menu_shell_deselect (menu_shell);
2010-12-23 20:50:18 +00:00
/* The X Grab, if present, will automatically be removed
* when we hide the window
*/
if (priv->toplevel)
{
2010-12-23 20:50:18 +00:00
gtk_widget_hide (priv->toplevel);
gtk_window_set_transient_for (GTK_WINDOW (priv->toplevel), NULL);
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
pointer = _gtk_menu_shell_get_grab_device (menu_shell);
2010-12-23 20:50:18 +00:00
if (priv->torn_off)
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
{
2010-12-23 20:50:18 +00:00
gtk_widget_set_size_request (priv->tearoff_window, -1, -1);
if (gtk_bin_get_child (GTK_BIN (priv->toplevel)))
{
gtk_menu_reparent (menu, priv->tearoff_hbox, TRUE);
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
else
2010-12-23 20:50:18 +00:00
{
2010-05-25 22:38:44 +00:00
/* We popped up the menu from the tearoff, so we need to
2010-12-23 20:50:18 +00:00
* release the grab - we aren't actually hiding the menu.
*/
if (menu_shell->priv->have_xgrab && pointer)
{
GdkDevice *keyboard;
gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
keyboard = gdk_device_get_associated_device (pointer);
if (keyboard)
gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
}
2010-12-23 20:50:18 +00:00
}
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.
2000-11-08 17:34:52 +00:00
/* gtk_menu_popdown is called each time a menu item is selected from
* a torn off menu. Only scroll back to the saved position if the
* non-tearoff menu was popped down.
*/
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
gtk_menu_scroll_to (menu, priv->saved_scroll_offset);
priv->tearoff_active = TRUE;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
else
gtk_widget_hide (GTK_WIDGET (menu));
menu_shell->priv->have_xgrab = FALSE;
2010-05-25 22:38:44 +00:00
if (pointer)
gtk_device_grab_remove (GTK_WIDGET (menu), pointer);
_gtk_menu_shell_set_grab_device (menu_shell, NULL);
menu_grab_transfer_window_destroy (menu);
1997-11-24 22:37:52 +00:00
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_get_active:
* @menu: a #GtkMenu
*
* Returns the selected menu item from the menu. This is used by the
* #GtkComboBox.
2011-01-15 13:51:11 +00:00
*
* Returns: (transfer none): the #GtkMenuItem that was last selected
* in the menu. If a selection has not yet been made, the
* first menu item is selected.
2011-01-15 13:51:11 +00:00
*/
1997-11-24 22:37:52 +00:00
GtkWidget*
gtk_menu_get_active (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
1997-11-24 22:37:52 +00:00
GtkWidget *child;
GList *children;
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
2010-12-23 20:50:18 +00:00
if (!priv->old_active_menu_item)
1997-11-24 22:37:52 +00:00
{
child = NULL;
children = GTK_MENU_SHELL (menu)->priv->children;
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
while (children)
2010-12-23 20:50:18 +00:00
{
child = children->data;
children = children->next;
if (gtk_bin_get_child (GTK_BIN (child)))
break;
child = NULL;
}
priv->old_active_menu_item = child;
if (priv->old_active_menu_item)
g_object_ref (priv->old_active_menu_item);
1997-11-24 22:37:52 +00:00
}
2010-12-23 20:50:18 +00:00
return priv->old_active_menu_item;
1997-11-24 22:37:52 +00:00
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_set_active:
* @menu: a #GtkMenu
* @index: the index of the menu item to select. Iindex values are
* from 0 to n-1
*
* Selects the specified menu item within the menu. This is used by
* the #GtkComboBox and should not be used by anyone else.
2011-01-15 13:51:11 +00:00
*/
1997-11-24 22:37:52 +00:00
void
gtk_menu_set_active (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
guint index)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
1997-11-24 22:37:52 +00:00
GtkWidget *child;
GList *tmp_list;
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
tmp_list = g_list_nth (GTK_MENU_SHELL (menu)->priv->children, index);
1997-11-24 22:37:52 +00:00
if (tmp_list)
{
child = tmp_list->data;
2010-05-24 20:31:36 +00:00
if (gtk_bin_get_child (GTK_BIN (child)))
2010-12-23 20:50:18 +00:00
{
if (priv->old_active_menu_item)
g_object_unref (priv->old_active_menu_item);
priv->old_active_menu_item = child;
g_object_ref (priv->old_active_menu_item);
}
1997-11-24 22:37:52 +00:00
}
}
/**
* gtk_menu_set_accel_group:
2011-01-15 13:51:11 +00:00
* @menu: a #GtkMenu
* @accel_group: (allow-none): the #GtkAccelGroup to be associated
* with the menu.
*
* Set the #GtkAccelGroup which holds global accelerators for the
* menu. This accelerator group needs to also be added to all windows
* that this menu is being used in with gtk_window_add_accel_group(),
* in order for those windows to support all the accelerators
* contained in this group.
*/
1997-11-24 22:37:52 +00:00
void
2010-12-23 20:50:18 +00:00
gtk_menu_set_accel_group (GtkMenu *menu,
GtkAccelGroup *accel_group)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
if (priv->accel_group != accel_group)
{
2010-12-23 20:50:18 +00:00
if (priv->accel_group)
g_object_unref (priv->accel_group);
priv->accel_group = accel_group;
if (priv->accel_group)
g_object_ref (priv->accel_group);
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
_gtk_menu_refresh_accel_paths (menu, TRUE);
}
1997-11-24 22:37:52 +00:00
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_get_accel_group:
2011-02-09 04:14:46 +00:00
* @menu: a #GtkMenu
2011-01-15 13:51:11 +00:00
*
* Gets the #GtkAccelGroup which holds global accelerators for the
2011-02-09 04:14:46 +00:00
* menu. See gtk_menu_set_accel_group().
2011-01-15 13:51:11 +00:00
*
2011-02-09 04:14:46 +00:00
* Returns: (transfer none): the #GtkAccelGroup associated with the menu
2011-01-15 13:51:11 +00:00
*/
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
GtkAccelGroup*
gtk_menu_get_accel_group (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
2010-12-23 20:50:18 +00:00
return menu->priv->accel_group;
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
}
static gboolean
gtk_menu_real_can_activate_accel (GtkWidget *widget,
guint signal_id)
{
/* Menu items chain here to figure whether they can activate their
* accelerators. Unlike ordinary widgets, menus allow accel
* activation even if invisible since that's the usual case for
* submenus/popup-menus. however, the state of the attach widget
* affects the "activeness" of the menu.
*/
GtkWidget *awidget = gtk_menu_get_attach_widget (GTK_MENU (widget));
if (awidget)
return gtk_widget_can_activate_accel (awidget, signal_id);
else
return gtk_widget_is_sensitive (widget);
}
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
/**
* gtk_menu_set_accel_path:
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
* @menu: a valid #GtkMenu
* @accel_path: (allow-none): a valid accelerator path
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
*
* Sets an accelerator path for this menu from which accelerator paths
* for its immediate children, its menu items, can be constructed.
* The main purpose of this function is to spare the programmer the
* inconvenience of having to call gtk_menu_item_set_accel_path() on
* each menu item that should support runtime user changable accelerators.
* Instead, by just calling gtk_menu_set_accel_path() on their parent,
2010-12-23 20:50:18 +00:00
* each menu item of this menu, that contains a label describing its
* purpose, automatically gets an accel path assigned.
*
* For example, a menu containing menu items "New" and "Exit", will, after
* <literal>gtk_menu_set_accel_path (menu, "&lt;Gnumeric-Sheet&gt;/File");</literal>
* has been called, assign its items the accel paths:
* <literal>"&lt;Gnumeric-Sheet&gt;/File/New"</literal> and <literal>"&lt;Gnumeric-Sheet&gt;/File/Exit"</literal>.
2010-12-23 20:50:18 +00:00
*
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
* Assigning accel paths to menu items then enables the user to change
* their accelerators at runtime. More details about accelerator paths
* and their default setups can be found at gtk_accel_map_add_entry().
2010-12-23 20:50:18 +00:00
*
* Note that @accel_path string will be stored in a #GQuark. Therefore,
* if you pass a static string, you can save some memory by interning
* it first with g_intern_static_string().
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
*/
void
gtk_menu_set_accel_path (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
const gchar *accel_path)
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
if (accel_path)
g_return_if_fail (accel_path[0] == '<' && strchr (accel_path, '/')); /* simplistic check */
/* FIXME: accel_path should be defined as const gchar* */
2010-12-23 20:50:18 +00:00
priv->accel_path = (gchar*)g_intern_string (accel_path);
if (priv->accel_path)
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
_gtk_menu_refresh_accel_paths (menu, FALSE);
}
/**
* gtk_menu_get_accel_path:
* @menu: a valid #GtkMenu
*
* Retrieves the accelerator path set on the menu.
*
* Returns: the accelerator path set on the menu.
*
* Since: 2.14
*/
const gchar*
gtk_menu_get_accel_path (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
2010-12-23 20:50:18 +00:00
return menu->priv->accel_path;
}
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
typedef struct {
GtkMenu *menu;
gboolean group_changed;
} AccelPropagation;
static void
applied patch from owen to get rid of accel map notifiers. changed things Tue Nov 20 21:25:08 2001 Tim Janik <timj@gtk.org> * applied patch from owen to get rid of accel map notifiers. changed things to fix reentrancy and API as discussed on gtk-devel. * gtk/gtkaccelgroup.[hc]: (gtk_accel_group_finalize): unregister this accel group from all accel map paths. (accel_closure_invalidate): handle invalidation of closures by disconnecting their accelerators. (quick_accel_add): move closure connection and changed notification into this function to reduce code duplication. don't emit change notification on closurers without accelerators. (quick_accel_remove): rewrite, do the exact opposite of quick_accel_add for a GtkAccelGroupEntry. (gtk_accel_group_connect): get rid of the accel_path_quark argument. (gtk_accel_group_connect_by_path): new function to add accelerators with an accel path. (gtk_accel_group_disconnect_closure): new function, disconnect a closure from of an accel group. (gtk_accel_group_disconnect): loop over all closure for a accel_ley, accel_mods pair and remove them. (_gtk_accel_group_reconnect): new function that basically does gtk_accel_group_disconnect_closure() and gtk_accel_group_connect_by_path() once an accel path changed. (gtk_accel_groups_disconnect_closure): remove this, there's gtk_accel_group_disconnect_closure(). * gtk/gtkaccelmap.[hc]: keep list of accel groups per entry now, nuke notifiers. (_gtk_accel_path_is_valid): make this non-static for gtkwidget.c and gtkaccelgroup.c assertions. (gtk_accel_map_add_notifer): removed this function. (gtk_accel_map_remove_notifer): same. (_gtk_accel_map_add_group): (_gtk_accel_map_remove_group): (un-)register accel groups, with accel paths for correct propagation. (gtk_accel_map_add_entry): return void. (gtk_accel_map_lookup): return gboolean instead of GQuark. * gtk/gtkitemfactory.c (gtk_item_factory_add_foreign): always set accel_path on widgets. * gtk/gtkwidget.[hc]: (accel_path_changed): got rid of this, changes are handled by accel maps internally now. (_gtk_widget_set_accel_path): get things to work without notifiers. (gtk_widget_list_accel_closures): list accel closures of a widget. * gtk/gtkwindow.[hc]: rename ::accels_changed, to ::keys_changed.
2001-11-20 23:43:03 +00:00
refresh_accel_paths_foreach (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
gpointer data)
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv;
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
AccelPropagation *prop = data;
2010-12-23 20:50:18 +00:00
if (GTK_IS_MENU_ITEM (widget)) /* should always be true */
{
priv = prop->menu->priv;
_gtk_menu_item_refresh_accel_path (GTK_MENU_ITEM (widget),
priv->accel_path,
priv->accel_group,
prop->group_changed);
}
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
}
applied patch from owen to get rid of accel map notifiers. changed things Tue Nov 20 21:25:08 2001 Tim Janik <timj@gtk.org> * applied patch from owen to get rid of accel map notifiers. changed things to fix reentrancy and API as discussed on gtk-devel. * gtk/gtkaccelgroup.[hc]: (gtk_accel_group_finalize): unregister this accel group from all accel map paths. (accel_closure_invalidate): handle invalidation of closures by disconnecting their accelerators. (quick_accel_add): move closure connection and changed notification into this function to reduce code duplication. don't emit change notification on closurers without accelerators. (quick_accel_remove): rewrite, do the exact opposite of quick_accel_add for a GtkAccelGroupEntry. (gtk_accel_group_connect): get rid of the accel_path_quark argument. (gtk_accel_group_connect_by_path): new function to add accelerators with an accel path. (gtk_accel_group_disconnect_closure): new function, disconnect a closure from of an accel group. (gtk_accel_group_disconnect): loop over all closure for a accel_ley, accel_mods pair and remove them. (_gtk_accel_group_reconnect): new function that basically does gtk_accel_group_disconnect_closure() and gtk_accel_group_connect_by_path() once an accel path changed. (gtk_accel_groups_disconnect_closure): remove this, there's gtk_accel_group_disconnect_closure(). * gtk/gtkaccelmap.[hc]: keep list of accel groups per entry now, nuke notifiers. (_gtk_accel_path_is_valid): make this non-static for gtkwidget.c and gtkaccelgroup.c assertions. (gtk_accel_map_add_notifer): removed this function. (gtk_accel_map_remove_notifer): same. (_gtk_accel_map_add_group): (_gtk_accel_map_remove_group): (un-)register accel groups, with accel paths for correct propagation. (gtk_accel_map_add_entry): return void. (gtk_accel_map_lookup): return gboolean instead of GQuark. * gtk/gtkitemfactory.c (gtk_item_factory_add_foreign): always set accel_path on widgets. * gtk/gtkwidget.[hc]: (accel_path_changed): got rid of this, changes are handled by accel maps internally now. (_gtk_widget_set_accel_path): get things to work without notifiers. (gtk_widget_list_accel_closures): list accel closures of a widget. * gtk/gtkwindow.[hc]: rename ::accels_changed, to ::keys_changed.
2001-11-20 23:43:03 +00:00
static void
_gtk_menu_refresh_accel_paths (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gboolean group_changed)
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
if (priv->accel_path && priv->accel_group)
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
{
AccelPropagation prop;
prop.menu = menu;
prop.group_changed = group_changed;
gtk_container_foreach (GTK_CONTAINER (menu),
2010-12-23 20:50:18 +00:00
refresh_accel_paths_foreach,
&prop);
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
}
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_reposition:
* @menu: a #GtkMenu
*
* Repositions the menu according to its position function.
*/
fixed an assertment. Sat Jun 6 06:01:24 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_emitv): fixed an assertment. * gtk/makeenums.awk: a script to generate the GtkEnumValue arrays from, this should eventually be done by gentypeinfo.el somewhen. * gtk/gtkenumvalues.c: new generated file to hold GtkEnumValue arrays. * gtk/gtktypeutils.h: new function gtk_enum_values() to retrive all the enum values of an enum type. * gtk/gtk.defs: * gtk/gtkcurve.h: * gtk/gtkobject.h: * gtk/gtkprivate.h: * gtk/gtkwidget.h: * gtk/gtkenums.h: brought enum/flags definitions in sync, added a few more enum definitions for bindings and pattern matching. * some more macro and GtkType fixups in various places. * gdk/gdktypes.h (enum): added a new value GDK_AFTER_MASK, which is used as a key-release modifier for the binding system. Fri Jun 5 06:06:06 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenu.h (struct _GtkMenu): removed GList*children, since it was a stale list pointer that is already present in GtkMenuShell. * gtk/gtkmenushell.h (struct _GtkMenuShellClass): added a signal GtkMenuShell::selection_done which is emitted after the menu shell poped down again and all possible menu items have been activated. Thu Jun 4 02:20:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_menu_shell_button_release): flush the x-queue before activation of the menuitem, so the menu is actually taken off the screen prior to any menu item activation. * gtk/gtkctree.c (gtk_ctree_get_row_data): allow function invokation for NULL nodes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: new function gtk_widget_stop_accelerator to stop the emission of the "add-accelerator" signal on a widget. this is usefull to prevent accelerator installation on certain widgets. * gtk/gtknotebook.c (gtk_notebook_menu_item_create): keep the menu labels left justified, by setting their alignment. stop accelerator installation for the menu items, since we use dynamic menus. Wed Jun 3 06:41:22 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenufactory.c: adaptions to use the new accel groups. people should *really* use GtkItemFactory. this is only for preserving source compatibility where possible, use of GtkMenuFactory is deprecated as of now. * gtk/gtkobject.h (gtk_object_class_add_user_signal): new function to create user signals of type GTK_RUN_NO_RECURSE. don't know why i missed this possibility when i added gtk_object_class_add_user_signal in late january. * gtk/gtkmain.c (gtk_init): ignore subsequent function calls. Sun May 31 07:31:09 1998 Tim Janik <timj@gtk.org> * gtk/gtkaccelgroup.h: * gtk/gtkaccelgroup.c: new implementation of the accelerator concept. * gtk/gtkaccellabel.h: * gtk/gtkaccellabel.c: new widget derived from GtkLabel whitch features display of the accelerators associated with a certain widget. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: new widget, item factory with automatic rc parsing and accelerator handling. * gtk/gtkmenu.c (gtk_menu_reposition): new function to care for positioning a menu. (gtk_menu_map): removed the allocation code. (gtk_menu_size_allocate): care for redrawing of children and resize our widget->window correctly. (gtk_menu_key_press): feature the new accelerator groups. * gtk/gtkmenuitem.c (gtk_menu_item_size_allocate): reposition the submenu if neccessary. * gtk/gtkmenuitem.c: * gtk/gtkcheckmenuitem.c: * gtk/gtkradiomenuitem.c: use GtkAccelLabel in the *_new_with_label() function variants. * gdk/gdk.c: (gdk_keyval_from_name): (gdk_keyval_name): new functions for keyval<->key-name associations. (gdk_keyval_to_upper): (gdk_keyval_to_lower): (gdk_keyval_is_upper): (gdk_keyval_is_lower): new functions to check/translate keyvalues with regards to their cases. Wed May 27 00:48:10 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_class_path): new function to calculate a widget's class path. (gtk_widget_path): new function to calculate a widget's name path. * gtk/gtkrc.c: newly introduced GtkPatternSpec structures to speed up pattern matching, features reversed pattern matches.
1998-06-07 06:48:56 +00:00
void
gtk_menu_reposition (GtkMenu *menu)
{
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
if (!menu->priv->torn_off && gtk_widget_is_drawable (GTK_WIDGET (menu)))
gtk_menu_position (menu, FALSE);
fixed an assertment. Sat Jun 6 06:01:24 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_emitv): fixed an assertment. * gtk/makeenums.awk: a script to generate the GtkEnumValue arrays from, this should eventually be done by gentypeinfo.el somewhen. * gtk/gtkenumvalues.c: new generated file to hold GtkEnumValue arrays. * gtk/gtktypeutils.h: new function gtk_enum_values() to retrive all the enum values of an enum type. * gtk/gtk.defs: * gtk/gtkcurve.h: * gtk/gtkobject.h: * gtk/gtkprivate.h: * gtk/gtkwidget.h: * gtk/gtkenums.h: brought enum/flags definitions in sync, added a few more enum definitions for bindings and pattern matching. * some more macro and GtkType fixups in various places. * gdk/gdktypes.h (enum): added a new value GDK_AFTER_MASK, which is used as a key-release modifier for the binding system. Fri Jun 5 06:06:06 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenu.h (struct _GtkMenu): removed GList*children, since it was a stale list pointer that is already present in GtkMenuShell. * gtk/gtkmenushell.h (struct _GtkMenuShellClass): added a signal GtkMenuShell::selection_done which is emitted after the menu shell poped down again and all possible menu items have been activated. Thu Jun 4 02:20:42 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_menu_shell_button_release): flush the x-queue before activation of the menuitem, so the menu is actually taken off the screen prior to any menu item activation. * gtk/gtkctree.c (gtk_ctree_get_row_data): allow function invokation for NULL nodes. * gtk/gtkwidget.h: * gtk/gtkwidget.c: new function gtk_widget_stop_accelerator to stop the emission of the "add-accelerator" signal on a widget. this is usefull to prevent accelerator installation on certain widgets. * gtk/gtknotebook.c (gtk_notebook_menu_item_create): keep the menu labels left justified, by setting their alignment. stop accelerator installation for the menu items, since we use dynamic menus. Wed Jun 3 06:41:22 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenufactory.c: adaptions to use the new accel groups. people should *really* use GtkItemFactory. this is only for preserving source compatibility where possible, use of GtkMenuFactory is deprecated as of now. * gtk/gtkobject.h (gtk_object_class_add_user_signal): new function to create user signals of type GTK_RUN_NO_RECURSE. don't know why i missed this possibility when i added gtk_object_class_add_user_signal in late january. * gtk/gtkmain.c (gtk_init): ignore subsequent function calls. Sun May 31 07:31:09 1998 Tim Janik <timj@gtk.org> * gtk/gtkaccelgroup.h: * gtk/gtkaccelgroup.c: new implementation of the accelerator concept. * gtk/gtkaccellabel.h: * gtk/gtkaccellabel.c: new widget derived from GtkLabel whitch features display of the accelerators associated with a certain widget. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: new widget, item factory with automatic rc parsing and accelerator handling. * gtk/gtkmenu.c (gtk_menu_reposition): new function to care for positioning a menu. (gtk_menu_map): removed the allocation code. (gtk_menu_size_allocate): care for redrawing of children and resize our widget->window correctly. (gtk_menu_key_press): feature the new accelerator groups. * gtk/gtkmenuitem.c (gtk_menu_item_size_allocate): reposition the submenu if neccessary. * gtk/gtkmenuitem.c: * gtk/gtkcheckmenuitem.c: * gtk/gtkradiomenuitem.c: use GtkAccelLabel in the *_new_with_label() function variants. * gdk/gdk.c: (gdk_keyval_from_name): (gdk_keyval_name): new functions for keyval<->key-name associations. (gdk_keyval_to_upper): (gdk_keyval_to_lower): (gdk_keyval_is_upper): (gdk_keyval_is_lower): new functions to check/translate keyvalues with regards to their cases. Wed May 27 00:48:10 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_class_path): new function to calculate a widget's class path. (gtk_widget_path): new function to calculate a widget's name path. * gtk/gtkrc.c: newly introduced GtkPatternSpec structures to speed up pattern matching, features reversed pattern matches.
1998-06-07 06:48:56 +00:00
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_scrollbar_changed (GtkAdjustment *adjustment,
2010-12-23 20:50:18 +00:00
GtkMenu *menu)
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.
2000-11-08 17:34:52 +00:00
{
double value;
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.
2000-11-08 17:34:52 +00:00
value = gtk_adjustment_get_value (adjustment);
if (menu->priv->scroll_offset != value)
gtk_menu_scroll_to (menu, value);
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.
2000-11-08 17:34:52 +00:00
}
static void
gtk_menu_set_tearoff_hints (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint width)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
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.
2000-11-08 17:34:52 +00:00
GdkGeometry geometry_hints;
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_window)
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.
2000-11-08 17:34:52 +00:00
return;
2010-12-23 20:50:18 +00:00
if (gtk_widget_get_visible (priv->tearoff_scrollbar))
{
GtkRequisition requisition;
2010-12-23 20:50:18 +00:00
gtk_widget_get_preferred_size (priv->tearoff_scrollbar,
&requisition, NULL);
width += requisition.width;
}
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.
2000-11-08 17:34:52 +00:00
geometry_hints.min_width = width;
geometry_hints.max_width = width;
2010-12-23 20:50:18 +00:00
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.
2000-11-08 17:34:52 +00:00
geometry_hints.min_height = 0;
geometry_hints.max_height = priv->requested_height;
2010-12-23 20:50:18 +00:00
gtk_window_set_geometry_hints (GTK_WINDOW (priv->tearoff_window),
NULL,
&geometry_hints,
GDK_HINT_MAX_SIZE|GDK_HINT_MIN_SIZE);
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.
2000-11-08 17:34:52 +00:00
}
static void
gtk_menu_update_title (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
if (priv->tearoff_window)
{
const gchar *title;
GtkWidget *attach_widget;
title = gtk_menu_get_title (menu);
if (!title)
2010-12-23 20:50:18 +00:00
{
attach_widget = gtk_menu_get_attach_widget (menu);
if (GTK_IS_MENU_ITEM (attach_widget))
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (attach_widget));
if (GTK_IS_LABEL (child))
title = gtk_label_get_text (GTK_LABEL (child));
}
}
if (title)
2010-12-23 20:50:18 +00:00
gtk_window_set_title (GTK_WINDOW (priv->tearoff_window), title);
}
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
static GtkWidget*
gtk_menu_get_toplevel (GtkWidget *menu)
{
GtkWidget *attach, *toplevel;
attach = gtk_menu_get_attach_widget (GTK_MENU (menu));
if (GTK_IS_MENU_ITEM (attach))
attach = gtk_widget_get_parent (attach);
if (GTK_IS_MENU (attach))
return gtk_menu_get_toplevel (attach);
else if (GTK_IS_WIDGET (attach))
{
toplevel = gtk_widget_get_toplevel (attach);
2010-12-23 20:50:18 +00:00
if (gtk_widget_is_toplevel (toplevel))
return toplevel;
}
return NULL;
}
static void
2004-05-10 04:51:13 +00:00
tearoff_window_destroyed (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GtkMenu *menu)
{
gtk_menu_set_tearoff_state (menu, FALSE);
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_set_tearoff_state:
* @menu: a #GtkMenu
* @torn_off: If %TRUE, menu is displayed as a tearoff menu.
*
* Changes the tearoff state of the menu. A menu is normally
* displayed as drop down menu which persists as long as the menu is
* active. It can also be displayed as a tearoff menu which persists
* until it is closed or reattached.
*/
2010-12-23 20:50:18 +00:00
void
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gtk_menu_set_tearoff_state (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gboolean torn_off)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gint height;
1997-11-24 22:37:52 +00:00
2010-12-23 20:50:18 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
if (priv->torn_off != torn_off)
1997-11-24 22:37:52 +00:00
{
2010-12-23 20:50:18 +00:00
priv->torn_off = torn_off;
priv->tearoff_active = torn_off;
if (priv->torn_off)
{
if (gtk_widget_get_visible (GTK_WIDGET (menu)))
gtk_menu_popdown (menu);
1997-11-24 22:37:52 +00:00
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_window)
{
GtkWidget *toplevel;
2010-12-23 20:50:18 +00:00
priv->tearoff_window = g_object_new (GTK_TYPE_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
"screen", gtk_widget_get_screen (priv->toplevel),
"app-paintable", TRUE,
NULL);
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
2010-12-23 20:50:18 +00:00
gtk_window_set_type_hint (GTK_WINDOW (priv->tearoff_window),
GDK_WINDOW_TYPE_HINT_MENU);
gtk_window_set_mnemonic_modifier (GTK_WINDOW (priv->tearoff_window), 0);
g_signal_connect (priv->tearoff_window, "destroy",
G_CALLBACK (tearoff_window_destroyed), menu);
g_signal_connect (priv->tearoff_window, "event",
G_CALLBACK (gtk_menu_window_event), menu);
2010-12-23 20:50:18 +00:00
gtk_menu_update_title (menu);
2010-12-23 20:50:18 +00:00
gtk_widget_realize (priv->tearoff_window);
2010-12-23 20:50:18 +00:00
toplevel = gtk_menu_get_toplevel (GTK_WIDGET (menu));
if (toplevel != NULL)
gtk_window_set_transient_for (GTK_WINDOW (priv->tearoff_window),
GTK_WINDOW (toplevel));
2010-12-23 20:50:18 +00:00
priv->tearoff_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (priv->tearoff_window),
priv->tearoff_hbox);
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.
2000-11-08 17:34:52 +00:00
height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET (menu)));
2010-12-23 20:50:18 +00:00
priv->tearoff_adjustment = gtk_adjustment_new (0,
0, priv->requested_height,
MENU_SCROLL_STEP2,
height/2,
height);
2010-12-23 20:50:18 +00:00
g_object_connect (priv->tearoff_adjustment,
"signal::value-changed", gtk_menu_scrollbar_changed, menu,
NULL);
priv->tearoff_scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, priv->tearoff_adjustment);
gtk_box_pack_end (GTK_BOX (priv->tearoff_hbox),
priv->tearoff_scrollbar,
FALSE, FALSE, 0);
if (gtk_adjustment_get_upper (priv->tearoff_adjustment) > height)
2010-12-23 20:50:18 +00:00
gtk_widget_show (priv->tearoff_scrollbar);
gtk_widget_show (priv->tearoff_hbox);
}
gtk_menu_reparent (menu, priv->tearoff_hbox, FALSE);
/* Update menu->requisition */
gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, NULL);
gtk_menu_set_tearoff_hints (menu, gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET (menu))));
gtk_widget_realize (priv->tearoff_window);
gtk_menu_position (menu, TRUE);
gtk_widget_show (GTK_WIDGET (menu));
gtk_widget_show (priv->tearoff_window);
gtk_menu_scroll_to (menu, 0);
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
else
2010-12-23 20:50:18 +00:00
{
gtk_widget_hide (GTK_WIDGET (menu));
gtk_widget_hide (priv->tearoff_window);
if (GTK_IS_CONTAINER (priv->toplevel))
gtk_menu_reparent (menu, priv->toplevel, FALSE);
gtk_widget_destroy (priv->tearoff_window);
priv->tearoff_window = NULL;
priv->tearoff_hbox = NULL;
priv->tearoff_scrollbar = NULL;
priv->tearoff_adjustment = NULL;
}
g_object_notify (G_OBJECT (menu), "tearoff-state");
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
1997-11-24 22:37:52 +00:00
}
/**
* gtk_menu_get_tearoff_state:
* @menu: a #GtkMenu
*
2010-12-23 20:50:18 +00:00
* Returns whether the menu is torn off.
* See gtk_menu_set_tearoff_state().
*
* Return value: %TRUE if the menu is currently torn off.
2010-12-23 20:50:18 +00:00
*/
gboolean
gtk_menu_get_tearoff_state (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), FALSE);
2010-12-23 20:50:18 +00:00
return menu->priv->torn_off;
}
/**
* gtk_menu_set_title:
* @menu: a #GtkMenu
2010-12-23 20:50:18 +00:00
* @title: a string containing the title for the menu
*
* Sets the title string for the menu.
*
* The title is displayed when the menu is shown as a tearoff
* menu. If @title is %NULL, the menu will see if it is attached
* to a parent menu item, and if so it will try to use the same
* text as that menu item's label.
*/
void
gtk_menu_set_title (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
const gchar *title)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
char *old_title;
g_return_if_fail (GTK_IS_MENU (menu));
old_title = priv->title;
priv->title = g_strdup (title);
g_free (old_title);
2010-12-23 20:50:18 +00:00
gtk_menu_update_title (menu);
g_object_notify (G_OBJECT (menu), "tearoff-title");
}
/**
* gtk_menu_get_title:
* @menu: a #GtkMenu
*
* Returns the title of the menu. See gtk_menu_set_title().
*
2010-12-23 20:50:18 +00:00
* Return value: the title of the menu, or %NULL if the menu
* has no title set on it. This string is owned by GTK+
* and should not be modified or freed.
**/
2011-06-06 18:13:44 +00:00
const gchar *
gtk_menu_get_title (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
2010-12-23 20:50:18 +00:00
return menu->priv->title;
}
2011-01-15 13:51:11 +00:00
/**
* gtk_menu_reorder_child:
* @menu: a #GtkMenu
* @child: the #GtkMenuItem to move
2011-02-09 04:14:46 +00:00
* @position: the new position to place @child.
* Positions are numbered from 0 to n - 1
*
* Moves @child to a new @position in the list of @menu
* children.
2011-01-15 13:51:11 +00:00
*/
void
gtk_menu_reorder_child (GtkMenu *menu,
GtkWidget *child,
gint position)
{
GtkMenuShell *menu_shell;
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_MENU_ITEM (child));
menu_shell = GTK_MENU_SHELL (menu);
if (g_list_find (menu_shell->priv->children, child))
2010-12-23 20:50:18 +00:00
{
menu_shell->priv->children = g_list_remove (menu_shell->priv->children, child);
menu_shell->priv->children = g_list_insert (menu_shell->priv->children, child, position);
menu_queue_resize (menu);
2010-12-23 20:50:18 +00:00
}
}
static void
gtk_menu_style_updated (GtkWidget *widget)
{
GTK_WIDGET_CLASS (gtk_menu_parent_class)->style_updated (widget);
if (gtk_widget_get_realized (widget))
{
GtkMenu *menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
2010-12-23 20:50:18 +00:00
gtk_style_context_set_background (context, priv->bin_window);
gtk_style_context_set_background (context, priv->view_window);
gtk_style_context_set_background (context, gtk_widget_get_window (widget));
}
}
static void
get_arrows_border (GtkMenu *menu,
GtkBorder *border)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
guint scroll_arrow_height;
GtkArrowPlacement arrow_placement;
gtk_widget_style_get (GTK_WIDGET (menu),
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow_placement", &arrow_placement,
NULL);
switch (arrow_placement)
{
case GTK_ARROWS_BOTH:
2010-12-23 20:50:18 +00:00
border->top = priv->upper_arrow_visible ? scroll_arrow_height : 0;
border->bottom = priv->lower_arrow_visible ? scroll_arrow_height : 0;
break;
case GTK_ARROWS_START:
2010-12-23 20:50:18 +00:00
border->top = (priv->upper_arrow_visible ||
priv->lower_arrow_visible) ? scroll_arrow_height : 0;
border->bottom = 0;
break;
case GTK_ARROWS_END:
border->top = 0;
2010-12-23 20:50:18 +00:00
border->bottom = (priv->upper_arrow_visible ||
priv->lower_arrow_visible) ? scroll_arrow_height : 0;
break;
}
border->left = border->right = 0;
}
static void
get_menu_padding (GtkWidget *widget,
GtkBorder *padding)
{
GtkStyleContext *context;
GtkStateFlags state;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, padding);
}
1997-11-24 22:37:52 +00:00
static void
gtk_menu_realize (GtkWidget *widget)
{
2010-12-23 20:50:18 +00:00
GtkMenu *menu = GTK_MENU (widget);
GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation;
GtkStyleContext *context;
GdkWindow *window;
1997-11-24 22:37:52 +00:00
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
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.
2000-11-08 17:34:52 +00:00
GtkWidget *child;
GList *children;
GtkBorder arrow_border, padding;
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (widget));
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.
2000-11-08 17:34:52 +00:00
gtk_widget_set_realized (widget, TRUE);
gtk_widget_get_allocation (widget, &allocation);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
1997-11-24 22:37:52 +00:00
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.event_mask = gtk_widget_get_events (widget);
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.
2000-11-08 17:34:52 +00:00
attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK |
2010-12-23 20:50:18 +00:00
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK );
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget);
gtk_widget_get_allocation (widget, &allocation);
attributes.x = border_width + padding.left;
attributes.y = border_width + padding.top;
attributes.width = allocation.width -
(2 * border_width) - padding.left - padding.right;
attributes.height = allocation.height -
(2 * border_width) - padding.top - padding.bottom;
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.
2000-11-08 17:34:52 +00:00
get_arrows_border (menu, &arrow_border);
attributes.y += arrow_border.top;
attributes.height -= arrow_border.top;
attributes.height -= arrow_border.bottom;
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.
2000-11-08 17:34:52 +00:00
attributes.width = MAX (1, attributes.width);
attributes.height = MAX (1, attributes.height);
2010-12-23 20:50:18 +00:00
priv->view_window = gdk_window_new (window,
&attributes, attributes_mask);
2010-12-23 20:50:18 +00:00
gdk_window_set_user_data (priv->view_window, menu);
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.
2000-11-08 17:34:52 +00:00
gtk_widget_get_allocation (widget, &allocation);
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.
2000-11-08 17:34:52 +00:00
attributes.x = 0;
attributes.y = 0;
attributes.width = allocation.width + (2 * border_width) +
padding.left + padding.right;
attributes.height = priv->requested_height - (2 * border_width) +
padding.top + padding.bottom;
attributes.width = MAX (1, attributes.width);
attributes.height = MAX (1, attributes.height);
2010-12-23 20:50:18 +00:00
priv->bin_window = gdk_window_new (priv->view_window,
&attributes, attributes_mask);
2010-12-23 20:50:18 +00:00
gdk_window_set_user_data (priv->bin_window, menu);
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.
2000-11-08 17:34:52 +00:00
children = GTK_MENU_SHELL (menu)->priv->children;
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.
2000-11-08 17:34:52 +00:00
while (children)
{
child = children->data;
children = children->next;
2010-12-23 20:50:18 +00:00
gtk_widget_set_parent_window (child, priv->bin_window);
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.
2000-11-08 17:34:52 +00:00
}
2010-12-23 20:50:18 +00:00
gtk_style_context_set_background (context, priv->bin_window);
gtk_style_context_set_background (context, priv->view_window);
gtk_style_context_set_background (context, window);
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.
2000-11-08 17:34:52 +00:00
if (GTK_MENU_SHELL (widget)->priv->active_menu_item)
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
GTK_MENU_SHELL (widget)->priv->active_menu_item);
2010-12-23 20:50:18 +00:00
gdk_window_show (priv->bin_window);
gdk_window_show (priv->view_window);
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.
2000-11-08 17:34:52 +00:00
}
2010-12-23 20:50:18 +00:00
static gboolean
gtk_menu_focus (GtkWidget *widget,
GtkDirectionType direction)
{
2010-12-23 20:50:18 +00:00
/* A menu or its menu items cannot have focus */
return FALSE;
}
2010-12-23 20:50:18 +00:00
/* See notes in gtk_menu_popup() for information
* about the "grab transfer window"
*/
static GdkWindow *
menu_grab_transfer_window_get (GtkMenu *menu)
{
GdkWindow *window = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-window");
if (!window)
{
GdkWindowAttr attributes;
gint attributes_mask;
2010-12-23 20:50:18 +00:00
attributes.x = -100;
attributes.y = -100;
attributes.width = 10;
attributes.height = 10;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_ONLY;
attributes.override_redirect = TRUE;
attributes.event_mask = 0;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
2010-12-23 20:50:18 +00:00
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
window = gdk_window_new (gtk_widget_get_root_window (GTK_WIDGET (menu)),
2010-12-23 20:50:18 +00:00
&attributes, attributes_mask);
gdk_window_set_user_data (window, menu);
gdk_window_show (window);
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-transfer-window"), window);
}
return window;
}
static void
menu_grab_transfer_window_destroy (GtkMenu *menu)
{
GdkWindow *window = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-window");
if (window)
{
gdk_window_set_user_data (window, NULL);
gdk_window_destroy (window);
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-transfer-window"), NULL);
}
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_unrealize (GtkWidget *widget)
{
GtkMenu *menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
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.
2000-11-08 17:34:52 +00:00
menu_grab_transfer_window_destroy (menu);
2010-12-23 20:50:18 +00:00
gdk_window_set_user_data (priv->view_window, NULL);
gdk_window_destroy (priv->view_window);
priv->view_window = NULL;
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
gdk_window_set_user_data (priv->bin_window, NULL);
gdk_window_destroy (priv->bin_window);
priv->bin_window = NULL;
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.
2000-11-08 17:34:52 +00:00
GTK_WIDGET_CLASS (gtk_menu_parent_class)->unrealize (widget);
1997-11-24 22:37:52 +00:00
}
static gint
calculate_line_heights (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint for_width,
guint **ret_min_heights,
guint **ret_nat_heights)
1997-11-24 22:37:52 +00:00
{
GtkBorder padding;
GtkMenuPrivate *priv;
2010-12-23 20:50:18 +00:00
GtkMenuShell *menu_shell;
GtkWidget *child, *widget;
GList *children;
guint border_width;
guint n_columns;
gint n_heights;
guint *min_heights;
guint *nat_heights;
gint avail_width;
2010-12-23 20:50:18 +00:00
priv = menu->priv;
widget = GTK_WIDGET (menu);
menu_shell = GTK_MENU_SHELL (widget);
2010-12-23 20:50:18 +00:00
min_heights = g_new0 (guint, gtk_menu_get_n_rows (menu));
nat_heights = g_new0 (guint, gtk_menu_get_n_rows (menu));
n_heights = gtk_menu_get_n_rows (menu);
n_columns = gtk_menu_get_n_columns (menu);
2010-12-23 20:50:18 +00:00
avail_width = for_width - (2 * priv->toggle_size + priv->accel_size) * n_columns;
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
avail_width -= (border_width) * 2 + padding.left + padding.right;
for (children = menu_shell->priv->children; children; children = children->next)
1997-11-24 22:37:52 +00:00
{
gint part;
gint toggle_size;
gint l, r, t, b;
gint child_min, child_nat;
1997-11-24 22:37:52 +00:00
child = children->data;
2010-12-23 20:50:18 +00:00
if (!gtk_widget_get_visible (child))
continue;
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.
2000-11-08 17:34:52 +00:00
get_effective_child_attach (child, &l, &r, &t, &b);
part = avail_width / (r - l);
gtk_widget_get_preferred_height_for_width (child, part,
&child_min, &child_nat);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
2010-12-23 20:50:18 +00:00
part = MAX (child_min, toggle_size) / (b - t);
min_heights[t] = MAX (min_heights[t], part);
part = MAX (child_nat, toggle_size) / (b - t);
nat_heights[t] = MAX (nat_heights[t], part);
}
if (ret_min_heights)
*ret_min_heights = min_heights;
else
g_free (min_heights);
if (ret_nat_heights)
*ret_nat_heights = nat_heights;
else
g_free (nat_heights);
2010-12-23 20:50:18 +00:00
return n_heights;
1997-11-24 22:37:52 +00:00
}
static void
gtk_menu_size_allocate (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GtkAllocation *allocation)
1997-11-24 22:37:52 +00:00
{
GtkMenu *menu;
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv;
1997-11-24 22:37:52 +00:00
GtkMenuShell *menu_shell;
GtkWidget *child;
GtkAllocation child_allocation;
GList *children;
gint x, y, i;
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.
2000-11-08 17:34:52 +00:00
gint width, height;
guint border_width;
GtkBorder padding;
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (widget));
g_return_if_fail (allocation != NULL);
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
menu = GTK_MENU (widget);
menu_shell = GTK_MENU_SHELL (widget);
2010-12-23 20:50:18 +00:00
priv = menu->priv;
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.
2000-11-08 17:34:52 +00:00
gtk_widget_set_allocation (widget, allocation);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
g_free (priv->heights);
2010-12-23 20:50:18 +00:00
priv->heights_length = calculate_line_heights (menu,
allocation->width,
&priv->heights,
NULL);
/* refresh our cached height request */
priv->requested_height = (2 * border_width) + padding.top + padding.bottom;
for (i = 0; i < priv->heights_length; i++)
priv->requested_height += priv->heights[i];
x = border_width + padding.left;
y = border_width + padding.top;
width = allocation->width - (2 * border_width) -
padding.left - padding.right;
height = allocation->height - (2 * border_width) -
padding.top - padding.bottom;
if (menu_shell->priv->active)
2010-12-23 20:50:18 +00:00
gtk_menu_scroll_to (menu, priv->scroll_offset);
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
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.
2000-11-08 17:34:52 +00:00
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
y += arrow_border.top;
height -= arrow_border.top;
height -= arrow_border.bottom;
}
width = MAX (1, width);
height = MAX (1, height);
if (gtk_widget_get_realized (widget))
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.
2000-11-08 17:34:52 +00:00
{
gdk_window_move_resize (gtk_widget_get_window (widget),
2010-12-23 20:50:18 +00:00
allocation->x, allocation->y,
allocation->width, allocation->height);
gdk_window_move_resize (priv->view_window, x, y, width, height);
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.
2000-11-08 17:34:52 +00:00
}
1997-11-24 22:37:52 +00:00
if (menu_shell->priv->children)
1997-11-24 22:37:52 +00:00
{
gint base_width = width / gtk_menu_get_n_columns (menu);
children = menu_shell->priv->children;
1997-11-24 22:37:52 +00:00
while (children)
2010-12-23 20:50:18 +00:00
{
child = children->data;
children = children->next;
2010-12-23 20:50:18 +00:00
if (gtk_widget_get_visible (child))
{
gint i;
2010-12-23 20:50:18 +00:00
gint l, r, t, b;
2010-12-23 20:50:18 +00:00
get_effective_child_attach (child, &l, &r, &t, &b);
if (gtk_widget_get_direction (GTK_WIDGET (menu)) == GTK_TEXT_DIR_RTL)
{
guint tmp;
2010-12-23 20:50:18 +00:00
tmp = gtk_menu_get_n_columns (menu) - l;
l = gtk_menu_get_n_columns (menu) - r;
r = tmp;
}
child_allocation.width = (r - l) * base_width;
child_allocation.height = 0;
child_allocation.x = l * base_width;
child_allocation.y = 0;
for (i = 0; i < b; i++)
{
if (i < t)
child_allocation.y += priv->heights[i];
else
child_allocation.height += priv->heights[i];
}
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
priv->toggle_size);
gtk_widget_size_allocate (child, &child_allocation);
gtk_widget_queue_draw (child);
}
}
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.
2000-11-08 17:34:52 +00:00
/* Resize the item window */
if (gtk_widget_get_realized (widget))
2010-12-23 20:50:18 +00:00
{
gint i;
gint width, height;
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.
2000-11-08 17:34:52 +00:00
height = 0;
2010-12-23 20:50:18 +00:00
for (i = 0; i < gtk_menu_get_n_rows (menu); i++)
height += priv->heights[i];
2010-12-23 20:50:18 +00:00
width = gtk_menu_get_n_columns (menu) * base_width;
gdk_window_resize (priv->bin_window, width, height);
}
if (priv->tearoff_active)
{
if (height >= priv->requested_height)
{
if (gtk_widget_get_visible (priv->tearoff_scrollbar))
{
gtk_widget_hide (priv->tearoff_scrollbar);
gtk_menu_set_tearoff_hints (menu, allocation->width);
gtk_menu_scroll_to (menu, 0);
}
}
else
{
gtk_adjustment_configure (priv->tearoff_adjustment,
gtk_adjustment_get_value (priv->tearoff_adjustment),
0,
priv->requested_height,
gtk_adjustment_get_step_increment (priv->tearoff_adjustment),
gtk_adjustment_get_page_increment (priv->tearoff_adjustment),
allocation->height);
2010-12-23 20:50:18 +00:00
if (!gtk_widget_get_visible (priv->tearoff_scrollbar))
{
gtk_widget_show (priv->tearoff_scrollbar);
gtk_menu_set_tearoff_hints (menu, allocation->width);
}
}
}
1997-11-24 22:37:52 +00:00
}
}
static void
get_arrows_visible_area (GtkMenu *menu,
GdkRectangle *border,
GdkRectangle *upper,
GdkRectangle *lower,
gint *arrow_space)
{
GtkArrowPlacement arrow_placement;
GtkWidget *widget = GTK_WIDGET (menu);
guint border_width;
gint scroll_arrow_height;
GtkBorder menu_padding;
gtk_widget_style_get (widget,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
get_menu_padding (widget, &menu_padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
border->x = border_width + menu_padding.left;
border->y = border_width + menu_padding.top;
border->width = gdk_window_get_width (gtk_widget_get_window (widget));
border->height = gdk_window_get_height (gtk_widget_get_window (widget));
switch (arrow_placement)
{
case GTK_ARROWS_BOTH:
upper->x = border->x;
upper->y = border->y;
upper->width = border->width - 2 * border->x;
upper->height = scroll_arrow_height;
lower->x = border->x;
lower->y = border->height - border->y - scroll_arrow_height;
lower->width = border->width - 2 * border->x;
lower->height = scroll_arrow_height;
break;
case GTK_ARROWS_START:
upper->x = border->x;
upper->y = border->y;
upper->width = (border->width - 2 * border->x) / 2;
upper->height = scroll_arrow_height;
lower->x = border->x + upper->width;
lower->y = border->y;
lower->width = (border->width - 2 * border->x) / 2;
lower->height = scroll_arrow_height;
break;
case GTK_ARROWS_END:
upper->x = border->x;
upper->y = border->height - border->y - scroll_arrow_height;
upper->width = (border->width - 2 * border->x) / 2;
upper->height = scroll_arrow_height;
lower->x = border->x + upper->width;
lower->y = border->height - border->y - scroll_arrow_height;
lower->width = (border->width - 2 * border->x) / 2;
lower->height = scroll_arrow_height;
break;
default:
g_assert_not_reached();
upper->x = upper->y = upper->width = upper->height = 0;
lower->x = lower->y = lower->width = lower->height = 0;
}
*arrow_space = scroll_arrow_height - menu_padding.top - menu_padding.bottom;
}
2010-09-06 15:32:30 +00:00
static gboolean
gtk_menu_draw (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
cairo_t *cr)
1997-11-24 22:37:52 +00:00
{
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.
2000-11-08 17:34:52 +00:00
GtkMenu *menu;
GtkMenuPrivate *priv;
GtkStyleContext *context;
GdkRectangle border;
GdkRectangle upper;
GdkRectangle lower;
gint arrow_space;
GtkBorder menu_padding;
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.
2000-11-08 17:34:52 +00:00
menu = GTK_MENU (widget);
priv = menu->priv;
context = gtk_widget_get_style_context (widget);
get_arrows_visible_area (menu, &border, &upper, &lower, &arrow_space);
get_menu_padding (widget, &menu_padding);
2010-09-06 15:32:30 +00:00
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
1997-11-24 22:37:52 +00:00
{
gfloat arrow_scaling;
gint arrow_size;
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
arrow_size = arrow_scaling * arrow_space;
gtk_render_background (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
gtk_render_frame (context, cr, 0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
2010-12-23 20:50:18 +00:00
if (priv->upper_arrow_visible && !priv->tearoff_active)
{
gtk_style_context_save (context);
gtk_style_context_set_state (context, priv->upper_arrow_state);
gtk_render_background (context, cr,
upper.x, upper.y,
upper.width, upper.height);
gtk_render_frame (context, cr,
upper.x, upper.y,
upper.width, upper.height);
gtk_render_arrow (context, cr, 0,
upper.x + (upper.width - arrow_size) / 2,
upper.y + menu_padding.top + (arrow_space - arrow_size) / 2,
arrow_size);
gtk_style_context_restore (context);
2010-12-23 20:50:18 +00:00
}
2010-12-23 20:50:18 +00:00
if (priv->lower_arrow_visible && !priv->tearoff_active)
{
gtk_style_context_save (context);
gtk_style_context_set_state (context, priv->lower_arrow_state);
gtk_render_background (context, cr,
lower.x, lower.y,
lower.width, lower.height);
gtk_render_frame (context, cr,
lower.x, lower.y,
lower.width, lower.height);
gtk_render_arrow (context, cr, G_PI,
lower.x + (lower.width - arrow_size) / 2,
lower.y + menu_padding.bottom + (arrow_space - arrow_size) / 2,
arrow_size);
gtk_style_context_restore (context);
2010-12-23 20:50:18 +00:00
}
gtk_style_context_restore (context);
}
2010-12-23 20:50:18 +00:00
if (gtk_cairo_should_draw_window (cr, priv->bin_window))
{
2010-12-23 20:50:18 +00:00
gint y = -border.y + priv->scroll_offset;
2010-09-06 15:32:30 +00:00
cairo_save (cr);
2010-12-23 20:50:18 +00:00
gtk_cairo_transform_to_window (cr, widget, priv->bin_window);
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
y -= arrow_border.top;
}
gtk_render_background (context, cr,
- border.x, y,
border.width, border.height);
gtk_render_frame (context, cr,
- border.x, y,
border.width, border.height);
1997-11-24 22:37:52 +00:00
2010-09-06 15:32:30 +00:00
cairo_restore (cr);
}
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
2010-09-06 15:32:30 +00:00
GTK_WIDGET_CLASS (gtk_menu_parent_class)->draw (widget, cr);
1997-11-24 22:37:52 +00:00
return FALSE;
}
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
static void
gtk_menu_show (GtkWidget *widget)
{
GtkMenu *menu = GTK_MENU (widget);
_gtk_menu_refresh_accel_paths (menu, FALSE);
2006-05-02 23:56:43 +00:00
GTK_WIDGET_CLASS (gtk_menu_parent_class)->show (widget);
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
}
static void
gtk_menu_get_preferred_width (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
GtkMenu *menu;
GtkMenuShell *menu_shell;
GtkMenuPrivate *priv;
GtkWidget *child;
GList *children;
guint max_toggle_size;
guint max_accel_width;
guint border_width;
gint child_min, child_nat;
gint min_width, nat_width;
GtkBorder padding;
menu = GTK_MENU (widget);
menu_shell = GTK_MENU_SHELL (widget);
2010-12-23 20:50:18 +00:00
priv = menu->priv;
min_width = nat_width = 0;
2010-12-23 20:50:18 +00:00
max_toggle_size = 0;
max_accel_width = 0;
2010-12-23 20:50:18 +00:00
children = menu_shell->priv->children;
while (children)
{
gint part;
gint toggle_size;
gint l, r, t, b;
child = children->data;
children = children->next;
2010-12-23 20:50:18 +00:00
if (! gtk_widget_get_visible (child))
continue;
get_effective_child_attach (child, &l, &r, &t, &b);
/* It's important to size_request the child
* before doing the toggle size request, in
* case the toggle size request depends on the size
* request of a child of the child (e.g. for ImageMenuItem)
*/
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
max_toggle_size = MAX (max_toggle_size, toggle_size);
max_accel_width = MAX (max_accel_width,
GTK_MENU_ITEM (child)->priv->accelerator_width);
part = child_min / (r - l);
min_width = MAX (min_width, part);
part = child_nat / (r - l);
nat_width = MAX (nat_width, part);
}
/* If the menu doesn't include any images or check items
* reserve the space so that all menus are consistent.
* We only do this for 'ordinary' menus, not for combobox
* menus or multi-column menus
*/
2010-12-23 20:50:18 +00:00
if (max_toggle_size == 0 &&
gtk_menu_get_n_columns (menu) == 1 &&
!priv->no_toggle_size)
{
GtkStyleContext *context;
GtkWidgetPath *check_path;
guint toggle_spacing;
guint indicator_size;
context = gtk_style_context_new ();
/* Create a GtkCheckMenuItem path, only to query indicator spacing */
check_path = _gtk_widget_create_path (widget);
gtk_widget_path_append_type (check_path, GTK_TYPE_CHECK_MENU_ITEM);
gtk_style_context_set_path (context, check_path);
gtk_widget_path_free (check_path);
gtk_style_context_set_screen (context, gtk_widget_get_screen (widget));
gtk_style_context_get_style (context,
"toggle-spacing", &toggle_spacing,
"indicator-size", &indicator_size,
NULL);
max_toggle_size = indicator_size + toggle_spacing;
g_object_unref (context);
}
min_width += 2 * max_toggle_size + max_accel_width;
min_width *= gtk_menu_get_n_columns (menu);
nat_width += 2 * max_toggle_size + max_accel_width;
nat_width *= gtk_menu_get_n_columns (menu);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
min_width += (2 * border_width) + padding.left + padding.right;
nat_width += (2 * border_width) + padding.left + padding.right;
2010-12-23 20:50:18 +00:00
priv->toggle_size = max_toggle_size;
priv->accel_size = max_accel_width;
if (minimum_size)
*minimum_size = min_width;
if (natural_size)
*natural_size = nat_width;
2010-12-23 20:50:18 +00:00
/* Don't resize the tearoff if it is not active,
* because it won't redraw (it is only a background pixmap).
*/
2010-12-23 20:50:18 +00:00
if (priv->tearoff_active)
gtk_menu_set_tearoff_hints (menu, min_width);
}
2010-12-23 20:50:18 +00:00
static void
gtk_menu_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
gint min_width;
2010-12-23 20:50:18 +00:00
/* Menus are height-for-width only, just return the height
* for the minimum width
*/
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, minimum_size, natural_size);
}
static void
gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
gint for_size,
gint *minimum_size,
gint *natural_size)
{
GtkBorder padding;
GtkMenu *menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
guint *min_heights, *nat_heights;
guint border_width;
gint n_heights, i;
gint min_height, nat_height;
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
min_height = nat_height = (2 * border_width) + padding.top + padding.bottom;
2010-12-23 20:50:18 +00:00
n_heights =
calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
for (i = 0; i < n_heights; i++)
{
min_height += min_heights[i];
nat_height += nat_heights[i];
}
2010-12-23 20:50:18 +00:00
if (priv->have_position)
{
2010-12-23 20:50:18 +00:00
GdkScreen *screen = gtk_widget_get_screen (priv->toplevel);
GdkRectangle monitor;
gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
2010-12-23 20:50:18 +00:00
if (priv->position_y + min_height > monitor.y + monitor.height)
min_height = monitor.y + monitor.height - priv->position_y;
2010-12-23 20:50:18 +00:00
if (priv->position_y + nat_height > monitor.y + monitor.height)
nat_height = monitor.y + monitor.height - priv->position_y;
2010-12-23 20:50:18 +00:00
if (priv->position_y < monitor.y)
{
min_height -= monitor.y - priv->position_y;
nat_height -= monitor.y - priv->position_y;
}
}
if (minimum_size)
*minimum_size = min_height;
if (natural_size)
*natural_size = nat_height;
g_free (min_heights);
g_free (nat_heights);
}
static gboolean
pointer_in_menu_window (GtkWidget *widget,
gdouble x_root,
gdouble y_root)
{
GtkMenu *menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation;
2010-12-23 20:50:18 +00:00
if (gtk_widget_get_mapped (priv->toplevel))
{
GtkMenuShell *menu_shell;
gint window_x, window_y;
2010-12-23 20:50:18 +00:00
gdk_window_get_position (gtk_widget_get_window (priv->toplevel),
&window_x, &window_y);
gtk_widget_get_allocation (widget, &allocation);
if (x_root >= window_x && x_root < window_x + allocation.width &&
y_root >= window_y && y_root < window_y + allocation.height)
return TRUE;
menu_shell = GTK_MENU_SHELL (widget);
if (GTK_IS_MENU (menu_shell->priv->parent_menu_shell))
return pointer_in_menu_window (menu_shell->priv->parent_menu_shell,
x_root, y_root);
}
return FALSE;
}
static gboolean
gtk_menu_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GdkDevice *source_device;
GtkWidget *event_widget;
GtkMenu *menu;
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
source_device = gdk_event_get_source_device ((GdkEvent *) event);
event_widget = gtk_get_event_widget ((GdkEvent *) event);
menu = GTK_MENU (widget);
/* Don't pass down to menu shell if a non-menuitem part of the menu
* was clicked. The check for the event_widget being a GtkMenuShell
* works because we have the pointer grabbed on menu_shell->window
* with owner_events=TRUE, so all events that are either outside
* the menu or on its border are delivered relative to
* menu_shell->window.
*/
if (GTK_IS_MENU_SHELL (event_widget) &&
pointer_in_menu_window (widget, event->x_root, event->y_root))
return TRUE;
if (GTK_IS_MENU_ITEM (event_widget) &&
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN &&
GTK_MENU_ITEM (event_widget)->priv->submenu != NULL &&
!gtk_widget_is_drawable (GTK_MENU_ITEM (event_widget)->priv->submenu))
menu->priv->ignore_button_release = TRUE;
2006-05-02 23:56:43 +00:00
return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_press_event (widget, event);
}
static gboolean
gtk_menu_button_release (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventButton *event)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = GTK_MENU (widget)->priv;
if (priv->ignore_button_release)
{
priv->ignore_button_release = FALSE;
return FALSE;
}
if (event->type != GDK_BUTTON_RELEASE)
return FALSE;
/* Don't pass down to menu shell if a non-menuitem part of the menu
* was clicked (see comment in button_press()).
*/
if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) &&
pointer_in_menu_window (widget, event->x_root, event->y_root))
{
/* Ugly: make sure menu_shell->button gets reset to 0 when we
* bail out early here so it is in a consistent state for the
* next button_press/button_release in GtkMenuShell.
* See bug #449371.
*/
if (GTK_MENU_SHELL (widget)->priv->active)
GTK_MENU_SHELL (widget)->priv->button = 0;
return TRUE;
}
2006-05-02 23:56:43 +00:00
return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_release_event (widget, event);
}
static const gchar *
get_accel_path (GtkWidget *menu_item,
2010-12-23 20:50:18 +00:00
gboolean *locked)
{
const gchar *path;
GtkWidget *label;
GClosure *accel_closure;
2010-12-23 20:50:18 +00:00
GtkAccelGroup *accel_group;
path = _gtk_widget_get_accel_path (menu_item, locked);
if (!path)
{
path = GTK_MENU_ITEM (menu_item)->priv->accel_path;
2010-12-23 20:50:18 +00:00
if (locked)
2010-12-23 20:50:18 +00:00
{
*locked = TRUE;
label = gtk_bin_get_child (GTK_BIN (menu_item));
if (GTK_IS_ACCEL_LABEL (label))
{
g_object_get (label,
"accel-closure", &accel_closure,
NULL);
if (accel_closure)
{
accel_group = gtk_accel_group_from_accel_closure (accel_closure);
*locked = gtk_accel_group_get_is_locked (accel_group);
}
}
}
}
return path;
}
static gboolean
2010-12-23 20:50:18 +00:00
gtk_menu_key_press (GtkWidget *widget,
GdkEventKey *event)
1997-11-24 22:37:52 +00:00
{
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
GtkMenuShell *menu_shell;
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
GtkMenu *menu;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gboolean delete = FALSE;
gboolean can_change_accels;
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
gchar *accel = NULL;
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
guint accel_key, accel_mods;
GdkModifierType consumed_modifiers;
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
GdkDisplay *display;
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
2010-12-23 20:50:18 +00:00
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
menu_shell = GTK_MENU_SHELL (widget);
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
gtk_menu_stop_navigating_submenu (menu);
2006-05-02 23:56:43 +00:00
if (GTK_WIDGET_CLASS (gtk_menu_parent_class)->key_press_event (widget, event))
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
return TRUE;
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
display = gtk_widget_get_display (widget);
2010-12-23 20:50:18 +00:00
g_object_get (gtk_widget_get_settings (widget),
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
"gtk-menu-bar-accel", &accel,
2010-12-23 20:50:18 +00:00
"gtk-can-change-accels", &can_change_accels,
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
NULL);
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
if (accel && *accel)
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
{
guint keyval = 0;
GdkModifierType mods = 0;
2010-12-23 20:50:18 +00:00
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
gtk_accelerator_parse (accel, &keyval, &mods);
if (keyval == 0)
g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
/* FIXME this is wrong, needs to be in the global accel resolution
* thing, to properly consider i18n etc., but that probably requires
* AccelGroup changes etc.
*/
if (event->keyval == keyval && (mods & event->state) == mods)
{
2010-12-23 20:50:18 +00:00
gtk_menu_shell_cancel (menu_shell);
g_free (accel);
return TRUE;
}
fix warning 2001-04-27 Havoc Pennington <hp@redhat.com> * gtk/gtkcombo.c (gtk_combo_popup_button_press): fix warning * gtk/gtkmessagedialog.c (gtk_message_dialog_init): make messages selectable * gtk/gtkentry.c (gtk_entry_real_insert_text): don't strip line/para separators (gtk_entry_create_layout): set single paragraph mode on the layout * gtk/gtkbutton.c (gtk_button_new_from_stock): don't put much spacing between the image and label; instead, inside a button box the button will get extra space that will go there, but if people configure button box for 0 chubbiness, then there's no spacing. * gtk/gtkbbox.c (gtk_button_box_class_init): Make child ipadding and min/max size style properties, so people can tune their chubbiness. * tests/testgtk.c (make_toolbar): remove calls to removed toolbar functions * gtk/gtktoolbar.c (gtk_toolbar_class_init): Make space_size, space_style, and button_relief into style properties, remove functions for setting them * gtk/gtkmenu.c (gtk_menu_key_press): handle menu bar accel to pop it back down * gtk/gtkoptionmenu.c (gtk_option_menu_get_props): free boxed types from gtk_widget_style_get * gtk/gtkmenubar.c (gtk_menu_bar_set_shadow_type): Remove, replace with a style property. * gdk/x11/gdkevents-x11.c: namespace the settings * gtk/gtkmenubar.c: Add F10 accelerator to move between menubars. * gtk/gtksettings.c (gtk_settings_class_init): remove code with side effects from inside g_assert(), so that G_DISABLE_ASSERT can be used. Also, translate doc strings for settings. Also, namespace the double-click-time property. Also, remove bell properties crap.
2001-04-28 00:12:47 +00:00
}
g_free (accel);
2010-12-23 20:50:18 +00:00
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
switch (event->keyval)
{
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
delete = TRUE;
break;
default:
break;
1997-11-24 22:37:52 +00:00
}
/* Figure out what modifiers went into determining the key symbol */
_gtk_translate_keyboard_accel_state (gdk_keymap_get_for_display (display),
2010-12-23 20:50:18 +00:00
event->hardware_keycode,
event->state,
gtk_accelerator_get_default_mod_mask (),
event->group,
&accel_key, NULL, NULL, &consumed_modifiers);
accel_key = gdk_keyval_to_lower (accel_key);
accel_mods = event->state & gtk_accelerator_get_default_mod_mask () & ~consumed_modifiers;
2010-12-23 20:50:18 +00:00
/* If lowercasing affects the keysym, then we need to include SHIFT
* in the modifiers, We re-upper case when we match against the
* keyval, but display and save in caseless form.
*/
if (accel_key != event->keyval)
accel_mods |= GDK_SHIFT_MASK;
2010-12-23 20:50:18 +00:00
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
/* Modify the accelerators */
if (can_change_accels &&
menu_shell->priv->active_menu_item &&
gtk_bin_get_child (GTK_BIN (menu_shell->priv->active_menu_item)) && /* no separators */
GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->priv->submenu == NULL && /* no submenus */
(delete || gtk_accelerator_valid (accel_key, accel_mods)))
1997-11-24 22:37:52 +00:00
{
GtkWidget *menu_item = menu_shell->priv->active_menu_item;
gboolean locked, replace_accels = TRUE;
added gtkaccelmap.sgml. other updates. Mon Nov 12 23:06:38 2001 Tim Janik <timj@gtk.org> * added gtkaccelmap.sgml. other updates. Mon Nov 12 23:08:37 2001 Tim Janik <timj@gtk.org> * gtk/maketypes.awk: fix type utils generation on unix. * gtk/gtkaccelmap.[hc]: new files, implementing a global accelerator registry. * gtk/gtkaccelgroup.[hc]: major API/implementation revamp: removed GTK_ACCEL_SIGNAL_VISIBLE, gtk_accel_group_get_default, gtk_accel_group_get_entry, gtk_accel_group_(un)lock_entry, gtk_accel_group_add/remove, gtk_accel_group_handle_add/remove, gtk_accel_group_create_add/remove, gtk_accel_group_entries_from_object. introduced ::accel_changed signal for change notification, and gtk_accel_group_connect/disconnect to connect closures to accel groups. made gtk_accel_group_attach/detach and gtk_accel_group_activate private functions. deprecated gtk_accel_group_ref/unref. * gtk/gtkaccellabel.[hc]: changes to make accellabels pay attention to accel group changed notification and basically operate on closures. removed gtk_accel_label_get_accel_object and gtk_accel_label_set_accel_object. introduced gtk_accel_label_set_accel_closure, and for convenience, gtk_accel_label_set_accel_widget. * gtk/gtkitemfactory.[hc]: removed accelerator propagation code which mostly moved into gtkaccelmap.[hc]. removed gtk_item_factory_parse_rc*, gtk_item_factory_dump_* and gtk_item_factory_print_func. * gtk/gtkmain.c: call _gtk_accel_map_init(). * gtk/gtkmenuitem.[hc]: introduced gtk_menu_item_set_accel_path(), that associates an accelerator path with menu items, through which persistent accelerator settings on menu items are enabled. * gtk/gtkmenu.[hc]: added gtk_menu_set_accel_path() so accelerator paths of menu item can be default constructed to allow installation of accelerators on menu items that don't come with an accelerator binding by default. * gtk/gtksettings.c: fix STRING type rc settings by special casing them appropriately in the parser. * gtk/gtksignal.[hc]: allow a class function offset of 0 for gtk_signal_newv(). * gtk/gtkwidget.[hc]: accelerator API revamp. removed ::accelerator_add/remove signals, gtk_widget_accelerator_signal, gtk_widget_accelerators_locked, gtk_widget_remove_accelerators and gtk_widget_(un)lock_accelerators. accelerators maintained through gtk_widget_add/remove_accelerator() are not runtime changable now, the correct sequence to setup a widget for runtime changable accelerators is now: gtk_accel_map_add_entry(accel_path, key, mods); _gtk_widget_set_accel_path(widget, accel_path, accel_group); * gtk/gtkwindow.[hc]: accelerator changes, proxy and coalesce accel group changes (as well as mnemonic changes) through the new signal ::accels_changed. Sat Nov 10 12:08:56 2001 Tim Janik <timj@gtk.org> * gtk/gtksettings.c (_gtk_settings_parse_convert): properly handle GString->string conversions.
2001-11-13 00:53:47 +00:00
const gchar *path;
path = get_accel_path (menu_item, &locked);
if (!path || locked)
2010-12-23 20:50:18 +00:00
{
/* Can't change accelerators on menu_items without paths
* (basically, those items are accelerator-locked).
*/
gtk_widget_error_bell (widget);
}
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
else
2010-12-23 20:50:18 +00:00
{
gboolean changed;
/* For the keys that act to delete the current setting,
* we delete the current setting if there is one, otherwise,
* we set the key as the accelerator.
*/
if (delete)
{
GtkAccelKey key;
if (gtk_accel_map_lookup_entry (path, &key) &&
(key.accel_key || key.accel_mods))
{
accel_key = 0;
accel_mods = 0;
}
}
changed = gtk_accel_map_change_entry (path, accel_key, accel_mods, replace_accels);
if (!changed)
{
/* We failed, probably because this key is in use
* and locked already.
*/
gtk_widget_error_bell (widget);
}
}
1997-11-24 22:37:52 +00:00
}
2010-12-23 20:50:18 +00:00
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
return TRUE;
1997-11-24 22:37:52 +00:00
}
static gboolean
check_threshold (GtkWidget *widget,
gint start_x,
gint start_y,
gint x,
gint y)
{
#define THRESHOLD 8
2010-12-23 20:50:18 +00:00
return
2010-12-23 20:50:18 +00:00
ABS (start_x - x) > THRESHOLD ||
ABS (start_y - y) > THRESHOLD;
}
static gboolean
definitely_within_item (GtkWidget *widget,
gint x,
gint y)
{
GdkWindow *window = GTK_MENU_ITEM (widget)->priv->event_window;
int w, h;
w = gdk_window_get_width (window);
h = gdk_window_get_height (window);
2010-12-23 20:50:18 +00:00
return
check_threshold (widget, 0, 0, x, y) &&
check_threshold (widget, w - 1, 0, x, y) &&
check_threshold (widget, w - 1, h - 1, x, y) &&
check_threshold (widget, 0, h - 1, x, y);
}
static gboolean
gtk_menu_has_navigation_triangle (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
return priv->navigation_height && priv->navigation_width;
}
static gboolean
gtk_menu_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
1997-11-24 22:37:52 +00:00
{
GtkWidget *menu_item;
GtkMenu *menu;
GtkMenuShell *menu_shell;
GtkWidget *parent;
GdkDevice *source_device;
gboolean need_enter;
source_device = gdk_event_get_source_device ((GdkEvent *) event);
if (GTK_IS_MENU (widget) &&
gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = GTK_MENU(widget)->priv;
if (priv->ignore_button_release)
priv->ignore_button_release = FALSE;
gtk_menu_handle_scrolling (GTK_MENU (widget), event->x_root, event->y_root,
TRUE, TRUE);
}
/* We received the event for one of two reasons:
*
* a) We are the active menu, and did gtk_grab_add()
* b) The widget is a child of ours, and the event was propagated
*
* Since for computation of navigation regions, we want the menu which
* is the parent of the menu item, for a), we need to find that menu,
* which may be different from 'widget'.
*/
menu_item = gtk_get_event_widget ((GdkEvent*) event);
parent = gtk_widget_get_parent (menu_item);
if (!GTK_IS_MENU_ITEM (menu_item) ||
!GTK_IS_MENU (parent))
return FALSE;
menu_shell = GTK_MENU_SHELL (parent);
menu = GTK_MENU (menu_shell);
if (definitely_within_item (menu_item, event->x, event->y))
menu_shell->priv->activate_time = 0;
need_enter = (gtk_menu_has_navigation_triangle (menu) || menu_shell->priv->ignore_enter);
/* Check to see if we are within an active submenu's navigation region
*/
if (gtk_menu_navigating_submenu (menu, event->x_root, event->y_root))
2010-12-23 20:50:18 +00:00
return TRUE;
/* Make sure we pop down if we enter a non-selectable menu item, so we
* don't show a submenu when the cursor is outside the stay-up triangle.
*/
if (!_gtk_menu_item_is_selectable (menu_item))
{
/* We really want to deselect, but this gives the menushell code
* a chance to do some bookkeeping about the menuitem.
*/
gtk_menu_shell_select_item (menu_shell, menu_item);
return FALSE;
}
if (need_enter)
1997-11-24 22:37:52 +00:00
{
/* The menu is now sensitive to enter events on its items, but
* was previously sensitive. So we fake an enter event.
*/
menu_shell->priv->ignore_enter = FALSE;
2010-12-23 20:50:18 +00:00
if (event->x >= 0 && event->x < gdk_window_get_width (event->window) &&
2010-12-23 20:50:18 +00:00
event->y >= 0 && event->y < gdk_window_get_height (event->window))
{
GdkEvent *send_event = gdk_event_new (GDK_ENTER_NOTIFY);
gboolean result;
send_event->crossing.window = g_object_ref (event->window);
send_event->crossing.time = event->time;
send_event->crossing.send_event = TRUE;
send_event->crossing.x_root = event->x_root;
send_event->crossing.y_root = event->y_root;
send_event->crossing.x = event->x;
send_event->crossing.y = event->y;
send_event->crossing.state = event->state;
2010-05-25 22:38:44 +00:00
gdk_event_set_device (send_event, gdk_event_get_device ((GdkEvent *) event));
2010-12-23 20:50:18 +00:00
/* We send the event to 'widget', the currently active menu,
* instead of 'menu', the menu that the pointer is in. This
* will ensure that the event will be ignored unless the
* menuitem is a child of the active menu or some parent
* menu of the active menu.
*/
result = gtk_widget_event (widget, send_event);
gdk_event_free (send_event);
return result;
}
1997-11-24 22:37:52 +00:00
}
Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> Wed Mar 17 01:46:28 1999 Tim Janik <timj@gtk.org> * merges from gtk-1-2: Tue Mar 16 17:43:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_parse_rc_string): ensure the item factory class has been created. (gtk_item_factory_parse_rc): likewise. * gtk/gtkmenu.c: keep proper references for old_active_menu_item. (gtk_menu_reparent): unset the usize of the new parent, so the menu can sanely be size requested and we don't get nasty screen artefacts upon next reparentation. (gtk_menu_motion_notify): set send_event to TRUE if we synthesize an enter notify. only synthesize enter notifies if the pointer really is inside the event window. (gtk_menu_popdown): use gtk_menu_shell_deselect(). (gtk_menu_popup): move the background setting stuff into gtk_menu_tearoff_bg_copy() so it can be called from other places as well. * gtk/gtkmenushell.c (gtk_menu_shell_button_press): use gtk_menu_shell_select_item() to select the new item. (gtk_menu_shell_deselect): export this function, so gtkmenu.c can do the right thing for deselection as well. Sat Mar 15 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.[hc]: (gtk_widget_accelerators_locked): return whether a widget's accelerators are locked. * gtk/gtkmenu.c (gtk_menu_key_press): don't remove or install new or existing accelerators if the widget's accelerators are locked. Sat Mar 14 19:44:05 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.[hc]: allow managing of foreign menu items. * gtk/gtkmenu.c: truely forward key press and key release events to the menu widget from the toplevel or tearoff window. we can't simply connect to that, we need to stop further processing of the events as well. Sat Mar 13 13:14:17 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: (gtk_menu_key_press): pass event->keyval, event->state to gtk_accelerator_valid, instead of event->keyval twice. refuse to install single letter accelerators for menus that use single letter shortcuts. * gtk/gtkitemfactory.c (gtk_item_factory_create_item): use gtk_menu_ensure_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_ensure_uline_accel_group() which will always return an uline accel group, made gtk_menu_get_uline_accel_group() return NULL if the group isn't yet created. Mon Mar 15 01:03:27 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h (struct _GtkCListColumn): added button_passive flag. * gtk/gtkclist.c (gtk_clist_column_title_passive): Leave button sensitive, trap button_press, button_release, motion_notify, enter_notify and leave_notify events instead. (gtk_clist_column_title_active): disconnect event handler. (gtk_clist_drag_data_get): fixed memory leak. Reported by Guillaume Laurent <glaurent@worldnet.fr> Wed Mar 10 23:49:55 1999 Lars Hamann <lars@gtk.org> * gtk/gtklayout.c (gtk_layout_adjustment_changed): fixed a few width/height mixups. * gtk/gtkctree.c (tree_delete): emit an tree_unselect_row signal if needed. Wed Mar 10 00:11:32 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c (create_item_factory): unref the item factory after window's destruction. * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): keep a reference count on the menu shell around the menu item's activation, since the signal emission may cause menu shell destruction. * gtk/gtkitemfactory.c: the previous code leaked one accel group per menu. we use gtk_menu_get_uline_accel_group() now to fix that, and with that also create the underline accelerator group of the menus only if required (i.e. an underline accelerator has been specified). (gtk_item_factory_construct): (gtk_item_factory_create_item): removed code that would create an extra accel group for the menu (and leak references). (gtk_item_factory_create_item): adapted the underline accelerator installation code to properly feature gtk_menu_get_uline_accel_group(). * gtk/gtkmenu.[hc]: added gtk_menu_get_accel_group() to retrive menu->accel_group, this may return NULL if the accelerator group hasn't been set yet. added gtk_menu_get_uline_accel_group() to retrive the underline accelerator group of the menu, this will be created on demand and proper care is taken about its reference count. * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: dumped the approach of keeping a widgets by action list on the factory since the factory<->widget destroy negotiation didn't work and would be hard to get going at all. instead we keep a list of GtkItemFactoryItem items on the factory (GtkItemFactoryItems are persistant throughout a program's life time). also, i removed the static const gchar *key_* variables, and made them inline strings (they weren't actually used anyways). (gtk_item_factory_add_item): update ifactory->items. (gtk_item_factory_destroy): destroy ifactory->items (and remove the item factory pointer from the remaining ifactory widgets). (gtk_item_factory_get_widget_by_action): walk the GtkItemFactoryItem list to find the widget. (gtk_item_factory_get_item): new function that works around gtk_item_factory_get_widget() limitations, this function will only return menu items, even for <Branch> entries. Tue Mar 9 01:01:28 1999 Tim Janik <timj@gtk.org> * gdk/gdkfont.c (gdk_font_load): first lookup the xfont ID in our font hash table, if we have a GdkFontPrivate entry for this font already, simply increment its reference count, provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. * gtk/gtkstyle.c (gtk_style_copy): plug a GdkFont reference leak, fix provided by Olaf Dietsche <olaf.dietsche+list.gtk@netcologne.de>. Sun Mar 7 06:13:29 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: (gtk_container_add_with_args): (gtk_container_addv): (gtk_container_add): before adding a child to a conatiner, make sure it is (default) constructed, this is neccessary because under certain circumstances the child will get relized and mapped immediatedly, in which case it has to be constructed already. Mon Mar 1 17:58:21 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_signal_connect_by_type): count object_signal values > 1 as TRUE also.
1999-03-17 01:39:42 +00:00
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
return FALSE;
1997-11-24 22:37:52 +00:00
}
static gboolean
get_double_arrows (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gboolean double_arrows;
GtkArrowPlacement arrow_placement;
gtk_widget_style_get (GTK_WIDGET (menu),
"double-arrows", &double_arrows,
"arrow-placement", &arrow_placement,
NULL);
if (arrow_placement != GTK_ARROWS_BOTH)
return TRUE;
return double_arrows || (priv->initially_pushed_in &&
2010-12-23 20:50:18 +00:00
priv->scroll_offset != 0);
}
static void
2010-12-23 20:50:18 +00:00
gtk_menu_scroll_by (GtkMenu *menu,
gint step)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkBorder arrow_border;
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.
2000-11-08 17:34:52 +00:00
GtkWidget *widget;
gint offset;
gint view_height;
gboolean double_arrows;
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.
2000-11-08 17:34:52 +00:00
widget = GTK_WIDGET (menu);
2010-12-23 20:50:18 +00:00
offset = priv->scroll_offset + step;
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.
2000-11-08 17:34:52 +00:00
get_arrows_border (menu, &arrow_border);
double_arrows = get_double_arrows (menu);
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.
2000-11-08 17:34:52 +00:00
/* If we scroll upward and the non-visible top part
* is smaller than the scroll arrow it would be
* pretty stupid to show the arrow and taking more
* screen space than just scrolling to the top.
*/
if (!double_arrows)
if ((step < 0) && (offset < arrow_border.top))
offset = 0;
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.
2000-11-08 17:34:52 +00:00
/* Don't scroll over the top if we weren't before: */
2010-12-23 20:50:18 +00:00
if ((priv->scroll_offset >= 0) && (offset < 0))
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.
2000-11-08 17:34:52 +00:00
offset = 0;
view_height = gdk_window_get_height (gtk_widget_get_window (widget));
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
if (priv->scroll_offset == 0 &&
view_height >= priv->requested_height)
return;
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.
2000-11-08 17:34:52 +00:00
/* Don't scroll past the bottom if we weren't before: */
2010-12-23 20:50:18 +00:00
if (priv->scroll_offset > 0)
view_height -= arrow_border.top;
2010-12-23 20:50:18 +00:00
/* When both arrows are always shown,
* reduce view height even more.
*/
if (double_arrows)
view_height -= arrow_border.bottom;
2010-12-23 20:50:18 +00:00
if ((priv->scroll_offset + view_height <= priv->requested_height) &&
(offset + view_height > priv->requested_height))
offset = priv->requested_height - view_height;
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
if (offset != priv->scroll_offset)
gtk_menu_scroll_to (menu, offset);
}
static gboolean
gtk_menu_scroll_timeout (gpointer data)
{
GtkMenu *menu;
menu = GTK_MENU (data);
gtk_menu_scroll_by (menu, menu->priv->scroll_step);
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.
2000-11-08 17:34:52 +00:00
return TRUE;
}
static gboolean
2010-12-23 20:50:18 +00:00
gtk_menu_scroll (GtkWidget *widget,
GdkEventScroll *event)
{
GtkMenu *menu = GTK_MENU (widget);
switch (event->direction)
{
case GDK_SCROLL_RIGHT:
case GDK_SCROLL_DOWN:
gtk_menu_scroll_by (menu, MENU_SCROLL_STEP2);
break;
case GDK_SCROLL_LEFT:
case GDK_SCROLL_UP:
gtk_menu_scroll_by (menu, - MENU_SCROLL_STEP2);
break;
case GDK_SCROLL_SMOOTH:
gtk_menu_scroll_by (menu, event->delta_y);
break;
}
return TRUE;
}
static void
get_arrows_sensitive_area (GtkMenu *menu,
GdkRectangle *upper,
GdkRectangle *lower)
{
GtkArrowPlacement arrow_placement;
GtkWidget *widget = GTK_WIDGET (menu);
GdkWindow *window;
gint width, height;
guint border;
gint win_x, win_y;
gint scroll_arrow_height;
GtkBorder padding;
window = gtk_widget_get_window (widget);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
gtk_widget_style_get (widget,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
border = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
gdk_window_get_position (window, &win_x, &win_y);
switch (arrow_placement)
{
case GTK_ARROWS_BOTH:
if (upper)
{
upper->x = win_x;
upper->y = win_y;
upper->width = width;
upper->height = scroll_arrow_height + border + padding.top;
}
if (lower)
{
lower->x = win_x;
lower->y = win_y + height - border - padding.bottom - scroll_arrow_height;
lower->width = width;
lower->height = scroll_arrow_height + border + padding.bottom;
}
break;
case GTK_ARROWS_START:
if (upper)
{
upper->x = win_x;
upper->y = win_y;
upper->width = width / 2;
upper->height = scroll_arrow_height + border + padding.top;
}
if (lower)
{
lower->x = win_x + width / 2;
lower->y = win_y;
lower->width = width / 2;
lower->height = scroll_arrow_height + border + padding.bottom;
}
break;
case GTK_ARROWS_END:
if (upper)
{
upper->x = win_x;
upper->y = win_y + height - border - scroll_arrow_height;
upper->width = width / 2;
upper->height = scroll_arrow_height + border + padding.top;
}
if (lower)
{
lower->x = win_x + width / 2;
lower->y = win_y + height - border - scroll_arrow_height;
lower->width = width / 2;
lower->height = scroll_arrow_height + border + padding.bottom;
}
break;
}
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_handle_scrolling (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint x,
gint y,
gboolean enter,
gboolean motion)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
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.
2000-11-08 17:34:52 +00:00
GtkMenuShell *menu_shell;
GdkRectangle rect;
gboolean in_arrow;
gboolean scroll_fast = FALSE;
gint top_x, top_y;
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.
2000-11-08 17:34:52 +00:00
menu_shell = GTK_MENU_SHELL (menu);
2010-12-23 20:50:18 +00:00
gdk_window_get_position (gtk_widget_get_window (priv->toplevel),
&top_x, &top_y);
x -= top_x;
y -= top_y;
/* upper arrow handling */
get_arrows_sensitive_area (menu, &rect, NULL);
in_arrow = FALSE;
2010-12-23 20:50:18 +00:00
if (priv->upper_arrow_visible && !priv->tearoff_active &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
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.
2000-11-08 17:34:52 +00:00
{
in_arrow = TRUE;
}
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.
2000-11-08 17:34:52 +00:00
if ((priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
gboolean arrow_pressed = FALSE;
2010-12-23 20:50:18 +00:00
if (priv->upper_arrow_visible && !priv->tearoff_active)
{
scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);
if (enter && in_arrow &&
(!priv->upper_arrow_prelight ||
priv->scroll_fast != scroll_fast))
{
priv->upper_arrow_prelight = TRUE;
priv->scroll_fast = scroll_fast;
/* Deselect the active item so that
* any submenus are popped down
*/
gtk_menu_shell_deselect (menu_shell);
gtk_menu_remove_scroll_timeout (menu);
priv->scroll_step = scroll_fast
? -MENU_SCROLL_STEP2
: -MENU_SCROLL_STEP1;
priv->scroll_timeout =
gdk_threads_add_timeout (scroll_fast
? MENU_SCROLL_TIMEOUT2
: MENU_SCROLL_TIMEOUT1,
gtk_menu_scroll_timeout, menu);
}
else if (!enter && !in_arrow && priv->upper_arrow_prelight)
{
gtk_menu_stop_scrolling (menu);
}
}
/* check if the button isn't insensitive before
* changing it to something else.
*/
if ((priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
GtkStateFlags arrow_state = 0;
if (arrow_pressed)
arrow_state |= GTK_STATE_FLAG_ACTIVE;
2010-12-23 20:50:18 +00:00
if (priv->upper_arrow_prelight)
arrow_state |= GTK_STATE_FLAG_PRELIGHT;
if (arrow_state != priv->upper_arrow_state)
{
priv->upper_arrow_state = arrow_state;
gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (menu)),
&rect, FALSE);
}
}
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.
2000-11-08 17:34:52 +00:00
}
/* lower arrow handling */
get_arrows_sensitive_area (menu, NULL, &rect);
in_arrow = FALSE;
2010-12-23 20:50:18 +00:00
if (priv->lower_arrow_visible && !priv->tearoff_active &&
(x >= rect.x) && (x < rect.x + rect.width) &&
(y >= rect.y) && (y < rect.y + rect.height))
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.
2000-11-08 17:34:52 +00:00
{
in_arrow = TRUE;
}
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.
2000-11-08 17:34:52 +00:00
if ((priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
gboolean arrow_pressed = FALSE;
2010-12-23 20:50:18 +00:00
if (priv->lower_arrow_visible && !priv->tearoff_active)
{
scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);
if (enter && in_arrow &&
(!priv->lower_arrow_prelight ||
priv->scroll_fast != scroll_fast))
{
priv->lower_arrow_prelight = TRUE;
priv->scroll_fast = scroll_fast;
/* Deselect the active item so that
* any submenus are popped down
*/
gtk_menu_shell_deselect (menu_shell);
gtk_menu_remove_scroll_timeout (menu);
priv->scroll_step = scroll_fast
? MENU_SCROLL_STEP2
: MENU_SCROLL_STEP1;
priv->scroll_timeout =
gdk_threads_add_timeout (scroll_fast
? MENU_SCROLL_TIMEOUT2
: MENU_SCROLL_TIMEOUT1,
gtk_menu_scroll_timeout, menu);
}
else if (!enter && !in_arrow && priv->lower_arrow_prelight)
{
gtk_menu_stop_scrolling (menu);
}
}
/* check if the button isn't insensitive before
* changing it to something else.
*/
if ((priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
{
GtkStateFlags arrow_state = 0;
if (arrow_pressed)
arrow_state |= GTK_STATE_FLAG_ACTIVE;
2010-12-23 20:50:18 +00:00
if (priv->lower_arrow_prelight)
arrow_state |= GTK_STATE_FLAG_PRELIGHT;
if (arrow_state != priv->lower_arrow_state)
{
priv->lower_arrow_state = arrow_state;
gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (menu)),
&rect, FALSE);
}
}
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.
2000-11-08 17:34:52 +00:00
}
}
static gboolean
gtk_menu_enter_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventCrossing *event)
{
GtkWidget *menu_item;
GtkWidget *parent;
GdkDevice *source_device;
if (event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_GTK_UNGRAB ||
event->mode == GDK_CROSSING_STATE_CHANGED)
return TRUE;
source_device = gdk_event_get_source_device ((GdkEvent *) event);
menu_item = gtk_get_event_widget ((GdkEvent*) event);
if (GTK_IS_MENU (widget) &&
gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget);
if (!menu_shell->priv->ignore_enter)
2010-12-23 20:50:18 +00:00
gtk_menu_handle_scrolling (GTK_MENU (widget),
event->x_root, event->y_root, TRUE, TRUE);
}
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN &&
GTK_IS_MENU_ITEM (menu_item))
{
GtkWidget *menu = gtk_widget_get_parent (menu_item);
2010-12-23 20:50:18 +00:00
if (GTK_IS_MENU (menu))
2010-12-23 20:50:18 +00:00
{
GtkMenuPrivate *priv = (GTK_MENU (menu))->priv;
2010-12-23 20:50:18 +00:00
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
if (priv->seen_item_enter)
{
/* This is the second enter we see for an item
* on this menu. This means a release should always
* mean activate.
*/
menu_shell->priv->activate_time = 0;
2010-12-23 20:50:18 +00:00
}
else if ((event->detail != GDK_NOTIFY_NONLINEAR &&
event->detail != GDK_NOTIFY_NONLINEAR_VIRTUAL))
{
if (definitely_within_item (menu_item, event->x, event->y))
{
/* This is an actual user-enter (ie. not a pop-under)
* In this case, the user must either have entered
* sufficiently far enough into the item, or he must move
* far enough away from the enter point. (see
* gtk_menu_motion_notify())
*/
menu_shell->priv->activate_time = 0;
2010-12-23 20:50:18 +00:00
}
}
priv->seen_item_enter = TRUE;
}
}
2010-12-23 20:50:18 +00:00
/* If this is a faked enter (see gtk_menu_motion_notify), 'widget'
* will not correspond to the event widget's parent. Check to see
* if we are in the parent's navigation region.
*/
parent = gtk_widget_get_parent (menu_item);
if (GTK_IS_MENU_ITEM (menu_item) && GTK_IS_MENU (parent) &&
gtk_menu_navigating_submenu (GTK_MENU (parent),
event->x_root, event->y_root))
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.
2000-11-08 17:34:52 +00:00
return TRUE;
2010-12-23 20:50:18 +00:00
return GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (widget, event);
}
static gboolean
gtk_menu_leave_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
GdkEventCrossing *event)
{
GtkMenuShell *menu_shell;
GtkMenu *menu;
GtkMenuItem *menu_item;
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.
2000-11-08 17:34:52 +00:00
GtkWidget *event_widget;
GdkDevice *source_device;
if (event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_GTK_UNGRAB ||
event->mode == GDK_CROSSING_STATE_CHANGED)
return TRUE;
menu = GTK_MENU (widget);
2010-12-23 20:50:18 +00:00
menu_shell = GTK_MENU_SHELL (widget);
if (gtk_menu_navigating_submenu (menu, event->x_root, event->y_root))
2010-12-23 20:50:18 +00:00
return TRUE;
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.
2000-11-08 17:34:52 +00:00
source_device = gdk_event_get_source_device ((GdkEvent *) event);
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
gtk_menu_handle_scrolling (menu, event->x_root, event->y_root, FALSE, TRUE);
event_widget = gtk_get_event_widget ((GdkEvent*) event);
2010-12-23 20:50:18 +00:00
if (!GTK_IS_MENU_ITEM (event_widget))
return TRUE;
2010-12-23 20:50:18 +00:00
menu_item = GTK_MENU_ITEM (event_widget);
/* Here we check to see if we're leaving an active menu item
* with a submenu, in which case we enter submenu navigation mode.
*/
if (menu_shell->priv->active_menu_item != NULL
&& menu_item->priv->submenu != NULL
&& menu_item->priv->submenu_placement == GTK_LEFT_RIGHT)
{
if (GTK_MENU_SHELL (menu_item->priv->submenu)->priv->active)
2010-12-23 20:50:18 +00:00
{
gtk_menu_set_submenu_navigation_region (menu, menu_item, event);
return TRUE;
}
else if (menu_item == GTK_MENU_ITEM (menu_shell->priv->active_menu_item))
2010-12-23 20:50:18 +00:00
{
/* We are leaving an active menu item with nonactive submenu.
* Deselect it so we don't surprise the user with by popping
* up a submenu _after_ he left the item.
*/
gtk_menu_shell_deselect (menu_shell);
return TRUE;
}
}
2010-12-23 20:50:18 +00:00
return GTK_WIDGET_CLASS (gtk_menu_parent_class)->leave_notify_event (widget, event);
}
static gboolean
pointer_on_menu_widget (GtkMenu *menu,
gdouble x_root,
gdouble y_root)
{
GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation;
gint window_x, window_y;
gtk_widget_get_allocation (GTK_WIDGET (menu), &allocation);
gdk_window_get_position (gtk_widget_get_window (priv->toplevel),
&window_x, &window_y);
if (x_root >= window_x && x_root < window_x + allocation.width &&
y_root >= window_y && y_root < window_y + allocation.height)
return TRUE;
return FALSE;
}
static gboolean
gtk_menu_captured_event (GtkWidget *widget,
GdkEvent *event)
{
GdkDevice *source_device;
gboolean retval = FALSE;
GtkMenuPrivate *priv;
GtkMenu *menu;
gdouble x_root, y_root;
guint button;
GdkModifierType state;
menu = GTK_MENU (widget);
priv = menu->priv;
if (!priv->upper_arrow_visible && !priv->lower_arrow_visible && priv->drag_start_y < 0)
return retval;
source_device = gdk_event_get_source_device (event);
gdk_event_get_root_coords (event, &x_root, &y_root);
switch (event->type)
{
case GDK_TOUCH_BEGIN:
case GDK_BUTTON_PRESS:
if ((!gdk_event_get_button (event, &button) || button == 1) &&
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN &&
pointer_on_menu_widget (menu, x_root, y_root))
{
priv->drag_start_y = event->button.y_root;
priv->initial_drag_offset = priv->scroll_offset;
priv->drag_scroll_started = FALSE;
}
else
priv->drag_start_y = -1;
priv->drag_already_pressed = TRUE;
break;
case GDK_TOUCH_END:
case GDK_BUTTON_RELEASE:
if (priv->drag_scroll_started)
{
priv->drag_scroll_started = FALSE;
priv->drag_start_y = -1;
priv->drag_already_pressed = FALSE;
retval = TRUE;
}
break;
case GDK_TOUCH_UPDATE:
case GDK_MOTION_NOTIFY:
if ((!gdk_event_get_state (event, &state) || (state & GDK_BUTTON1_MASK) != 0) &&
gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN)
{
if (!priv->drag_already_pressed)
{
if (pointer_on_menu_widget (menu, x_root, y_root))
{
priv->drag_start_y = y_root;
priv->initial_drag_offset = priv->scroll_offset;
priv->drag_scroll_started = FALSE;
}
else
priv->drag_start_y = -1;
priv->drag_already_pressed = TRUE;
}
if (priv->drag_start_y < 0 && !priv->drag_scroll_started)
break;
if (priv->drag_scroll_started)
{
gint offset, view_height;
GtkBorder arrow_border;
gdouble y_diff;
y_diff = y_root - priv->drag_start_y;
offset = priv->initial_drag_offset - y_diff;
view_height = gdk_window_get_height (gtk_widget_get_window (widget));
get_arrows_border (menu, &arrow_border);
if (priv->upper_arrow_visible)
view_height -= arrow_border.top;
if (priv->lower_arrow_visible)
view_height -= arrow_border.bottom;
offset = CLAMP (offset,
MIN (priv->scroll_offset, 0),
MAX (priv->scroll_offset, priv->requested_height - view_height));
gtk_menu_scroll_to (menu, offset);
retval = TRUE;
}
else if (gtk_drag_check_threshold (widget,
0, priv->drag_start_y,
0, y_root))
{
priv->drag_scroll_started = TRUE;
gtk_menu_shell_deselect (GTK_MENU_SHELL (menu));
retval = TRUE;
}
}
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
if (priv->drag_scroll_started)
retval = TRUE;
break;
default:
break;
}
return retval;
}
2010-12-23 20:50:18 +00:00
static void
gtk_menu_stop_navigating_submenu (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
priv->navigation_x = 0;
priv->navigation_y = 0;
priv->navigation_width = 0;
priv->navigation_height = 0;
2010-12-23 20:50:18 +00:00
if (priv->navigation_timeout)
{
2010-12-23 20:50:18 +00:00
g_source_remove (priv->navigation_timeout);
priv->navigation_timeout = 0;
}
}
/* When the timeout is elapsed, the navigation region is destroyed
* and the menuitem under the pointer (if any) is selected.
*/
static gboolean
gtk_menu_stop_navigating_submenu_cb (gpointer user_data)
{
2010-05-25 22:38:44 +00:00
GtkMenuPopdownData *popdown_data = user_data;
GtkMenu *menu = popdown_data->menu;
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GdkWindow *child_window;
gtk_menu_stop_navigating_submenu (menu);
2010-12-23 20:50:18 +00:00
if (gtk_widget_get_realized (GTK_WIDGET (menu)))
{
2010-12-23 20:50:18 +00:00
child_window = gdk_window_get_device_position (priv->bin_window,
2010-05-25 22:38:44 +00:00
popdown_data->device,
NULL, NULL, NULL);
if (child_window)
2010-12-23 20:50:18 +00:00
{
GdkEvent *send_event = gdk_event_new (GDK_ENTER_NOTIFY);
2010-12-23 20:50:18 +00:00
send_event->crossing.window = g_object_ref (child_window);
send_event->crossing.time = GDK_CURRENT_TIME; /* Bogus */
send_event->crossing.send_event = TRUE;
2010-05-25 22:38:44 +00:00
gdk_event_set_device (send_event, popdown_data->device);
2010-12-23 20:50:18 +00:00
GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event);
2010-12-23 20:50:18 +00:00
gdk_event_free (send_event);
}
}
2010-12-23 20:50:18 +00:00
return FALSE;
}
static gboolean
gtk_menu_navigating_submenu (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint event_x,
gint event_y)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gint width, height;
if (!gtk_menu_has_navigation_triangle (menu))
return FALSE;
width = priv->navigation_width;
height = priv->navigation_height;
2010-12-23 20:50:18 +00:00
/* Check if x/y are in the triangle spanned by the navigation parameters */
/* 1) Move the coordinates so the triangle starts at 0,0 */
event_x -= priv->navigation_x;
event_y -= priv->navigation_y;
/* 2) Ensure both legs move along the positive axis */
if (width < 0)
{
event_x = -event_x;
width = -width;
}
if (height < 0)
{
event_y = -event_y;
height = -height;
}
/* 3) Check that the given coordinate is inside the triangle. The formula
* is a transformed form of this formula: x/w + y/h <= 1
*/
if (event_x >= 0 && event_y >= 0 &&
event_x * height + event_y * width <= width * height)
{
return TRUE;
}
else
{
gtk_menu_stop_navigating_submenu (menu);
return FALSE;
}
}
static void
gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GtkMenuItem *menu_item,
GdkEventCrossing *event)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gint submenu_left = 0;
gint submenu_right = 0;
gint submenu_top = 0;
gint submenu_bottom = 0;
gint width = 0;
GtkWidget *event_widget;
2010-05-25 22:38:44 +00:00
GtkMenuPopdownData *popdown_data;
GdkWindow *window;
g_return_if_fail (menu_item->priv->submenu != NULL);
g_return_if_fail (event != NULL);
event_widget = gtk_get_event_widget ((GdkEvent*) event);
window = gtk_widget_get_window (menu_item->priv->submenu);
gdk_window_get_origin (window, &submenu_left, &submenu_top);
submenu_right = submenu_left + gdk_window_get_width (window);
submenu_bottom = submenu_top + gdk_window_get_height (window);
width = gdk_window_get_width (gtk_widget_get_window (event_widget));
if (event->x >= 0 && event->x < width)
{
gint popdown_delay;
2010-12-23 20:50:18 +00:00
gtk_menu_stop_navigating_submenu (menu);
/* The navigation region is the triangle closest to the x/y
* location of the rectangle. This is why the width or height
* can be negative.
*/
if (menu_item->priv->submenu_direction == GTK_DIRECTION_RIGHT)
2010-12-23 20:50:18 +00:00
{
/* right */
priv->navigation_x = submenu_left;
priv->navigation_width = event->x_root - submenu_left;
2010-12-23 20:50:18 +00:00
}
else
2010-12-23 20:50:18 +00:00
{
/* left */
priv->navigation_x = submenu_right;
priv->navigation_width = event->x_root - submenu_right;
2010-12-23 20:50:18 +00:00
}
if (event->y < 0)
2010-12-23 20:50:18 +00:00
{
/* top */
priv->navigation_y = event->y_root;
priv->navigation_height = submenu_top - event->y_root - NAVIGATION_REGION_OVERSHOOT;
2010-12-23 20:50:18 +00:00
if (priv->navigation_height >= 0)
return;
}
else
2010-12-23 20:50:18 +00:00
{
/* bottom */
priv->navigation_y = event->y_root;
priv->navigation_height = submenu_bottom - event->y_root + NAVIGATION_REGION_OVERSHOOT;
2010-12-23 20:50:18 +00:00
if (priv->navigation_height <= 0)
return;
}
g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu)),
2010-12-23 20:50:18 +00:00
"gtk-menu-popdown-delay", &popdown_delay,
NULL);
2010-05-25 22:38:44 +00:00
popdown_data = g_new (GtkMenuPopdownData, 1);
popdown_data->menu = menu;
popdown_data->device = gdk_event_get_device ((GdkEvent *) event);
2010-12-23 20:50:18 +00:00
priv->navigation_timeout = gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT,
2010-05-25 22:38:44 +00:00
popdown_delay,
gtk_menu_stop_navigating_submenu_cb,
popdown_data,
(GDestroyNotify) g_free);
}
}
1997-11-24 22:37:52 +00:00
static void
gtk_menu_deactivate (GtkMenuShell *menu_shell)
{
GtkWidget *parent;
2010-12-23 20:50:18 +00:00
1997-11-24 22:37:52 +00:00
g_return_if_fail (GTK_IS_MENU (menu_shell));
2010-12-23 20:50:18 +00:00
parent = menu_shell->priv->parent_menu_shell;
2010-12-23 20:50:18 +00:00
menu_shell->priv->activate_time = 0;
1997-11-24 22:37:52 +00:00
gtk_menu_popdown (GTK_MENU (menu_shell));
2010-12-23 20:50:18 +00:00
if (parent)
gtk_menu_shell_deactivate (GTK_MENU_SHELL (parent));
1997-11-24 22:37:52 +00:00
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
static void
gtk_menu_position (GtkMenu *menu,
gboolean set_scroll_offset)
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
GtkWidget *widget;
GtkRequisition requisition;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
gint x, y;
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.
2000-11-08 17:34:52 +00:00
gint scroll_offset;
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
GdkScreen *screen;
GdkScreen *pointer_screen;
GdkRectangle monitor;
2010-05-25 22:38:44 +00:00
GdkDevice *pointer;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
widget = GTK_WIDGET (menu);
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
screen = gtk_widget_get_screen (widget);
pointer = _gtk_menu_shell_get_grab_device (GTK_MENU_SHELL (menu));
gdk_device_get_position (pointer, &pointer_screen, &x, &y);
2010-05-25 22:38:44 +00:00
/* Realize so we have the proper width and heigh to figure out
2010-12-23 20:50:18 +00:00
* the right place to popup the menu.
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
*/
gtk_widget_realize (priv->toplevel);
requisition.width = gtk_widget_get_allocated_width (widget);
requisition.height = gtk_widget_get_allocated_height (widget);
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.
2000-11-08 17:34:52 +00:00
if (pointer_screen != screen)
{
/* Pointer is on a different screen; roughly center the
* menu on the screen. If someone was using multiscreen
* + Xinerama together they'd probably want something
* fancier; but that is likely to be vanishingly rare.
*/
x = MAX (0, (gdk_screen_get_width (screen) - requisition.width) / 2);
y = MAX (0, (gdk_screen_get_height (screen) - requisition.height) / 2);
}
2010-12-23 20:50:18 +00:00
priv->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
priv->initially_pushed_in = FALSE;
2010-12-23 20:50:18 +00:00
/* Set the type hint here to allow custom position functions
* to set a different hint
*/
if (!gtk_widget_get_visible (priv->toplevel))
gtk_window_set_type_hint (GTK_WINDOW (priv->toplevel), GDK_WINDOW_TYPE_HINT_POPUP_MENU);
Create 'composited' label. Tue Apr 25 10:25:28 2006 Søren Sandmann <sandmann@redhat.com> * tests/testgtk.c (create_alpha_window): Create 'composited' label. * tests/testgtk.c (on_composited_changed): New function, change the label to say whether the screen is composited or not. * gtk/gtkwindow.c (gtk_window_on_composited_changed): When composited status change, invalidate the window and propagate the signal;. * gtk/gtkwindow.c (gtk_window_map): Set the appropriate type hint if reset_type_hint is TRUE. * gtk/gtkwindow.c (gtk_window_set_type_hint): If hint is one of the old hints, store a shadow copy in the public window->type_hint bitfield, otherwise set this field to normal. Set the private field to the type hint. * gtk/gtkwindow.c (gtk_window_init): Initialize priv->type_hint. * gtk/gtkwindow.c (struct _GtkWindowPrivate): New field "reset_type_hint" indicating whether the type hint needs to be reset. New field type_hint containing a GdkWindowTypeHint. * gtk/gtkwidget.c (propagate_composited_changed): New function to propagate changes in composited status. (gtk_widget_class_init): Add composited_changed signal. * gtk/gtkwidget.h (struct _GtkWidgetClass): New signal composited-changed. * gtk/gtkwidget.c (gtk_widget_is_composited): New function. * gtk/gtktooltips.c (gtk_tooltips_draw_tips): Set transient for. * gtk/gtktooltips.c (gtk_tooltips_force_window): Set the type hint * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Compute whether the item belongs to a menubar. Set the type_hint appropriately depending on the outcome. * gtk/gtkmenu.c (gtk_menu_position): Set the default type hint here. * gtk/gtkmenu.c (gtk_menu_attach_to_widget): connect to hierarchy changed on the attach widget. * gtk/gtkmenu.c (attach_widget_hierarchy_changed): New function to set the transient_for property for menus. * gtk/gtkdnd.c (set_icon_stock_pixbuf): Set the appropriate type hint. * gtk/gtkcombo.c (gtk_combo_popup_list): Make the popup window transient for the toplevel. * gtk/gtkcombobox.c (gtk_combo_box_set_popup_widget): Set transient-for, for the popup window. * gdk/x11/gdkwindow-x11.c (gdk_window_get_type_hint): Support for new window types. * gdk/x11/gdkwindow-x11.c (gdk_window_set_type_hint): Add support for new window types. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_process_owner_change): New function called whenever the compositing manager comes and goes. * gdk/x11/gdkscreen-x11.c (gdk_screen_is_composited): New function. * gdk/x11/gdkscreen-x11.c (_gdk_x11_screen_request_cm_notification, make_cm_atom, check_is_composited): New functions * gdk/x11/gdkevents-x11.c (gdk_event_translate): Call _gdk_x11_screen_process_owner_change when an XFixesSelectionNotifyEvent is received. * gdk/x11/gdkdisplay-x11.c (gdk_display_open): Call _gdk_x11_screen_request_cm_notification() on all screens. * gdk/quartz/gdkscreen-quartz.c (gdk_screen_is_composited): Dummy implementation. * gdk/gdkscreen.c (gdk_screen_class_init): New signal, 'composited-changed'. * gdk/gdkwindow.h: Add new EWMH window types. * gdk/win32/gdkscreen-win32.c (gdk_screen_is_composited)
2006-04-25 14:27:32 +00:00
2010-12-23 20:50:18 +00:00
if (priv->position_func)
{
2010-12-23 20:50:18 +00:00
(* priv->position_func) (menu, &x, &y, &priv->initially_pushed_in,
priv->position_func_data);
2010-12-23 20:50:18 +00:00
if (priv->monitor_num < 0)
priv->monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
else
{
gint space_left, space_right, space_above, space_below;
gint needed_width;
gint needed_height;
GtkBorder padding;
gboolean rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
get_menu_padding (widget, &padding);
/* The placement of popup menus horizontally works like this (with
* RTL in parentheses)
*
* - If there is enough room to the right (left) of the mouse cursor,
* position the menu there.
2010-12-23 20:50:18 +00:00
*
* - Otherwise, if if there is enough room to the left (right) of the
* mouse cursor, position the menu there.
2010-12-23 20:50:18 +00:00
*
* - Otherwise if the menu is smaller than the monitor, position it
* on the side of the mouse cursor that has the most space available
*
* - Otherwise (if there is simply not enough room for the menu on the
* monitor), position it as far left (right) as possible.
*
* Positioning in the vertical direction is similar: first try below
* mouse cursor, then above.
*/
gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
space_left = x - monitor.x;
space_right = monitor.x + monitor.width - x - 1;
space_above = y - monitor.y;
space_below = monitor.y + monitor.height - y - 1;
2010-12-23 20:50:18 +00:00
/* Position horizontally. */
2010-12-23 20:50:18 +00:00
/* the amount of space we need to position the menu.
* Note the menu is offset "thickness" pixels
*/
needed_width = requisition.width - padding.left;
if (needed_width <= space_left ||
2010-12-23 20:50:18 +00:00
needed_width <= space_right)
{
if ((rtl && needed_width <= space_left) ||
(!rtl && needed_width > space_right))
{
/* position left */
x = x + padding.left - requisition.width + 1;
2010-12-23 20:50:18 +00:00
}
else
{
/* position right */
x = x - padding.right;
2010-12-23 20:50:18 +00:00
}
/* x is clamped on-screen further down */
}
else if (requisition.width <= monitor.width)
2010-12-23 20:50:18 +00:00
{
/* the menu is too big to fit on either side of the mouse
* cursor, but smaller than the monitor. Position it on
* the side that has the most space
*/
if (space_left > space_right)
{
/* left justify */
x = monitor.x;
}
else
{
/* right justify */
x = monitor.x + monitor.width - requisition.width;
}
}
else /* menu is simply too big for the monitor */
2010-12-23 20:50:18 +00:00
{
if (rtl)
{
/* right justify */
x = monitor.x + monitor.width - requisition.width;
}
else
{
/* left justify */
x = monitor.x;
}
}
/* Position vertically.
* The algorithm is the same as above, but simpler
* because we don't have to take RTL into account.
*/
needed_height = requisition.height - padding.top;
if (needed_height <= space_above ||
2010-12-23 20:50:18 +00:00
needed_height <= space_below)
{
if (needed_height <= space_below)
y = y - padding.top;
2010-12-23 20:50:18 +00:00
else
y = y + padding.bottom - requisition.height + 1;
2010-12-23 20:50:18 +00:00
y = CLAMP (y, monitor.y,
monitor.y + monitor.height - requisition.height);
}
else if (needed_height > space_below && needed_height > space_above)
2010-12-23 20:50:18 +00:00
{
if (space_below >= space_above)
y = monitor.y + monitor.height - requisition.height;
else
y = monitor.y;
}
else
2010-12-23 20:50:18 +00:00
{
y = monitor.y;
}
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
Adapt cast macros to standard. Fri Nov 19 10:34:41 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkgamma.h: Adapt cast macros to standard. [ Merges from 1.2 ] Tue Nov 16 10:15:54 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkitemfactory.c (gtk_item_factory_parse_path): If translation does not include a '/', use entire translation instead of crashing. Sun Oct 31 22:21:11 1999 Tim Janik <timj@gtk.org> * docs/gtk_tut.sgml: s/gtk_accel_group_attach/gtk_window_add_accel_group/. Sat Oct 30 09:09:09 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkselection.c (gtk_target_list_remove): Use g_list_remove_link, not g_list_remove. [ From Geert Bevin <gbevin@thunderstorms.org> ] Sun Oct 24 07:41:40 1999 Tim Janik <timj@gtk.org> * gtk/gtkclist.c (real_undo_selection): commented out g_print() statement upon unselection (how the heck did that slip in?). Sat Oct 23 03:03:08 1999 Tim Janik <timj@gtk.org> * gtk/gtktext.c (gtk_text_freeze): (gtk_text_thaw): undraw/draw cursor here to avoid unnecessary scrolling in frozen state (and aparently crashes). patch provided by Anders Melchiorsen <and@kampsax.dtu.dk>. Sat Oct 23 02:53:20 1999 Tim Janik <timj@gtk.org> * fix insensitive default/focus widget activation, reported by Matt Goodall <mgg@isotek.co.uk>. * gtk/gtkwindow.c (gtk_window_key_press_event): (gtk_window_activate_default): (gtk_window_activate_focus): return handled=FALSE for actiavtion of insensitive default widgets. return handled=TRUE for activation of insensitive focus widgets. don't activate in either case. Tue Oct 19 09:55:08 1999 Owen Taylor <otaylor@redhat.com> * gtk-config.in (lib_gtk): Switch order of @x_cflags@ and $glib_cflags to match library order and in the theory that an old version of GLib is more likely to be in the include directory for X then vice-versa. (Bug #2776) Tue Oct 19 09:46:49 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_init): Always use LC_CTYPE to determine the locale for fontsets, not LC_MESSAGES; the user may want English messages with a handling for non-English languages. (LC_CTYPE=ru_RU LC_MESSAGES=fr_FR will still be broken) (Bug #2891) Tue Oct 19 20:36:42 1999 Changwoo Ryu <cwryu@adam.kaist.ac.kr> * gtk/gtkrc.ko: Fixed the wrong number of "*"'s. Tue Oct 19 12:15:13 1999 Changwoo Ryu <cwryu@adam.kaist.ac.kr> * gtk/gtkrc.ko: Changed the Korean default fontset. Fri Oct 8 02:32:47 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtklayout.c (gtk_layout_adjustment_changed): Fix bug where when scrolling to the left or top double exposes were done, causing major slowdowns. Thu Oct 7 18:31:55 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_init): Always normalize codeset names to lowercase and alphanumeric, before looking them up. * gtk/Makefile.am: Install codeset variant gtkrc files with normalized names. Thu Oct 7 22:52:42 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_popup_with_data): even popup menus when the menu is already visible, but its parent is still hidden, (happens after tornoff window got hidden). Thu Oct 7 11:09:55 1999 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (install-data-local): Fix a typo where gtkrc.vi_VN.tcvn5712 wasn't getting deleted, causing error messages on install. Thu Oct 7 11:03:06 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtk[hv]paned.c (gtk_{h,v}paned_draw): Redraw the handle as well, since we now sometimes ignore exposes on the handle while resizing. Wed Oct 6 18:02:31 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_append_default_pixmap_path): Fix stupid extra g_free introduced in one of the last one or two commits. Wed Oct 6 16:38:36 1999 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am gtk/gtkrc*: Make naming of gtkrc files consistent, put each style that a gtkrc.* file creates in a unique namespace, remove old files before installing. Wed Oct 6 14:31:16 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_init): Avoid leaking memory when gtk_rc_init is called multiple times. (Yes, people who do that have bugs in their code.) Tue Oct 5 11:36:57 PDT 1999 Manish Singh <yosh@gimp.org> * gtk/Makefile.am: listing gtkrc in gtkconf_DATA seems to barf. Remove it since it's generated by the Makefile anyway Tue Oct 5 02:43:41 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkinputcommon.h (gdk_input_device_new): Free device->info.axes for core pointer. Thu Sep 30 13:55:25 1999 Owen Taylor <otaylor@redhat.com> * gtk/testgtk.c (destroy_idle_test): Rename idle to idle_id, to deal with obsolete, broken C libraries. Mon Sep 27 02:50:15 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkvscale.c (gtk_vscale_draw): Don't add in allocation->x/y twice! * gtk/gtkhscale.c: Make usage of gtk_hscale_pos_trough() consistent with gtk_vscale_pos_trough(). Sun Sep 26 19:44:34 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkcontainer.c (gtk_container_queue_resize): We may be queueing a resize on a toplevel container between the time we show it and when we map it. So, we need to test GTK_WIDGET_VISIBLE() for toplevels, and only use GTK_WIDGET_DRAWABLE() for child windows. Thu Sep 23 16:41:03 1999 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (LDADDS): Add GDK_WLIBS to LDADDS (fixes bug #2144) Fri Sep 24 00:51:45 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c (gtk_container_queue_resize): check for container DRAWABLE (instead of VISIBLE), so we don't queue resizes on non-toplevel containers. Sun Sep 19 18:13:31 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkselection.[ch]: Make the data argument const guchar *. Sat Sep 18 21:27:40 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c: Try to behave sensibly if the focus widget is the window itself. (Should we allow this at all?) Fri Sep 17 09:57:15 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_set_sensitive): * gtk/gtknotebook.c (gtk_notebook_set_scrollable): * gtk/gtknotebook.c (gtk_notebook_set_show_border): * gtk/gtkclist.c (gtk_notebook_set_show_border): make gboolean args in prototypes and implementations consistent (Tomas Ogren). * gtk/gtklayout.c (gtk_layout_remove): unset GTK_IS_OFFSCREEN flag before the widget is unparented (reported by damon). * gtk/gtkdnd.c: make the cursor and icon data _unsigned_ char, since we provide unsigned data anyways. Thu Sep 16 21:32:01 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktooltips.c (gtk_tooltips_set_tip): Delay the call to gtk_tooltips_layout_text() until later. * gtk/gtktooltips.c (gtk_tooltips_draw_tips): Call gtk_widget_ensure_style() before using the style. Wed Sep 15 02:52:19 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_event): Added workaround for old widgets that don't propagate draws to all children. (Namely gnome-dock for gnome-libs <= 1.0.16) Tue Sep 14 19:22:19 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_queue_resize): don't queue the parent for a redraw but just the widget that requested the resize. Tue Sep 14 18:29:47 1999 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.c: added new widget level method gtk_container_set_reallocate_redraws() and a GtkContainer flag reallocate_redraws : 1 to reflect the setting, exported this through the argument system as a boolean ::reallocate_redraws. * gtk/gtkwidget.c (gtk_widget_size_allocate): when queueing redraws on the widget because the allocation changes, do so as well for widget->parent if the parent has reallocate_redraws set to TRUE. with that containers requesting reallocation redraws get automatically redrawn if their children changed allocation (this unfortunately affects also other children that didn't change allocation, but we cannot work around that before 1.3). Tue Sep 14 18:23:01 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_idle_draw): only emit ::draw if width _and_ height are >0 (not _or_). * gtk/gtktable.c (gtk_table_remove): use gtk_widget_queue_resize() instead of gtk_container_queue_resize(), which is a core gtk internal function (must have been on crack when i queued that). * gtk/gtkprivate.h: added new private flag GTK_FULLDRAW_PENDING, so we can check more reliably if we want to discard expose events. * gtk/gtkwidget.c: added setting/unsetting of the GTK_FULLDRAW_PENDING flag. * gtk/gtkwidget.c (gtk_widget_event): don't discard synthesized exposes, we simply trust these events. for deciding whether to discard exposes, check GTK_FULLDRAW_PENDING instead of RESIZE_PENDING. Mon Sep 13 15:01:21 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_queue_clear_area): Ignore queues of areas that are completely off screen. * gtk/gtkwidget.c (gtk_widget_idle_draw): Fix broken logic for handleboxes. * gtk/gtkwidget.c (gtk_widget_queue_draw_data): Add santity check on width/height. Mon Sep 13 02:22:47 1999 Tim Janik <timj@gtk.org> * gtk/Makefile.am: backed out Raja's recent VPATH build "improvements", we are fine with using $@ the way we do (if we actually encounter brokeness with $@ in VPATH builds because of additional path prefixes, we need to use $(@F) actually). Mon Sep 13 01:34:53 1999 Tim Janik <timj@gtk.org> * gtk/gtksignal.c: renamed two variables, hopefully didn't introduce short lived bugs, that would allow language bindings to do surgeries to our guts. Fri Sep 10 15:22:50 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_size_allocate): Fix typo where comparison was being done against an uninitialized value causing intermittant results depending on compiler flags. Also make it clearer that we aren't ever initializing the child as 0x0 (though this will be caught in gtk_widget_size_allocate()) Fri Sep 10 10:06:56 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_set_transient_for): Move gtk_window_unset_transient_for() call after we do checks involving the old transient parent. [ From Lance Capser <lmc@cyberhighway.net> ] 1999-09-07 Raja R Harinath <harinath@cs.umn.edu> * gtk/Makefile.am (gtk.defs): Go back to using `touch' to create an empty file. Mon Sep 6 00:11:56 1999 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_is_ancestor): return FALSE if node has no children. (Reported by: Chris Rogers <gandalf@pobox.com>) 1999-09-03 Raja R Harinath <harinath@cs.umn.edu> * gtk/Makefile.am (gen_sources): Improve VPATH builds. `$@' is valid only in the build dir, not after we've done `cd $srcdir'. Also use `test -f' instead of less portable `test -e'. Fri Sep 3 15:59:56 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (correct_cache_insert): Rewrite for simplicity, and hopefully correctness. (Fixes bug #1322, which was a segfault when on some insertions with the properties around the insertion set up just wrong.) * gtk/gtktext.c (gtk_text_adjustment): When we receive a "changed" signal, clamp the new value to the adjustment bounds to avoid segfaulting if someone tries to change the adjustment to a bogus value. (Bug #1795) Thu Sep 2 16:33:59 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c: Ignore unexpected destroy notifies for children, for toplevel windows handle them like delete_event. * gtk/gtkplug.c: Add an unrealize handler so that we unref plug->socket_window when we are done with it. Fri Sep 3 14:52:54 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c (clear_area): Fix stupid signedness problem that was causing background to sometimes be misaligned. Fri Sep 3 12:26:33 1999 Owen Taylor <otaylor@redhat.com> [ Fixes pointed out by Ettore Perazzoli <ettore@comm2000.it> ] * gtk/gtkmenu.c (gtk_menu_position): Make sure we never position menus with negative x, y, since gtk_widget_set_uposition() can't handle that. * gtk/gtkmenuitem.c (gtk_menu_item_position_menu): Modify the positioning code a bit so that we always put the top-left corner onscreen. (This is for UI reasons, gtk_menu_position() now takes care of gtk_widet_set_uposition() brokeness.) Fri Sep 3 03:06:30 1999 Tim Janik <timj@gtk.org> * gtk/Makefile.am: fixed up things for -jx, x > 1. Sun Sep 5 08:48:51 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_modify_style): Ref the RC style that is passed in. The lack of the ref before was a bug. If people worked around this bug, this will introduce a slight memory leak in their code. The code should typically look like: rc_style = gtk_rc_style_new (); [...] gtk_widget_modify_style (widget, rc_style); gtk_rc_style_unref (rc_style); * gtk/gtkwidget.c (gtk_widget_modify_style): Reset the style if it was already set. * gtk/gtkwidget.c (gtk_widget_set_name): Only set the style if it was set before. Thu Sep 2 19:02:37 1999 Owen Taylor <otaylor@redhat.com> * gtk/testgtk.c (main): Add a check to see if we are being run from the correct directory and to quit nicely if we are not. * gtk/gtkrc.c (gtk_rc_slist_remove_all): Make function static. Thu Sep 2 23:00:03 1999 Tim Janik <timj@gtk.org> * gtk/gtkenums.h (GtkWindowPosition): added GTK_WIN_POS_CENTER_ALWAYS. * gtk/gtkwindow.c: queue resizes unconditionally (gtk_widget_queue_resize will figure what to do if the window is not realized). (gtk_window_move_resize): only recenter the window for GTK_WIN_POS_CENTER_ALWAYS. (gtk_window_compute_reposition): handle GTK_WIN_POS_CENTER_ALWAYS in the same way as GTK_WIN_POS_CENTER. Thu Sep 2 22:39:27 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_reposition): check for the last position with (!(info->last_flags & GDK_HINT_POS)) instead of (!info->last_flags & GDK_HINT_POS). * gtk/gtkwindow.c (gtk_window_move_resize): constrain new_width and new_height unconditionally, because we use these values even if !default_size_changed && !hints_changed. comented the (default_size_changed || hints_changed) case with respect to resize rejects from the window manager. * gtk/gtkwindow.c (gtk_window_move_resize): save info->last values in the zvt condition hack, since this includes the window hints, set the hints after the handling_resize case. * gtk/gtkwindow.c (gtk_window_show): constrain the default size that a window is initially shown with to the geometry. Thu Sep 2 07:38:56 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_move_resize): s/size_changed/default_size_changed/g so i know what's really going on (frying brain on smaller flame now). Thu Sep 2 05:47:47 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_move_resize): queue a new resize if we have size_changed upon handling_resize. this is a gross workaround for the broken zvt widget and should be removed in 1.3 again (search for FIXME). Owen provided an accurate comment for this: /* We could be here for two reasons * 1) We coincidentally got a resize while handling * another resize. * 2) Our computation of size_changed was completely * screwed up, probably because one of our children * is broken. It's probably a zvt widget. * * For 1), we could just go ahead and ask for the * new size right now, but doing that for 2) * might well be fighting the user (and can even * trigger a loop). Since we really don't want to * do that, we requeue a resize in hopes that * by the time it gets handled, the child has seen * the light and is willing to go along with the * new size. (this happens for the zvt widget, since * the size_allocate() above will have stored the * requisition corresponding to the new size in the * zvt widget) * * This doesn't buy us anything for 1), but it shouldn't * hurt us too badly, since it is what would have * happened if we had gotten the configure event before * the new size had been set. */ Wed Sep 1 20:46:11 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c: deal properly with the fact that RC style lists may include rc styles more than once. * gtk/gtkrc.c (gtk_rc_append_pixmap_path): Removed unused static function. * gtk/gtkrc.c (gtk_rc_find_pixmap_in_path): Keep a stack of directories of RC files currently being parsed and implicitely add them to pixmap path. This fixes a bug where the directory would get appended then overwritten by pixmap_path declarations. (bug #1462, from Peter Wainright <prw@wainpr.demon.co.uk>) * gtk/gtkthemes.c (gtk_theme_engine_unref): Call theme's exit function. (Patch from Peter Wainwright, bug #1454) * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_destroy): Add a destroy() handler to take care of removing group for menu item. (Fixes bug #1197) * gtk/gtkwidget.c (gtk_widget_size_request): Fixed thinko in warning message. Wed Sep 1 21:27:42 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_move_resize): don't require a server roundtrip to figure window's width and height, since we know that anyways from widget->allocation. Wed Sep 1 12:37:44 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_move_resize): Compute the hints after we request the new size. Wed Sep 1 10:38:37 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_compute_hints): Removed GTK_WIDGET_REALIZED() assertion - we can compute the hints before we are realized. * gtk/gtkwindow.c (gtk_window_move_resize): Reorder hint changing so that we have a value of hints_changed when we decide whether to constrain the window size. * gtk/gtkwindow.c (gtk_window_move_resize): Spelling fix. * gtk/gtkwindow.c (gtk_window_constrain_size): cleanups, change back to G_MAXINT. Wed Sep 1 06:54:59 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_get_geometry_info): zero initialize new GtkWindowGeometryInfo, so fields like GdkGeometry geometry contain uncluttered values. (gtk_window_compute_hints): simply assert that window is realized and that geometry_info is valid, since we rely on this anyways. (gtk_window_constrain_size): major cleanups to the code. if (flags & GDK_HINT_BASE_SIZE) use geometry's base width and height for the base size, instead of the minimums. use 32767 as max width and height (like in gtkwindow.c) instead of G_MAXINT. Wed Sep 1 04:41:25 1999 Tim Janik <timj@gtk.org> * cleaned up the GtkContainer.need_resize flag handling mess, we only need to force resize requests when we were prematurely realized, or our widget tree was modified when we were temporarily hidden. handling these cases directly upon showing the window (i.e. while the GdkWindow is still unmapped) avoids the need to wait for a configure event response and therefore makes the GUI more snappier and avoids blank windows during the roundtrip. * gtk/gtkwidget.c: (gtk_widget_hide): (gtk_widget_show): don't queue resizes on toplevels, they know how to deal with matters. * gtk/gtkcontainer.c (gtk_container_queue_resize): set the ->need_resize flag directly for not visible resize containers and spare us unecessary signal emissions. * gtk/gtkwindow.c: (gtk_window_realize): if we need to enforce premature size allocation, queue a container resize so we are correctly resized later on. (gtk_window_init): (gtk_window_size_request): don't freak around with the ->need_resize flag, gtk_container_queue_resize() will care about that. (gtk_window_show): handle initial resizing issues here, we can handle matters better in this place, especially since we know that our GdkWindow is still unmapped. (gtk_window_move_resize): don't care about ->need_resize at all. handle size changes properly that occoured while we waited for a configure event. Tue Aug 31 15:58:46 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_set_uposition): * gtk/gtkwindow.[hc] (gtk_window_reposition): Move the hint setting code from gtk_widget_set_uposition to here; set the hints so that we respect any previously set geometry hints. * gtk/gtkwindow.c (gtk_window_compute_reposition): Don't change the window hints here or move the window here, let that happen in gtk_window_move_resize(). Tue Aug 31 06:58:52 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_event): when discarding exposes due to already queued resizes (and therefore redraws) on a widget, check its anchestry as well. * gtk/gtkcontainer.c: (gtk_container_queue_resize): clear resize widgets for resize containers before aborting prematurely. this is especially important for toplevels which may need imemdiate processing or their resize handler to be queued. (gtk_container_dequeue_resize_handler): added new internal function for gtkwindow.c. * gtk/gtkwindow.c (gtk_window_move_resize): if we are resizing due to a configure event, take possible changes in window position into account as well. if we request a new window size, queue up a resize handler that will last until the configure event response arrives. combined the ->need_resize case (initial show) with the general size (hints) changed case and added even more comments. if !auto_shrink, only revert to the old allocation if the new size is smaller than the current allocation. Tue Aug 31 11:55:20 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c (gtk_window_set_arg, gtk_window_set_policy, gtk_window_set_geometry_hints gtk_window_set_default_size): When hints are set, queue a resize so that the hints will be eventually reset on the toplevel. * gtk/gtkwindow.c (gtk_window_show): Use gtk_window_compute_default_size(). Clear the need_resize flag on the initail map so that we don't unnecessarily trigger the resize code. * gtk/gtkwindow.c (gtk_window_move_resize): Split apart into separate functions. Compare the hints we are setting with what we set last time so that we can accurately tell when we need to reset the hints. * gtk/gtkwindow.c (gtk_window_compute_default_size): New function to figure out the size from requisition and default_size. * gtk/gtkwindow.c (gtk_window_constrain_size): Function from fvwm to constrain a size to the geometry hints. * gtk/gtkwindow.c (gtk_window_compare_hints): New function to compare two sets of geometry hints. * gtk/gtkwindow.c (gtk_window_compute_hints): Renamed from gtk_window_set_hints(), just compute the hints, don't set them. * gtk/gtkwindow.c (gtk_window_compute_reposition): Move code from gtk_window_move_resize() to separate function, rationalize a bit. Tue Aug 31 13:05:03 1999 Owen Taylor <otaylor@redhat.com> * gtkrc.h: Move the ref_count member out of the GtkRcStyle structure into a new private structure. * gtkrc.c: Split GtkRcStyle into public/private. In the private part, add a list of pointers to the RcStyle lists this RcStyle participates in. * gtkrc.c: When a RcStyle is free, remove all lists referencing it from the realized_style_ht hash, and free those lists. * gtk/gtkrc.c (gtk_rc_clear_styles): Don't call gtk_rc_init(), since that adds the default styles to the list of parsed RC files again. * gtk/gtkrc.c: Use gtk_rc_style_find() consistently. Thu Aug 26 14:14:42 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_size_allocate): reactivated the sanity checks that ensure that a widget's allocation is at least 1 in width and height. (GNOME note: this doesn't affect old panel code anymore, because GtkSocket will request width and height of at least 1 since Fri Jul 23). * gtk/gtkwindow.c (gtk_window_realize): if the widget hasn't been allocated yet (happens if the user realizes the window prematurely), size request and allocate it. (gtk_window_size_allocate): guard against guint underflows. Wed Aug 25 19:01:36 1999 Lars Hamann <lars@gtk.org> * gtk/Makefile.am (gtk_built_sources): reordered stamp-gtk.defs in gtk_built_sources, so gtk.defs gets built prior to all other sources. Mon Aug 23 19:11:17 1999 Tim Janik <timj@gtk.org> * gtk/Makefile.am: invoke indent on gtkmarshal.*. rewrote source generation rules, use COPYING as oldest source tag for a piggyback rule to generate all sources from (don't touch it ;). major cleanups, strip spaces on build rules for GNU Make. * gtk/genmarshal.pl: don't operate on hardcoded filenames but take source and target files from commandline arguments. don't invoke indent. Sat Aug 21 14:07:36 1999 Lars Hamann <lars@gtk.org> * gtk/gtknotebook.c (gtk_notebook_real_switch_page): queue_resize notebook after switch to avoid drawing problems. (Bug#856 Reported by: Theodore Roth <troth@netmagic.net>) (gtk_notebook_pages_allocate): don't map not visible tab_labels, show them instead. (Bug#1805 Reported by: Dave Cole <dave@dccs.com.au>) Sat Aug 21 14:07:36 1999 Lars Hamann <lars@gtk.org> * gtk/gtknotebook.c (gtk_notebook_real_switch_page): queue_resize notebook after switch to avoid drawing problems. (Bug#856 Reported by: Theodore Roth <troth@netmagic.net>) (gtk_notebook_pages_allocate): don't map not visible tab_labels, show them instead. (Bug#1805 Reported by: Dave Cole <dave@dccs.com.au>) Wed Aug 18 09:20:10 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c: we use window->need_resize from configure_event now, to indicate that the gtkwindow should keep its allocation (e.g. because the user resized the window through window manager handles). resize_count is now reliably used to figure whether we got the allocation we requested from the window manager. configure events get queued as resizes now, the real stuff (size computation and allocation) now only goes on in gtk_window_move_resize(). GtkWindow's requisition now contains its *real* requisition (like all other widgets), *not* taking usize into account. geometry_info->last_{width|height} is now updated from set_hints() only so it always contains the last hints we set for the window manager. made some event handlers return TRUE instead of FALSE. the overall code should be much more straight forward now, and the significant code portions are accompanied by comments now. (gtk_window_set_hints): removed requisition argument and made it fetch the requisition through gtk_widget_get_child_requisition. we also don't move the gdkwindow here anymore, gtk_window_move_resize() does that now. (gtk_window_show): ensure that the widget is realized before calling gtk_container_check_resize() (and thus gtk_window_move_resize()), also ensure that we got properly size requested and allocated before realization. (gtk_window_configure_event): ignore plain window moves, or reallocate the widget tree through the resize queue otherwise. (gtk_window_move_resize): mostly rewrote this function to figure window manager hints more reliably, coalesce window moves and resizes to reduce configure events and do actuall size allocations. Tue Aug 17 07:43:04 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_event): discard expose events for widgets that have a resize pending, because a redraw is already queued for them. * gtk/gtkcontainer.c: removed ugly connect_to ::size_allocate signal hack to clear resize_widgets. * gtk/gtkwidget.c (gtk_widget_size_allocate): call clear_resize_widgets for resize containers prior to size allocation. (this is also a bit ugly, but avoids side effects for stopped emissions and is thus more reliable). (gtk_widget_unparent): removed disconnect call for clear_resize_widgets. * gtk/gtktooltips.c (gtk_tooltips_paint_window): renamed this function from gtk_tooltips_expose, as we connect to ::expose_event *and* ::draw now. 1999-08-18 Federico Mena Quintero <federico@redhat.com> * gtk/gtkselection.c (gtk_target_list_ref): Added missing sanity checks. (gtk_target_list_unref): Likewise. * gtk/gtkthemes.c (gtk_theme_engine_unref): Likewise. Tue Aug 17 15:47:07 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkcolorsel.c (gtk_color_selection_draw_value_bar): guard against division by zero. (Fixes bug #1339) Tue Aug 17 10:56:49 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_move_{forward,backward}_word): Prevent the trivial leak of information of allowing word motion when the entry is not visible. Tue Aug 17 10:28:52 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_fileop_error): Propagate modality to error dialog as well as confirmation dialogs. (Bug #1803, reported by Rosanna Wing Sze Yuen) Wed Aug 11 01:04:57 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktreeitem.c (gtk_tree_item_draw_lines): Honor tree->view_lines. (gtk-guy-990611-3.patch: Guy Harris <guy@netapp.com>) * gtk/Makefile.am (install-data-local): Solaris apparently has various troubles with ln -f; use rm first instead. (gtk-guy-990611-2.patch: Guy Harris <guy@netapp.com>) 1999-07-30 Raja R Harinath <harinath@cs.umn.edu> * gtk/Makefile.am (stamp-m): Don't `mv' from builddir to srcdir, use `cp' followed by `rm' (the `rm' was already there). July 30, 1999 Elliot Lee <sopwith@redhat.com> * configure.in: Fix autoconf warnings about cross compilation by trying to provide sane defaults for AC_TRY_RUN. * gtk/Makefile.am: If we refer to gtkmarshal.[ch] in $(srcdir), put them into $(srcdir) when generated. Also add a dependency of gtksignal.h on gtkmarshal.h for -j builds. * gtk/gtk(dnd,style,gamma).c: Minor warning fixes. Wed Jul 28 09:29:19 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_main_iteration_do): Added missing GDK_THREADS_{LEAVE,ENTER} pair. (From Paul Fisher <pnfisher@redhat.com>) Fri Jul 23 01:00:15 1999 Tim Janik <timj@gtk.org> * gtk/gtksocket.c (gtk_socket_size_request): asure that the requested width and height are always >0 (owen). Fri Jul 23 00:00:47 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_size_allocate): backed out my recent change that assured that a widget's allocated with and height are always >1, since this breaks *buggy* panel code. unfortunately this back-breaks the gimp's color selector. * gtk/gtkdrawingarea.c (gtk_drawing_area_size_allocate): asure that our allocation is always >0 in width and height, before sending the configure event; this is a *gross* hack to get the gimp back to work. * marked both cases with TODO-1.3 Wed Jul 21 15:47:39 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c: Don't display wrap indicators when text is not editable and word wrap is on. Wed Jul 21 08:21:40 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_create_item): special case option menus here as they are not derived from menu shell, assure that the option menu has a menu we can add items to. Tue Jul 20 23:29:48 1999 Tim Janik <timj@gtk.org> * gtk/gtknotebook.c (gtk_notebook_page_allocate): convert allocation-> width/height to (gint) before calculations and check against < 0 to avoid guint wraparounds. Sun Jul 18 00:35:49 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_size_allocate): ensure that the allocated width and height is never zero. sanity check both dimensions against 32767 and issue a warning if the allocation is greater than that. Wed Jul 7 15:03:30 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_events_pending): Unlock around call to g_main_pending() as well. Wed Jul 7 14:59:01 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_main_iteration): Unlock around call to g_main_iteration() - since that will regrab GTK+ lock to process events. Thu Jul 1 15:01:55 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwindow.c - Regularize with the rest of GTK+ by making widget->requisition not reflect the set_usize() - Always recompute geometry hints, then check if they changed before sending them to the X server. The previous checks for changes would fail in a number of circumstances. Thu Jul 1 11:55:59 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkstyle.c: Include <stdlib.h> for strcmp(). Wed Jun 30 19:26:36 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkdnd.c: - Code cleanups - Instantaneously update on modifier key presses - Allow cancellation of the drag with Escape. Tue Jun 29 17:04:09 1999 Owen Taylor <otaylor@redhat.com> * gtk/testgtk.c (create_handle_box): Set the policy to auto_shrink - otherwise the appearance is rather strange when flipping between horizontal and vertical. Mon Jun 28 09:29:52 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c: add ::default_width and ::default_height arguments. (gtk_window_set_default_size): don't change a value if it's < 0. queue a resize. Sun Jun 27 11:00:33 1999 Tim Janik <timj@gtk.org> * gtk/gtktext.c (gtk_text_insert): don't segfault on NULL inserts. Mon Jun 28 12:08:25 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (cmpl_completion_fullname): Don't add an extra "/" when concating "/" + filename. (From Matt Grossman <mattg@oz.net>) Mon Jun 28 10:57:12 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkctree.c (draw_cell_pixmap): Reset clip mask for fg_gc if we set it for drawing pixmap. Tue Jun 15 12:45:12 1999 Owen Taylor <otaylor@redhat.com> Fixes from Peter Wainwright <prw@wainpr.demon.co.uk> * gtk/gtkrc.c (gtk_rc_parse_engine): If rc_style->engine is already set, call old engine's destroy function and unref the old engine. Thu Jun 10 17:59:38 1999 Tim Janik <timj@gtk.org> * gtk/gtkdrawingarea.c (gtk_drawing_area_size): queue a resize. Wed Jun 9 15:13:16 1999 Tim Janik <timj@gtk.org> * gtk/gtkaccelgroup.h: mark certain functions as internal. Wed Jun 9 13:48:28 1999 Tim Janik <timj@gtk.org> * gtk/gtkpreview.c (gtk_preview_set_expand): queue a resize if the expand behaviour changed. * gtk/gtklabel.c (gtk_label_set_pattern): (gtk_label_set_justify): (gtk_label_set_line_wrap): don't bother invoking queue_clear, the reallocation does that for us, always free_words so the upcoming resize will relayout the label's contents. Wed Jun 9 12:50:48 1999 Tim Janik <timj@gtk.org> * applied argument implementation patches from Elena Devdariani <elena@cogent.ca>. * gtk/gtktoolbar.c: ::orientation, ::toolbar_style, ::space_size, ::space_style, ::relief * gtk/gtkruler.c: ::lower, ::upper, ::position, ::max_size * gtk/gtkpreview.c: ::expand * gtk/gtkpaned.c: ::handle_size, ::gutter_size * gtk/gtknotebook.c: ::homogeneous * gtk/gtklabel.c: ::wrap * gtk/gtklist.c: ::selection_mode * gtk/gtkhandlebox.c: ::handle_position, ::snap_edge * gtk/gtkcurve.c: ::curve_type, ::min_x, ::max_x, ::min_y, ::max_y * gtk/gtkcolorsel.c: ::update_policy, ::use_opacity * gtk/gtkclist.c: ::sort_type * gtk/gtkcheckmenuitem.c: ::active, ::show_toggle * gtk/gtkaspectframe.c: ::xalign, ::yalign, ::ratio, ::obey_child Tue Jun 1 23:38:38 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkstyle.c: Removed ill-thought-out part of last comment. Tue Jun 1 23:30:09 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkstyle.c (gtk_style_attach): Get the reference counting right when we have to attach a new style for a different visual. (Chi-Deok Hwang <cdhwang@sr.hei.co.kr>) * gtk/gtkstyle.c: Documented the refcounting peculularities of gtk_style_attach. 1999-06-01 Tim Janik <timj@dhcpd7.redhat.com> * gtk/gtkwindow.c (gtk_window_new): added return if fail for invalid window types. * examples/packer/pack.c (main): use GTK_WINDOW_TOPLEVEL instead of GTK_TOPLEVEL for creating the window. 1999-06-01 Tim Janik <timj@dhcpd7.redhat.com> * gtk/gtkmain.c (gtk_init_check): don't segfault when --gtk-module is the last argument (reported by Per Winkvist). Tue May 25 13:13:12 1999 Owen Taylor <otaylor@redhat.com> Fixes for invisible XOR lines (Frank Loemker <floemker@TechFak.Uni-Bielefeld.DE>) * gtk/gtkclist.c (gtk_clist_realize): Always use a non-zero pixel for GDK_XOR. * gtk/gtkvpaned.c gtk/gtkhpaned.c: Use GDK_INVERT instead of GDK_XOR. Wed May 12 21:56:40 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.c (adjust_adjustments): signal emit value_changed signals if h/voffsets differ from adjustment values. Reportet by Jerome Bolliet <bolliet@in2p3.fr> Mon May 10 04:20:41 1999 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_menu_shell_activate_item): propagate ::selection-done emissions up to the topmost menu shell. Fri May 7 10:15:14 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtknotebook.c (gtk_notebook_set_scrollable): Unset the user data on the window before destroying it. * gtk/gtknotebook.c (gtk_notebook_unrealize): Add an unrealize handler to take care of destroying notebook->panel properly. (Bug #1198 - Morten Welinder <terra@diku.dk>) * gtk/gtktext.c (expand_scratch_buffer): Fix reversal of g_new and g_realloc to stop memory leak. (Actually, we could just use g_realloc(), but I'm not 100% sure that is portable). (Bug #1196 - Morten Welinder <terra@diku.dk>) Wed Apr 21 00:42:08 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkplug.h: Removed stray GtkPlugButton declaration. * gdk/gdkfont.c (gdk_text_measure): Fix the return value for fontsets. * gtk/gtkbutton.c (gtkbutton_expose): Fix warning with bin/button confusion. Thu May 6 04:53:26 1999 Tim Janik <timj@gtk.org> * gtk/testgtk.c: in the ItemFactory test, link radio items together, and show how preselection of radio items is done. Sun May 2 13:31:14 1999 Tim Janik <timj@gtk.org> * gtk/gtktreeitem.c (gtk_tree_item_set_subtree): * gtk/gtktree.c (gtk_tree_add) (gtk_tree_insert): * gtk/gtktoolbar.c (gtk_toolbar_insert_element): * gtk/gtkpaned.c (gtk_paned_pack2) (gtk_paned_pack1): * gtk/gtkscrolledwindow.c (gtk_scrolled_window_add): * gtk/gtktable.c (gtk_table_attach): * gtk/gtklist.c (gtk_list_insert_items): * gtk/gtkmenushell.c (gtk_menu_shell_insert): * gtk/gtknotebook.c (gtk_notebook_insert_page_menu): * gtk/gtkpacker.c (gtk_packer_add_defaults) (gtk_packer_add): * gtk/gtkbin.c (gtk_bin_add): * gtk/gtkbox.c (gtk_box_pack_start) (gtk_box_pack_end): * gtk/gtkfixed.c (gtk_fixed_put): * gtk/gtklayout.c (gtk_layout_put): general fixups to container_add logic. always realize child if child->parent is realized, only map the child and queue a resize if child and child->parent are both visible. Fri Apr 30 09:02:28 1999 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_real_unrealize): use gtk_container_forall instead of gtk_container_foreach to walk and unrealize children, so composite children get also unrealized. (gtk_widget_real_show): don't call gtk_widget_map() if we don't need to. (gtk_widget_map): assert that the widget is visible (basic constrain). (gtk_widget_real_map): assert that the widget is realized (basic constrain). Fri Apr 29 00:53:20 1999 Tim Janik <timj@gtk.org> * gtk/gtkbindings.c (gtk_pattern_spec_init): plugged a memory leak. Tue May 4 09:32:08 1999 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am gtk/gtkrc.iso-8859-2: Add a gtkrc file for iso-8859-2 locales. * configure.in (ALL_LINGUAS): ALL_LINGUAS update. Tue Apr 27 16:38:32 1999 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am: Fix typo of static_sources for static_SOURCES. (Pointed out by andy@rz.uni-karlsruhe.de and others). Remove some suspicious and useless lines. Tue May 4 08:44:08 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkclist.c (gtk_clist_draw, draw_rows): Use width,height = 0, 0 to mean - here to edge of window, instead of -1, -1, since the former is all we support. Tue May 4 08:34:43 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.c (gtk_main): Correctly free list nodes when removing from quit_functions list. Tue Apr 27 14:17:16 1999 Tim Janik <timj@gtk.org> * gtk/gtkpacker.c (gtk_packer_size_request): remove unused variable. Tue Apr 27 18:23:35 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c (gtk_entry_draw_cursor_on_drawable): When redrawing characters on non-visible entry, use appropriate '*' character. (Bug #1130 - Jean-Marc Jacquet <jm@littleigloo.org>) Tue Apr 27 01:31:40 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.c (drag_dest_cell): compute destination cell from drag coordinates. (gtk_clist_drag_data_received) (gtk_clist_drag_motion): use drag_dest_cell. * gtk/gtktree (drag_dest_cell) (gtk_ctree_drag_data_received) (gtk_ctree_drag_motion): likewise. (Bug #1129) Wed Apr 21 21:26:11 1999 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.c (gtk_item_factory_init): properly initialize translate_* fields. (gtk_item_factory_finalize): invoke translate_notify independant from translate_data. (gtk_item_factory_set_translate_func): likewise. (gtk_item_factory_destroy): only remove ifactory pointer from those widgets that belong to us (stupid me). Mon Apr 19 12:05:31 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_style_init): Fixed leak of rc_style list when lookup succeeeds. Thu Apr 15 01:11:24 1999 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (resync_selection): * gtk/gtkclist.c (resync_selection): fixed undo_selection bug. * gtk/gtkclist.c (gtk_clist_button_release): fixed resync_selection bug. Fri Apr 9 19:22:19 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkcolorsel.c gtk/gtkdnd.c gtk/gtkmenuitem.c: Add some missing GDK_THREADS_ENTER()/LEAVE around timeouts. (Patches from Sebastian Wilhelmi <wilhelmi@ira.uka.de>) Thu Apr 8 20:10:33 1999 Tim Janik <timj@gtk.org> * gtk/gtkentry.c (gtk_entry_key_press): use gtk_widget_activate() rather than emit_by_name. * gtk/gtkeditable.c (gtk_editable_insert_text): keep a reference on the widget across multiple signal emissions. (gtk_editable_delete_text): same here. (gtk_editable_class_init): set widget_class->activate_signal after editable_signals[ACTIVATE] has been created. Wed Apr 7 22:59:47 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkpaned.c (gtk_paned_set_position): Don't clamp position here prematurely -- we might not have the right ->min_position and ->max_position yet. Tue Apr 6 16:38:51 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkselection.c gdk/gdkselection.c: (gtk_selection_request): Add error traps so if the other end of the connection dies, we survive. * gtk/gtkselection.c (gtk_selection_notify): Clean up properly when selection property retrieval fails. * gtk/gtkselection.c (gtk_selection_request): Correctly reject SelectionRequest notifies where the handler returns no data. Tue Apr 6 12:24:21 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkdnd.c (gtk_drag_dest_leave): Only unhighlight when we've previously highlighted. * gtk/gtkdnd.c (gtk_drag_dest_handle_event): Don't emit two "drag_leave" signals for Motif drops. * gtk/gtkdnd.c (gtk_drag_source_handle_event): Send back the correct status messages when dropping from Motif onto a proxy window that is rejecting the drop. Sat Mar 27 23:32:13 1999 Tim Janik <timj@gtk.org> * gtk/gtkarg.[hc]: added functions from GLE, gtk_arg_reset() to free the value and reset type to GTK_TYPE_INVALID, and gtk_arg_values_equal() to compare two argument values. added gtk_arg_to_valueloc() to set a variable from an arg through its location (pointer). * gtk/gtkobject.[hc]: implemented gtk_object_get() in terms of gtk_object_arg_get() and gtk_arg_to_valueloc(), floats are collected as gfloat*, uchars are collected as guchar*, ints are collected as gint*, etc... Mon Mar 29 17:45:47 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkaccelgroup.c gtk/gtkgtkbindings.c: Include <string.h> instead of <strings.h>. * gtk/gtkstyle.c: Fix double include of gtkthemes.h (actually, a lot more duplicate includes occur if you trace through the sequence of #include's) gtk-jbb-990320-0: John Bley, jbb6@acpub.duke.edu Mon Mar 29 17:02:58 1999 Owen Taylor <otaylor@redhat.com> Patches from Akira Higuchi <a-higuti@math.sci.hokudai.ac.jp> gtk-a-higuti-990322-[0-3] * configure.in: Fix confusion between GTK_LOCALE_[C]FLAGS that was causing -DX_LOCALE not to work. * gtk/gtkrc.c (gtk_rc_init): X_LOCALE will never have LC_MESSAGES defined Thu Mar 25 12:38:31 1999 Tim Janik <timj@gtk.org> * gtk/gtkrc.c (gtk_rc_append_default_module_path): get $HOME from g_get_home_dir() (gtk-pmc-990123-0.patch.gz). * gtk/gtkwindow.c (gtk_window_key_press_event): feature keypad up/down/ left/right as well (gtk-michael-980726-0.patch.gz). * gtk/gtklabel.[hc]: bunch of miscellaneous cleanups, such as s/0/NULL/ for pointer values, use gchar instead of char. fixed uline allocation leaks, changed the allocation pattern so we use G_ALLOC_AND_FREE mem chunks instead of G_ALLOC_ONLY. (gtk_label_size_request): always alter requisition as passed and leave widget->requisition alone. (gtk_label_set_text): allow NULL strings. (gtk_label_new): likewise. Wed Mar 24 09:24:03 1999 Tim Janik <timj@gtk.org> * gtk/gtkdrawingarea.[hc]: type/macro fixups. Mon Mar 22 05:51:34 1999 Tim Janik <timj@gtk.org> * gtk/gtkbin.c (gtk_bin_draw): only redraw children that are visible *and* mapped (i.e. drawable). (gtk_bin_expose): only send exposes to drawable children. * gtk/gtkbox.c (gtk_box_draw): only redraw children that are drawable. (gtk_box_expose): only send exposes to drawable children. * gtk/gtkhscale.c (gtk_hscale_draw): * gtk/gtkvscale.c (gtk_vscale_draw): hm, this is an ugly one. we first compute the size of our trough area here (window relative) and then check intersection with the draw_area which is parent relative because we're a NO_WINDOW widget, so we need to offset the trough area by allocation.x and allocation.y before the check. (this must not be done for the background area though, since that's already computed parent relative). Mon Mar 22 00:41:39 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.c (gtk_clist_unrealize): unmap clist if neccessary, unrealize title buttons. Fri Mar 19 00:00:22 1999 Lars Hamann <lars@gtk.org> * gtk/gtkclist.c (gtk_clist_column_title_passive) (gtk_clist_column_title_active): only connect/disconnect to GtkWidgetClass::event to block mouse events. * gtk/gtkclist.c (vertical_timeout) (horizontal_timeout): zero initialize event, removed superfluous gdk_window_get_pointer call * gtk/gtklist.c (gtk_list_vertical_timeout) (gtk_list_horizontal_timeout): removed superfluous gdk_window_get_pointer call Wed Mar 17 09:00:00 1999 Tim Janik <timj@gtk.org> * plugging problems reported by "Bruce Mitchener, Jr." <bruce@puremagic.com> due to a purify session. * gtk/gtkstyle.c: (gtk_style_ref): (gtk_style_unref): assert ref_count to be > 0. * gtk/gtkclist.c (gtk_clist_set_cell_style): { 0 } initilaize the requisition. (gtk_clist_set_shift): likewise. * gtk/gtklayout.c: introduce gtk_layout_finalize() to unref the adjustments. * gtk/gtklist.c (gtk_list_horizontal_timeout): zero initialize the event before sending it and set send_event to TRUE (which needs to be done for *all* synthesized events). (gtk_list_vertical_timeout): likewise. * gtk/gtktipsquery.c (gtk_tips_query_destroy): plug small memory leaks. * gtk/gtkdrawingarea.c (gtk_drawing_area_send_configure): set send_event to TRUE when synthesizing events. [ *** end of merges from 1.2 *** ]
1999-11-22 21:52:50 +00:00
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.
2000-11-08 17:34:52 +00:00
scroll_offset = 0;
if (y + requisition.height > monitor.y + monitor.height)
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.
2000-11-08 17:34:52 +00:00
{
if (priv->initially_pushed_in)
scroll_offset += (monitor.y + monitor.height) - requisition.height - y;
y = (monitor.y + monitor.height) - requisition.height;
}
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.
2000-11-08 17:34:52 +00:00
if (y < monitor.y)
{
if (priv->initially_pushed_in)
scroll_offset += monitor.y - y;
y = monitor.y;
}
2010-12-23 20:50:18 +00:00
x = CLAMP (x, monitor.x, MAX (monitor.x, monitor.x + monitor.width - requisition.width));
if (GTK_MENU_SHELL (menu)->priv->active)
{
2010-12-23 20:50:18 +00:00
priv->have_position = TRUE;
priv->position_x = x;
priv->position_y = y;
}
2010-12-23 20:50:18 +00:00
if (scroll_offset != 0)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
scroll_offset += arrow_border.top;
}
2010-12-23 20:50:18 +00:00
gtk_window_move (GTK_WINDOW (GTK_MENU_SHELL (menu)->priv->active ? priv->toplevel : priv->tearoff_window),
2010-12-23 20:50:18 +00:00
x, y);
if (!GTK_MENU_SHELL (menu)->priv->active)
{
2010-12-23 20:50:18 +00:00
gtk_window_resize (GTK_WINDOW (priv->tearoff_window),
requisition.width, requisition.height);
}
if (set_scroll_offset)
2010-12-23 20:50:18 +00:00
priv->scroll_offset = scroll_offset;
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.
2000-11-08 17:34:52 +00:00
}
static void
gtk_menu_remove_scroll_timeout (GtkMenu *menu)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
if (priv->scroll_timeout)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
g_source_remove (priv->scroll_timeout);
priv->scroll_timeout = 0;
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.
2000-11-08 17:34:52 +00:00
}
}
static void
gtk_menu_stop_scrolling (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gtk_menu_remove_scroll_timeout (menu);
priv->upper_arrow_prelight = FALSE;
priv->lower_arrow_prelight = FALSE;
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_scroll_to (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint offset)
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.
2000-11-08 17:34:52 +00:00
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkBorder arrow_border, padding;
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.
2000-11-08 17:34:52 +00:00
GtkWidget *widget;
gint x, y;
gint view_width, view_height;
gint border_width;
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.
2000-11-08 17:34:52 +00:00
gint menu_height;
gboolean double_arrows;
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.
2000-11-08 17:34:52 +00:00
widget = GTK_WIDGET (menu);
if (priv->tearoff_active && priv->tearoff_adjustment)
gtk_adjustment_set_value (priv->tearoff_adjustment, offset);
2010-12-23 20:50:18 +00:00
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.
2000-11-08 17:34:52 +00:00
/* Move/resize the viewport according to arrows: */
view_width = gtk_widget_get_allocated_width (widget);
view_height = gtk_widget_get_allocated_height (widget);
get_menu_padding (widget, &padding);
double_arrows = get_double_arrows (menu);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
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.
2000-11-08 17:34:52 +00:00
view_width -= (2 * border_width) + padding.left + padding.right;
view_height -= (2 * border_width) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * border_width) - padding.top - padding.bottom;
x = border_width + padding.left;
y = border_width + padding.top;
2010-12-23 20:50:18 +00:00
if (double_arrows && !priv->tearoff_active)
{
if (view_height < menu_height ||
2010-12-23 20:50:18 +00:00
(offset > 0 && priv->scroll_offset > 0) ||
(offset < 0 && priv->scroll_offset < 0))
{
2010-12-23 20:50:18 +00:00
GtkStateFlags upper_arrow_previous_state = priv->upper_arrow_state;
GtkStateFlags lower_arrow_previous_state = priv->lower_arrow_state;
2010-12-23 20:50:18 +00:00
if (!priv->upper_arrow_visible || !priv->lower_arrow_visible)
gtk_widget_queue_draw (GTK_WIDGET (menu));
2010-12-23 20:50:18 +00:00
priv->upper_arrow_visible = priv->lower_arrow_visible = TRUE;
2010-12-23 20:50:18 +00:00
get_arrows_border (menu, &arrow_border);
y += arrow_border.top;
view_height -= arrow_border.top;
view_height -= arrow_border.bottom;
if (offset <= 0)
priv->upper_arrow_state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
priv->upper_arrow_state &= ~(GTK_STATE_FLAG_INSENSITIVE);
2010-12-23 20:50:18 +00:00
if (priv->upper_arrow_prelight)
priv->upper_arrow_state |= GTK_STATE_FLAG_PRELIGHT;
else
priv->upper_arrow_state &= ~(GTK_STATE_FLAG_PRELIGHT);
}
if (offset >= menu_height - view_height)
priv->lower_arrow_state |= GTK_STATE_FLAG_INSENSITIVE;
else
{
priv->lower_arrow_state &= ~(GTK_STATE_FLAG_INSENSITIVE);
2010-12-23 20:50:18 +00:00
if (priv->lower_arrow_prelight)
priv->lower_arrow_state |= GTK_STATE_FLAG_PRELIGHT;
else
priv->lower_arrow_state &= ~(GTK_STATE_FLAG_PRELIGHT);
}
if ((priv->upper_arrow_state != upper_arrow_previous_state) ||
(priv->lower_arrow_state != lower_arrow_previous_state))
gtk_widget_queue_draw (GTK_WIDGET (menu));
if ((upper_arrow_previous_state & GTK_STATE_FLAG_INSENSITIVE) == 0 &&
(priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) != 0)
{
/* At the upper border, possibly remove timeout */
2010-12-23 20:50:18 +00:00
if (priv->scroll_step < 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
if ((lower_arrow_previous_state & GTK_STATE_FLAG_INSENSITIVE) == 0 &&
(priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) != 0)
{
/* At the lower border, possibly remove timeout */
2010-12-23 20:50:18 +00:00
if (priv->scroll_step > 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
}
2010-12-23 20:50:18 +00:00
else if (priv->upper_arrow_visible || priv->lower_arrow_visible)
{
offset = 0;
2010-12-23 20:50:18 +00:00
priv->upper_arrow_visible = priv->lower_arrow_visible = FALSE;
priv->upper_arrow_prelight = priv->lower_arrow_prelight = FALSE;
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
2010-12-23 20:50:18 +00:00
else if (!priv->tearoff_active)
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.
2000-11-08 17:34:52 +00:00
{
gboolean last_visible;
2010-12-23 20:50:18 +00:00
last_visible = priv->upper_arrow_visible;
priv->upper_arrow_visible = offset > 0;
/* upper_arrow_visible may have changed, so requery the border */
get_arrows_border (menu, &arrow_border);
view_height -= arrow_border.top;
2010-12-23 20:50:18 +00:00
if ((last_visible != priv->upper_arrow_visible) &&
!priv->upper_arrow_visible)
{
priv->upper_arrow_prelight = FALSE;
/* If we hide the upper arrow, possibly remove timeout */
if (priv->scroll_step < 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
last_visible = priv->lower_arrow_visible;
priv->lower_arrow_visible = offset < menu_height - view_height;
/* lower_arrow_visible may have changed, so requery the border */
get_arrows_border (menu, &arrow_border);
view_height -= arrow_border.bottom;
2010-12-23 20:50:18 +00:00
if ((last_visible != priv->lower_arrow_visible) &&
!priv->lower_arrow_visible)
{
priv->lower_arrow_prelight = FALSE;
/* If we hide the lower arrow, possibly remove timeout */
if (priv->scroll_step > 0)
{
gtk_menu_stop_scrolling (menu);
gtk_widget_queue_draw (GTK_WIDGET (menu));
}
}
y += arrow_border.top;
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.
2000-11-08 17:34:52 +00:00
}
/* Scroll the menu: */
if (gtk_widget_get_realized (widget))
{
gdk_window_move (priv->bin_window, 0, -offset);
gdk_window_move_resize (priv->view_window, x, y, view_width, view_height);
}
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.
2000-11-08 17:34:52 +00:00
2010-12-23 20:50:18 +00:00
priv->scroll_offset = offset;
Added gdk_text/string_extents() - too calculate all the metrics at once of Tue Jul 21 12:42:01 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.h gdk/gdkfont.c: Added gdk_text/string_extents() - too calculate all the metrics at once of a string, including things which weren't calculated before. * gtk/Makefile.am gtk/gtk.h gtk/gtktearoffmenu.[ch]: New MenuItem type, that when put as the first thing in a menu, makes the menu tearoff. Currently drawn as a dashed line. * gtk/gtkmenuitem.h gtk/gtkcheckmenuitem.c: Added a flag "hide_on_activate" to the MenuItem class structure to allow check and radio buttons to be changed with <Space> without hiding the menu. * gtk/gtkaccellabel.[ch]: Added new capabilities to set a underline_group and underline_mods for the label - accelerators added in the underline group matching underline_mods will be displayed as an underline character. This doesn't work - Save As needs to be underlined as Save _As. * gtk/gtkitemfactory.c: - Create a AccelGroup for each MenuShell we create. - If an '&' appears before a character 'c' in the path, then make 'c' an accelerator in the menu's accel group, and if the menuitem is menubar <alt>C an accelerator in the itemfactory's accel group. * gtk/gtklabel.[ch]: Add support for a pattern arg - which is a string. If an '_' appears in this string, the corresponding position in the label is underlined. Add gtk_label_parse_uline() convenience function which takes a string with embedded underlines, sets the pattern and label, and returns the accelerator keyval. * gtk/gtkmenu.[ch]: Make menus no longer a toplevel widget. Instead, they create a GtkWindow and add themselves to that. (When torn off, another new feature, they create another GtkWindow to hold the torn off menu) New function gtk_menu_set_tearoff_state() * gtk/gtkenums.h gtk/gtkmenushell.[ch] gtk/gtkenums.h: Added action signals for keyboard navigation of menus. * gtk/gtkmenushell.c: Key press handler which activates bindings for navigation, and accelerators, for handling underline accelerators. Exported functions to select and activate menu items in a menushell. * gtk/testgtk.c: Added a new "Item Factory" test which tests GtkItemFactory and the new keyboard navigation of menus.
1998-08-12 16:49:13 +00:00
}
static gboolean
compute_child_offset (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GtkWidget *menu_item,
gint *offset,
gint *height,
gboolean *is_last_child)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gint item_top_attach;
gint item_bottom_attach;
gint child_offset = 0;
gint i;
get_effective_child_attach (menu_item, NULL, NULL,
2010-12-23 20:50:18 +00:00
&item_top_attach, &item_bottom_attach);
2010-12-23 20:50:18 +00:00
/* there is a possibility that we get called before _size_request,
* so check the height table for safety.
*/
if (!priv->heights || priv->heights_length < gtk_menu_get_n_rows (menu))
return FALSE;
/* when we have a row with only invisible children, its height will
* be zero, so there's no need to check WIDGET_VISIBLE here
*/
for (i = 0; i < item_top_attach; i++)
child_offset += priv->heights[i];
if (is_last_child)
*is_last_child = (item_bottom_attach == gtk_menu_get_n_rows (menu));
if (offset)
*offset = child_offset;
if (height)
*height = priv->heights[item_top_attach];
return TRUE;
}
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.
2000-11-08 17:34:52 +00:00
static void
gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *menu_item)
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.
2000-11-08 17:34:52 +00:00
{
GtkMenu *menu = GTK_MENU (menu_shell);
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkWidget *widget = GTK_WIDGET (menu_shell);
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.
2000-11-08 17:34:52 +00:00
gint child_offset, child_height;
gint height;
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.
2000-11-08 17:34:52 +00:00
gint y;
gint arrow_height;
gboolean last_child = 0;
/* We need to check if the selected item fully visible.
* If not we need to scroll the menu so that it becomes fully
* visible.
*/
if (compute_child_offset (menu, menu_item,
2010-12-23 20:50:18 +00:00
&child_offset, &child_height, &last_child))
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.
2000-11-08 17:34:52 +00:00
{
gboolean double_arrows;
GtkBorder padding;
2010-12-23 20:50:18 +00:00
y = priv->scroll_offset;
height = gdk_window_get_height (gtk_widget_get_window (widget));
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.
2000-11-08 17:34:52 +00:00
double_arrows = get_double_arrows (menu);
get_menu_padding (widget, &padding);
height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) +
padding.top + padding.bottom;
if (child_offset < y)
2010-12-23 20:50:18 +00:00
{
/* Ignore the enter event we might get if the pointer
* is on the menu
*/
menu_shell->priv->ignore_enter = TRUE;
2010-12-23 20:50:18 +00:00
gtk_menu_scroll_to (menu, child_offset);
}
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.
2000-11-08 17:34:52 +00:00
else
2010-12-23 20:50:18 +00:00
{
GtkBorder arrow_border;
arrow_height = 0;
get_arrows_border (menu, &arrow_border);
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
arrow_height = arrow_border.top + arrow_border.bottom;
2010-12-23 20:50:18 +00:00
if (child_offset + child_height > y + height - arrow_height)
{
arrow_height = 0;
if ((!last_child && !priv->tearoff_active) || double_arrows)
arrow_height += arrow_border.bottom;
y = child_offset + child_height - height + arrow_height;
if (((y > 0) && !priv->tearoff_active) || double_arrows)
{
/* Need upper arrow */
arrow_height += arrow_border.top;
y = child_offset + child_height - height + arrow_height;
}
/* Ignore the enter event we might get if the pointer
* is on the menu
*/
menu_shell->priv->ignore_enter = TRUE;
2010-12-23 20:50:18 +00:00
gtk_menu_scroll_to (menu, y);
}
}
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.
2000-11-08 17:34:52 +00:00
}
}
static void
gtk_menu_select_item (GtkMenuShell *menu_shell,
2010-12-23 20:50:18 +00:00
GtkWidget *menu_item)
{
GtkMenu *menu = GTK_MENU (menu_shell);
if (gtk_widget_get_realized (GTK_WIDGET (menu)))
gtk_menu_scroll_item_visible (menu_shell, menu_item);
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.
2000-11-08 17:34:52 +00:00
2006-05-02 23:56:43 +00:00
GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->select_item (menu_shell, menu_item);
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.
2000-11-08 17:34:52 +00:00
}
/* Reparent the menu, taking care of the refcounting
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.
2000-11-08 17:34:52 +00:00
*
* If unrealize is true we force a unrealize while reparenting the parent.
* This can help eliminate flicker in some cases.
*
* What happens is that when the menu is unrealized and then re-realized,
* the allocations are as follows:
*
2010-12-23 20:50:18 +00:00
* parent - 1x1 at (0,0)
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.
2000-11-08 17:34:52 +00:00
* child1 - 100x20 at (0,0)
* child2 - 100x20 at (0,20)
* child3 - 100x20 at (0,40)
*
* That is, the parent is small but the children are full sized. Then,
* when the queued_resize gets processed, the parent gets resized to
2010-12-23 20:50:18 +00:00
* full size.
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.
2000-11-08 17:34:52 +00:00
*
* But in order to eliminate flicker when scrolling, gdkgeometry-x11.c
* contains the following logic:
2010-12-23 20:50:18 +00:00
*
* - if a move or resize operation on a window would change the clip
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.
2000-11-08 17:34:52 +00:00
* region on the children, then before the window is resized
* the background for children is temporarily set to None, the
* move/resize done, and the background for the children restored.
*
* So, at the point where the parent is resized to final size, the
* background for the children is temporarily None, and thus they
* are not cleared to the background color and the previous background
* (the image of the menu) is left in place.
*/
2010-12-23 20:50:18 +00:00
static void
gtk_menu_reparent (GtkMenu *menu,
GtkWidget *new_parent,
gboolean unrealize)
{
GObject *object = G_OBJECT (menu);
GtkWidget *widget = GTK_WIDGET (menu);
gboolean was_floating = g_object_is_floating (object);
GTK_MENU_DIR_CHILD: check for the existance of Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_real_menu_shell_move_current): GTK_MENU_DIR_CHILD: check for the existance of menu_shell->active_menu_item before accessing its child. GTK_MENU_DIR_PREV: GTK_MENU_DIR_NEXT: if we haven't had an active item and still don't, make a default selection. Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_propagate_state): iterate the children with _forall for sensitivity changes and with _foreach on pure state changes. this fixes a lot of the old inclusions of internal widgets into _foreach calls. * gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall do the work. don't walk the subtrees of first level children. * gtk/gtktreeitem.c: provide a _forall implementation, which walks the subtrees as well for include_internals. * gtk/gtkmenuitem.c: provide a _forall implementation, which walks the submenus as well for include_internals. * gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and implemented gtk_scrolled_window_forall, which will iterate over the viewport and the scrollbars for gtk_container_forall or iterate over the viewports children for gtk_container_foreach. * gtk/gtktoolbar.c: * gtk/gtktable.c: * gtk/gtkpaned.c: * gtk/gtkpacker.c: * gtk/gtkmenushell.c: * gtk/gtklist.c: * gtk/gtkfixed.c: * gtk/gtkclist.c: * gtk/gtkbox.c: * gtk/gtkbin.c: * gtk/gtknotebook.c: removed the old gtk_*_foreach functions and provided gtk_*_forall. * gtk/gtknotebook.c: (gtk_notebook_real_switch_page): expose tabs. (gtk_notebook_page_num): new function to return the page number of a distinct child. (gtk_notebook_focus): minor fixups. foxus handling is still screwed under some circumstances. * gtk/gtktreeitem.c: (gtk_real_tree_item_select): (gtk_real_tree_item_deselect): major fixes. some general fixups wrt queue_redraw, and tree items not being NO_WINDOW widgets. * gtk/gtklistitem.c: (gtk_real_list_item_select): (gtk_real_list_item_deselect): (gtk_real_list_item_toggle): removed unneccessary queue_redraw calls. Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: allow optionmenus to have the focus and automatically popup the menu on space bar. Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class method), which acts similar to gtk_container_foreach(), but iterates over internal children. the GtkContainer::foreach signal vanished in favour of a new class method ->forall() that optionally includes internal widgets. * gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation but a _forall implementation, since all child widgets we have are internal ones. (column_button_create): set the parent window prior to gtk_widget_set_parent(). * gtk/gtkwidget.c: exchanged all calls to gtk_container_foreach() with gtk_container_forall(). * gtk/gtkwidget.h: * gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through the GtkWidget::composite_child argument. to have a widget created with the flag initially, two new functions got added to wrap a widgets creation: gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag(). Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktooltips.h: * gtk/gtktooltips.c: exported gtk_tooltips_create_window() as gtk_tooltips_force_window(), so tooltips->tip_window can be accessed prior to the first tip being set. don't put an extra reference on the window, since it is a toplevel, it wont get destroyed from anywhere else. * overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
g_object_ref_sink (object);
if (unrealize)
{
g_object_ref (object);
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (object);
}
else
gtk_widget_reparent (widget, new_parent);
if (was_floating)
g_object_force_floating (object);
else
g_object_unref (object);
}
GTK_MENU_DIR_CHILD: check for the existance of Thu Sep 3 04:22:20 1998 Tim Janik <timj@gtk.org> * gtk/gtkmenushell.c (gtk_real_menu_shell_move_current): GTK_MENU_DIR_CHILD: check for the existance of menu_shell->active_menu_item before accessing its child. GTK_MENU_DIR_PREV: GTK_MENU_DIR_NEXT: if we haven't had an active item and still don't, make a default selection. Wed Sep 2 00:28:58 1998 Tim Janik <timj@gtk.org> * gtk/gtkwidget.c (gtk_widget_propagate_state): iterate the children with _forall for sensitivity changes and with _foreach on pure state changes. this fixes a lot of the old inclusions of internal widgets into _foreach calls. * gtk/gtktree.c: removed gtk_tree_foreach, let gtk_tree_forall do the work. don't walk the subtrees of first level children. * gtk/gtktreeitem.c: provide a _forall implementation, which walks the subtrees as well for include_internals. * gtk/gtkmenuitem.c: provide a _forall implementation, which walks the submenus as well for include_internals. * gtk/gtkscrolledwindow.c: removed gtk_scrolled_window_foreach and implemented gtk_scrolled_window_forall, which will iterate over the viewport and the scrollbars for gtk_container_forall or iterate over the viewports children for gtk_container_foreach. * gtk/gtktoolbar.c: * gtk/gtktable.c: * gtk/gtkpaned.c: * gtk/gtkpacker.c: * gtk/gtkmenushell.c: * gtk/gtklist.c: * gtk/gtkfixed.c: * gtk/gtkclist.c: * gtk/gtkbox.c: * gtk/gtkbin.c: * gtk/gtknotebook.c: removed the old gtk_*_foreach functions and provided gtk_*_forall. * gtk/gtknotebook.c: (gtk_notebook_real_switch_page): expose tabs. (gtk_notebook_page_num): new function to return the page number of a distinct child. (gtk_notebook_focus): minor fixups. foxus handling is still screwed under some circumstances. * gtk/gtktreeitem.c: (gtk_real_tree_item_select): (gtk_real_tree_item_deselect): major fixes. some general fixups wrt queue_redraw, and tree items not being NO_WINDOW widgets. * gtk/gtklistitem.c: (gtk_real_list_item_select): (gtk_real_list_item_deselect): (gtk_real_list_item_toggle): removed unneccessary queue_redraw calls. Wed Aug 30 09:42:07 1998 Tim Janik <timj@gtk.org> * gtk/gtkoptionmenu.c: allow optionmenus to have the focus and automatically popup the menu on space bar. Wed Aug 26 06:40:34 1998 Tim Janik <timj@gtk.org> * gtk/gtkcontainer.h: * gtk/gtkcontainer.c: implemented gtk_container_forall() (as a class method), which acts similar to gtk_container_foreach(), but iterates over internal children. the GtkContainer::foreach signal vanished in favour of a new class method ->forall() that optionally includes internal widgets. * gtk/gtkclist.c (gtk_clist_init): provide no _foreach implementation but a _forall implementation, since all child widgets we have are internal ones. (column_button_create): set the parent window prior to gtk_widget_set_parent(). * gtk/gtkwidget.c: exchanged all calls to gtk_container_foreach() with gtk_container_forall(). * gtk/gtkwidget.h: * gtk/gtkwidget.c: added the GTK_COMPOSITE_CHILD, exported through the GtkWidget::composite_child argument. to have a widget created with the flag initially, two new functions got added to wrap a widgets creation: gtk_widget_push_composite_flag() and gtk_widget_pop_composite_flag(). Wed Aug 25 23:37:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktooltips.h: * gtk/gtktooltips.c: exported gtk_tooltips_create_window() as gtk_tooltips_force_window(), so tooltips->tip_window can be accessed prior to the first tip being set. don't put an extra reference on the window, since it is a toplevel, it wont get destroyed from anywhere else. * overall macro and GtkType fixups.
1998-09-03 02:38:53 +00:00
static void
gtk_menu_show_all (GtkWidget *widget)
{
/* Show children, but not self. */
gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_show_all, NULL);
}
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
/**
* gtk_menu_set_screen:
2010-12-23 20:50:18 +00:00
* @menu: a #GtkMenu
* @screen: (allow-none): a #GdkScreen, or %NULL if the screen should be
2010-12-23 20:50:18 +00:00
* determined by the widget the menu is attached to
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
*
* Sets the #GdkScreen on which the menu will be displayed.
*
2002-11-28 00:33:17 +00:00
* Since: 2.2
2010-12-23 20:50:18 +00:00
*/
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
void
2010-12-23 20:50:18 +00:00
gtk_menu_set_screen (GtkMenu *menu,
GdkScreen *screen)
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
{
g_return_if_fail (GTK_IS_MENU (menu));
2010-12-23 20:50:18 +00:00
g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-explicit-screen"), screen);
if (screen)
{
menu_change_screen (menu, screen);
}
else
{
GtkWidget *attach_widget = gtk_menu_get_attach_widget (menu);
if (attach_widget)
2010-12-23 20:50:18 +00:00
attach_widget_screen_changed (attach_widget, NULL, menu);
}
Integrate Erwann Chenede's multihead changes for the gtk/ directory. Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com> Integrate Erwann Chenede's multihead changes for the gtk/ directory. * gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(), make internals multihead aware. * gtk/gtkcolorsel.[ch]: Add gtk_color_selection_set_change_palette_with_screen_hook () [ugh!] make up for non-multihead safety of gtk_color_selection_set_change_palette_hook() * gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add gtk_{invisible,menu,window}_set_screen(); add "screen" properties for GtkWindow and GtkMenu. * gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(), gtk_plug_new_for_display(). Multihead fixes. * gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(), make internals multihead aware. * gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get rid of now-useless gtk_settings_constructor(). * gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix check/radio button indicators bitmap handling to be multihead safe. * gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(), gtk_widget_get_display(), gtk_widget_get_clipboard(), gtk_widget_get_root_window(). * gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c: misc mechanical multihead-safety fixes. * gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for the dropper, look up the color palette only at realization time, other multihead fixes. * gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when unrealizing. * gtk/gtkentry.c: Only claim ownership of the primary selection when realized, misc multihead fixes. * gtk/gtkfontsel.c: Only fill in fonts when attached to a screen, fix gtk_font_selection_get_font() for multihead. * gtk/gtkgc.c: make the depth => drawable hash per-screen. * gtk/gtkinvisible.c: Add a constructor that realizes the widget, so we get a realized widget with g_object_new() as well gtk_invisible_new() as before. * gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap variables. * gtk/gtktextdisplay.c: Add warnings if stipple bitmaps are used on the wrong screen. * gtk/gtktoolbar.c: Make handling of GtkSettings-based layout read properties and connect to settings when the screen is changed, rather than on init/finalize. * gtk/gtkwindow.c: Fix icon handing to be multihead safe ... default icon pixmaps/mask are only shared between windows on the same screen. Misc multihead fixes. Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkclipboard.c (gtk_clipboard_get_for_display): Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE. 2002-04-29 Alex Larsson <alexl@redhat.com> * gdk/linux-fb/gdkproperty-fb.c (gdk_property_get): Fix silly bug, noticed by Sven Neumann. Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org> * gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
}
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.
2000-11-08 17:34:52 +00:00
/**
* gtk_menu_attach:
2010-12-23 20:50:18 +00:00
* @menu: a #GtkMenu
* @child: a #GtkMenuItem
* @left_attach: The column number to attach the left side of the item to
* @right_attach: The column number to attach the right side of the item to
* @top_attach: The row number to attach the top of the item to
* @bottom_attach: The row number to attach the bottom of the item to
*
* Adds a new #GtkMenuItem to a (table) menu. The number of 'cells' that
* an item will occupy is specified by @left_attach, @right_attach,
* @top_attach and @bottom_attach. These each represent the leftmost,
* rightmost, uppermost and lower column and row numbers of the table.
* (Columns and rows are indexed from zero).
*
* Note that this function is not related to gtk_menu_detach().
*
* Since: 2.4
2010-12-23 20:50:18 +00:00
*/
void
gtk_menu_attach (GtkMenu *menu,
GtkWidget *child,
guint left_attach,
guint right_attach,
guint top_attach,
guint bottom_attach)
{
GtkMenuShell *menu_shell;
GtkWidget *parent;
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_MENU_ITEM (child));
parent = gtk_widget_get_parent (child);
g_return_if_fail (parent == NULL || parent == GTK_WIDGET (menu));
g_return_if_fail (left_attach < right_attach);
g_return_if_fail (top_attach < bottom_attach);
menu_shell = GTK_MENU_SHELL (menu);
if (!parent)
{
AttachInfo *ai = get_attach_info (child);
2010-12-23 20:50:18 +00:00
ai->left_attach = left_attach;
ai->right_attach = right_attach;
ai->top_attach = top_attach;
ai->bottom_attach = bottom_attach;
2010-12-23 20:50:18 +00:00
menu_shell->priv->children = g_list_append (menu_shell->priv->children, child);
gtk_widget_set_parent (child, GTK_WIDGET (menu));
menu_queue_resize (menu);
}
else
{
gtk_container_child_set (GTK_CONTAINER (parent), child,
2010-12-23 20:50:18 +00:00
"left-attach", left_attach,
"right-attach", right_attach,
"top-attach", top_attach,
"bottom-attach", bottom_attach,
NULL);
}
}
static gint
gtk_menu_get_popup_delay (GtkMenuShell *menu_shell)
{
gint popup_delay;
g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
2010-12-23 20:50:18 +00:00
"gtk-menu-popup-delay", &popup_delay,
NULL);
return popup_delay;
}
static GtkWidget *
find_child_containing (GtkMenuShell *menu_shell,
int left,
int right,
int top,
int bottom)
{
GList *list;
/* find a child which includes the area given by
* left, right, top, bottom.
*/
for (list = menu_shell->priv->children; list; list = list->next)
{
gint l, r, t, b;
if (!_gtk_menu_item_is_selectable (list->data))
continue;
get_effective_child_attach (list->data, &l, &r, &t, &b);
2010-12-23 20:50:18 +00:00
if (l <= left && right <= r && t <= top && bottom <= b)
return GTK_WIDGET (list->data);
}
return NULL;
}
static void
gtk_menu_move_current (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction)
{
GtkMenu *menu = GTK_MENU (menu_shell);
Support vertical menubars (#166632): 2005-02-11 Matthias Clasen <mclasen@redhat.com> Support vertical menubars (#166632): * gtk/gtkenums.h (GtkPackDirection): New enumeration for pack directions, with values for left-to-right, right-to-left, top-to-bottom and bottom-to-top. * gtk/gtk.symbols: * gtk/gtkmenubar.h: * gtk/gtkmenubar.c: Add two properties, pack-direction and child-pack-direction, which specify how children and grandchildren of a menubar are packed, with getters and setters. * gtk/gtkmenubar.c (gtk_menu_bar_set_property): (gtk_menu_bar_get_property): Implement set_property and get_property. * gtk/gtkmenubar.c (gtk_menu_bar_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkmenubar.c (gtk_menu_bar_move_current): Implement move_current here move all the menubar-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenu.c (gtk_menu_move_current): Move menu-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenuitem.c (gtk_menu_item_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_request) (gtk_image_menu_item_size_allocate): (gtk_image_menu_item_toggle_size_request): Take child pack direction into account and pack the image vertically if necessary. * gtk/gtkmenushell.c (gtk_menu_shell_real_select_item): Set the submenu direction to left-right for menuitems in vertical menubars. (gtk_real_menu_shell_move_current): Simplify by moving direction tweaking to menu- and menubar-specific implementations. Take pack direction into account when doing fallbacks. * tests/testmenubars.c: Test menubars in various packing direction combinations. * tests/Makefile.am (noinst_PROGRAMS): Add testmenubars.
2005-02-11 07:15:11 +00:00
gint i;
gint l, r, t, b;
Support vertical menubars (#166632): 2005-02-11 Matthias Clasen <mclasen@redhat.com> Support vertical menubars (#166632): * gtk/gtkenums.h (GtkPackDirection): New enumeration for pack directions, with values for left-to-right, right-to-left, top-to-bottom and bottom-to-top. * gtk/gtk.symbols: * gtk/gtkmenubar.h: * gtk/gtkmenubar.c: Add two properties, pack-direction and child-pack-direction, which specify how children and grandchildren of a menubar are packed, with getters and setters. * gtk/gtkmenubar.c (gtk_menu_bar_set_property): (gtk_menu_bar_get_property): Implement set_property and get_property. * gtk/gtkmenubar.c (gtk_menu_bar_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkmenubar.c (gtk_menu_bar_move_current): Implement move_current here move all the menubar-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenu.c (gtk_menu_move_current): Move menu-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenuitem.c (gtk_menu_item_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_request) (gtk_image_menu_item_size_allocate): (gtk_image_menu_item_toggle_size_request): Take child pack direction into account and pack the image vertically if necessary. * gtk/gtkmenushell.c (gtk_menu_shell_real_select_item): Set the submenu direction to left-right for menuitems in vertical menubars. (gtk_real_menu_shell_move_current): Simplify by moving direction tweaking to menu- and menubar-specific implementations. Take pack direction into account when doing fallbacks. * tests/testmenubars.c: Test menubars in various packing direction combinations. * tests/Makefile.am (noinst_PROGRAMS): Add testmenubars.
2005-02-11 07:15:11 +00:00
GtkWidget *match = NULL;
if (gtk_widget_get_direction (GTK_WIDGET (menu_shell)) == GTK_TEXT_DIR_RTL)
{
switch (direction)
2010-12-23 20:50:18 +00:00
{
case GTK_MENU_DIR_CHILD:
direction = GTK_MENU_DIR_PARENT;
break;
case GTK_MENU_DIR_PARENT:
direction = GTK_MENU_DIR_CHILD;
break;
default: ;
}
Support vertical menubars (#166632): 2005-02-11 Matthias Clasen <mclasen@redhat.com> Support vertical menubars (#166632): * gtk/gtkenums.h (GtkPackDirection): New enumeration for pack directions, with values for left-to-right, right-to-left, top-to-bottom and bottom-to-top. * gtk/gtk.symbols: * gtk/gtkmenubar.h: * gtk/gtkmenubar.c: Add two properties, pack-direction and child-pack-direction, which specify how children and grandchildren of a menubar are packed, with getters and setters. * gtk/gtkmenubar.c (gtk_menu_bar_set_property): (gtk_menu_bar_get_property): Implement set_property and get_property. * gtk/gtkmenubar.c (gtk_menu_bar_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkmenubar.c (gtk_menu_bar_move_current): Implement move_current here move all the menubar-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenu.c (gtk_menu_move_current): Move menu-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenuitem.c (gtk_menu_item_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_request) (gtk_image_menu_item_size_allocate): (gtk_image_menu_item_toggle_size_request): Take child pack direction into account and pack the image vertically if necessary. * gtk/gtkmenushell.c (gtk_menu_shell_real_select_item): Set the submenu direction to left-right for menuitems in vertical menubars. (gtk_real_menu_shell_move_current): Simplify by moving direction tweaking to menu- and menubar-specific implementations. Take pack direction into account when doing fallbacks. * tests/testmenubars.c: Test menubars in various packing direction combinations. * tests/Makefile.am (noinst_PROGRAMS): Add testmenubars.
2005-02-11 07:15:11 +00:00
}
/* use special table menu key bindings */
if (menu_shell->priv->active_menu_item && gtk_menu_get_n_columns (menu) > 1)
{
get_effective_child_attach (menu_shell->priv->active_menu_item, &l, &r, &t, &b);
if (direction == GTK_MENU_DIR_NEXT)
{
2010-12-23 20:50:18 +00:00
for (i = b; i < gtk_menu_get_n_rows (menu); i++)
{
match = find_child_containing (menu_shell, l, l + 1, i, i + 1);
if (match)
break;
}
2010-12-23 20:50:18 +00:00
if (!match)
{
/* wrap around */
for (i = 0; i < t; i++)
{
match = find_child_containing (menu_shell,
l, l + 1, i, i + 1);
if (match)
break;
2010-12-23 20:50:18 +00:00
}
}
}
else if (direction == GTK_MENU_DIR_PREV)
{
for (i = t; i > 0; i--)
{
2010-12-23 20:50:18 +00:00
match = find_child_containing (menu_shell,
l, l + 1, i - 1, i);
if (match)
break;
}
2010-12-23 20:50:18 +00:00
if (!match)
{
/* wrap around */
for (i = gtk_menu_get_n_rows (menu); i > b; i--)
{
match = find_child_containing (menu_shell,
l, l + 1, i - 1, i);
if (match)
2010-12-23 20:50:18 +00:00
break;
}
}
}
Support vertical menubars (#166632): 2005-02-11 Matthias Clasen <mclasen@redhat.com> Support vertical menubars (#166632): * gtk/gtkenums.h (GtkPackDirection): New enumeration for pack directions, with values for left-to-right, right-to-left, top-to-bottom and bottom-to-top. * gtk/gtk.symbols: * gtk/gtkmenubar.h: * gtk/gtkmenubar.c: Add two properties, pack-direction and child-pack-direction, which specify how children and grandchildren of a menubar are packed, with getters and setters. * gtk/gtkmenubar.c (gtk_menu_bar_set_property): (gtk_menu_bar_get_property): Implement set_property and get_property. * gtk/gtkmenubar.c (gtk_menu_bar_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkmenubar.c (gtk_menu_bar_move_current): Implement move_current here move all the menubar-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenu.c (gtk_menu_move_current): Move menu-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenuitem.c (gtk_menu_item_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_request) (gtk_image_menu_item_size_allocate): (gtk_image_menu_item_toggle_size_request): Take child pack direction into account and pack the image vertically if necessary. * gtk/gtkmenushell.c (gtk_menu_shell_real_select_item): Set the submenu direction to left-right for menuitems in vertical menubars. (gtk_real_menu_shell_move_current): Simplify by moving direction tweaking to menu- and menubar-specific implementations. Take pack direction into account when doing fallbacks. * tests/testmenubars.c: Test menubars in various packing direction combinations. * tests/Makefile.am (noinst_PROGRAMS): Add testmenubars.
2005-02-11 07:15:11 +00:00
else if (direction == GTK_MENU_DIR_PARENT)
{
/* we go one left if possible */
if (l > 0)
2010-12-23 20:50:18 +00:00
match = find_child_containing (menu_shell,
l - 1, l, t, t + 1);
if (!match)
{
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
if (!parent
|| g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1)
match = menu_shell->priv->active_menu_item;
}
}
Support vertical menubars (#166632): 2005-02-11 Matthias Clasen <mclasen@redhat.com> Support vertical menubars (#166632): * gtk/gtkenums.h (GtkPackDirection): New enumeration for pack directions, with values for left-to-right, right-to-left, top-to-bottom and bottom-to-top. * gtk/gtk.symbols: * gtk/gtkmenubar.h: * gtk/gtkmenubar.c: Add two properties, pack-direction and child-pack-direction, which specify how children and grandchildren of a menubar are packed, with getters and setters. * gtk/gtkmenubar.c (gtk_menu_bar_set_property): (gtk_menu_bar_get_property): Implement set_property and get_property. * gtk/gtkmenubar.c (gtk_menu_bar_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkmenubar.c (gtk_menu_bar_move_current): Implement move_current here move all the menubar-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenu.c (gtk_menu_move_current): Move menu-specific direction tweaking from the generic menushell implementation here. * gtk/gtkmenuitem.c (gtk_menu_item_size_request): (gtk_menu_bar_size_allocate): Take pack direction into account. * gtk/gtkimagemenuitem.c (gtk_image_menu_item_size_request) (gtk_image_menu_item_size_allocate): (gtk_image_menu_item_toggle_size_request): Take child pack direction into account and pack the image vertically if necessary. * gtk/gtkmenushell.c (gtk_menu_shell_real_select_item): Set the submenu direction to left-right for menuitems in vertical menubars. (gtk_real_menu_shell_move_current): Simplify by moving direction tweaking to menu- and menubar-specific implementations. Take pack direction into account when doing fallbacks. * tests/testmenubars.c: Test menubars in various packing direction combinations. * tests/Makefile.am (noinst_PROGRAMS): Add testmenubars.
2005-02-11 07:15:11 +00:00
else if (direction == GTK_MENU_DIR_CHILD)
{
/* we go one right if possible */
2010-12-23 20:50:18 +00:00
if (r < gtk_menu_get_n_columns (menu))
match = find_child_containing (menu_shell, r, r + 1, t, t + 1);
if (!match)
{
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
if (! GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->priv->submenu &&
(!parent ||
g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1))
match = menu_shell->priv->active_menu_item;
}
}
if (match)
{
2010-12-23 20:50:18 +00:00
gtk_menu_shell_select_item (menu_shell, match);
return;
}
}
2006-05-02 23:56:43 +00:00
GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->move_current (menu_shell, direction);
}
static gint
get_visible_size (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (menu);
GtkContainer *container = GTK_CONTAINER (menu);
GtkBorder padding;
gint menu_height;
gtk_widget_get_allocation (widget, &allocation);
get_menu_padding (widget, &padding);
menu_height = (allocation.height -
(2 * gtk_container_get_border_width (container)) -
padding.top - padding.bottom);
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
menu_height -= arrow_border.top;
menu_height -= arrow_border.bottom;
}
2010-12-23 20:50:18 +00:00
return menu_height;
}
/* Find the sensitive on-screen child containing @y, or if none,
* the nearest selectable onscreen child. (%NULL if none)
*/
static GtkWidget *
child_at (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint y)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
GtkWidget *child = NULL;
gint child_offset = 0;
GList *children;
gint menu_height;
2010-12-23 20:50:18 +00:00
gint lower, upper; /* Onscreen bounds */
menu_height = get_visible_size (menu);
2010-12-23 20:50:18 +00:00
lower = priv->scroll_offset;
upper = priv->scroll_offset + menu_height;
for (children = menu_shell->priv->children; children; children = children->next)
{
if (gtk_widget_get_visible (children->data))
2010-12-23 20:50:18 +00:00
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (children->data,
&child_requisition, NULL);
2010-12-23 20:50:18 +00:00
if (_gtk_menu_item_is_selectable (children->data) &&
child_offset >= lower &&
child_offset + child_requisition.height <= upper)
{
child = children->data;
if (child_offset + child_requisition.height > y &&
!GTK_IS_TEAROFF_MENU_ITEM (child))
return child;
}
child_offset += child_requisition.height;
}
}
return child;
}
static gint
get_menu_height (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
GtkWidget *widget = GTK_WIDGET (menu);
GtkBorder padding;
gint height;
get_menu_padding (widget, &padding);
height = priv->requested_height;
height -= (gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2) +
padding.top + padding.bottom;
2010-12-23 20:50:18 +00:00
if (!priv->tearoff_active)
{
GtkBorder arrow_border;
get_arrows_border (menu, &arrow_border);
height -= arrow_border.top;
height -= arrow_border.bottom;
}
return height;
}
static void
gtk_menu_real_move_scroll (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
GtkScrollType type)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gint page_size = get_visible_size (menu);
gint end_position = get_menu_height (menu);
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
2010-12-23 20:50:18 +00:00
switch (type)
{
case GTK_SCROLL_PAGE_UP:
case GTK_SCROLL_PAGE_DOWN:
{
2010-12-23 20:50:18 +00:00
gint old_offset;
gint new_offset;
2010-12-23 20:50:18 +00:00
gint child_offset = 0;
gboolean old_upper_arrow_visible;
gint step;
if (type == GTK_SCROLL_PAGE_UP)
step = - page_size;
else
step = page_size;
if (menu_shell->priv->active_menu_item)
2010-12-23 20:50:18 +00:00
{
gint child_height;
compute_child_offset (menu, menu_shell->priv->active_menu_item,
2010-12-23 20:50:18 +00:00
&child_offset, &child_height, NULL);
child_offset += child_height / 2;
}
menu_shell->priv->ignore_enter = TRUE;
2010-12-23 20:50:18 +00:00
old_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
old_offset = priv->scroll_offset;
new_offset = priv->scroll_offset + step;
new_offset = CLAMP (new_offset, 0, end_position - page_size);
gtk_menu_scroll_to (menu, new_offset);
2010-12-23 20:50:18 +00:00
if (menu_shell->priv->active_menu_item)
2010-12-23 20:50:18 +00:00
{
GtkWidget *new_child;
gboolean new_upper_arrow_visible = priv->upper_arrow_visible && !priv->tearoff_active;
GtkBorder arrow_border;
2010-12-23 20:50:18 +00:00
get_arrows_border (menu, &arrow_border);
2010-12-23 20:50:18 +00:00
if (priv->scroll_offset != old_offset)
step = priv->scroll_offset - old_offset;
2010-12-23 20:50:18 +00:00
step -= (new_upper_arrow_visible - old_upper_arrow_visible) * arrow_border.top;
2010-12-23 20:50:18 +00:00
new_child = child_at (menu, child_offset + step);
if (new_child)
gtk_menu_shell_select_item (menu_shell, new_child);
}
}
break;
case GTK_SCROLL_START:
2010-12-23 20:50:18 +00:00
/* Ignore the enter event we might get if the pointer is on the menu */
menu_shell->priv->ignore_enter = TRUE;
gtk_menu_shell_select_first (menu_shell, TRUE);
break;
case GTK_SCROLL_END:
2010-12-23 20:50:18 +00:00
/* Ignore the enter event we might get if the pointer is on the menu */
menu_shell->priv->ignore_enter = TRUE;
_gtk_menu_shell_select_last (menu_shell, TRUE);
break;
default:
break;
}
}
/**
* gtk_menu_set_monitor:
* @menu: a #GtkMenu
* @monitor_num: the number of the monitor on which the menu should
* be popped up
2010-12-23 20:50:18 +00:00
*
* Informs GTK+ on which monitor a menu should be popped up.
* See gdk_screen_get_monitor_geometry().
*
2010-12-23 20:50:18 +00:00
* This function should be called from a #GtkMenuPositionFunc
* if the menu should not appear on the same monitor as the pointer.
* This information can't be reliably inferred from the coordinates
* returned by a #GtkMenuPositionFunc, since, for very long menus,
* these coordinates may extend beyond the monitor boundaries or even
* the screen boundaries.
*
* Since: 2.4
2010-12-23 20:50:18 +00:00
*/
void
gtk_menu_set_monitor (GtkMenu *menu,
2010-12-23 20:50:18 +00:00
gint monitor_num)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
g_return_if_fail (GTK_IS_MENU (menu));
priv->monitor_num = monitor_num;
}
/**
* gtk_menu_get_monitor:
* @menu: a #GtkMenu
*
* Retrieves the number of the monitor on which to show the menu.
*
* Returns: the number of the monitor on which the menu should
* be popped up or -1, if no monitor has been set
*
* Since: 2.14
2010-12-23 20:50:18 +00:00
*/
gint
gtk_menu_get_monitor (GtkMenu *menu)
{
g_return_val_if_fail (GTK_IS_MENU (menu), -1);
2010-12-23 20:50:18 +00:00
return menu->priv->monitor_num;
}
/**
* gtk_menu_get_for_attach_widget:
* @widget: a #GtkWidget
*
* Returns a list of the menus which are attached to this widget.
* This list is owned by GTK+ and must not be modified.
*
2010-12-23 20:50:18 +00:00
* Return value: (element-type GtkWidget) (transfer none): the list
* of menus attached to his widget.
*
* Since: 2.6
2010-12-23 20:50:18 +00:00
*/
GList*
gtk_menu_get_for_attach_widget (GtkWidget *widget)
{
GList *list;
2010-12-23 20:50:18 +00:00
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
2010-12-23 20:50:18 +00:00
list = g_object_get_data (G_OBJECT (widget), ATTACHED_MENUS);
2010-12-23 20:50:18 +00:00
return list;
}
static void
gtk_menu_grab_notify (GtkWidget *widget,
2010-12-23 20:50:18 +00:00
gboolean was_grabbed)
{
GtkMenu *menu;
GtkWidget *toplevel;
GtkWindowGroup *group;
GtkWidget *grab;
2010-05-25 22:38:44 +00:00
GdkDevice *pointer;
menu = GTK_MENU (widget);
pointer = _gtk_menu_shell_get_grab_device (GTK_MENU_SHELL (widget));
2010-05-25 22:38:44 +00:00
if (!pointer ||
!gtk_widget_device_is_shadowed (widget, pointer))
return;
toplevel = gtk_widget_get_toplevel (widget);
2010-05-25 22:38:44 +00:00
if (!GTK_IS_WINDOW (toplevel))
return;
group = gtk_window_get_group (GTK_WINDOW (toplevel));
2010-05-25 22:38:44 +00:00
grab = gtk_window_group_get_current_device_grab (group, pointer);
if (GTK_MENU_SHELL (widget)->priv->active && !GTK_IS_MENU_SHELL (grab))
2010-05-25 22:38:44 +00:00
gtk_menu_shell_cancel (GTK_MENU_SHELL (widget));
menu->priv->drag_scroll_started = FALSE;
}
/**
* gtk_menu_set_reserve_toggle_size:
* @menu: a #GtkMenu
* @reserve_toggle_size: whether to reserve size for toggles
*
2010-12-23 20:50:18 +00:00
* Sets whether the menu should reserve space for drawing toggles
* or icons, regardless of their actual presence.
*
* Since: 2.18
*/
void
gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
gboolean reserve_toggle_size)
{
2010-12-23 20:50:18 +00:00
GtkMenuPrivate *priv = menu->priv;
gboolean no_toggle_size;
2010-12-23 20:50:18 +00:00
g_return_if_fail (GTK_IS_MENU (menu));
no_toggle_size = !reserve_toggle_size;
if (priv->no_toggle_size != no_toggle_size)
{
priv->no_toggle_size = no_toggle_size;
g_object_notify (G_OBJECT (menu), "reserve-toggle-size");
}
}
/**
* gtk_menu_get_reserve_toggle_size:
* @menu: a #GtkMenu
*
* Returns whether the menu reserves space for toggles and
* icons, regardless of their actual presence.
*
* Returns: Whether the menu reserves toggle space
*
* Since: 2.18
*/
gboolean
gtk_menu_get_reserve_toggle_size (GtkMenu *menu)
{
2010-12-23 20:50:18 +00:00
g_return_val_if_fail (GTK_IS_MENU (menu), FALSE);
2010-12-23 20:50:18 +00:00
return !menu->priv->no_toggle_size;
}
/**
* gtk_menu_new_from_model:
* @model: a #GMenuModel
*
* Creates a #GtkMenu and populates it with menu items and
* submenus according to @model.
*
* The created menu items are connected to actions found in the
* #GtkApplicationWindow to which the menu belongs - typically
* by means of being attached to a widget (see gtk_menu_attach_to_widget())
* that is contained within the #GtkApplicationWindows widget hierarchy.
*
* Returns: a new #GtkMenu
*
* Since: 3.4
*/
GtkWidget *
gtk_menu_new_from_model (GMenuModel *model)
{
GtkWidget *menu;
g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL);
menu = gtk_menu_new ();
gtk_menu_shell_bind_model (GTK_MENU_SHELL (menu), model, NULL, TRUE);
return menu;
}