2008-07-01 22:57:50 +00:00
|
|
|
|
/* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +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
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-09-03 15:23:17 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
2012-07-02 06:19:06 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*
|
2018-07-25 14:41:15 +00:00
|
|
|
|
* Applications can display a #GtkMenu as a popup menu by calling one of the
|
|
|
|
|
* gtk_menu_popup_*() function. The example below shows how an application can
|
|
|
|
|
* pop up a menu when the 3rd mouse button is pressed.
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*
|
2014-02-04 21:57:57 +00:00
|
|
|
|
* ## Connecting the popup signal handler.
|
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2014-03-29 04:24:15 +00:00
|
|
|
|
* // connect our handler which will popup the menu
|
2018-02-03 10:41:33 +00:00
|
|
|
|
* gesture = gtk_gesture_multi_press_new (window);
|
|
|
|
|
* gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture),
|
|
|
|
|
* GDK_BUTTON_SECONDARY);
|
2018-07-25 14:41:15 +00:00
|
|
|
|
* g_signal_connect (gesture, "begin", G_CALLBACK (my_popup_handler), menu);
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*
|
2014-02-04 21:57:57 +00:00
|
|
|
|
* ## Signal handler which displays a popup menu.
|
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
|
* |[<!-- language="C" -->
|
2018-02-03 10:41:33 +00:00
|
|
|
|
* static void
|
2018-07-25 14:41:15 +00:00
|
|
|
|
* my_popup_handler (GtkGesture *gesture,
|
|
|
|
|
* GdkEventSequence *sequence
|
|
|
|
|
* gpointer data)
|
2011-01-15 13:51:11 +00:00
|
|
|
|
* {
|
2018-02-03 10:41:33 +00:00
|
|
|
|
* GtkMenu *menu = data;
|
2018-07-25 14:41:15 +00:00
|
|
|
|
* const GdkEvent *event;
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*
|
2018-07-25 14:41:15 +00:00
|
|
|
|
* event = gtk_gesture_get_last_event (gesture, sequence);
|
|
|
|
|
* gtk_menu_popup_at_pointer (menu, event);
|
2011-01-15 13:51:11 +00:00
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
|
* ]|
|
2015-11-03 02:40:40 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2015-11-03 19:24:25 +00:00
|
|
|
|
* |[<!-- language="plain" -->
|
|
|
|
|
* menu
|
|
|
|
|
* ├── arrow.top
|
2015-12-16 15:55:52 +00:00
|
|
|
|
* ├── <child>
|
|
|
|
|
* ┊
|
|
|
|
|
* ├── <child>
|
2015-11-03 19:24:25 +00:00
|
|
|
|
* ╰── arrow.bottom
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2015-11-03 02:40:40 +00:00
|
|
|
|
* The main CSS node of GtkMenu has name menu, and there are two subnodes
|
|
|
|
|
* with name arrow, for scrolling menu arrows. These subnodes get the
|
|
|
|
|
* .top and .bottom style classes.
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2011-01-04 17:21:41 +00:00
|
|
|
|
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkmenuprivate.h"
|
2011-01-04 17:21:41 +00:00
|
|
|
|
|
2003-09-11 21:02:24 +00:00
|
|
|
|
#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"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
#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"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkbox.h"
|
2015-12-19 01:52:16 +00:00
|
|
|
|
#include "gtkcheckmenuitemprivate.h"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkcssnodeprivate.h"
|
|
|
|
|
#include "gtkcssstylepropertyprivate.h"
|
|
|
|
|
#include "gtkdnd.h"
|
|
|
|
|
#include "gtkeventcontrollerscroll.h"
|
|
|
|
|
#include "gtkiconprivate.h"
|
|
|
|
|
#include "gtkintl.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
#include "gtkmain.h"
|
2002-12-14 22:43:52 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2010-12-27 01:36:51 +00:00
|
|
|
|
#include "gtkmenuitemprivate.h"
|
2010-12-23 23:21:53 +00:00
|
|
|
|
#include "gtkmenushellprivate.h"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkprivate.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"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtksnapshot.h"
|
|
|
|
|
#include "gtkstylecontextprivate.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkwidgetpath.h"
|
2011-12-12 17:11:57 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include "gtkwindowgroup.h"
|
2014-06-06 22:00:36 +00:00
|
|
|
|
#include "gtkwindowprivate.h"
|
2018-03-11 12:56:32 +00:00
|
|
|
|
#include "gtkeventcontrollerkey.h"
|
2011-10-01 03:49:48 +00:00
|
|
|
|
|
2011-07-02 02:30:54 +00:00
|
|
|
|
#include "a11y/gtkmenuaccessible.h"
|
2018-02-08 23:56:26 +00:00
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
#include "gdk/gdk-private.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2018-02-08 23:56:26 +00:00
|
|
|
|
#include <gobject/gvaluecollector.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
2002-10-29 19:44:59 +00:00
|
|
|
|
#define NAVIGATION_REGION_OVERSHOOT 50 /* How much the navigation region
|
2010-12-23 20:50:18 +00:00
|
|
|
|
* extends below the submenu
|
|
|
|
|
*/
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2008-09-03 15:23:17 +00:00
|
|
|
|
#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
|
|
|
|
|
2013-06-26 18:08:37 +00:00
|
|
|
|
#define MENU_POPUP_DELAY 225
|
|
|
|
|
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
|
2004-05-06 07:35:26 +00:00
|
|
|
|
#define ATTACHED_MENUS "gtk-attached-menus"
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
typedef struct _GtkMenuAttachData GtkMenuAttachData;
|
|
|
|
|
typedef struct _GtkMenuPopdownData GtkMenuPopdownData;
|
1998-02-03 14:13:05 +00:00
|
|
|
|
|
|
|
|
|
struct _GtkMenuAttachData
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *attach_widget;
|
|
|
|
|
GtkMenuDetachFunc detacher;
|
|
|
|
|
};
|
|
|
|
|
|
2010-05-25 22:38:44 +00:00
|
|
|
|
struct _GtkMenuPopdownData
|
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu;
|
|
|
|
|
GdkDevice *device;
|
|
|
|
|
};
|
|
|
|
|
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2004-03-15 02:03:59 +00:00
|
|
|
|
gint effective_top_attach;
|
|
|
|
|
} AttachInfo;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
enum {
|
|
|
|
|
MOVE_SCROLL,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
POPPED_UP,
|
2002-12-14 22:43:52 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2001-08-25 03:15:26 +00:00
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2008-06-20 11:06:52 +00:00
|
|
|
|
PROP_ACTIVE,
|
|
|
|
|
PROP_ACCEL_GROUP,
|
|
|
|
|
PROP_ACCEL_PATH,
|
|
|
|
|
PROP_ATTACH_WIDGET,
|
2004-05-07 04:43:56 +00:00
|
|
|
|
PROP_TEAROFF_STATE,
|
2008-06-20 11:06:52 +00:00
|
|
|
|
PROP_TEAROFF_TITLE,
|
2009-06-24 05:01:51 +00:00
|
|
|
|
PROP_MONITOR,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
PROP_RESERVE_TOGGLE_SIZE,
|
|
|
|
|
PROP_ANCHOR_HINTS,
|
|
|
|
|
PROP_RECT_ANCHOR_DX,
|
|
|
|
|
PROP_RECT_ANCHOR_DY,
|
|
|
|
|
PROP_MENU_TYPE_HINT
|
2001-08-25 03:15:26 +00:00
|
|
|
|
};
|
1998-02-03 14:13:05 +00:00
|
|
|
|
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +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);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
static void gtk_menu_get_property (GObject *object,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2016-06-05 23:34:30 +00:00
|
|
|
|
static void gtk_menu_finalize (GObject *object);
|
2010-09-18 23:55:42 +00:00
|
|
|
|
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);
|
2018-08-16 04:53:03 +00:00
|
|
|
|
static void gtk_menu_size_allocate (GtkWidget *widget,
|
|
|
|
|
int widget_width,
|
|
|
|
|
int widget_height,
|
|
|
|
|
int baseline);
|
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);
|
2016-12-17 19:46:25 +00:00
|
|
|
|
static void gtk_menu_snapshot (GtkWidget *widget,
|
|
|
|
|
GtkSnapshot *snapshot);
|
2018-01-02 18:22:36 +00:00
|
|
|
|
static void gtk_menu_motion (GtkEventController *controller,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_menu_enter (GtkEventController *controller,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2019-03-18 13:24:42 +00:00
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
|
GdkNotifyType detail,
|
2018-01-02 18:22:36 +00:00
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_menu_leave (GtkEventController *controller,
|
2019-03-18 13:24:42 +00:00
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
|
GdkNotifyType detail,
|
2018-01-02 18:22:36 +00:00
|
|
|
|
gpointer user_data);
|
2018-04-25 17:07:50 +00:00
|
|
|
|
static gboolean gtk_menu_key_pressed (GtkEventControllerKey *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
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_scroll_to (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint offset);
|
2005-06-27 17:36:34 +00:00
|
|
|
|
static void gtk_menu_grab_notify (GtkWidget *widget,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gboolean was_grabbed);
|
2011-12-12 17:11:57 +00:00
|
|
|
|
static gboolean gtk_menu_captured_event (GtkWidget *widget,
|
|
|
|
|
GdkEvent *event);
|
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean gtk_menu_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
2017-09-15 11:53:27 +00:00
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy,
|
|
|
|
|
GtkMenu *menu);
|
2002-11-09 20:52:31 +00:00
|
|
|
|
|
2006-02-22 10:10:23 +00:00
|
|
|
|
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);
|
2002-11-09 20:52:31 +00:00
|
|
|
|
|
2001-09-22 14:55:02 +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
|
|
|
|
static void gtk_menu_select_item (GtkMenuShell *menu_shell,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkWidget *menu_item);
|
2001-08-23 23:30:43 +00:00
|
|
|
|
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_handle_scrolling (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint event_x,
|
|
|
|
|
gint event_y,
|
2019-04-15 02:19:28 +00:00
|
|
|
|
gboolean enter);
|
2002-10-01 09:57:55 +00:00
|
|
|
|
static gboolean gtk_menu_focus (GtkWidget *widget,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkDirectionType direction);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static gint gtk_menu_get_popup_delay (GtkMenuShell *menu_shell);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
static void gtk_menu_move_current (GtkMenuShell *menu_shell,
|
|
|
|
|
GtkMenuDirectionType direction);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static void gtk_menu_real_move_scroll (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkScrollType type);
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
|
|
|
|
static void gtk_menu_stop_navigating_submenu (GtkMenu *menu);
|
|
|
|
|
static gboolean gtk_menu_navigating_submenu (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint event_x,
|
|
|
|
|
gint event_y);
|
2017-05-02 15:53:14 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
static void gtk_menu_deactivate (GtkMenuShell *menu_shell);
|
2010-10-31 19:52:32 +00:00
|
|
|
|
static void gtk_menu_position (GtkMenu *menu,
|
|
|
|
|
gboolean set_scroll_offset);
|
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
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
static void menu_grab_transfer_surface_destroy (GtkMenu *menu);
|
|
|
|
|
static GdkSurface *menu_grab_transfer_surface_get (GtkMenu *menu);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2003-11-27 15:51:32 +00:00
|
|
|
|
static gboolean gtk_menu_real_can_activate_accel (GtkWidget *widget,
|
|
|
|
|
guint signal_id);
|
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);
|
2016-10-22 14:06:14 +00:00
|
|
|
|
static void gtk_menu_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline);
|
2016-12-02 12:20:47 +00:00
|
|
|
|
static void gtk_menu_pressed_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
int n_press,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_menu_released_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
int n_press,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
|
|
|
|
|
2008-09-03 15:23:17 +00:00
|
|
|
|
static const gchar attach_data_key[] = "gtk-menu-attach-data";
|
1998-02-03 14:13:05 +00:00
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static guint menu_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2004-03-15 02:03:59 +00:00
|
|
|
|
static void
|
|
|
|
|
menu_queue_resize (GtkMenu *menu)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2004-03-15 02:03:59 +00:00
|
|
|
|
|
|
|
|
|
priv->have_layout = FALSE;
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (menu));
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-25 22:33:34 +00:00
|
|
|
|
static void
|
|
|
|
|
attach_info_free (AttachInfo *info)
|
|
|
|
|
{
|
|
|
|
|
g_slice_free (AttachInfo, info);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-15 02:03:59 +00:00
|
|
|
|
static AttachInfo *
|
|
|
|
|
get_attach_info (GtkWidget *child)
|
|
|
|
|
{
|
|
|
|
|
GObject *object = G_OBJECT (child);
|
|
|
|
|
AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
|
|
|
|
|
|
|
|
|
|
if (!ai)
|
|
|
|
|
{
|
2008-05-25 22:33:34 +00:00
|
|
|
|
ai = g_slice_new0 (AttachInfo);
|
2008-05-30 12:12:19 +00:00
|
|
|
|
g_object_set_data_full (object, I_(ATTACH_INFO_KEY), ai,
|
|
|
|
|
(GDestroyNotify) attach_info_free);
|
2004-03-15 02:03:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ai;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
menu_ensure_layout (GtkMenu *menu)
|
|
|
|
|
{
|
2011-01-04 17:32:22 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2004-03-15 02:03:59 +00:00
|
|
|
|
|
|
|
|
|
if (!priv->have_layout)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
|
|
|
|
|
GList *l;
|
|
|
|
|
gchar *row_occupied;
|
|
|
|
|
gint current_row;
|
|
|
|
|
gint max_bottom_attach;
|
|
|
|
|
|
|
|
|
|
/* Find extents of gridded portion
|
|
|
|
|
*/
|
|
|
|
|
max_bottom_attach = 0;
|
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
/* Find empty rows */
|
2004-03-15 02:03:59 +00:00
|
|
|
|
row_occupied = g_malloc0 (max_bottom_attach);
|
|
|
|
|
|
|
|
|
|
/* Lay non-grid-items out in those rows
|
|
|
|
|
*/
|
|
|
|
|
current_row = 0;
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2019-04-13 10:17:57 +00:00
|
|
|
|
while (current_row < max_bottom_attach && row_occupied[current_row])
|
|
|
|
|
current_row++;
|
|
|
|
|
|
|
|
|
|
ai->effective_top_attach = current_row;
|
|
|
|
|
|
|
|
|
|
current_row++;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
}
|
2004-03-15 02:03:59 +00:00
|
|
|
|
|
|
|
|
|
g_free (row_occupied);
|
|
|
|
|
|
|
|
|
|
priv->n_rows = MAX (current_row, max_bottom_attach);
|
|
|
|
|
priv->have_layout = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
gtk_menu_get_n_rows (GtkMenu *menu)
|
|
|
|
|
{
|
2011-01-04 17:32:22 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2004-03-15 02:03:59 +00:00
|
|
|
|
|
|
|
|
|
menu_ensure_layout (menu);
|
|
|
|
|
|
|
|
|
|
return priv->n_rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_effective_child_attach (GtkWidget *child,
|
2019-04-14 22:42:57 +00:00
|
|
|
|
int *t)
|
2004-03-15 02:03:59 +00:00
|
|
|
|
{
|
2010-08-11 21:08:37 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (child));
|
2004-03-15 02:03:59 +00:00
|
|
|
|
AttachInfo *ai;
|
|
|
|
|
|
|
|
|
|
menu_ensure_layout (menu);
|
|
|
|
|
|
|
|
|
|
ai = get_attach_info (child);
|
|
|
|
|
|
|
|
|
|
if (t)
|
|
|
|
|
*t = ai->effective_top_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
|
|
|
|
|
2001-08-25 03:15:26 +00:00
|
|
|
|
gobject_class->set_property = gtk_menu_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_menu_get_property;
|
2016-06-05 23:34:30 +00:00
|
|
|
|
gobject_class->finalize = gtk_menu_finalize;
|
2001-08-25 03:15:26 +00:00
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
widget_class->destroy = gtk_menu_destroy;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
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;
|
2016-12-17 19:46:25 +00:00
|
|
|
|
widget_class->snapshot = gtk_menu_snapshot;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
widget_class->focus = gtk_menu_focus;
|
2003-11-27 15:51:32 +00:00
|
|
|
|
widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
|
2005-06-27 17:36:34 +00:00
|
|
|
|
widget_class->grab_notify = gtk_menu_grab_notify;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
widget_class->measure = gtk_menu_measure;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
|
|
|
|
container_class->remove = gtk_menu_remove;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
2002-12-14 22:43:52 +00:00
|
|
|
|
menu_signals[MOVE_SCROLL] =
|
2008-08-11 11:52:06 +00:00
|
|
|
|
g_signal_new_class_handler (I_("move-scroll"),
|
2010-09-18 23:55:42 +00:00
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_menu_real_move_scroll),
|
|
|
|
|
NULL, NULL,
|
2016-08-29 14:00:17 +00:00
|
|
|
|
NULL,
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
GTK_TYPE_SCROLL_TYPE);
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkMenu::popped-up:
|
|
|
|
|
* @menu: the #GtkMenu that popped up
|
|
|
|
|
* @flipped_rect: (nullable): the position of @menu after any possible
|
|
|
|
|
* flipping or %NULL if the backend can't obtain it
|
|
|
|
|
* @final_rect: (nullable): the final position of @menu or %NULL if the
|
|
|
|
|
* backend can't obtain it
|
|
|
|
|
* @flipped_x: %TRUE if the anchors were flipped horizontally
|
|
|
|
|
* @flipped_y: %TRUE if the anchors were flipped vertically
|
|
|
|
|
*
|
|
|
|
|
* Emitted when the position of @menu is finalized after being popped up
|
|
|
|
|
* using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or
|
|
|
|
|
* gtk_menu_popup_at_pointer ().
|
|
|
|
|
*
|
|
|
|
|
* @menu might be flipped over the anchor rectangle in order to keep it
|
|
|
|
|
* on-screen, in which case @flipped_x and @flipped_y will be set to %TRUE
|
|
|
|
|
* accordingly.
|
|
|
|
|
*
|
|
|
|
|
* @flipped_rect is the ideal position of @menu after any possible flipping,
|
|
|
|
|
* but before any possible sliding. @final_rect is @flipped_rect, but possibly
|
|
|
|
|
* translated in the case that flipping is still ineffective in keeping @menu
|
|
|
|
|
* on-screen.
|
|
|
|
|
*
|
|
|
|
|
* ![](popup-slide.png)
|
|
|
|
|
*
|
|
|
|
|
* The blue menu is @menu's ideal position, the green menu is @flipped_rect,
|
|
|
|
|
* and the red menu is @final_rect.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
|
|
|
|
|
* gtk_menu_popup_at_pointer (), #GtkMenu:anchor-hints,
|
|
|
|
|
* #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and
|
|
|
|
|
* #GtkMenu:menu-type-hint.
|
|
|
|
|
*/
|
|
|
|
|
menu_signals[POPPED_UP] =
|
|
|
|
|
g_signal_new_class_handler (I_("popped-up"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
_gtk_marshal_VOID__POINTER_POINTER_BOOLEAN_BOOLEAN,
|
|
|
|
|
G_TYPE_NONE,
|
|
|
|
|
4,
|
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
|
G_TYPE_POINTER,
|
|
|
|
|
G_TYPE_BOOLEAN,
|
|
|
|
|
G_TYPE_BOOLEAN);
|
|
|
|
|
|
2008-06-20 11:06:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:active:
|
|
|
|
|
*
|
2008-07-04 21:20:25 +00:00
|
|
|
|
* The index of the currently selected menu item, or -1 if no
|
|
|
|
|
* menu item is selected.
|
2008-06-20 11:06:52 +00:00
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_ACTIVE,
|
2008-07-04 21:20:25 +00:00
|
|
|
|
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));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:accel-group:
|
|
|
|
|
*
|
|
|
|
|
* The accel group holding accelerators for the menu.
|
|
|
|
|
**/
|
|
|
|
|
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));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:accel-path:
|
|
|
|
|
*
|
|
|
|
|
* An accel path used to conveniently construct accel paths of child items.
|
|
|
|
|
**/
|
|
|
|
|
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));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:attach-widget:
|
|
|
|
|
*
|
2008-07-04 20:01:50 +00:00
|
|
|
|
* 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.
|
2008-06-20 11:06:52 +00:00
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
2008-07-04 20:01:50 +00:00
|
|
|
|
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));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:monitor:
|
|
|
|
|
*
|
|
|
|
|
* The monitor the menu will be popped up on.
|
|
|
|
|
**/
|
|
|
|
|
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,
|
2014-06-09 13:04:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
2009-06-24 05:01:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
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,
|
2014-06-09 13:04:53 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2009-06-24 05:01:51 +00:00
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:anchor-hints:
|
|
|
|
|
*
|
|
|
|
|
* Positioning hints for aligning the menu relative to a rectangle.
|
|
|
|
|
*
|
|
|
|
|
* These hints determine how the menu should be positioned in the case that
|
|
|
|
|
* the menu would fall off-screen if placed in its ideal position.
|
|
|
|
|
*
|
|
|
|
|
* ![](popup-flip.png)
|
|
|
|
|
*
|
|
|
|
|
* For example, %GDK_ANCHOR_FLIP_Y will replace %GDK_GRAVITY_NORTH_WEST with
|
|
|
|
|
* %GDK_GRAVITY_SOUTH_WEST and vice versa if the menu extends beyond the
|
|
|
|
|
* bottom edge of the monitor.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
|
|
|
|
|
* gtk_menu_popup_at_pointer (), #GtkMenu:rect-anchor-dx,
|
|
|
|
|
* #GtkMenu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_ANCHOR_HINTS,
|
|
|
|
|
g_param_spec_flags ("anchor-hints",
|
|
|
|
|
P_("Anchor hints"),
|
|
|
|
|
P_("Positioning hints for when the menu might fall off-screen"),
|
|
|
|
|
GDK_TYPE_ANCHOR_HINTS,
|
|
|
|
|
GDK_ANCHOR_FLIP |
|
|
|
|
|
GDK_ANCHOR_SLIDE |
|
|
|
|
|
GDK_ANCHOR_RESIZE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
G_PARAM_STATIC_NAME |
|
|
|
|
|
G_PARAM_STATIC_NICK |
|
2016-08-03 03:42:11 +00:00
|
|
|
|
G_PARAM_STATIC_BLURB |
|
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY));
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:rect-anchor-dx:
|
|
|
|
|
*
|
|
|
|
|
* Horizontal offset to apply to the menu, i.e. the rectangle or widget
|
|
|
|
|
* anchor.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
|
|
|
|
|
* gtk_menu_popup_at_pointer (), #GtkMenu:anchor-hints,
|
|
|
|
|
* #GtkMenu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_RECT_ANCHOR_DX,
|
|
|
|
|
g_param_spec_int ("rect-anchor-dx",
|
|
|
|
|
P_("Rect anchor dx"),
|
|
|
|
|
P_("Rect anchor horizontal offset"),
|
|
|
|
|
G_MININT,
|
|
|
|
|
G_MAXINT,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
G_PARAM_STATIC_NAME |
|
|
|
|
|
G_PARAM_STATIC_NICK |
|
2016-08-03 03:42:11 +00:00
|
|
|
|
G_PARAM_STATIC_BLURB |
|
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY));
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:rect-anchor-dy:
|
|
|
|
|
*
|
|
|
|
|
* Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
|
|
|
|
|
* gtk_menu_popup_at_pointer (), #GtkMenu:anchor-hints,
|
|
|
|
|
* #GtkMenu:rect-anchor-dx, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_RECT_ANCHOR_DY,
|
|
|
|
|
g_param_spec_int ("rect-anchor-dy",
|
|
|
|
|
P_("Rect anchor dy"),
|
|
|
|
|
P_("Rect anchor vertical offset"),
|
|
|
|
|
G_MININT,
|
|
|
|
|
G_MAXINT,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
G_PARAM_STATIC_NAME |
|
|
|
|
|
G_PARAM_STATIC_NICK |
|
2016-08-03 03:42:11 +00:00
|
|
|
|
G_PARAM_STATIC_BLURB |
|
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY));
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkMenu:menu-type-hint:
|
|
|
|
|
*
|
2018-03-20 10:40:08 +00:00
|
|
|
|
* The #GdkSurfaceTypeHint to use for the menu's #GdkSurface.
|
2016-06-14 19:42:13 +00:00
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
|
|
|
|
|
* gtk_menu_popup_at_pointer (), #GtkMenu:anchor-hints,
|
|
|
|
|
* #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and #GtkMenu::popped-up.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_MENU_TYPE_HINT,
|
|
|
|
|
g_param_spec_enum ("menu-type-hint",
|
|
|
|
|
P_("Menu type hint"),
|
|
|
|
|
P_("Menu window type hint"),
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GDK_TYPE_SURFACE_TYPE_HINT,
|
|
|
|
|
GDK_SURFACE_TYPE_HINT_POPUP_MENU,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
G_PARAM_STATIC_NAME |
|
|
|
|
|
G_PARAM_STATIC_NICK |
|
2016-08-03 03:42:11 +00:00
|
|
|
|
G_PARAM_STATIC_BLURB |
|
|
|
|
|
G_PARAM_EXPLICIT_NOTIFY));
|
2016-06-14 19:42:13 +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
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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);
|
2002-02-02 22:52:22 +00:00
|
|
|
|
|
2011-07-02 02:30:54 +00:00
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_ACCESSIBLE);
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("menu"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-25 03:15:26 +00:00
|
|
|
|
|
2008-09-03 13:18:34 +00:00
|
|
|
|
static void
|
2001-08-25 03:15:26 +00:00
|
|
|
|
gtk_menu_set_property (GObject *object,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2001-08-25 03:15:26 +00:00
|
|
|
|
{
|
2008-09-03 13:18:34 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (object);
|
|
|
|
|
|
2001-08-25 03:15:26 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2008-06-20 11:06:52 +00:00
|
|
|
|
case PROP_ACTIVE:
|
2008-07-04 21:20:25 +00:00
|
|
|
|
gtk_menu_set_active (menu, g_value_get_int (value));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
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:
|
2008-07-04 20:09:57 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2008-06-20 11:06:52 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_MONITOR:
|
|
|
|
|
gtk_menu_set_monitor (menu, g_value_get_int (value));
|
|
|
|
|
break;
|
2009-06-24 05:01:51 +00:00
|
|
|
|
case PROP_RESERVE_TOGGLE_SIZE:
|
|
|
|
|
gtk_menu_set_reserve_toggle_size (menu, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
case PROP_ANCHOR_HINTS:
|
2016-08-03 03:42:11 +00:00
|
|
|
|
if (menu->priv->anchor_hints != g_value_get_flags (value))
|
|
|
|
|
{
|
|
|
|
|
menu->priv->anchor_hints = g_value_get_flags (value);
|
|
|
|
|
g_object_notify_by_pspec (object, pspec);
|
|
|
|
|
}
|
2016-06-14 19:42:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_RECT_ANCHOR_DX:
|
2016-08-03 03:42:11 +00:00
|
|
|
|
if (menu->priv->rect_anchor_dx != g_value_get_int (value))
|
|
|
|
|
{
|
|
|
|
|
menu->priv->rect_anchor_dx = g_value_get_int (value);
|
|
|
|
|
g_object_notify_by_pspec (object, pspec);
|
|
|
|
|
}
|
2016-06-14 19:42:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_RECT_ANCHOR_DY:
|
2016-08-03 03:42:11 +00:00
|
|
|
|
if (menu->priv->rect_anchor_dy != g_value_get_int (value))
|
|
|
|
|
{
|
|
|
|
|
menu->priv->rect_anchor_dy = g_value_get_int (value);
|
|
|
|
|
g_object_notify_by_pspec (object, pspec);
|
|
|
|
|
}
|
2016-06-14 19:42:13 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_MENU_TYPE_HINT:
|
2016-08-03 03:42:11 +00:00
|
|
|
|
if (menu->priv->menu_type_hint != g_value_get_enum (value))
|
|
|
|
|
{
|
|
|
|
|
menu->priv->menu_type_hint = g_value_get_enum (value);
|
|
|
|
|
g_object_notify_by_pspec (object, pspec);
|
|
|
|
|
}
|
2016-06-14 19:42:13 +00:00
|
|
|
|
break;
|
2001-08-25 03:15:26 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-03 13:18:34 +00:00
|
|
|
|
static void
|
2001-08-25 03:15:26 +00:00
|
|
|
|
gtk_menu_get_property (GObject *object,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2001-08-25 03:15:26 +00:00
|
|
|
|
{
|
2008-09-03 13:18:34 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (object);
|
|
|
|
|
|
2001-08-25 03:15:26 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2008-06-20 11:06:52 +00:00
|
|
|
|
case PROP_ACTIVE:
|
2010-12-23 23:21:53 +00:00
|
|
|
|
g_value_set_int (value, g_list_index (GTK_MENU_SHELL (menu)->priv->children, gtk_menu_get_active (menu)));
|
2008-06-20 11:06:52 +00:00
|
|
|
|
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_MONITOR:
|
|
|
|
|
g_value_set_int (value, gtk_menu_get_monitor (menu));
|
|
|
|
|
break;
|
2009-06-24 05:01:51 +00:00
|
|
|
|
case PROP_RESERVE_TOGGLE_SIZE:
|
|
|
|
|
g_value_set_boolean (value, gtk_menu_get_reserve_toggle_size (menu));
|
|
|
|
|
break;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
case PROP_ANCHOR_HINTS:
|
|
|
|
|
g_value_set_flags (value, menu->priv->anchor_hints);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RECT_ANCHOR_DX:
|
|
|
|
|
g_value_set_int (value, menu->priv->rect_anchor_dx);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_RECT_ANCHOR_DY:
|
|
|
|
|
g_value_set_int (value, menu->priv->rect_anchor_dy);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MENU_TYPE_HINT:
|
|
|
|
|
g_value_set_enum (value, menu->priv->menu_type_hint);
|
|
|
|
|
break;
|
2001-08-25 03:15:26 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2018-03-09 05:14:59 +00:00
|
|
|
|
GtkGesture *gesture;
|
2018-03-10 17:29:57 +00:00
|
|
|
|
GtkEventController *controller;
|
2004-02-17 22:25:13 +00:00
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
|
priv = gtk_menu_get_instance_private (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
|
|
|
|
menu->priv = priv;
|
|
|
|
|
|
2016-10-10 14:52:50 +00:00
|
|
|
|
priv->toplevel = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->toplevel), GTK_WIDGET (menu));
|
|
|
|
|
g_signal_connect (priv->toplevel, "destroy", G_CALLBACK (gtk_widget_destroyed), &priv->toplevel);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
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
|
|
|
|
|
2014-06-07 01:30:55 +00:00
|
|
|
|
_gtk_window_request_csd (GTK_WINDOW (priv->toplevel));
|
2014-06-12 13:09:30 +00:00
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (priv->toplevel),
|
|
|
|
|
GTK_STYLE_CLASS_POPUP);
|
2014-06-06 23:06:15 +00:00
|
|
|
|
|
1998-09-01 18:41:26 +00:00
|
|
|
|
/* Refloat the menu, so that reference counting for the menu isn't
|
|
|
|
|
* affected by it being a child of the toplevel
|
|
|
|
|
*/
|
2005-11-23 18:06:58 +00:00
|
|
|
|
g_object_force_floating (G_OBJECT (menu));
|
2010-12-23 20:50:18 +00:00
|
|
|
|
priv->needs_destruction_ref = TRUE;
|
1998-09-01 18:41:26 +00:00
|
|
|
|
|
2008-07-04 21:20:25 +00:00
|
|
|
|
priv->monitor_num = -1;
|
2011-12-12 17:11:57 +00:00
|
|
|
|
priv->drag_start_y = -1;
|
2010-11-21 18:40:28 +00:00
|
|
|
|
|
2016-08-03 03:42:11 +00:00
|
|
|
|
priv->anchor_hints = GDK_ANCHOR_FLIP | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE;
|
|
|
|
|
priv->rect_anchor_dx = 0;
|
|
|
|
|
priv->rect_anchor_dy = 0;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
priv->menu_type_hint = GDK_SURFACE_TYPE_HINT_POPUP_MENU;
|
2016-08-03 03:42:11 +00:00
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
_gtk_widget_set_captured_event_handler (GTK_WIDGET (menu), gtk_menu_captured_event);
|
2015-11-03 01:45:46 +00:00
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
|
|
|
|
|
priv->top_arrow_widget = gtk_icon_new ("arrow");
|
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (priv->top_arrow_widget),
|
|
|
|
|
GTK_STYLE_CLASS_TOP);
|
|
|
|
|
gtk_widget_set_parent (priv->top_arrow_widget, GTK_WIDGET (menu));
|
2018-09-17 09:07:41 +00:00
|
|
|
|
gtk_widget_set_child_visible (priv->top_arrow_widget, FALSE);
|
2017-05-10 20:13:16 +00:00
|
|
|
|
|
|
|
|
|
priv->bottom_arrow_widget = gtk_icon_new ("arrow");
|
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (priv->bottom_arrow_widget),
|
|
|
|
|
GTK_STYLE_CLASS_BOTTOM);
|
|
|
|
|
gtk_widget_set_parent (priv->bottom_arrow_widget, GTK_WIDGET (menu));
|
2018-09-17 09:07:41 +00:00
|
|
|
|
gtk_widget_set_child_visible (priv->bottom_arrow_widget, FALSE);
|
2016-12-02 12:20:47 +00:00
|
|
|
|
|
2018-03-09 05:14:59 +00:00
|
|
|
|
gesture = gtk_gesture_multi_press_new ();
|
|
|
|
|
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
|
|
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
|
|
|
|
|
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_BUBBLE);
|
|
|
|
|
g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_menu_pressed_cb), menu);
|
|
|
|
|
g_signal_connect (gesture, "released", G_CALLBACK (gtk_menu_released_cb), menu);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (menu), GTK_EVENT_CONTROLLER (gesture));
|
2017-09-15 11:53:27 +00:00
|
|
|
|
|
2018-03-10 17:29:57 +00:00
|
|
|
|
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
|
|
|
|
|
g_signal_connect (controller, "scroll",
|
2017-09-15 11:53:27 +00:00
|
|
|
|
G_CALLBACK (gtk_menu_scroll_controller_scroll), menu);
|
2018-03-10 17:29:57 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (menu), controller);
|
2018-01-02 18:22:36 +00:00
|
|
|
|
|
2018-03-10 17:45:23 +00:00
|
|
|
|
controller = gtk_event_controller_motion_new ();
|
|
|
|
|
g_signal_connect (controller, "enter", G_CALLBACK (gtk_menu_enter), menu);
|
|
|
|
|
g_signal_connect (controller, "motion", G_CALLBACK (gtk_menu_motion), menu);
|
|
|
|
|
g_signal_connect (controller, "leave", G_CALLBACK (gtk_menu_leave), menu);
|
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (menu), controller);
|
2018-03-11 12:56:32 +00:00
|
|
|
|
|
2018-04-20 17:58:06 +00:00
|
|
|
|
controller = gtk_event_controller_key_new ();
|
|
|
|
|
g_signal_connect (controller, "key-pressed",
|
2018-04-25 17:07:50 +00:00
|
|
|
|
G_CALLBACK (gtk_menu_key_pressed), menu);
|
2018-04-20 17:58:06 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (menu), controller);
|
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
|
|
|
|
}
|
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
static void
|
2018-03-21 10:49:14 +00:00
|
|
|
|
moved_to_rect_cb (GdkSurface *surface,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
const GdkRectangle *flipped_rect,
|
|
|
|
|
const GdkRectangle *final_rect,
|
|
|
|
|
gboolean flipped_x,
|
|
|
|
|
gboolean flipped_y,
|
|
|
|
|
GtkMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (menu,
|
|
|
|
|
menu_signals[POPPED_UP],
|
|
|
|
|
0,
|
|
|
|
|
flipped_rect,
|
|
|
|
|
final_rect,
|
|
|
|
|
flipped_x,
|
|
|
|
|
flipped_y);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2010-09-18 23:55:42 +00:00
|
|
|
|
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
|
|
|
|
{
|
2010-09-18 23:55:42 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (widget);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
1998-02-03 14:13:05 +00:00
|
|
|
|
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
|
|
|
|
|
2006-07-20 19:07:51 +00:00
|
|
|
|
gtk_menu_remove_scroll_timeout (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
data = g_object_get_data (G_OBJECT (widget), attach_data_key);
|
1998-02-03 14:13:05 +00:00
|
|
|
|
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
|
|
|
|
|
2000-09-02 02:43:50 +00:00
|
|
|
|
gtk_menu_stop_navigating_submenu (menu);
|
|
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
|
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
|
|
|
|
|
1998-09-01 18:41:26 +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;
|
2010-09-18 23:55:42 +00:00
|
|
|
|
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
|
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
|
g_clear_object (&priv->accel_group);
|
2005-11-21 16:15:11 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (priv->toplevel)
|
2016-06-14 19:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->toplevel, moved_to_rect_cb, menu);
|
|
|
|
|
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
|
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
|
g_clear_pointer (&priv->heights, g_free);
|
2005-11-21 16:15:11 +00:00
|
|
|
|
|
2016-06-05 23:34:30 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_menu_parent_class)->destroy (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu = GTK_MENU (object);
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_unparent (priv->top_arrow_widget);
|
|
|
|
|
gtk_widget_unparent (priv->bottom_arrow_widget);
|
2015-12-21 01:30:52 +00:00
|
|
|
|
|
2016-06-05 23:34:30 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_menu_parent_class)->finalize (object);
|
1998-02-03 14:13:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-14 04:07:08 +00:00
|
|
|
|
static void
|
2017-10-31 06:41:15 +00:00
|
|
|
|
menu_change_display (GtkMenu *menu,
|
|
|
|
|
GdkDisplay *new_display)
|
2002-12-14 04:07:08 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2004-01-27 00:49:03 +00:00
|
|
|
|
|
2017-10-31 06:41:15 +00:00
|
|
|
|
if (new_display == gtk_widget_get_display (GTK_WIDGET (menu)))
|
2017-10-30 21:19:02 +00:00
|
|
|
|
return;
|
2004-11-05 15:58:36 +00:00
|
|
|
|
|
2017-10-31 06:41:15 +00:00
|
|
|
|
gtk_window_set_display (GTK_WINDOW (priv->toplevel), new_display);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
priv->monitor_num = -1;
|
2002-12-14 04:07:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 20:41:59 +00:00
|
|
|
|
static void
|
|
|
|
|
attach_widget_root_changed (GObject *attach_widget,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer menu)
|
|
|
|
|
{
|
|
|
|
|
if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-display"))
|
|
|
|
|
menu_change_display (menu, gtk_widget_get_display (GTK_WIDGET (attach_widget)));
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-23 06:34:12 +00:00
|
|
|
|
static void
|
|
|
|
|
menu_toplevel_attached_to (GtkWindow *toplevel, GParamSpec *pspec, GtkMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuAttachData *data;
|
|
|
|
|
|
|
|
|
|
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (data);
|
|
|
|
|
|
|
|
|
|
gtk_menu_detach (menu);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-15 13:51:11 +00:00
|
|
|
|
/**
|
2011-03-03 21:06:28 +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
|
2011-03-03 21:06:28 +00:00
|
|
|
|
* @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.
|
2013-07-22 12:08:11 +00:00
|
|
|
|
*
|
|
|
|
|
* If the menu is attached to the widget then it will be destroyed
|
|
|
|
|
* when the widget is destroyed, as if it was a child widget.
|
|
|
|
|
* An attached menu will also move between screens correctly if the
|
|
|
|
|
* widgets moves between screens.
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*/
|
1998-02-03 14:13:05 +00:00
|
|
|
|
void
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gtk_menu_attach_to_widget (GtkMenu *menu,
|
|
|
|
|
GtkWidget *attach_widget,
|
|
|
|
|
GtkMenuDetachFunc detacher)
|
1998-02-03 14:13:05 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenuAttachData *data;
|
2004-05-06 07:35:26 +00:00
|
|
|
|
GList *list;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
1998-02-03 14:13:05 +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() */
|
2002-10-05 01:51:16 +00:00
|
|
|
|
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
|
1998-02-03 14:13:05 +00:00
|
|
|
|
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)));
|
2002-11-14 05:46:34 +00:00
|
|
|
|
return;
|
1998-02-03 14:13:05 +00:00
|
|
|
|
}
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2005-11-23 18:06:58 +00:00
|
|
|
|
g_object_ref_sink (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2008-05-25 22:33:34 +00:00
|
|
|
|
data = g_slice_new (GtkMenuAttachData);
|
1998-02-03 14:13:05 +00:00
|
|
|
|
data->attach_widget = attach_widget;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2019-05-01 20:41:59 +00:00
|
|
|
|
g_signal_connect (attach_widget, "notify::root",
|
|
|
|
|
G_CALLBACK (attach_widget_root_changed), menu);
|
2019-05-01 22:52:13 +00:00
|
|
|
|
attach_widget_root_changed (G_OBJECT (attach_widget), NULL, menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
1998-02-03 14:13:05 +00:00
|
|
|
|
data->detacher = detacher;
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (menu), I_(attach_data_key), data);
|
2004-08-25 20:06:29 +00:00
|
|
|
|
list = g_object_steal_data (G_OBJECT (attach_widget), ATTACHED_MENUS);
|
2004-05-06 07:35:26 +00:00
|
|
|
|
if (!g_list_find (list, menu))
|
2010-12-23 20:50:18 +00:00
|
|
|
|
list = g_list_prepend (list, menu);
|
|
|
|
|
|
2008-06-18 09:12:32 +00:00
|
|
|
|
g_object_set_data_full (G_OBJECT (attach_widget), I_(ATTACHED_MENUS), list,
|
|
|
|
|
(GDestroyNotify) g_list_free);
|
|
|
|
|
|
2012-01-12 18:29:52 +00:00
|
|
|
|
/* Attach the widget to the toplevel window. */
|
|
|
|
|
gtk_window_set_attached_to (GTK_WINDOW (menu->priv->toplevel), attach_widget);
|
2015-07-23 06:34:12 +00:00
|
|
|
|
g_signal_connect (GTK_WINDOW (menu->priv->toplevel), "notify::attached-to",
|
|
|
|
|
G_CALLBACK (menu_toplevel_attached_to), menu);
|
2001-12-27 20:22:16 +00:00
|
|
|
|
|
2012-08-17 22:09:35 +00:00
|
|
|
|
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
|
|
|
|
|
|
2010-06-16 18:18:39 +00:00
|
|
|
|
g_object_notify (G_OBJECT (menu), "attach-widget");
|
1998-02-03 14:13:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
2011-01-18 09:01:17 +00:00
|
|
|
|
* Returns: (transfer none): the #GtkWidget that the menu is attached to
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*/
|
1998-02-08 19:00:01 +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)
|
1998-02-08 19:00:01 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenuAttachData *data;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
1998-02-08 19:00:01 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2002-10-05 01:51:16 +00:00
|
|
|
|
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
|
1998-02-08 19:00:01 +00:00
|
|
|
|
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.
|
|
|
|
|
*/
|
1998-02-03 14:13:05 +00:00
|
|
|
|
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)
|
1998-02-03 14:13:05 +00:00
|
|
|
|
{
|
2015-07-23 06:34:12 +00:00
|
|
|
|
GtkWindow *toplevel;
|
1998-02-03 14:13:05 +00:00
|
|
|
|
GtkMenuAttachData *data;
|
2004-05-06 07:35:26 +00:00
|
|
|
|
GList *list;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
1998-02-03 14:13:05 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
2015-07-23 06:34:12 +00:00
|
|
|
|
toplevel = GTK_WINDOW (menu->priv->toplevel);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
|
|
|
|
/* keep this function in sync with gtk_widget_unparent() */
|
2002-10-05 01:51:16 +00:00
|
|
|
|
data = g_object_get_data (G_OBJECT (menu), attach_data_key);
|
1998-02-03 14:13:05 +00:00
|
|
|
|
if (!data)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("gtk_menu_detach(): menu is not attached");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (menu), I_(attach_data_key), NULL);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2012-01-12 18:29:52 +00:00
|
|
|
|
/* Detach the toplevel window. */
|
2017-09-26 05:10:39 +00:00
|
|
|
|
if (toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (toplevel,
|
|
|
|
|
(gpointer) menu_toplevel_attached_to,
|
|
|
|
|
menu);
|
|
|
|
|
if (gtk_window_get_attached_to (toplevel) == data->attach_widget)
|
|
|
|
|
gtk_window_set_attached_to (toplevel, NULL);
|
|
|
|
|
}
|
2012-01-12 18:29:52 +00:00
|
|
|
|
|
2019-05-01 20:41:59 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (data->attach_widget,
|
|
|
|
|
(gpointer) attach_widget_root_changed,
|
|
|
|
|
menu);
|
2002-11-14 05:46:34 +00:00
|
|
|
|
|
2005-12-06 17:33:46 +00:00
|
|
|
|
if (data->detacher)
|
|
|
|
|
data->detacher (data->attach_widget, menu);
|
2004-05-06 07:35:26 +00:00
|
|
|
|
list = g_object_steal_data (G_OBJECT (data->attach_widget), ATTACHED_MENUS);
|
|
|
|
|
list = g_list_remove (list, menu);
|
|
|
|
|
if (list)
|
2008-06-18 09:12:32 +00:00
|
|
|
|
g_object_set_data_full (G_OBJECT (data->attach_widget), I_(ATTACHED_MENUS), list,
|
|
|
|
|
(GDestroyNotify) g_list_free);
|
2004-05-06 07:35:26 +00:00
|
|
|
|
else
|
2005-09-01 05:11:46 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (data->attach_widget), I_(ATTACHED_MENUS), NULL);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
|
if (gtk_widget_get_realized (GTK_WIDGET (menu)))
|
1998-02-03 14:13:05 +00:00
|
|
|
|
gtk_widget_unrealize (GTK_WIDGET (menu));
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2008-05-25 22:33:34 +00:00
|
|
|
|
g_slice_free (GtkMenuAttachData, data);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2012-08-17 22:09:35 +00:00
|
|
|
|
_gtk_widget_update_parent_muxer (GTK_WIDGET (menu));
|
|
|
|
|
|
2012-07-05 17:21:03 +00:00
|
|
|
|
g_object_notify (G_OBJECT (menu), "attach-widget");
|
2002-10-05 01:51:16 +00:00
|
|
|
|
g_object_unref (menu);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-20 21:11:30 +00:00
|
|
|
|
static void
|
2001-07-12 17:50:14 +00:00
|
|
|
|
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
|
|
|
|
{
|
2008-02-07 16:59:42 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (container);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
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
|
|
|
|
|
2005-09-01 05:11:46 +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
|
|
|
|
|
2004-03-15 02:03:59 +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:
|
|
|
|
|
*
|
2011-01-18 09:12:38 +00:00
|
|
|
|
* Creates a new #GtkMenu
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*
|
2011-01-18 09:12:38 +00:00
|
|
|
|
* Returns: a new #GtkMenu
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
|
gtk_menu_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2002-10-05 01:51:16 +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
|
2004-03-15 02:03:59 +00:00
|
|
|
|
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
|
|
|
|
{
|
2004-03-15 02:03:59 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (menu_shell);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_insert_before (child, GTK_WIDGET (menu), priv->bottom_arrow_widget);
|
2015-11-03 02:49:10 +00:00
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->insert (menu_shell, child, position);
|
2003-12-19 20:56:19 +00:00
|
|
|
|
|
2004-03-15 02:03:59 +00:00
|
|
|
|
menu_queue_resize (menu);
|
2003-12-19 20:56:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-02 21:50:46 +00:00
|
|
|
|
static gboolean
|
2018-03-21 10:49:14 +00:00
|
|
|
|
popup_grab_on_surface (GdkSurface *surface,
|
|
|
|
|
GdkDevice *pointer)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2015-11-26 18:54:54 +00:00
|
|
|
|
GdkGrabStatus status;
|
|
|
|
|
GdkSeat *seat;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-01 20:41:59 +00:00
|
|
|
|
g_return_val_if_fail (gdk_surface_get_display (surface) == gdk_device_get_display (pointer), FALSE);
|
|
|
|
|
|
2015-11-26 18:54:54 +00:00
|
|
|
|
seat = gdk_device_get_seat (pointer);
|
2018-03-21 10:49:14 +00:00
|
|
|
|
status = gdk_seat_grab (seat, surface,
|
2015-11-26 18:54:54 +00:00
|
|
|
|
GDK_SEAT_CAPABILITY_ALL, TRUE,
|
|
|
|
|
NULL, NULL, NULL, NULL);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2015-11-26 18:54:54 +00:00
|
|
|
|
return status == GDK_GRAB_SUCCESS;
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
static void
|
2018-03-21 10:49:14 +00:00
|
|
|
|
associate_menu_grab_transfer_surface (GtkMenu *menu)
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *toplevel_surface;
|
|
|
|
|
GdkSurface *transfer_surface;
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
toplevel_surface = gtk_widget_get_surface (priv->toplevel);
|
|
|
|
|
transfer_surface = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-surface");
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (toplevel_surface == NULL || transfer_surface == NULL)
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (toplevel_surface), I_("gdk-attached-grab-surface"), transfer_surface);
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_popup_internal (GtkMenu *menu,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
GtkWidget *parent_menu_shell,
|
|
|
|
|
GtkWidget *parent_menu_item,
|
|
|
|
|
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;
|
2005-03-31 17:02:19 +00:00
|
|
|
|
gboolean grab_keyboard;
|
2006-05-12 16:06:53 +00:00
|
|
|
|
GtkWidget *parent_toplevel;
|
2015-11-26 18:54:54 +00:00
|
|
|
|
GdkDevice *pointer, *source_device = NULL;
|
2015-06-15 23:46:33 +00:00
|
|
|
|
GdkDisplay *display;
|
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-09-24 17:52:49 +00:00
|
|
|
|
g_return_if_fail (device == NULL || GDK_IS_DEVICE (device));
|
|
|
|
|
|
2015-06-15 23:46:33 +00:00
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (menu));
|
|
|
|
|
|
2010-09-24 17:52:49 +00:00
|
|
|
|
if (device == NULL)
|
|
|
|
|
device = gtk_get_current_event_device ();
|
|
|
|
|
|
2015-06-15 23:46:33 +00:00
|
|
|
|
if (device && gdk_device_get_display (device) != display)
|
|
|
|
|
device = NULL;
|
|
|
|
|
|
2010-09-24 17:52:49 +00:00
|
|
|
|
if (device == NULL)
|
2019-05-01 20:41:59 +00:00
|
|
|
|
{
|
|
|
|
|
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
|
|
|
|
|
g_return_if_fail (gdk_device_get_display (device) == display);
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-27 02:07:35 +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
|
|
|
|
widget = GTK_WIDGET (menu);
|
|
|
|
|
menu_shell = GTK_MENU_SHELL (menu);
|
2005-03-31 17:02:19 +00:00
|
|
|
|
|
2010-11-23 19:25:13 +00:00
|
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
2015-11-26 18:54:54 +00:00
|
|
|
|
pointer = gdk_device_get_associated_device (device);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
else
|
2015-11-26 18:54:54 +00:00
|
|
|
|
pointer = device;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-01 20:41:59 +00:00
|
|
|
|
g_return_if_fail (gdk_device_get_display (pointer) == display);
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->parent_menu_shell = parent_menu_shell;
|
2004-12-22 16:52:23 +00:00
|
|
|
|
|
2002-02-02 21:50:46 +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
|
|
|
|
|
2002-02-02 21:50:46 +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);
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-02 21:50:46 +00:00
|
|
|
|
if (viewable)
|
2010-12-23 20:50:18 +00:00
|
|
|
|
xgrab_shell = parent;
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
parent = GTK_MENU_SHELL (parent)->priv->parent_menu_shell;
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
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.
|
2002-02-02 21:50:46 +00:00
|
|
|
|
*
|
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.
|
2002-02-02 21:50:46 +00:00
|
|
|
|
*
|
2010-12-23 20:50:18 +00:00
|
|
|
|
* When grabbing on the menu itself, things get more convoluted --
|
2002-02-02 21:50:46 +00:00
|
|
|
|
* 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*).
|
2002-02-02 21:50:46 +00:00
|
|
|
|
*/
|
2005-03-31 17:02:19 +00:00
|
|
|
|
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);
|
2005-03-31 17:02:19 +00:00
|
|
|
|
|
2002-02-03 00:18:41 +00:00
|
|
|
|
if (xgrab_shell && xgrab_shell != widget)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (popup_grab_on_surface (gtk_widget_get_surface (xgrab_shell), pointer))
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2010-06-15 23:09:41 +00:00
|
|
|
|
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
|
2010-12-23 23:21:53 +00:00
|
|
|
|
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *transfer_surface;
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
|
|
|
|
xgrab_shell = widget;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
transfer_surface = menu_grab_transfer_surface_get (menu);
|
|
|
|
|
if (popup_grab_on_surface (transfer_surface, pointer))
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2010-06-15 23:09:41 +00:00
|
|
|
|
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
|
2010-12-23 23:21:53 +00:00
|
|
|
|
GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab = TRUE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (!GTK_MENU_SHELL (xgrab_shell)->priv->have_xgrab)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
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.
|
2002-02-02 21:50:46 +00:00
|
|
|
|
*/
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->parent_menu_shell = NULL;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
menu_grab_transfer_surface_destroy (menu);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-15 23:09:41 +00:00
|
|
|
|
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (menu), pointer);
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
|
2001-07-12 17:50:14 +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)
|
|
|
|
|
{
|
2017-08-25 14:49:38 +00:00
|
|
|
|
GdkEventType event_type = gdk_event_get_event_type (current_event);
|
|
|
|
|
|
|
|
|
|
if ((event_type != GDK_BUTTON_PRESS) &&
|
|
|
|
|
(event_type != GDK_ENTER_NOTIFY))
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->ignore_enter = TRUE;
|
2002-02-04 17:46:33 +00:00
|
|
|
|
|
2011-12-12 17:21:40 +00:00
|
|
|
|
source_device = gdk_event_get_source_device (current_event);
|
2017-10-31 12:45:41 +00:00
|
|
|
|
g_object_unref (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
|
|
|
|
}
|
2003-11-12 09:09:25 +00:00
|
|
|
|
else
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
|
|
|
|
2006-05-12 16:06:53 +00:00
|
|
|
|
parent_toplevel = NULL;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (parent_menu_shell)
|
2006-05-12 16:06:53 +00:00
|
|
|
|
parent_toplevel = gtk_widget_get_toplevel (parent_menu_shell);
|
2019-05-01 21:49:25 +00:00
|
|
|
|
else
|
2004-03-02 20:49:15 +00:00
|
|
|
|
{
|
2006-05-12 16:06:53 +00:00
|
|
|
|
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);
|
2004-03-02 20:49:15 +00:00
|
|
|
|
}
|
2006-05-12 16:06:53 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
/* Set transient for to get the right window group and parent */
|
2008-02-06 09:53:34 +00:00
|
|
|
|
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;
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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));
|
2002-02-18 22:08:41 +00:00
|
|
|
|
|
2002-03-26 19:59:34 +00:00
|
|
|
|
/* Position the menu, possibly changing the size request
|
|
|
|
|
*/
|
2010-10-31 19:52:32 +00:00
|
|
|
|
gtk_menu_position (menu, TRUE);
|
2002-03-26 19:59:34 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
associate_menu_grab_transfer_surface (menu);
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gtk_menu_scroll_to (menu, priv->scroll_offset);
|
2001-03-29 00:24:58 +00:00
|
|
|
|
|
2007-04-27 14:49:37 +00:00
|
|
|
|
/* if no item is selected, select the first one */
|
2011-12-12 17:21:40 +00:00
|
|
|
|
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);
|
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);
|
2002-02-18 22:08:41 +00:00
|
|
|
|
|
2002-02-02 21:50:46 +00:00
|
|
|
|
if (xgrab_shell == widget)
|
2018-03-21 10:49:14 +00:00
|
|
|
|
popup_grab_on_surface (gtk_widget_get_surface (widget), pointer); /* Should always succeed */
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2015-11-26 18:54:54 +00:00
|
|
|
|
gtk_grab_add (GTK_WIDGET (menu));
|
2009-12-20 08:04:52 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2010-12-23 23:21:53 +00:00
|
|
|
|
else if (menu_shell->priv->button == 0) /* a keynav-activated context menu */
|
2009-12-20 08:04:52 +00:00
|
|
|
|
_gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
|
|
|
|
|
|
|
|
|
|
_gtk_menu_shell_update_mnemonics (menu_shell);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
static GdkDevice *
|
|
|
|
|
get_device_for_event (const GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
GdkDevice *device = NULL;
|
|
|
|
|
GdkSeat *seat = NULL;
|
|
|
|
|
GdkDisplay *display = NULL;
|
|
|
|
|
|
|
|
|
|
device = gdk_event_get_device (event);
|
|
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
|
return device;
|
|
|
|
|
|
|
|
|
|
seat = gdk_event_get_seat (event);
|
|
|
|
|
|
|
|
|
|
if (!seat)
|
|
|
|
|
{
|
2017-10-31 02:15:57 +00:00
|
|
|
|
display = gdk_event_get_display (event);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
|
|
|
|
if (!display)
|
|
|
|
|
{
|
|
|
|
|
g_warning ("no display for event, using default");
|
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
|
seat = gdk_display_get_default_seat (display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return seat ? gdk_seat_get_pointer (seat) : NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_popup_at_rect:
|
|
|
|
|
* @menu: the #GtkMenu to pop up
|
2018-03-21 10:49:14 +00:00
|
|
|
|
* @rect_surface: (not nullable): the #GdkSurface @rect is relative to
|
2016-06-14 19:42:13 +00:00
|
|
|
|
* @rect: (not nullable): the #GdkRectangle to align @menu with
|
|
|
|
|
* @rect_anchor: the point on @rect to align with @menu's anchor point
|
|
|
|
|
* @menu_anchor: the point on @menu to align with @rect's anchor point
|
|
|
|
|
* @trigger_event: (nullable): the #GdkEvent that initiated this request or
|
|
|
|
|
* %NULL if it's the current event
|
|
|
|
|
*
|
|
|
|
|
* Displays @menu and makes it available for selection.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which
|
|
|
|
|
* handle more common cases for popping up menus.
|
|
|
|
|
*
|
|
|
|
|
* @menu will be positioned at @rect, aligning their anchor points. @rect is
|
2018-03-21 10:49:14 +00:00
|
|
|
|
* relative to the top-left corner of @rect_surface. @rect_anchor and
|
2016-06-14 19:42:13 +00:00
|
|
|
|
* @menu_anchor determine anchor points on @rect and @menu to pin together.
|
|
|
|
|
* @menu can optionally be offset by #GtkMenu:rect-anchor-dx and
|
|
|
|
|
* #GtkMenu:rect-anchor-dy.
|
|
|
|
|
*
|
|
|
|
|
* Anchors should be specified under the assumption that the text direction is
|
|
|
|
|
* left-to-right; they will be flipped horizontally automatically if the text
|
|
|
|
|
* direction is right-to-left.
|
|
|
|
|
*
|
|
|
|
|
* Other properties that influence the behaviour of this function are
|
|
|
|
|
* #GtkMenu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the
|
|
|
|
|
* #GtkMenu::popped-up signal to find out how it was actually positioned.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_popup_at_rect (GtkMenu *menu,
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *rect_surface,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
const GdkRectangle *rect,
|
|
|
|
|
GdkGravity rect_anchor,
|
|
|
|
|
GdkGravity menu_anchor,
|
|
|
|
|
const GdkEvent *trigger_event)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv;
|
2018-01-30 09:18:54 +00:00
|
|
|
|
GdkEvent *current_event = NULL;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
GdkDevice *device = NULL;
|
|
|
|
|
guint button = 0;
|
|
|
|
|
guint32 activate_time = GDK_CURRENT_TIME;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
2018-03-21 10:49:14 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_SURFACE (rect_surface));
|
2016-06-14 19:42:13 +00:00
|
|
|
|
g_return_if_fail (rect);
|
|
|
|
|
|
|
|
|
|
priv = menu->priv;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
priv->rect_surface = rect_surface;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
priv->rect = *rect;
|
|
|
|
|
priv->widget = NULL;
|
|
|
|
|
priv->rect_anchor = rect_anchor;
|
|
|
|
|
priv->menu_anchor = menu_anchor;
|
|
|
|
|
|
|
|
|
|
if (!trigger_event)
|
|
|
|
|
{
|
2018-01-30 09:18:54 +00:00
|
|
|
|
current_event = gtk_get_current_event ();
|
|
|
|
|
trigger_event = current_event;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trigger_event)
|
|
|
|
|
{
|
|
|
|
|
device = get_device_for_event (trigger_event);
|
|
|
|
|
gdk_event_get_button (trigger_event, &button);
|
|
|
|
|
activate_time = gdk_event_get_time (trigger_event);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_warning ("no trigger event for menu popup");
|
|
|
|
|
|
|
|
|
|
gtk_menu_popup_internal (menu,
|
|
|
|
|
device,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
button,
|
|
|
|
|
activate_time);
|
2018-01-30 09:18:54 +00:00
|
|
|
|
|
|
|
|
|
g_clear_object (¤t_event);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_popup_at_widget:
|
|
|
|
|
* @menu: the #GtkMenu to pop up
|
|
|
|
|
* @widget: (not nullable): the #GtkWidget to align @menu with
|
|
|
|
|
* @widget_anchor: the point on @widget to align with @menu's anchor point
|
|
|
|
|
* @menu_anchor: the point on @menu to align with @widget's anchor point
|
|
|
|
|
* @trigger_event: (nullable): the #GdkEvent that initiated this request or
|
|
|
|
|
* %NULL if it's the current event
|
|
|
|
|
*
|
|
|
|
|
* Displays @menu and makes it available for selection.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer.
|
|
|
|
|
* gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
|
|
|
|
|
* rectangle.
|
|
|
|
|
*
|
|
|
|
|
* ![](popup-anchors.png)
|
|
|
|
|
*
|
|
|
|
|
* @menu will be positioned at @widget, aligning their anchor points.
|
|
|
|
|
* @widget_anchor and @menu_anchor determine anchor points on @widget and @menu
|
|
|
|
|
* to pin together. @menu can optionally be offset by #GtkMenu:rect-anchor-dx
|
|
|
|
|
* and #GtkMenu:rect-anchor-dy.
|
|
|
|
|
*
|
|
|
|
|
* Anchors should be specified under the assumption that the text direction is
|
|
|
|
|
* left-to-right; they will be flipped horizontally automatically if the text
|
|
|
|
|
* direction is right-to-left.
|
|
|
|
|
*
|
|
|
|
|
* Other properties that influence the behaviour of this function are
|
|
|
|
|
* #GtkMenu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the
|
|
|
|
|
* #GtkMenu::popped-up signal to find out how it was actually positioned.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_popup_at_widget (GtkMenu *menu,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
GdkGravity widget_anchor,
|
|
|
|
|
GdkGravity menu_anchor,
|
|
|
|
|
const GdkEvent *trigger_event)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv;
|
|
|
|
|
GdkEvent *current_event = NULL;
|
|
|
|
|
GdkDevice *device = NULL;
|
|
|
|
|
guint button = 0;
|
|
|
|
|
guint32 activate_time = GDK_CURRENT_TIME;
|
|
|
|
|
GtkWidget *parent_menu_shell = NULL;
|
|
|
|
|
GtkWidget *parent_menu_item = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
|
|
|
|
|
priv = menu->priv;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
priv->rect_surface = NULL;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
priv->widget = widget;
|
|
|
|
|
priv->rect_anchor = widget_anchor;
|
|
|
|
|
priv->menu_anchor = menu_anchor;
|
|
|
|
|
|
|
|
|
|
if (!trigger_event)
|
|
|
|
|
{
|
|
|
|
|
current_event = gtk_get_current_event ();
|
|
|
|
|
trigger_event = current_event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trigger_event)
|
|
|
|
|
{
|
|
|
|
|
device = get_device_for_event (trigger_event);
|
|
|
|
|
gdk_event_get_button (trigger_event, &button);
|
|
|
|
|
activate_time = gdk_event_get_time (trigger_event);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_warning ("no trigger event for menu popup");
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_MENU_ITEM (priv->widget))
|
|
|
|
|
{
|
|
|
|
|
parent_menu_item = priv->widget;
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_MENU_SHELL (gtk_widget_get_parent (parent_menu_item)))
|
|
|
|
|
parent_menu_shell = gtk_widget_get_parent (parent_menu_item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_menu_popup_internal (menu,
|
|
|
|
|
device,
|
|
|
|
|
parent_menu_shell,
|
|
|
|
|
parent_menu_item,
|
|
|
|
|
button,
|
|
|
|
|
activate_time);
|
|
|
|
|
|
2017-10-31 12:45:41 +00:00
|
|
|
|
g_clear_object (¤t_event);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_popup_at_pointer:
|
|
|
|
|
* @menu: the #GtkMenu to pop up
|
|
|
|
|
* @trigger_event: (nullable): the #GdkEvent that initiated this request or
|
|
|
|
|
* %NULL if it's the current event
|
|
|
|
|
*
|
|
|
|
|
* Displays @menu and makes it available for selection.
|
|
|
|
|
*
|
|
|
|
|
* See gtk_menu_popup_at_widget () to pop up a menu at a widget.
|
|
|
|
|
* gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary
|
|
|
|
|
* rectangle.
|
|
|
|
|
*
|
|
|
|
|
* @menu will be positioned at the pointer associated with @trigger_event.
|
|
|
|
|
*
|
|
|
|
|
* Properties that influence the behaviour of this function are
|
|
|
|
|
* #GtkMenu:anchor-hints, #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and
|
|
|
|
|
* #GtkMenu:menu-type-hint. Connect to the #GtkMenu::popped-up signal to find
|
|
|
|
|
* out how it was actually positioned.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_popup_at_pointer (GtkMenu *menu,
|
|
|
|
|
const GdkEvent *trigger_event)
|
|
|
|
|
{
|
|
|
|
|
GdkEvent *current_event = NULL;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *rect_surface = NULL;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
GdkDevice *device = NULL;
|
|
|
|
|
GdkRectangle rect = { 0, 0, 1, 1 };
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
|
|
|
|
|
if (!trigger_event)
|
|
|
|
|
{
|
|
|
|
|
current_event = gtk_get_current_event ();
|
|
|
|
|
trigger_event = current_event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (trigger_event)
|
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
rect_surface = gdk_event_get_surface (trigger_event);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (rect_surface)
|
2016-06-14 19:42:13 +00:00
|
|
|
|
{
|
|
|
|
|
device = get_device_for_event (trigger_event);
|
|
|
|
|
|
|
|
|
|
if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
|
|
|
|
device = gdk_device_get_associated_device (device);
|
|
|
|
|
|
|
|
|
|
if (device)
|
2019-03-25 12:32:50 +00:00
|
|
|
|
{
|
|
|
|
|
double px, py;
|
2019-03-25 14:12:01 +00:00
|
|
|
|
gdk_surface_get_device_position (rect_surface, device, &px, &py, NULL);
|
2019-03-25 12:32:50 +00:00
|
|
|
|
rect.x = round (px);
|
|
|
|
|
rect.y = round (py);
|
|
|
|
|
}
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_warning ("no trigger event for menu popup");
|
|
|
|
|
|
|
|
|
|
gtk_menu_popup_at_rect (menu,
|
2018-03-21 10:49:14 +00:00
|
|
|
|
rect_surface,
|
2016-06-14 19:42:13 +00:00
|
|
|
|
&rect,
|
|
|
|
|
GDK_GRAVITY_SOUTH_EAST,
|
|
|
|
|
GDK_GRAVITY_NORTH_WEST,
|
|
|
|
|
trigger_event);
|
|
|
|
|
|
2017-10-31 12:45:41 +00:00
|
|
|
|
g_clear_object (¤t_event);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_arrows_border (GtkMenu *menu,
|
|
|
|
|
GtkBorder *border)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
gint top_arrow_height, bottom_arrow_height;
|
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_measure (priv->top_arrow_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
-1,
|
|
|
|
|
&top_arrow_height, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
gtk_widget_measure (priv->bottom_arrow_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
-1,
|
|
|
|
|
&bottom_arrow_height, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
border->top = gtk_widget_get_child_visible (priv->top_arrow_widget) ? top_arrow_height : 0;
|
|
|
|
|
border->bottom = gtk_widget_get_child_visible (priv->bottom_arrow_widget) ? bottom_arrow_height : 0;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
border->left = border->right = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_update_scroll_offset:
|
|
|
|
|
* @menu: the #GtkMenu that popped up
|
|
|
|
|
* @flipped_rect: (nullable): the position of @menu after any possible flipping
|
|
|
|
|
* or %NULL if unknown
|
|
|
|
|
* @final_rect: (nullable): the final position of @menu or %NULL if unknown
|
|
|
|
|
* @flipped_x: %TRUE if the anchors were flipped horizontally
|
|
|
|
|
* @flipped_y: %TRUE if the anchors were flipped vertically
|
|
|
|
|
* @user_data: user data
|
|
|
|
|
*
|
|
|
|
|
* Updates the scroll offset of @menu based on the amount of sliding done while
|
|
|
|
|
* positioning @menu. Connect this to the #GtkMenu::popped-up signal to keep the
|
|
|
|
|
* contents of the menu vertically aligned with their ideal position, for combo
|
|
|
|
|
* boxes for example.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_menu_update_scroll_offset (GtkMenu *menu,
|
|
|
|
|
const GdkRectangle *flipped_rect,
|
|
|
|
|
const GdkRectangle *final_rect,
|
|
|
|
|
gboolean flipped_x,
|
|
|
|
|
gboolean flipped_y,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkBorder arrows_border;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
|
|
|
|
|
if (!flipped_rect || !final_rect)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
get_arrows_border (menu, &arrows_border);
|
|
|
|
|
menu->priv->scroll_offset = arrows_border.top + (final_rect->y - flipped_rect->y);
|
|
|
|
|
gtk_menu_scroll_to (menu, menu->priv->scroll_offset);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
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;
|
2006-05-12 09:47:58 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
gtk_menu_stop_scrolling (menu);
|
2000-09-02 02:43:50 +00:00
|
|
|
|
gtk_menu_stop_navigating_submenu (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +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);
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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-11-25 05:04:52 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gtk_widget_hide (priv->toplevel);
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (priv->toplevel), NULL);
|
2010-11-25 05:04: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
|
|
|
|
|
2016-09-05 01:09:20 +00:00
|
|
|
|
gtk_widget_hide (GTK_WIDGET (menu));
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->have_xgrab = FALSE;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2015-11-26 18:54:54 +00:00
|
|
|
|
gtk_grab_remove (GTK_WIDGET (menu));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2010-06-15 23:09:41 +00:00
|
|
|
|
_gtk_menu_shell_set_grab_device (menu_shell, NULL);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
menu_grab_transfer_surface_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
|
2012-07-02 06:19:06 +00:00
|
|
|
|
* #GtkComboBox.
|
2011-01-15 13:51:11 +00:00
|
|
|
|
*
|
2011-01-18 09:01:17 +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)
|
|
|
|
|
{
|
2018-04-17 18:51:53 +00:00
|
|
|
|
GtkMenuPrivate *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
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
priv = menu->priv;
|
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (!priv->old_active_menu_item)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
|
|
|
|
child = NULL;
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
2014-06-09 13:04:53 +00:00
|
|
|
|
* @index: the index of the menu item to select. Index values are
|
2011-01-15 13:51:11 +00:00
|
|
|
|
* from 0 to n-1
|
|
|
|
|
*
|
|
|
|
|
* Selects the specified menu item within the menu. This is used by
|
2012-07-02 06:19:06 +00:00
|
|
|
|
* 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
|
|
|
|
{
|
2018-04-17 18:51:53 +00:00
|
|
|
|
GtkMenuPrivate *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
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
priv = menu->priv;
|
|
|
|
|
|
2010-12-23 23:21:53 +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
|
|
|
|
}
|
2014-06-09 13:04:53 +00:00
|
|
|
|
g_object_notify (G_OBJECT (menu), "active");
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-10 10:23:40 +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.
|
2009-12-10 10:23:40 +00:00
|
|
|
|
*/
|
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
|
|
|
|
{
|
2018-04-17 18:51:53 +00:00
|
|
|
|
GtkMenuPrivate *priv;
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
2018-04-17 19:19:38 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
priv = menu->priv;
|
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (priv->accel_group != accel_group)
|
1997-12-18 02:17:14 +00:00
|
|
|
|
{
|
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-12-18 02:17:14 +00:00
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
2003-11-27 15:51:32 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_menu_real_can_activate_accel (GtkWidget *widget,
|
|
|
|
|
guint signal_id)
|
|
|
|
|
{
|
2003-12-08 22:55:03 +00:00
|
|
|
|
/* 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.
|
2003-11-27 15:51:32 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *awidget = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
2003-12-08 22:55:03 +00:00
|
|
|
|
|
|
|
|
|
if (awidget)
|
|
|
|
|
return gtk_widget_can_activate_accel (awidget, signal_id);
|
|
|
|
|
else
|
2010-02-27 04:24:24 +00:00
|
|
|
|
return gtk_widget_is_sensitive (widget);
|
2003-11-27 15:51:32 +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
|
|
|
|
/**
|
2012-04-13 00:07:28 +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
|
2018-04-17 19:19:45 +00:00
|
|
|
|
* @accel_path: (nullable): a valid accelerator path, or %NULL to unset the 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.
|
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* For example, a menu containing menu items “New” and “Exit”, will, after
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* `gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");` has been
|
|
|
|
|
* called, assign its items the accel paths: `"<Gnumeric-Sheet>/File/New"`
|
|
|
|
|
* and `"<Gnumeric-Sheet>/File/Exit"`.
|
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
|
|
|
|
{
|
2018-04-17 18:51:53 +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
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
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
|
|
|
|
if (accel_path)
|
|
|
|
|
g_return_if_fail (accel_path[0] == '<' && strchr (accel_path, '/')); /* simplistic check */
|
|
|
|
|
|
2018-04-17 19:03:07 +00:00
|
|
|
|
priv->accel_path = g_intern_string (accel_path);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-20 11:06:52 +00:00
|
|
|
|
/**
|
2012-04-13 00:07:28 +00:00
|
|
|
|
* gtk_menu_get_accel_path:
|
2008-06-20 13:54:31 +00:00
|
|
|
|
* @menu: a valid #GtkMenu
|
2008-06-20 11:06:52 +00:00
|
|
|
|
*
|
|
|
|
|
* Retrieves the accelerator path set on the menu.
|
|
|
|
|
*
|
2008-07-21 23:23:41 +00:00
|
|
|
|
* Returns: the accelerator path set on the menu.
|
2008-06-20 11:06:52 +00:00
|
|
|
|
*/
|
|
|
|
|
const gchar*
|
2008-09-03 13:18:34 +00:00
|
|
|
|
gtk_menu_get_accel_path (GtkMenu *menu)
|
2008-06-20 11:06:52 +00:00
|
|
|
|
{
|
2008-06-21 09:49:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
return menu->priv->accel_path;
|
2008-06-20 11:06:52 +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
|
|
|
|
typedef struct {
|
|
|
|
|
GtkMenu *menu;
|
|
|
|
|
gboolean group_changed;
|
|
|
|
|
} AccelPropagation;
|
|
|
|
|
|
|
|
|
|
static void
|
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
|
|
|
|
}
|
|
|
|
|
|
2001-11-20 23:43:03 +00:00
|
|
|
|
static void
|
2008-09-03 13:18:34 +00:00
|
|
|
|
_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;
|
2008-09-03 13:18:34 +00:00
|
|
|
|
|
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));
|
|
|
|
|
|
2016-09-05 01:09:20 +00:00
|
|
|
|
if (gtk_widget_is_drawable (GTK_WIDGET (menu)))
|
2010-10-31 19:52:32 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
*/
|
1999-02-25 08:17:13 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_menu_reorder_child (GtkMenu *menu,
|
|
|
|
|
GtkWidget *child,
|
|
|
|
|
gint position)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuShell *menu_shell;
|
2003-12-19 20:56:19 +00:00
|
|
|
|
|
1999-02-25 08:17:13 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU_ITEM (child));
|
2003-12-19 20:56:19 +00:00
|
|
|
|
|
1999-02-25 08:17:13 +00:00
|
|
|
|
menu_shell = GTK_MENU_SHELL (menu);
|
2003-12-19 20:56:19 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (g_list_find (menu_shell->priv->children, child))
|
2010-12-23 20:50:18 +00:00
|
|
|
|
{
|
2010-12-23 23:21:53 +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);
|
2003-12-19 20:56:19 +00:00
|
|
|
|
|
2004-03-15 02:03:59 +00:00
|
|
|
|
menu_queue_resize (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
}
|
1999-02-25 08:17:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_realize (GtkWidget *widget)
|
|
|
|
|
{
|
2016-11-02 16:50:12 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_menu_parent_class)->realize (widget);
|
2010-08-11 21:08:37 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (GTK_MENU_SHELL (widget)->priv->active_menu_item)
|
2002-02-18 22:08:41 +00:00
|
|
|
|
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
|
2010-12-23 23:21:53 +00:00
|
|
|
|
GTK_MENU_SHELL (widget)->priv->active_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
|
|
|
|
}
|
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
static gboolean
|
2002-10-01 09:57:55 +00:00
|
|
|
|
gtk_menu_focus (GtkWidget *widget,
|
|
|
|
|
GtkDirectionType direction)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
/* A menu or its menu items cannot have focus */
|
2002-10-01 09:57:55 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
|
static GdkSurface *
|
2018-03-21 10:49:14 +00:00
|
|
|
|
menu_grab_transfer_surface_get (GtkMenu *menu)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-surface");
|
|
|
|
|
if (!surface)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
surface = gdk_surface_new_temp (gtk_widget_get_display (GTK_WIDGET (menu)));
|
|
|
|
|
gtk_widget_register_surface (GTK_WIDGET (menu), surface);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gdk_surface_show (surface);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-transfer-surface"), surface);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
return surface;
|
2002-02-02 21:50:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-03-21 10:49:14 +00:00
|
|
|
|
menu_grab_transfer_surface_destroy (GtkMenu *menu)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface = g_object_get_data (G_OBJECT (menu), "gtk-menu-transfer-surface");
|
|
|
|
|
if (surface)
|
2002-02-02 21:50:46 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *widget_surface;
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gtk_widget_unregister_surface (GTK_WIDGET (menu), surface);
|
|
|
|
|
gdk_surface_destroy (surface);
|
|
|
|
|
g_object_set_data (G_OBJECT (menu), I_("gtk-menu-transfer-surface"), NULL);
|
wayland: Fix GtkMenuButton popups in a terrible, hacky way
Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.
For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path. For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.
Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.
It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
2014-05-15 21:20:00 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
widget_surface = gtk_widget_get_surface (GTK_WIDGET (menu));
|
|
|
|
|
g_object_set_data (G_OBJECT (widget_surface), I_("gdk-attached-grab-surface"), surface);
|
2002-02-02 21:50:46 +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_unrealize (GtkWidget *widget)
|
|
|
|
|
{
|
2008-02-07 16:59:42 +00:00
|
|
|
|
GtkMenu *menu = GTK_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
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
menu_grab_transfer_surface_destroy (menu);
|
2002-02-02 21:50:46 +00:00
|
|
|
|
|
2008-08-12 09:06:34 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_menu_parent_class)->unrealize (widget);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 23:42:02 +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
|
|
|
|
{
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
GtkMenuPrivate *priv;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuShell *menu_shell;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
GtkWidget *child, *widget;
|
|
|
|
|
GList *children;
|
|
|
|
|
gint n_heights;
|
|
|
|
|
guint *min_heights;
|
|
|
|
|
guint *nat_heights;
|
|
|
|
|
gint avail_width;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
|
|
|
|
priv = menu->priv;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
widget = GTK_WIDGET (menu);
|
|
|
|
|
menu_shell = GTK_MENU_SHELL (widget);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-08-18 23:42:02 +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);
|
2019-04-13 10:36:34 +00:00
|
|
|
|
avail_width = for_width - (2 * priv->toggle_size + priv->accel_size);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
for (children = menu_shell->priv->children; children; children = children->next)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
gint part;
|
|
|
|
|
gint toggle_size;
|
2019-04-14 22:42:57 +00:00
|
|
|
|
gint t;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
gint child_min, child_nat;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
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))
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
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
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
get_effective_child_attach (child, &t);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2017-03-04 07:18:36 +00:00
|
|
|
|
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL,
|
2019-04-13 10:36:34 +00:00
|
|
|
|
avail_width,
|
2017-03-04 07:18:36 +00:00
|
|
|
|
&child_min, &child_nat,
|
|
|
|
|
NULL, NULL);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
part = MAX (child_min, toggle_size);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
min_heights[t] = MAX (min_heights[t], part);
|
2008-11-01 04:32:40 +00:00
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
part = MAX (child_nat, toggle_size);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
nat_heights[t] = MAX (nat_heights[t], part);
|
2008-11-01 04:32:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
if (ret_min_heights)
|
|
|
|
|
*ret_min_heights = min_heights;
|
|
|
|
|
else
|
|
|
|
|
g_free (min_heights);
|
2005-12-02 19:49:10 +00:00
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
if (ret_nat_heights)
|
|
|
|
|
*ret_nat_heights = nat_heights;
|
|
|
|
|
else
|
|
|
|
|
g_free (nat_heights);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
return n_heights;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_menu_size_allocate (GtkWidget *widget,
|
|
|
|
|
int widget_width,
|
|
|
|
|
int widget_height,
|
|
|
|
|
int baseline)
|
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;
|
2015-12-21 01:30:52 +00:00
|
|
|
|
GtkAllocation arrow_allocation, child_allocation;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
GList *children;
|
2010-11-30 23:55:14 +00:00
|
|
|
|
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;
|
2017-05-07 10:36:47 +00:00
|
|
|
|
GtkBorder arrow_border;
|
2018-09-18 14:29:10 +00:00
|
|
|
|
int base_width;
|
2010-11-21 18:40:28 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_MENU (widget));
|
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
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
g_free (priv->heights);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
priv->heights_length = calculate_line_heights (menu,
|
2018-08-16 04:53:03 +00:00
|
|
|
|
widget_width,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
&priv->heights,
|
|
|
|
|
NULL);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
|
|
|
|
/* refresh our cached height request */
|
2017-05-07 10:36:47 +00:00
|
|
|
|
priv->requested_height = 0;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
for (i = 0; i < priv->heights_length; i++)
|
|
|
|
|
priv->requested_height += priv->heights[i];
|
|
|
|
|
|
2018-09-17 09:19:57 +00:00
|
|
|
|
|
|
|
|
|
/* Show scroll arrows if necessary */
|
2018-08-16 04:53:03 +00:00
|
|
|
|
if (priv->requested_height > widget_height)
|
2018-09-17 09:19:57 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_child_visible (priv->top_arrow_widget, TRUE);
|
|
|
|
|
gtk_widget_set_child_visible (priv->bottom_arrow_widget, TRUE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_child_visible (priv->top_arrow_widget, FALSE);
|
|
|
|
|
gtk_widget_set_child_visible (priv->bottom_arrow_widget, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-16 04:53:03 +00:00
|
|
|
|
x = 0;
|
|
|
|
|
y = 0;
|
|
|
|
|
width = widget_width;
|
|
|
|
|
height = widget_height;
|
2002-08-02 22:03:23 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (menu_shell->priv->active)
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gtk_menu_scroll_to (menu, priv->scroll_offset);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
2015-12-21 01:30:52 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
|
|
|
|
|
|
|
|
|
arrow_allocation.x = x;
|
|
|
|
|
arrow_allocation.y = y;
|
|
|
|
|
arrow_allocation.width = width;
|
|
|
|
|
arrow_allocation.height = arrow_border.top;
|
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->top_arrow_widget, &arrow_allocation, -1);
|
2015-12-21 01:30:52 +00:00
|
|
|
|
|
|
|
|
|
arrow_allocation.y = height - y - arrow_border.bottom;
|
|
|
|
|
arrow_allocation.height = arrow_border.bottom;
|
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget))
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->bottom_arrow_widget, &arrow_allocation, -1);
|
2015-12-21 01:30:52 +00:00
|
|
|
|
|
2018-09-18 14:29:10 +00:00
|
|
|
|
|
2019-04-13 10:36:34 +00:00
|
|
|
|
base_width = width;
|
2018-09-18 14:29:10 +00:00
|
|
|
|
children = menu_shell->priv->children;
|
|
|
|
|
while (children)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-09-18 14:29:10 +00:00
|
|
|
|
child = children->data;
|
|
|
|
|
children = children->next;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2018-09-18 14:29:10 +00:00
|
|
|
|
if (gtk_widget_get_visible (child))
|
2010-12-23 20:50:18 +00:00
|
|
|
|
{
|
2019-04-14 22:42:57 +00:00
|
|
|
|
gint t;
|
2018-09-18 14:29:10 +00:00
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
get_effective_child_attach (child, &t);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2019-04-13 10:36:34 +00:00
|
|
|
|
child_allocation.width = base_width;
|
2018-09-18 14:29:10 +00:00
|
|
|
|
child_allocation.height = 0;
|
2019-04-13 10:36:34 +00:00
|
|
|
|
child_allocation.x = 0;
|
2018-09-18 14:29:10 +00:00
|
|
|
|
child_allocation.y = - priv->scroll_offset;
|
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
for (i = 0; i < t + 1; i++)
|
2018-09-18 14:29:10 +00:00
|
|
|
|
{
|
|
|
|
|
if (i < t)
|
|
|
|
|
child_allocation.y += priv->heights[i];
|
|
|
|
|
else
|
|
|
|
|
child_allocation.height += priv->heights[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child),
|
|
|
|
|
priv->toggle_size);
|
|
|
|
|
|
|
|
|
|
gtk_widget_size_allocate (child, &child_allocation, -1);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-17 19:46:25 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_snapshot (GtkWidget *widget,
|
|
|
|
|
GtkSnapshot *snapshot)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-09-17 09:19:57 +00:00
|
|
|
|
GtkMenuPrivate *priv = gtk_menu_get_instance_private (GTK_MENU (widget));
|
|
|
|
|
GtkBorder arrows_border;
|
|
|
|
|
|
|
|
|
|
get_arrows_border (GTK_MENU (widget), &arrows_border);
|
|
|
|
|
|
|
|
|
|
/* TODO: This snapshots the arrow widgets twice. */
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
|
|
|
|
|
gtk_widget_snapshot_child (widget, priv->top_arrow_widget, snapshot);
|
|
|
|
|
|
2016-12-17 19:46:25 +00:00
|
|
|
|
gtk_snapshot_push_clip (snapshot,
|
2017-12-04 11:42:52 +00:00
|
|
|
|
&GRAPHENE_RECT_INIT(
|
2018-09-17 09:19:57 +00:00
|
|
|
|
0, arrows_border.top,
|
2017-12-04 11:42:52 +00:00
|
|
|
|
gtk_widget_get_width (widget),
|
2018-09-17 09:19:57 +00:00
|
|
|
|
gtk_widget_get_height (widget) - arrows_border.top - arrows_border.bottom));
|
2016-03-24 18:50:45 +00:00
|
|
|
|
|
2016-12-17 19:46:25 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_menu_parent_class)->snapshot (widget, snapshot);
|
2008-08-12 09:06:34 +00:00
|
|
|
|
|
2017-01-12 23:39:59 +00:00
|
|
|
|
gtk_snapshot_pop (snapshot);
|
2018-09-17 09:19:57 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget))
|
|
|
|
|
gtk_widget_snapshot_child (widget, priv->bottom_arrow_widget, snapshot);
|
1997-11-24 22:37:52 +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
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
static void gtk_menu_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2010-08-18 23:42:02 +00:00
|
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (widget);
|
|
|
|
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget);
|
|
|
|
|
GtkMenuPrivate *priv = gtk_menu_get_instance_private (menu);
|
|
|
|
|
GtkWidget *child;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
|
|
|
|
GList *children;
|
|
|
|
|
guint max_toggle_size;
|
|
|
|
|
guint max_accel_width;
|
|
|
|
|
gint child_min, child_nat;
|
|
|
|
|
gint min_width, nat_width;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
min_width = nat_width = 0;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
max_toggle_size = 0;
|
|
|
|
|
max_accel_width = 0;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
children = menu_shell->priv->children;
|
|
|
|
|
while (children)
|
|
|
|
|
{
|
|
|
|
|
gint toggle_size;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
child = children->data;
|
|
|
|
|
children = children->next;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
if (! gtk_widget_get_visible (child))
|
|
|
|
|
continue;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
/* 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)
|
|
|
|
|
*/
|
2017-03-04 07:18:36 +00:00
|
|
|
|
gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
-1, &child_min, &child_nat, NULL, NULL);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
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);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2019-04-13 10:36:34 +00:00
|
|
|
|
min_width = MAX (min_width, child_min);
|
|
|
|
|
nat_width = MAX (nat_width, child_min);
|
2016-10-22 14:06:14 +00:00
|
|
|
|
}
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
/* 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
|
|
|
|
|
*/
|
|
|
|
|
if (max_toggle_size == 0 &&
|
|
|
|
|
!priv->no_toggle_size)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *menu_item;
|
2017-05-10 19:22:42 +00:00
|
|
|
|
GtkWidget *indicator_widget;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
gint indicator_width;
|
|
|
|
|
|
|
|
|
|
/* Create a GtkCheckMenuItem, to query indicator size */
|
|
|
|
|
menu_item = gtk_check_menu_item_new ();
|
2017-05-10 19:22:42 +00:00
|
|
|
|
indicator_widget = _gtk_check_menu_item_get_indicator_widget (GTK_CHECK_MENU_ITEM (menu_item));
|
|
|
|
|
|
|
|
|
|
gtk_widget_measure (indicator_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
|
-1,
|
|
|
|
|
&indicator_width, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-10-22 14:06:14 +00:00
|
|
|
|
max_toggle_size = indicator_width;
|
|
|
|
|
|
2016-11-23 19:48:17 +00:00
|
|
|
|
g_object_ref_sink (menu_item);
|
|
|
|
|
g_object_unref (menu_item);
|
2016-10-22 14:06:14 +00:00
|
|
|
|
}
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
min_width += 2 * max_toggle_size + max_accel_width;
|
|
|
|
|
nat_width += 2 * max_toggle_size + max_accel_width;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
priv->toggle_size = max_toggle_size;
|
|
|
|
|
priv->accel_size = max_accel_width;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
*minimum = min_width;
|
|
|
|
|
*natural = nat_width;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
}
|
|
|
|
|
else /* VERTICAL */
|
|
|
|
|
{
|
|
|
|
|
if (for_size < 0)
|
|
|
|
|
{
|
|
|
|
|
gint min_width, nat_width;
|
|
|
|
|
|
|
|
|
|
/* Menus are height-for-width only, just return the height
|
|
|
|
|
* for the minimum width
|
|
|
|
|
*/
|
|
|
|
|
GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&min_width, &nat_width, NULL, NULL);
|
|
|
|
|
GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_VERTICAL, min_width,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-07 10:36:47 +00:00
|
|
|
|
GtkBorder arrow_border;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
guint *min_heights, *nat_heights;
|
|
|
|
|
gint n_heights, i;
|
|
|
|
|
gint min_height, single_height, nat_height;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2017-05-07 10:36:47 +00:00
|
|
|
|
min_height = nat_height = 0;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
single_height = 0;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
n_heights =
|
|
|
|
|
calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
|
2011-01-12 19:35:04 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
for (i = 0; i < n_heights; i++)
|
|
|
|
|
{
|
|
|
|
|
min_height += min_heights[i];
|
|
|
|
|
single_height = MAX (single_height, min_heights[i]);
|
|
|
|
|
nat_height += nat_heights[i];
|
|
|
|
|
}
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
2017-05-07 10:36:47 +00:00
|
|
|
|
single_height += arrow_border.top + arrow_border.bottom;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
min_height = MIN (min_height, single_height);
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
*minimum = min_height;
|
|
|
|
|
*natural = nat_height;
|
2014-10-31 01:10:13 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
g_free (min_heights);
|
|
|
|
|
g_free (nat_heights);
|
2010-08-21 01:15:35 +00:00
|
|
|
|
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-08-18 23:42:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 15:47:49 +00:00
|
|
|
|
static gboolean
|
2018-03-21 10:49:14 +00:00
|
|
|
|
pointer_in_menu_surface (GtkWidget *widget,
|
|
|
|
|
gdouble x_root,
|
|
|
|
|
gdouble y_root)
|
2007-03-29 15:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu = GTK_MENU (widget);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
GtkAllocation allocation;
|
2007-03-29 15:47:49 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (gtk_widget_get_mapped (priv->toplevel))
|
2007-03-29 15:47:49 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenuShell *menu_shell;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gint surface_x, surface_y;
|
2007-03-29 15:47:49 +00:00
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
|
gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
|
2018-03-21 10:49:14 +00:00
|
|
|
|
&surface_x, &surface_y);
|
2007-03-29 15:47:49 +00:00
|
|
|
|
|
2010-08-11 21:08:37 +00:00
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (x_root >= surface_x && x_root < surface_x + allocation.width &&
|
|
|
|
|
y_root >= surface_y && y_root < surface_y + allocation.height)
|
2007-03-29 15:47:49 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
menu_shell = GTK_MENU_SHELL (widget);
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (GTK_IS_MENU (menu_shell->priv->parent_menu_shell))
|
2018-03-21 10:49:14 +00:00
|
|
|
|
return pointer_in_menu_surface (menu_shell->priv->parent_menu_shell,
|
2007-03-29 15:47:49 +00:00
|
|
|
|
x_root, y_root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 12:20:47 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_pressed_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
int n_press,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu = user_data;
|
|
|
|
|
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
const GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
|
|
|
|
const GdkEventButton *button_event = (GdkEventButton *)event;
|
2011-12-12 19:07:57 +00:00
|
|
|
|
GdkDevice *source_device;
|
|
|
|
|
GtkWidget *event_widget;
|
|
|
|
|
|
2016-12-02 12:20:47 +00:00
|
|
|
|
source_device = gdk_event_get_source_device (event);
|
|
|
|
|
event_widget = gtk_get_event_widget ((GdkEvent *)event);
|
2007-03-29 15:47:49 +00:00
|
|
|
|
/* 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.
|
|
|
|
|
*/
|
2011-12-12 19:07:57 +00:00
|
|
|
|
if (GTK_IS_MENU_SHELL (event_widget) &&
|
2018-03-21 10:49:14 +00:00
|
|
|
|
pointer_in_menu_surface (GTK_WIDGET (menu), button_event->x_root, button_event->y_root))
|
2016-12-02 12:20:47 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-03-29 15:47:49 +00:00
|
|
|
|
|
2011-12-12 19:07:57 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2016-12-02 12:20:47 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
2002-11-09 20:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-02 12:20:47 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_released_cb (GtkGestureMultiPress *gesture,
|
|
|
|
|
int n_press,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data)
|
2002-11-09 20:52:31 +00:00
|
|
|
|
{
|
2016-12-02 12:20:47 +00:00
|
|
|
|
GtkMenu *menu = user_data;
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
GdkEventSequence *sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
const GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
|
|
|
|
const GdkEventButton *button_event = (GdkEventButton *)event;
|
2002-11-09 20:52:31 +00:00
|
|
|
|
|
2007-02-01 13:57:36 +00:00
|
|
|
|
if (priv->ignore_button_release)
|
|
|
|
|
{
|
|
|
|
|
priv->ignore_button_release = FALSE;
|
2016-12-02 12:20:47 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
|
|
|
|
|
return;
|
2002-11-09 20:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-29 15:47:49 +00:00
|
|
|
|
/* Don't pass down to menu shell if a non-menuitem part of the menu
|
2018-01-16 18:41:29 +00:00
|
|
|
|
* was clicked (see comment in gtk_menu_pressed_cb()).
|
2007-03-29 15:47:49 +00:00
|
|
|
|
*/
|
|
|
|
|
if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) &&
|
2018-03-21 10:49:14 +00:00
|
|
|
|
pointer_in_menu_surface (GTK_WIDGET (menu), button_event->x_root, button_event->y_root))
|
2007-09-11 17:38:12 +00:00
|
|
|
|
{
|
|
|
|
|
/* 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
|
2018-01-16 18:41:29 +00:00
|
|
|
|
* next button press or release in GtkMenuShell.
|
2007-09-11 17:38:12 +00:00
|
|
|
|
* See bug #449371.
|
|
|
|
|
*/
|
2016-12-02 12:20:47 +00:00
|
|
|
|
if (GTK_MENU_SHELL (menu)->priv->active)
|
|
|
|
|
GTK_MENU_SHELL (menu)->priv->button = 0;
|
2007-09-11 17:38:12 +00:00
|
|
|
|
|
2016-12-02 12:20:47 +00:00
|
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
2007-09-11 17:38:12 +00:00
|
|
|
|
}
|
2002-11-09 20:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-22 16:52:23 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
check_threshold (GtkWidget *widget,
|
2008-09-03 13:18:34 +00:00
|
|
|
|
gint start_x,
|
|
|
|
|
gint start_y,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2004-12-22 16:52:23 +00:00
|
|
|
|
{
|
|
|
|
|
#define THRESHOLD 8
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2004-12-22 16:52:23 +00:00
|
|
|
|
return
|
2010-12-23 20:50:18 +00:00
|
|
|
|
ABS (start_x - x) > THRESHOLD ||
|
2004-12-22 16:52:23 +00:00
|
|
|
|
ABS (start_y - y) > THRESHOLD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-04-07 11:37:24 +00:00
|
|
|
|
definitely_within_item (GtkMenu *menu,
|
|
|
|
|
GtkWidget *widget,
|
2008-09-03 13:18:34 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
2004-12-22 16:52:23 +00:00
|
|
|
|
{
|
|
|
|
|
int w, h;
|
2018-04-07 11:37:24 +00:00
|
|
|
|
graphene_rect_t bounds;
|
2004-12-22 16:52:23 +00:00
|
|
|
|
|
2019-02-20 03:53:47 +00:00
|
|
|
|
if (!gtk_widget_compute_bounds (widget, GTK_WIDGET (menu), &bounds))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2018-04-07 11:37:24 +00:00
|
|
|
|
w = bounds.size.width;
|
|
|
|
|
h = bounds.size.height;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2004-12-22 16:52:23 +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);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:14:01 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_menu_has_navigation_triangle (GtkMenu *menu)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2010-06-16 11:14:01 +00:00
|
|
|
|
|
|
|
|
|
return priv->navigation_height && priv->navigation_width;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_motion (GtkEventController *controller,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
gpointer user_data)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2000-09-02 02:43:50 +00:00
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
|
GtkMenu *menu;
|
|
|
|
|
GtkMenuShell *menu_shell;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
GtkWidget *parent;
|
2011-12-12 17:11:57 +00:00
|
|
|
|
GdkDevice *source_device;
|
2018-01-02 18:22:36 +00:00
|
|
|
|
GdkEventMotion *event;
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
menu_item = GTK_WIDGET (user_data);
|
|
|
|
|
|
|
|
|
|
event = (GdkEventMotion *)gtk_get_current_event (); /* FIXME: controller event */
|
|
|
|
|
|
|
|
|
|
source_device = gdk_event_get_source_device ((GdkEvent *)event);
|
2011-12-12 17:11:57 +00:00
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
if (GTK_IS_MENU (menu_item) &&
|
2011-12-12 17:11:57 +00:00
|
|
|
|
gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2018-01-02 18:22:36 +00:00
|
|
|
|
GtkMenuPrivate *priv = GTK_MENU(menu_item)->priv;
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
if (priv->ignore_button_release)
|
|
|
|
|
priv->ignore_button_release = FALSE;
|
|
|
|
|
|
2019-04-15 02:19:28 +00:00
|
|
|
|
gtk_menu_handle_scrolling (GTK_MENU (menu_item), event->x_root, event->y_root, TRUE);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
}
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
/*We received the event for one of two reasons:
|
2000-09-02 02:43:50 +00:00
|
|
|
|
*
|
|
|
|
|
* 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'.
|
|
|
|
|
*/
|
2010-08-11 21:08:37 +00:00
|
|
|
|
parent = gtk_widget_get_parent (menu_item);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
if (!GTK_IS_MENU_ITEM (menu_item) ||
|
2010-08-11 21:08:37 +00:00
|
|
|
|
!GTK_IS_MENU (parent))
|
2018-01-02 18:22:36 +00:00
|
|
|
|
return;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
menu_shell = GTK_MENU_SHELL (parent);
|
2000-09-02 02:43:50 +00:00
|
|
|
|
menu = GTK_MENU (menu_shell);
|
2004-12-22 16:52:23 +00:00
|
|
|
|
|
2018-04-07 11:37:24 +00:00
|
|
|
|
if (definitely_within_item (menu, menu_item, event->x, event->y))
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->activate_time = 0;
|
2007-04-25 12:11:08 +00:00
|
|
|
|
|
2000-09-02 02:43:50 +00:00
|
|
|
|
/* 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))
|
2018-01-02 18:22:36 +00:00
|
|
|
|
return;
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2004-02-21 18:20:59 +00:00
|
|
|
|
/* 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))
|
|
|
|
|
{
|
2010-03-14 20:11:48 +00:00
|
|
|
|
/* 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);
|
2004-02-21 18:20:59 +00:00
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-12-13 18:22:02 +00:00
|
|
|
|
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;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
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;
|
2010-09-20 14:39:25 +00:00
|
|
|
|
gint view_height;
|
2010-08-11 21:08:37 +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
|
|
|
|
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
|
|
|
|
|
2007-05-09 15:46:41 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
2006-05-10 14:02:20 +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
|
|
|
|
/* 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;
|
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
|
view_height = gdk_surface_get_height (gtk_widget_get_surface (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 &&
|
2010-08-18 23:42:02 +00:00
|
|
|
|
view_height >= priv->requested_height)
|
2006-03-27 17:00:01 +00:00
|
|
|
|
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)
|
2007-05-09 15:46:41 +00:00
|
|
|
|
view_height -= arrow_border.top;
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
2015-12-21 02:44:10 +00:00
|
|
|
|
/* Since arrows are shown, reduce view height even more */
|
|
|
|
|
view_height -= arrow_border.bottom;
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if ((priv->scroll_offset + view_height <= priv->requested_height) &&
|
2010-08-18 23:42:02 +00:00
|
|
|
|
(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)
|
2004-12-13 18:22:02 +00:00
|
|
|
|
gtk_menu_scroll_to (menu, offset);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-13 18:40:12 +00:00
|
|
|
|
static gboolean
|
2007-03-29 08:14:22 +00:00
|
|
|
|
gtk_menu_scroll_timeout (gpointer data)
|
2004-12-13 18:22:02 +00:00
|
|
|
|
{
|
2007-03-29 08:14:22 +00:00
|
|
|
|
GtkMenu *menu;
|
2004-12-13 18:22:02 +00:00
|
|
|
|
|
|
|
|
|
menu = GTK_MENU (data);
|
2011-12-12 17:48:30 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean
|
2017-09-15 11:53:27 +00:00
|
|
|
|
gtk_menu_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
|
|
|
|
gdouble dx,
|
|
|
|
|
gdouble dy,
|
|
|
|
|
GtkMenu *menu)
|
2004-12-13 18:22:02 +00:00
|
|
|
|
{
|
2017-09-15 11:53:27 +00:00
|
|
|
|
gtk_menu_scroll_by (menu, dy * MENU_SCROLL_STEP2);
|
2018-07-18 13:34:39 +00:00
|
|
|
|
|
|
|
|
|
return GDK_EVENT_STOP;
|
2004-12-13 18:22:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-05-09 15:46:41 +00:00
|
|
|
|
static void
|
2008-09-03 13:18:34 +00:00
|
|
|
|
get_arrows_sensitive_area (GtkMenu *menu,
|
2007-05-09 15:46:41 +00:00
|
|
|
|
GdkRectangle *upper,
|
|
|
|
|
GdkRectangle *lower)
|
|
|
|
|
{
|
2015-12-21 01:30:52 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (menu);
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface;
|
2007-05-09 15:46:41 +00:00
|
|
|
|
gint width, height;
|
|
|
|
|
gint win_x, win_y;
|
2015-12-21 01:30:52 +00:00
|
|
|
|
gint top_arrow_height, bottom_arrow_height;
|
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_measure (priv->top_arrow_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
-1,
|
|
|
|
|
&top_arrow_height, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
gtk_widget_measure (priv->bottom_arrow_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL,
|
|
|
|
|
-1,
|
|
|
|
|
&bottom_arrow_height, NULL,
|
|
|
|
|
NULL, NULL);
|
2007-05-09 15:46:41 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
surface = gtk_widget_get_surface (widget);
|
|
|
|
|
width = gdk_surface_get_width (surface);
|
|
|
|
|
height = gdk_surface_get_height (surface);
|
2010-08-11 21:08:37 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gdk_surface_get_position (surface, &win_x, &win_y);
|
2007-05-09 15:46:41 +00:00
|
|
|
|
|
2015-12-20 19:19:23 +00:00
|
|
|
|
if (upper)
|
2007-05-09 15:46:41 +00:00
|
|
|
|
{
|
2015-12-20 19:19:23 +00:00
|
|
|
|
upper->x = win_x;
|
|
|
|
|
upper->y = win_y;
|
|
|
|
|
upper->width = width;
|
2017-05-07 10:36:47 +00:00
|
|
|
|
upper->height = top_arrow_height;
|
2015-12-20 19:19:23 +00:00
|
|
|
|
}
|
2008-10-08 02:16:08 +00:00
|
|
|
|
|
2015-12-20 19:19:23 +00:00
|
|
|
|
if (lower)
|
|
|
|
|
{
|
|
|
|
|
lower->x = win_x;
|
2017-05-07 10:36:47 +00:00
|
|
|
|
lower->y = win_y + height - bottom_arrow_height;
|
2015-12-20 19:19:23 +00:00
|
|
|
|
lower->width = width;
|
2017-05-07 10:36:47 +00:00
|
|
|
|
lower->height = bottom_arrow_height;
|
2007-05-09 15:46:41 +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
|
2005-02-03 18:09:41 +00:00
|
|
|
|
gtk_menu_handle_scrolling (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
2019-04-15 02:19:28 +00:00
|
|
|
|
gboolean enter)
|
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;
|
2005-02-03 18:09:41 +00:00
|
|
|
|
gint top_x, top_y;
|
2007-03-29 08:14:22 +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
|
|
|
|
menu_shell = GTK_MENU_SHELL (menu);
|
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
|
gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
|
2010-08-11 21:08:37 +00:00
|
|
|
|
&top_x, &top_y);
|
2005-04-04 16:20:28 +00:00
|
|
|
|
x -= top_x;
|
|
|
|
|
y -= top_y;
|
|
|
|
|
|
2006-02-22 10:10:23 +00:00
|
|
|
|
/* upper arrow handling */
|
|
|
|
|
|
2007-05-09 15:46:41 +00:00
|
|
|
|
get_arrows_sensitive_area (menu, &rect, NULL);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
in_arrow = FALSE;
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->top_arrow_widget) &&
|
2006-02-22 10:10:23 +00:00
|
|
|
|
(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
|
|
|
|
{
|
2006-02-22 10:10:23 +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
|
|
|
|
|
2010-11-21 18:40:28 +00:00
|
|
|
|
if ((priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);
|
|
|
|
|
|
|
|
|
|
if (enter && in_arrow &&
|
|
|
|
|
(!priv->upper_arrow_prelight ||
|
|
|
|
|
priv->scroll_fast != scroll_fast))
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2018-02-02 14:51:47 +00:00
|
|
|
|
priv->scroll_timeout = g_timeout_add (scroll_fast
|
|
|
|
|
? MENU_SCROLL_TIMEOUT2
|
|
|
|
|
: MENU_SCROLL_TIMEOUT1,
|
|
|
|
|
gtk_menu_scroll_timeout,
|
|
|
|
|
menu);
|
2019-02-05 10:26:20 +00:00
|
|
|
|
g_source_set_name_by_id (priv->scroll_timeout, "[gtk] gtk_menu_scroll_timeout");
|
2006-02-22 10:10:23 +00:00
|
|
|
|
}
|
2011-12-12 17:48:30 +00:00
|
|
|
|
else if (!enter && !in_arrow && priv->upper_arrow_prelight)
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
gtk_menu_stop_scrolling (menu);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-12 17:48:30 +00:00
|
|
|
|
/* check if the button isn't insensitive before
|
2007-06-27 11:43:16 +00:00
|
|
|
|
* changing it to something else.
|
|
|
|
|
*/
|
2010-11-21 18:40:28 +00:00
|
|
|
|
if ((priv->upper_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
|
2007-04-25 12:11:08 +00:00
|
|
|
|
{
|
2010-11-21 18:40:28 +00:00
|
|
|
|
GtkStateFlags arrow_state = 0;
|
2007-06-27 11:43:16 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (priv->upper_arrow_prelight)
|
2010-11-21 18:40:28 +00:00
|
|
|
|
arrow_state |= GTK_STATE_FLAG_PRELIGHT;
|
2007-04-25 12:11:08 +00:00
|
|
|
|
|
2007-06-27 11:43:16 +00:00
|
|
|
|
if (arrow_state != priv->upper_arrow_state)
|
|
|
|
|
{
|
|
|
|
|
priv->upper_arrow_state = arrow_state;
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_set_state_flags (priv->top_arrow_widget, arrow_state, TRUE);
|
2007-06-27 11:43:16 +00:00
|
|
|
|
}
|
2007-04-25 12:11:08 +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
|
|
|
|
}
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
/* lower arrow handling */
|
|
|
|
|
|
2007-05-09 15:46:41 +00:00
|
|
|
|
get_arrows_sensitive_area (menu, NULL, &rect);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
|
|
|
|
in_arrow = FALSE;
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget) &&
|
2006-02-22 10:10:23 +00:00
|
|
|
|
(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
|
|
|
|
{
|
2006-02-22 10:10:23 +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
|
|
|
|
|
2010-11-21 18:40:28 +00:00
|
|
|
|
if ((priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget))
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);
|
|
|
|
|
|
|
|
|
|
if (enter && in_arrow &&
|
|
|
|
|
(!priv->lower_arrow_prelight ||
|
|
|
|
|
priv->scroll_fast != scroll_fast))
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2018-02-02 14:51:47 +00:00
|
|
|
|
priv->scroll_timeout = g_timeout_add (scroll_fast
|
|
|
|
|
? MENU_SCROLL_TIMEOUT2
|
|
|
|
|
: MENU_SCROLL_TIMEOUT1,
|
|
|
|
|
gtk_menu_scroll_timeout,
|
|
|
|
|
menu);
|
2019-02-05 10:26:20 +00:00
|
|
|
|
g_source_set_name_by_id (priv->scroll_timeout, "[gtk] gtk_menu_scroll_timeout");
|
2006-02-22 10:10:23 +00:00
|
|
|
|
}
|
2011-12-12 17:48:30 +00:00
|
|
|
|
else if (!enter && !in_arrow && priv->lower_arrow_prelight)
|
2006-02-22 10:10:23 +00:00
|
|
|
|
{
|
2011-12-12 17:48:30 +00:00
|
|
|
|
gtk_menu_stop_scrolling (menu);
|
2006-02-22 10:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-12 17:48:30 +00:00
|
|
|
|
/* check if the button isn't insensitive before
|
2007-06-27 11:43:16 +00:00
|
|
|
|
* changing it to something else.
|
|
|
|
|
*/
|
2010-11-21 18:40:28 +00:00
|
|
|
|
if ((priv->lower_arrow_state & GTK_STATE_FLAG_INSENSITIVE) == 0)
|
2007-04-25 12:11:08 +00:00
|
|
|
|
{
|
2010-11-21 18:40:28 +00:00
|
|
|
|
GtkStateFlags arrow_state = 0;
|
2007-06-27 11:43:16 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (priv->lower_arrow_prelight)
|
2010-11-21 18:40:28 +00:00
|
|
|
|
arrow_state |= GTK_STATE_FLAG_PRELIGHT;
|
2007-04-25 12:11:08 +00:00
|
|
|
|
|
2007-06-27 11:43:16 +00:00
|
|
|
|
if (arrow_state != priv->lower_arrow_state)
|
|
|
|
|
{
|
|
|
|
|
priv->lower_arrow_state = arrow_state;
|
2017-05-10 20:13:16 +00:00
|
|
|
|
gtk_widget_set_state_flags (priv->bottom_arrow_widget, arrow_state, TRUE);
|
2007-06-27 11:43:16 +00:00
|
|
|
|
}
|
2007-04-25 12:11:08 +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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_enter (GtkEventController *controller,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
2019-03-18 13:24:42 +00:00
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
|
GdkNotifyType detail,
|
2018-01-02 18:22:36 +00:00
|
|
|
|
gpointer user_data)
|
2000-09-02 02:43:50 +00:00
|
|
|
|
{
|
2011-12-11 17:46:50 +00:00
|
|
|
|
GdkDevice *source_device;
|
2018-01-02 18:22:36 +00:00
|
|
|
|
GdkEventCrossing *event;
|
|
|
|
|
|
|
|
|
|
event = (GdkEventCrossing *)gtk_get_current_event ();
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
2008-08-09 04:20:14 +00:00
|
|
|
|
if (event->mode == GDK_CROSSING_GTK_GRAB ||
|
|
|
|
|
event->mode == GDK_CROSSING_GTK_UNGRAB ||
|
|
|
|
|
event->mode == GDK_CROSSING_STATE_CHANGED)
|
2018-01-02 18:22:36 +00:00
|
|
|
|
return;
|
2008-08-09 04:20:14 +00:00
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
source_device = gdk_event_get_source_device ((GdkEvent *) event);
|
2011-12-11 17:46:50 +00:00
|
|
|
|
|
2017-05-02 15:53:14 +00:00
|
|
|
|
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
|
2002-11-09 20:52:31 +00:00
|
|
|
|
{
|
2018-01-02 18:22:36 +00:00
|
|
|
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL (user_data);
|
2002-11-09 20:52:31 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (!menu_shell->priv->ignore_enter)
|
2018-01-02 18:22:36 +00:00
|
|
|
|
gtk_menu_handle_scrolling (GTK_MENU (user_data),
|
2019-04-15 02:19:28 +00:00
|
|
|
|
event->x_root, event->y_root, TRUE);
|
2002-11-09 20:52:31 +00:00
|
|
|
|
}
|
2000-09-02 02:43:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_leave (GtkEventController *controller,
|
2019-03-18 13:24:42 +00:00
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
|
GdkNotifyType detail,
|
2018-01-02 18:22:36 +00:00
|
|
|
|
gpointer user_data)
|
2000-09-02 02:43:50 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu;
|
2011-12-12 17:11:57 +00:00
|
|
|
|
GdkDevice *source_device;
|
2018-01-02 18:22:36 +00:00
|
|
|
|
GdkEventCrossing *event;
|
|
|
|
|
|
|
|
|
|
event = (GdkEventCrossing *)gtk_get_current_event ();
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2008-08-09 04:20:14 +00:00
|
|
|
|
if (event->mode == GDK_CROSSING_GTK_GRAB ||
|
|
|
|
|
event->mode == GDK_CROSSING_GTK_UNGRAB ||
|
|
|
|
|
event->mode == GDK_CROSSING_STATE_CHANGED)
|
2018-01-02 18:22:36 +00:00
|
|
|
|
return;
|
2008-08-09 04:20:14 +00:00
|
|
|
|
|
2018-01-02 18:22:36 +00:00
|
|
|
|
menu = GTK_MENU (user_data);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2000-09-02 02:43:50 +00:00
|
|
|
|
if (gtk_menu_navigating_submenu (menu, event->x_root, event->y_root))
|
2018-01-02 18:22:36 +00:00
|
|
|
|
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
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
source_device = gdk_event_get_source_device ((GdkEvent *) event);
|
|
|
|
|
|
|
|
|
|
if (gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN)
|
2019-04-15 02:19:28 +00:00
|
|
|
|
gtk_menu_handle_scrolling (menu, event->x_root, event->y_root, FALSE);
|
2000-09-02 02:43:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-25 17:07:50 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_menu_key_pressed (GtkEventControllerKey *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GtkMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
gtk_menu_stop_navigating_submenu (menu);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
pointer_on_menu_widget (GtkMenu *menu,
|
|
|
|
|
gdouble x_root,
|
|
|
|
|
gdouble y_root)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
GtkAllocation allocation;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gint surface_x, surface_y;
|
2011-12-12 17:11:57 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (GTK_WIDGET (menu), &allocation);
|
2018-03-20 14:21:12 +00:00
|
|
|
|
gdk_surface_get_position (gtk_widget_get_surface (priv->toplevel),
|
2018-03-21 10:49:14 +00:00
|
|
|
|
&surface_x, &surface_y);
|
2011-12-12 17:11:57 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (x_root >= surface_x && x_root < surface_x + allocation.width &&
|
|
|
|
|
y_root >= surface_y && y_root < surface_y + allocation.height)
|
2011-12-12 17:11:57 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (!gtk_widget_get_child_visible (priv->top_arrow_widget) &&
|
|
|
|
|
!gtk_widget_get_child_visible (priv->bottom_arrow_widget) &&
|
|
|
|
|
priv->drag_start_y < 0)
|
2011-12-12 17:11:57 +00:00
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
|
|
source_device = gdk_event_get_source_device (event);
|
|
|
|
|
gdk_event_get_root_coords (event, &x_root, &y_root);
|
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
switch ((guint) gdk_event_get_event_type (event))
|
2011-12-12 17:11:57 +00:00
|
|
|
|
{
|
|
|
|
|
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:
|
2012-07-13 12:47:38 +00:00
|
|
|
|
if ((!gdk_event_get_state (event, &state) || (state & GDK_BUTTON1_MASK) != 0) &&
|
2011-12-12 17:11:57 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
|
view_height = gdk_surface_get_height (gtk_widget_get_surface (widget));
|
2011-12-12 17:11:57 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->top_arrow_widget))
|
2011-12-12 17:11:57 +00:00
|
|
|
|
view_height -= arrow_border.top;
|
|
|
|
|
|
2018-09-17 09:07:41 +00:00
|
|
|
|
if (gtk_widget_get_child_visible (priv->bottom_arrow_widget))
|
2011-12-12 17:11:57 +00:00
|
|
|
|
view_height -= arrow_border.bottom;
|
|
|
|
|
|
2012-07-13 13:03:30 +00:00
|
|
|
|
offset = CLAMP (offset,
|
|
|
|
|
MIN (priv->scroll_offset, 0),
|
|
|
|
|
MAX (priv->scroll_offset, priv->requested_height - view_height));
|
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
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
|
2000-09-02 02:43:50 +00:00
|
|
|
|
gtk_menu_stop_navigating_submenu (GtkMenu *menu)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2010-06-16 11:14:01 +00:00
|
|
|
|
|
|
|
|
|
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)
|
2000-09-02 02:43:50 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
g_source_remove (priv->navigation_timeout);
|
|
|
|
|
priv->navigation_timeout = 0;
|
2000-09-02 02:43:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gtk_menu_navigating_submenu (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint event_x,
|
|
|
|
|
gint event_y)
|
2000-09-02 02:43:50 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
|
|
|
|
gint width, height;
|
2000-09-02 02:43:50 +00:00
|
|
|
|
|
2010-06-16 11:14:01 +00:00
|
|
|
|
if (!gtk_menu_has_navigation_triangle (menu))
|
|
|
|
|
return FALSE;
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
|
2010-06-16 11:14:01 +00:00
|
|
|
|
width = priv->navigation_width;
|
|
|
|
|
height = priv->navigation_height;
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
/* Check if x/y are in the triangle spanned by the navigation parameters */
|
2010-06-16 11:14:01 +00:00
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_deactivate (GtkMenuShell *menu_shell)
|
|
|
|
|
{
|
1998-03-09 07:36:55 +00:00
|
|
|
|
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
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
parent = menu_shell->priv->parent_menu_shell;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +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
|
|
|
|
|
1998-03-09 07:36:55 +00:00
|
|
|
|
if (parent)
|
|
|
|
|
gtk_menu_shell_deactivate (GTK_MENU_SHELL (parent));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
1998-01-02 20:22:38 +00:00
|
|
|
|
|
2016-06-14 19:42:13 +00:00
|
|
|
|
static GdkGravity
|
|
|
|
|
get_horizontally_flipped_anchor (GdkGravity anchor)
|
|
|
|
|
{
|
|
|
|
|
switch (anchor)
|
|
|
|
|
{
|
|
|
|
|
case GDK_GRAVITY_STATIC:
|
|
|
|
|
case GDK_GRAVITY_NORTH_WEST:
|
|
|
|
|
return GDK_GRAVITY_NORTH_EAST;
|
|
|
|
|
case GDK_GRAVITY_NORTH:
|
|
|
|
|
return GDK_GRAVITY_NORTH;
|
|
|
|
|
case GDK_GRAVITY_NORTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_NORTH_WEST;
|
|
|
|
|
case GDK_GRAVITY_WEST:
|
|
|
|
|
return GDK_GRAVITY_EAST;
|
|
|
|
|
case GDK_GRAVITY_CENTER:
|
|
|
|
|
return GDK_GRAVITY_CENTER;
|
|
|
|
|
case GDK_GRAVITY_EAST:
|
|
|
|
|
return GDK_GRAVITY_WEST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_WEST:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_EAST;
|
|
|
|
|
case GDK_GRAVITY_SOUTH:
|
|
|
|
|
return GDK_GRAVITY_SOUTH;
|
|
|
|
|
case GDK_GRAVITY_SOUTH_EAST:
|
|
|
|
|
return GDK_GRAVITY_SOUTH_WEST;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
default:
|
|
|
|
|
g_warning ("unknown GdkGravity: %d", anchor);
|
|
|
|
|
return anchor;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_menu_position (GtkMenu *menu,
|
|
|
|
|
gboolean set_scroll_offset)
|
|
|
|
|
{
|
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *rect_surface = NULL;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
GdkRectangle rect;
|
|
|
|
|
GtkTextDirection text_direction = GTK_TEXT_DIR_NONE;
|
|
|
|
|
GdkGravity rect_anchor;
|
|
|
|
|
GdkGravity menu_anchor;
|
2016-10-14 08:41:50 +00:00
|
|
|
|
GdkAnchorHints anchor_hints;
|
|
|
|
|
gint rect_anchor_dx, rect_anchor_dy;
|
2018-03-20 10:40:08 +00:00
|
|
|
|
GdkSurface *toplevel;
|
2016-10-14 08:41:50 +00:00
|
|
|
|
gboolean emulated_move_to_rect = FALSE;
|
|
|
|
|
|
|
|
|
|
rect_anchor = priv->rect_anchor;
|
|
|
|
|
menu_anchor = priv->menu_anchor;
|
|
|
|
|
anchor_hints = priv->anchor_hints;
|
|
|
|
|
rect_anchor_dx = priv->rect_anchor_dx;
|
|
|
|
|
rect_anchor_dy = priv->rect_anchor_dy;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (priv->rect_surface)
|
2016-06-14 19:42:13 +00:00
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
rect_surface = priv->rect_surface;
|
2016-06-14 19:42:13 +00:00
|
|
|
|
rect = priv->rect;
|
|
|
|
|
}
|
|
|
|
|
else if (priv->widget)
|
|
|
|
|
{
|
2018-03-21 10:49:14 +00:00
|
|
|
|
rect_surface = gtk_widget_get_surface (priv->widget);
|
2018-03-20 14:21:12 +00:00
|
|
|
|
gtk_widget_get_surface_allocation (priv->widget, &rect);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
text_direction = gtk_widget_get_direction (priv->widget);
|
|
|
|
|
}
|
2018-07-25 14:41:15 +00:00
|
|
|
|
else
|
2016-06-14 19:42:13 +00:00
|
|
|
|
{
|
2018-07-25 14:41:15 +00:00
|
|
|
|
g_assert_not_reached ();
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Realize so we have the proper width and height to figure out
|
|
|
|
|
* the right place to popup the menu.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_realize (priv->toplevel);
|
|
|
|
|
|
|
|
|
|
if (!gtk_widget_get_visible (priv->toplevel))
|
|
|
|
|
gtk_window_set_type_hint (GTK_WINDOW (priv->toplevel), priv->menu_type_hint);
|
|
|
|
|
|
|
|
|
|
if (text_direction == GTK_TEXT_DIR_NONE)
|
|
|
|
|
text_direction = gtk_widget_get_direction (GTK_WIDGET (menu));
|
|
|
|
|
|
|
|
|
|
if (text_direction == GTK_TEXT_DIR_RTL)
|
|
|
|
|
{
|
2016-10-14 08:41:50 +00:00
|
|
|
|
rect_anchor = get_horizontally_flipped_anchor (rect_anchor);
|
|
|
|
|
menu_anchor = get_horizontally_flipped_anchor (menu_anchor);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-20 14:21:12 +00:00
|
|
|
|
toplevel = gtk_widget_get_surface (priv->toplevel);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
gdk_surface_set_transient_for (toplevel, rect_surface);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (toplevel, moved_to_rect_cb, menu);
|
2016-10-14 08:41:50 +00:00
|
|
|
|
|
|
|
|
|
if (!emulated_move_to_rect)
|
|
|
|
|
g_signal_connect (toplevel, "moved-to-rect", G_CALLBACK (moved_to_rect_cb),
|
|
|
|
|
menu);
|
2016-06-14 19:42:13 +00:00
|
|
|
|
|
2017-05-07 10:36:47 +00:00
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
|
gdk_surface_move_to_rect (toplevel,
|
2016-11-24 00:31:16 +00:00
|
|
|
|
&rect,
|
|
|
|
|
rect_anchor,
|
|
|
|
|
menu_anchor,
|
|
|
|
|
anchor_hints,
|
|
|
|
|
rect_anchor_dx,
|
|
|
|
|
rect_anchor_dy);
|
2016-06-14 19:42:13 +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
|
2002-11-09 20:52:31 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-09 20:52:31 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_stop_scrolling (GtkMenu *menu)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2015-12-21 01:30:52 +00:00
|
|
|
|
GtkCssNode *top_arrow_node, *bottom_arrow_node;
|
2015-11-03 01:45:46 +00:00
|
|
|
|
GtkStateFlags state;
|
2006-02-22 10:10:23 +00:00
|
|
|
|
|
2002-11-09 20:52:31 +00:00
|
|
|
|
gtk_menu_remove_scroll_timeout (menu);
|
2011-12-12 17:48:30 +00:00
|
|
|
|
priv->upper_arrow_prelight = FALSE;
|
|
|
|
|
priv->lower_arrow_prelight = FALSE;
|
2015-11-03 01:45:46 +00:00
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
top_arrow_node = gtk_widget_get_css_node (priv->top_arrow_widget);
|
2015-12-21 01:30:52 +00:00
|
|
|
|
state = gtk_css_node_get_state (top_arrow_node);
|
|
|
|
|
gtk_css_node_set_state (top_arrow_node, state & ~GTK_STATE_FLAG_PRELIGHT);
|
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
bottom_arrow_node = gtk_widget_get_css_node (priv->bottom_arrow_widget);
|
2015-12-21 01:30:52 +00:00
|
|
|
|
state = gtk_css_node_get_state (bottom_arrow_node);
|
|
|
|
|
gtk_css_node_set_state (bottom_arrow_node, state & ~GTK_STATE_FLAG_PRELIGHT);
|
2002-11-09 20:52:31 +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_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;
|
2015-12-21 01:30:52 +00:00
|
|
|
|
GtkCssNode *top_arrow_node, *bottom_arrow_node;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
top_arrow_node = gtk_widget_get_css_node (priv->top_arrow_widget);
|
2018-09-17 09:07:41 +00:00
|
|
|
|
gtk_css_node_set_visible (top_arrow_node,
|
|
|
|
|
gtk_widget_get_child_visible (priv->top_arrow_widget));
|
2015-12-21 01:30:52 +00:00
|
|
|
|
gtk_css_node_set_state (top_arrow_node, priv->upper_arrow_state);
|
|
|
|
|
|
2017-05-10 20:13:16 +00:00
|
|
|
|
bottom_arrow_node = gtk_widget_get_css_node (priv->bottom_arrow_widget);
|
2018-09-17 09:07:41 +00:00
|
|
|
|
gtk_css_node_set_visible (top_arrow_node,
|
|
|
|
|
gtk_widget_get_child_visible (priv->bottom_arrow_widget));
|
2015-12-21 01:30:52 +00:00
|
|
|
|
gtk_css_node_set_state (bottom_arrow_node, priv->lower_arrow_state);
|
2015-11-03 01:45:46 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
priv->scroll_offset = offset;
|
2018-07-20 16:43:26 +00:00
|
|
|
|
gtk_widget_queue_allocate (GTK_WIDGET (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
|
|
|
|
}
|
1998-09-01 18:41:26 +00:00
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
compute_child_offset (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkWidget *menu_item,
|
|
|
|
|
gint *offset,
|
2019-04-13 10:26:10 +00:00
|
|
|
|
gint *height)
|
2002-12-14 22:43:52 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2005-11-10 14:33:51 +00:00
|
|
|
|
gint item_top_attach;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
gint child_offset = 0;
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
gint i;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
2019-04-14 22:42:57 +00:00
|
|
|
|
get_effective_child_attach (menu_item, &item_top_attach);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
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.
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
*/
|
2004-03-15 02:03:59 +00:00
|
|
|
|
if (!priv->heights || priv->heights_length < gtk_menu_get_n_rows (menu))
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
|
2011-02-23 09:26:21 +00:00
|
|
|
|
/* when we have a row with only invisible children, its height will
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
* 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 (offset)
|
|
|
|
|
*offset = child_offset;
|
|
|
|
|
if (height)
|
|
|
|
|
*height = priv->heights[item_top_attach];
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-14 22:43: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
|
2008-09-03 13:18:34 +00:00
|
|
|
|
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
|
|
|
|
{
|
2010-08-11 21:08:37 +00:00
|
|
|
|
GtkMenu *menu = GTK_MENU (menu_shell);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
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;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/* We need to check if the selected item fully visible.
|
|
|
|
|
* If not we need to scroll the menu so that it becomes fully
|
|
|
|
|
* visible.
|
|
|
|
|
*/
|
2019-04-13 10:26:10 +00:00
|
|
|
|
if (compute_child_offset (menu, menu_item, &child_offset, &child_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
|
|
|
|
y = priv->scroll_offset;
|
2018-03-20 14:21:12 +00:00
|
|
|
|
height = gdk_surface_get_height (gtk_widget_get_surface (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
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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
|
|
|
|
|
*/
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
|
|
|
{
|
2007-05-09 15:46:41 +00:00
|
|
|
|
GtkBorder arrow_border;
|
|
|
|
|
|
|
|
|
|
arrow_height = 0;
|
|
|
|
|
|
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
2016-09-05 01:09:20 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2015-12-21 02:44:10 +00:00
|
|
|
|
arrow_height = arrow_border.bottom + arrow_border.top;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
y = child_offset + child_height - height + arrow_height;
|
2015-12-21 02:44:10 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
/* Ignore the enter event we might get if the pointer
|
|
|
|
|
* is on the menu
|
|
|
|
|
*/
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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
|
|
|
|
}
|
2001-09-22 14:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-09-03 13:18:34 +00:00
|
|
|
|
gtk_menu_select_item (GtkMenuShell *menu_shell,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkWidget *menu_item)
|
2001-09-22 14:55:02 +00:00
|
|
|
|
{
|
|
|
|
|
GtkMenu *menu = GTK_MENU (menu_shell);
|
|
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
|
if (gtk_widget_get_realized (GTK_WIDGET (menu)))
|
2001-09-22 14:55:02 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
static gint
|
|
|
|
|
gtk_menu_get_popup_delay (GtkMenuShell *menu_shell)
|
|
|
|
|
{
|
2013-06-26 18:08:37 +00:00
|
|
|
|
return MENU_POPUP_DELAY;
|
gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c, gtkmenushell.h,
Sun Oct 20 23:58:03 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* gtkmenu.c, gtkmenubar.c, gtkmenuitem.c, gtkmenushell.c,
gtkmenushell.h, gtkmenushell.h
- make the delay before submenus appear below menu bars a
GtkSetting
- make the delay before submenus pops up a GtkSetting
- make the stay up triangle slightly larger
- don't pop up the first submenu immediately.
- make the default delay for submenus 225 ms, and 0 for menubars.
- make the default delay before popping down inside the stay-up
triangle 1000 ms
Fixes #74950
2002-10-20 22:29:57 +00:00
|
|
|
|
}
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
static void
|
2008-09-03 13:18:34 +00:00
|
|
|
|
gtk_menu_move_current (GtkMenuShell *menu_shell,
|
|
|
|
|
GtkMenuDirectionType direction)
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
{
|
2005-02-11 07:15:11 +00:00
|
|
|
|
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;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
case GTK_MENU_DIR_NEXT:
|
|
|
|
|
case GTK_MENU_DIR_PREV:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
}
|
2005-02-11 07:15:11 +00:00
|
|
|
|
}
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->move_current (menu_shell, direction);
|
The table menu patch! Turns GtkMenu into a table, so you can attach menu
Wed Sep 10 22:25:04 2003 Kristian Rietveld <kris@gtk.org>
The table menu patch! Turns GtkMenu into a table, so you can attach
menu items in numerous new ways! Be creative!
Contains some bug fixes and RTL adaptions from Matthias Clasen.
* gtk/gtkmenu.c [toplevel]: introduce ATTACH_INFO_KEY, extend
GtkMenuPrivate, introduce AttachInfo, add child properties enum,
(gtk_menu_free_private), (gtk_menu_get_private): we have to free
the heights array in the private struct,
(gtk_menu_class_init): reorder code a bit, install child properties,
(get_attach_info), (get_child_attach): new utility functions,
(gtk_menu_set_child_property), (gtk_menu_get_child_property): introduce
child properties, for the attach info,
(gtk_menu_remove): remove AttachInfo from menu item,
(gtk_menu_real_insert): implemented algorithm to automagically place
inserted menu items at the correct place in the table,
(gtk_menu_size_request), (gtk_menu_size_allocate),
(compute_child_offset): reworked/rewritten to support table menus,
(gtk_menu_attach): new function,
(find_child_containing), (gtk_menu_move_current): new functions to
get table menu keynav right.
* gtk/gtkmenu.h: add gtk_menu_attach() prototype.
2003-09-10 20:32:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static gint
|
|
|
|
|
get_visible_size (GtkMenu *menu)
|
|
|
|
|
{
|
2017-05-07 10:36:47 +00:00
|
|
|
|
GtkBorder arrow_border;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
gint menu_height;
|
|
|
|
|
|
2018-07-20 17:19:37 +00:00
|
|
|
|
menu_height = gtk_widget_get_height (GTK_WIDGET (menu));
|
2006-05-10 14:02:20 +00:00
|
|
|
|
|
2016-09-05 01:09:20 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
|
|
|
|
menu_height -= arrow_border.top;
|
|
|
|
|
menu_height -= arrow_border.bottom;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2002-12-14 22:43:52 +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)
|
2002-12-14 22:43:52 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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 */
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
|
|
|
|
menu_height = get_visible_size (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
lower = priv->scroll_offset;
|
|
|
|
|
upper = priv->scroll_offset + menu_height;
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
for (children = menu_shell->priv->children; children; children = children->next)
|
2002-12-14 22:43:52 +00:00
|
|
|
|
{
|
2010-03-01 06:47:38 +00:00
|
|
|
|
if (gtk_widget_get_visible (children->data))
|
2010-12-23 20:50:18 +00:00
|
|
|
|
{
|
|
|
|
|
GtkRequisition child_requisition;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
|
gtk_widget_get_preferred_size (children->data,
|
|
|
|
|
&child_requisition, NULL);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
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;
|
|
|
|
|
|
2016-09-05 01:09:20 +00:00
|
|
|
|
if (child_offset + child_requisition.height > y)
|
2010-12-23 20:50:18 +00:00
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
child_offset += child_requisition.height;
|
|
|
|
|
}
|
2002-12-14 22:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return child;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-21 19:42:44 +00:00
|
|
|
|
static gint
|
|
|
|
|
get_menu_height (GtkMenu *menu)
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2017-05-07 10:36:47 +00:00
|
|
|
|
GtkBorder arrow_border;
|
2010-08-11 21:08:37 +00:00
|
|
|
|
gint height;
|
2010-08-18 23:42:02 +00:00
|
|
|
|
|
2012-04-25 03:34:12 +00:00
|
|
|
|
height = priv->requested_height;
|
2003-08-21 19:42:44 +00:00
|
|
|
|
|
2016-09-05 01:09:20 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
|
|
|
|
height -= arrow_border.top;
|
|
|
|
|
height -= arrow_border.bottom;
|
2003-08-21 19:42:44 +00:00
|
|
|
|
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-14 22:43:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_real_move_scroll (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkScrollType type)
|
2002-12-14 22:43:52 +00:00
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
GtkMenuPrivate *priv = menu->priv;
|
2003-09-03 21:26:13 +00:00
|
|
|
|
gint page_size = get_visible_size (menu);
|
|
|
|
|
gint end_position = get_menu_height (menu);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menu);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
switch ((guint) type)
|
2002-12-14 22:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_SCROLL_PAGE_UP:
|
|
|
|
|
case GTK_SCROLL_PAGE_DOWN:
|
|
|
|
|
{
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint old_offset;
|
2003-08-21 19:42:44 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (menu_shell->priv->active_menu_item)
|
2010-12-23 20:50:18 +00:00
|
|
|
|
{
|
|
|
|
|
gint child_height;
|
|
|
|
|
|
2013-11-20 17:31:28 +00:00
|
|
|
|
if (compute_child_offset (menu, menu_shell->priv->active_menu_item,
|
2019-04-13 10:26:10 +00:00
|
|
|
|
&child_offset, &child_height))
|
2013-11-20 17:31:28 +00:00
|
|
|
|
child_offset += child_height / 2;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->ignore_enter = TRUE;
|
2018-09-17 09:07:41 +00:00
|
|
|
|
old_upper_arrow_visible = gtk_widget_get_child_visible (priv->top_arrow_widget);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
old_offset = priv->scroll_offset;
|
|
|
|
|
|
|
|
|
|
new_offset = priv->scroll_offset + step;
|
2003-09-03 21:26:13 +00:00
|
|
|
|
new_offset = CLAMP (new_offset, 0, end_position - page_size);
|
2003-08-21 19:42:44 +00:00
|
|
|
|
|
|
|
|
|
gtk_menu_scroll_to (menu, new_offset);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
if (menu_shell->priv->active_menu_item)
|
2010-12-23 20:50:18 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *new_child;
|
2018-09-17 09:07:41 +00:00
|
|
|
|
gboolean new_upper_arrow_visible = gtk_widget_get_child_visible (priv->top_arrow_widget);
|
2007-05-09 15:46:41 +00:00
|
|
|
|
GtkBorder arrow_border;
|
2012-04-25 03:34:12 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
get_arrows_border (menu, &arrow_border);
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
if (priv->scroll_offset != old_offset)
|
|
|
|
|
step = priv->scroll_offset - old_offset;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
step -= (new_upper_arrow_visible - old_upper_arrow_visible) * arrow_border.top;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
|
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);
|
|
|
|
|
}
|
2002-12-14 22:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
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 */
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->ignore_enter = TRUE;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
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 */
|
2010-12-23 23:21:53 +00:00
|
|
|
|
menu_shell->priv->ignore_enter = TRUE;
|
2002-12-14 22:43:52 +00:00
|
|
|
|
_gtk_menu_shell_select_last (menu_shell, TRUE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-12 20:53:03 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
2016-04-11 02:59:53 +00:00
|
|
|
|
* See gdk_monitor_get_geometry().
|
2003-11-12 20:53:03 +00:00
|
|
|
|
*
|
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.
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* This information can’t be reliably inferred from the coordinates
|
2010-12-23 20:50:18 +00:00
|
|
|
|
* returned by a #GtkMenuPositionFunc, since, for very long menus,
|
|
|
|
|
* these coordinates may extend beyond the monitor boundaries or even
|
|
|
|
|
* the screen boundaries.
|
|
|
|
|
*/
|
2004-03-09 01:21:45 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_menu_set_monitor (GtkMenu *menu,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gint monitor_num)
|
2003-11-12 20:53:03 +00:00
|
|
|
|
{
|
2018-04-17 18:51:53 +00:00
|
|
|
|
GtkMenuPrivate *priv;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2003-11-12 20:53:03 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
priv = menu->priv;
|
|
|
|
|
|
2014-06-09 13:04:53 +00:00
|
|
|
|
if (priv->monitor_num != monitor_num)
|
|
|
|
|
{
|
|
|
|
|
priv->monitor_num = monitor_num;
|
|
|
|
|
g_object_notify (G_OBJECT (menu), "monitor");
|
|
|
|
|
}
|
2008-06-20 11:06:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
2008-07-04 21:20:25 +00:00
|
|
|
|
* be popped up or -1, if no monitor has been set
|
2010-12-23 20:50:18 +00:00
|
|
|
|
*/
|
2008-06-20 11:06:52 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_menu_get_monitor (GtkMenu *menu)
|
|
|
|
|
{
|
2008-06-21 09:49:00 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_MENU (menu), -1);
|
2008-06-20 11:06:52 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
return menu->priv->monitor_num;
|
2003-11-12 20:53:03 +00:00
|
|
|
|
}
|
2004-05-06 07:35:26 +00:00
|
|
|
|
|
2016-11-19 18:51:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_place_on_monitor:
|
|
|
|
|
* @menu: a #GtkMenu
|
|
|
|
|
* @monitor: the monitor to place the menu on
|
|
|
|
|
*
|
|
|
|
|
* Places @menu on the given monitor.
|
|
|
|
|
*/
|
2016-04-11 02:59:53 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_menu_place_on_monitor (GtkMenu *menu,
|
|
|
|
|
GdkMonitor *monitor)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
gint i, monitor_num;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (GTK_WIDGET (menu));
|
|
|
|
|
monitor_num = 0;
|
|
|
|
|
for (i = 0; ; i++)
|
|
|
|
|
{
|
|
|
|
|
GdkMonitor *m = gdk_display_get_monitor (display, i);
|
|
|
|
|
if (m == monitor)
|
|
|
|
|
{
|
|
|
|
|
monitor_num = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_menu_set_monitor (menu, monitor_num);
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-06 07:35:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_menu_get_for_attach_widget:
|
|
|
|
|
* @widget: a #GtkWidget
|
2006-04-24 05:42:12 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns a list of the menus which are attached to this widget.
|
2004-05-06 07:35:26 +00:00
|
|
|
|
* This list is owned by GTK+ and must not be modified.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: (element-type GtkWidget) (transfer none): the list
|
2010-12-23 20:50:18 +00:00
|
|
|
|
* of menus attached to his widget.
|
|
|
|
|
*/
|
2004-05-06 07:35:26 +00:00
|
|
|
|
GList*
|
|
|
|
|
gtk_menu_get_for_attach_widget (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GList *list;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2004-05-06 07:35:26 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2004-05-06 07:35:26 +00:00
|
|
|
|
list = g_object_get_data (G_OBJECT (widget), ATTACHED_MENUS);
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
2004-05-06 07:35:26 +00:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-27 17:36:34 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_menu_grab_notify (GtkWidget *widget,
|
2010-12-23 20:50:18 +00:00
|
|
|
|
gboolean was_grabbed)
|
2005-06-27 17:36:34 +00:00
|
|
|
|
{
|
2011-12-12 17:11:57 +00:00
|
|
|
|
GtkMenu *menu;
|
2005-07-05 22:34:07 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
GtkWindowGroup *group;
|
|
|
|
|
GtkWidget *grab;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
GdkDevice *pointer;
|
|
|
|
|
|
2018-05-14 16:19:44 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_menu_parent_class)->grab_notify (widget, was_grabbed);
|
|
|
|
|
|
2011-12-12 17:11:57 +00:00
|
|
|
|
menu = GTK_MENU (widget);
|
2010-06-15 23:09:41 +00:00
|
|
|
|
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;
|
2005-07-05 22:34:07 +00:00
|
|
|
|
|
|
|
|
|
toplevel = gtk_widget_get_toplevel (widget);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
|
|
|
|
if (!GTK_IS_WINDOW (toplevel))
|
|
|
|
|
return;
|
|
|
|
|
|
2006-01-10 04:33:30 +00:00
|
|
|
|
group = gtk_window_get_group (GTK_WINDOW (toplevel));
|
2015-11-26 18:54:54 +00:00
|
|
|
|
grab = gtk_window_group_get_current_grab (group);
|
2005-07-05 22:34:07 +00:00
|
|
|
|
|
2010-12-23 23:21:53 +00:00
|
|
|
|
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));
|
2011-12-12 17:11:57 +00:00
|
|
|
|
|
|
|
|
|
menu->priv->drag_scroll_started = FALSE;
|
2005-06-27 17:36:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-06-24 05:01:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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
|
2009-06-24 05:01:51 +00:00
|
|
|
|
* or icons, regardless of their actual presence.
|
|
|
|
|
*/
|
2009-06-22 04:53:14 +00:00
|
|
|
|
void
|
2009-06-24 05:01:51 +00:00
|
|
|
|
gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
|
|
|
|
|
gboolean reserve_toggle_size)
|
2009-06-22 04:53:14 +00:00
|
|
|
|
{
|
2018-04-17 18:51:53 +00:00
|
|
|
|
GtkMenuPrivate *priv;
|
2009-06-24 05:01:51 +00:00
|
|
|
|
gboolean no_toggle_size;
|
2010-12-23 20:50:18 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_MENU (menu));
|
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
priv = menu->priv;
|
2009-06-24 05:01:51 +00:00
|
|
|
|
|
2018-04-17 18:51:53 +00:00
|
|
|
|
no_toggle_size = !reserve_toggle_size;
|
2009-06-24 05:01:51 +00:00
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
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);
|
2009-06-24 05:01:51 +00:00
|
|
|
|
|
2010-12-23 20:50:18 +00:00
|
|
|
|
return !menu->priv->no_toggle_size;
|
2009-06-22 04:53:14 +00:00
|
|
|
|
}
|
2012-09-11 15:38:06 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
2013-10-11 08:25:24 +00:00
|
|
|
|
* Actions can also be added using gtk_widget_insert_action_group() on the menu's
|
|
|
|
|
* attach widget or on any of its parent widgets.
|
2013-10-10 17:00:53 +00:00
|
|
|
|
*
|
2012-09-11 15:38:06 +00:00
|
|
|
|
* Returns: a new #GtkMenu
|
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
}
|