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.
This commit is contained in:
Alexander Larsson 2000-11-08 17:34:52 +00:00 committed by Alexander Larsson
parent b440118aa4
commit 814957b46e
22 changed files with 1571 additions and 230 deletions

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -1,3 +1,64 @@
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-07 Havoc Pennington <hp@redhat.com>
* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location):

View File

@ -256,3 +256,14 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
GtkProgressBarOrientation orientation);
- GtkMenuPositionFunc has a new parameter push_in which controls how
menus placed outside the screen is handled. If this is set to true and
part of the menu is outside the screen then Gtk+ pushes it into the visible
area. Otherwise the menu is cut of at the end of the visible screen area.
Regardles of what happens to the size of the menu, the result is always
that the items are placed in the same place as if the menu was placed
outside the screen, using menu scrolling if necessary.

View File

@ -28,7 +28,7 @@
#include "gtkaccellabel.h"
#include "gtksignal.h"
#define CHECK_TOGGLE_SIZE 12
enum {
TOGGLED,
@ -36,17 +36,19 @@ enum {
};
static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass);
static void gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item);
static void gtk_check_menu_item_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_check_menu_item_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_check_menu_item_activate (GtkMenuItem *menu_item);
static void gtk_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GdkRectangle *area);
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GdkRectangle *area);
static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass);
static void gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item);
static void gtk_check_menu_item_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_check_menu_item_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_check_menu_item_activate (GtkMenuItem *menu_item);
static void gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition);
static void gtk_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GdkRectangle *area);
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
GdkRectangle *area);
static GtkMenuItemClass *parent_class = NULL;
@ -95,8 +97,8 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
widget_class->expose_event = gtk_check_menu_item_expose;
menu_item_class->activate = gtk_check_menu_item_activate;
menu_item_class->toggle_size = 12;
menu_item_class->hide_on_activate = FALSE;
menu_item_class->toggle_size_request = gtk_check_menu_item_toggle_size_request;
klass->toggled = NULL;
klass->draw_indicator = gtk_real_check_menu_item_draw_indicator;
@ -147,6 +149,16 @@ gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
gtk_menu_item_activate (GTK_MENU_ITEM (check_menu_item));
}
static void
gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition)
{
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
*requisition = CHECK_TOGGLE_SIZE;
}
void
gtk_check_menu_item_set_show_toggle (GtkCheckMenuItem *menu_item,
gboolean always)

View File

@ -71,6 +71,9 @@ extern "C" {
#define gtk_window_position gtk_window_set_position
#define gtk_toggle_button_set_state gtk_toggle_button_set_active
#define gtk_check_menu_item_set_state gtk_check_menu_item_set_active
#define gtk_menu_append gtk_menu_shell_append
#define gtk_menu_prepend gtk_menu_shell_prepend
#define gtk_menu_insert gtk_menu_shell_insert
/* strongly deprecated, very likely to be removed in the future:

View File

@ -1341,7 +1341,7 @@ gtk_file_selection_update_history_menu (GtkFileSelection *fs,
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) gtk_file_selection_history_callback,
(gpointer) fs);
gtk_menu_append (GTK_MENU (fs->history_menu), menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (fs->history_menu), menu_item);
gtk_widget_show (menu_item);
}
}

View File

@ -207,8 +207,8 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
{
menuitem = gtk_menu_item_new_with_label(info->name);
gtk_menu_append(GTK_MENU(device_menu),menuitem);
gtk_widget_show(menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (device_menu), menuitem);
gtk_widget_show (menuitem);
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_device,
@ -236,25 +236,25 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
mapping_menu = gtk_menu_new ();
menuitem = gtk_menu_item_new_with_label(_("Disabled"));
gtk_menu_append(GTK_MENU(mapping_menu),menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_widget_show(menuitem);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_mapping_mode,
GINT_TO_POINTER (GDK_MODE_DISABLED));
menuitem = gtk_menu_item_new_with_label(_("Screen"));
gtk_menu_append(GTK_MENU(mapping_menu),menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_widget_show(menuitem);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_mapping_mode,
GINT_TO_POINTER (GDK_MODE_SCREEN));
menuitem = gtk_menu_item_new_with_label(_("Window"));
gtk_menu_append(GTK_MENU(mapping_menu),menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (mapping_menu), menuitem);
gtk_object_set_user_data (GTK_OBJECT (menuitem), inputd);
gtk_widget_show(menuitem);
gtk_widget_show (menuitem);
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
(GtkSignalFunc) gtk_input_dialog_set_mapping_mode,
GINT_TO_POINTER (GDK_MODE_WINDOW));
@ -524,7 +524,7 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDevice *info)
(GtkSignalFunc) gtk_input_dialog_set_axis,
GINT_TO_POINTER (0x10000 * (j + 1) + i));
gtk_widget_show (menu_item);
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
}
inputd->axis_items[i] = option_menu = gtk_option_menu_new ();

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,6 @@
extern "C" {
#endif /* __cplusplus */
#define GTK_TYPE_MENU (gtk_menu_get_type ())
#define GTK_MENU(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MENU, GtkMenu))
#define GTK_MENU_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU, GtkMenuClass))
@ -52,6 +51,7 @@ typedef struct _GtkMenuClass GtkMenuClass;
typedef void (*GtkMenuPositionFunc) (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data);
typedef void (*GtkMenuDetachFunc) (GtkWidget *attach_widget,
GtkMenu *menu);
@ -62,18 +62,31 @@ struct _GtkMenu
GtkWidget *parent_menu_item;
GtkWidget *old_active_menu_item;
GtkAccelGroup *accel_group;
GtkMenuPositionFunc position_func;
gpointer position_func_data;
guint toggle_size;
/* Do _not_ touch these widgets directly. We hide the reference
* count from the toplevel to the menu, so it must be restored
* before operating on these widgets
*/
GtkWidget *toplevel;
GtkWidget *tearoff_window;
GtkWidget *tearoff_hbox;
GtkWidget *tearoff_scrollbar;
GtkAdjustment *tearoff_adjustment;
GdkWindow *view_window;
GdkWindow *bin_window;
gint scroll_offset;
gint saved_scroll_offset;
gint scroll_step;
guint timeout_id;
/* When a submenu of this menu is popped up, motion in this
* region is ignored
*/
@ -82,6 +95,17 @@ struct _GtkMenu
guint needs_destruction_ref_count : 1;
guint torn_off : 1;
/* The tearoff is active when it is torn off and the not-torn-off
* menu is not popped up.
*/
guint tearoff_active : 1;
guint scroll_fast : 1;
guint upper_arrow_visible : 1;
guint lower_arrow_visible : 1;
guint upper_arrow_prelight : 1;
guint lower_arrow_prelight : 1;
};
struct _GtkMenuClass
@ -93,15 +117,6 @@ struct _GtkMenuClass
GtkType gtk_menu_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_menu_new (void);
/* Wrappers for the Menu Shell operations */
void gtk_menu_append (GtkMenu *menu,
GtkWidget *child);
void gtk_menu_prepend (GtkMenu *menu,
GtkWidget *child);
void gtk_menu_insert (GtkMenu *menu,
GtkWidget *child,
gint position);
/* Display the menu onscreen */
void gtk_menu_popup (GtkMenu *menu,
GtkWidget *parent_menu_shell,

View File

@ -42,6 +42,8 @@
enum {
ACTIVATE,
ACTIVATE_ITEM,
TOGGLE_SIZE_REQUEST,
TOGGLE_SIZE_ALLOCATE,
LAST_SIGNAL
};
@ -59,14 +61,21 @@ static void gtk_menu_item_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_menu_item_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_real_menu_item_select (GtkItem *item);
static void gtk_real_menu_item_deselect (GtkItem *item);
static void gtk_real_menu_item_activate_item (GtkMenuItem *item);
static void gtk_real_menu_item_select (GtkItem *item);
static void gtk_real_menu_item_deselect (GtkItem *item);
static void gtk_real_menu_item_activate_item (GtkMenuItem *item);
static void gtk_real_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition);
static void gtk_real_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
guint16 allocation);
static gint gtk_menu_item_select_timeout (gpointer data);
static void gtk_menu_item_popup_submenu (gpointer data);
static void gtk_menu_item_position_menu (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data);
static void gtk_menu_item_show_all (GtkWidget *widget);
static void gtk_menu_item_hide_all (GtkWidget *widget);
@ -138,6 +147,24 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
menu_item_signals[TOGGLE_SIZE_REQUEST] =
gtk_signal_new ("toggle_size_request",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuItemClass, toggle_size_request),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
menu_item_signals[TOGGLE_SIZE_ALLOCATE] =
gtk_signal_new ("toggle_size_allocate",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkMenuItemClass, toggle_size_allocate),
gtk_marshal_NONE__UINT,
GTK_TYPE_NONE, 1,
GTK_TYPE_UINT);
gtk_object_class_add_signals (object_class, menu_item_signals, LAST_SIGNAL);
object_class->destroy = gtk_menu_item_destroy;
@ -157,8 +184,9 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
klass->activate = NULL;
klass->activate_item = gtk_real_menu_item_activate_item;
klass->toggle_size_request = gtk_real_menu_item_toggle_size_request;
klass->toggle_size_allocate = gtk_real_menu_item_toggle_size_allocate;
klass->toggle_size = 0;
klass->hide_on_activate = TRUE;
}
@ -313,6 +341,26 @@ gtk_menu_item_activate (GtkMenuItem *menu_item)
gtk_signal_emit (GTK_OBJECT (menu_item), menu_item_signals[ACTIVATE]);
}
void
gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition)
{
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_signal_emit (GTK_OBJECT (menu_item), menu_item_signals[TOGGLE_SIZE_REQUEST], requisition);
}
void
gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
guint16 allocation)
{
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_signal_emit (GTK_OBJECT (menu_item), menu_item_signals[TOGGLE_SIZE_ALLOCATE], allocation);
}
static void
gtk_menu_item_accel_width_foreach (GtkWidget *widget,
gpointer data)
@ -631,6 +679,25 @@ gtk_real_menu_item_activate_item (GtkMenuItem *menu_item)
}
}
}
static void
gtk_real_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition)
{
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
*requisition = 0;
}
static void
gtk_real_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
guint16 allocation)
{
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
menu_item->toggle_size = allocation;
}
static gint
gtk_menu_item_select_timeout (gpointer data)
@ -668,6 +735,7 @@ static void
gtk_menu_item_position_menu (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data)
{
GtkMenuItem *menu_item;
@ -702,9 +770,10 @@ gtk_menu_item_position_menu (GtkMenu *menu,
ty += GTK_WIDGET (menu_item)->allocation.height;
else if ((ty - theight) >= 0)
ty -= theight;
else
else if (screen_height - (ty + GTK_WIDGET (menu_item)->allocation.height) > ty)
ty += GTK_WIDGET (menu_item)->allocation.height;
else
ty -= theight;
break;
case GTK_LEFT_RIGHT:
@ -738,14 +807,16 @@ gtk_menu_item_position_menu (GtkMenu *menu,
ty += GTK_WIDGET (menu_item)->allocation.height / 4;
/* If the height of the menu doesn't fit we move it upward. */
ty = CLAMP (ty, 0, MAX (0, screen_height - theight));
break;
}
/* If we have negative, tx, ty here it is because we can't get
* the menu all the way on screen. Favor the upper-left portion.
/* If we have negative, tx, here it is because we can't get
* the menu all the way on screen. Favor the left portion.
*/
*x = CLAMP (tx, 0, MAX (0, screen_width - twidth));
*y = CLAMP (ty, 0, MAX (0, screen_height - theight));
*y = ty;
}
void
@ -812,6 +883,4 @@ gtk_menu_item_forall (GtkContainer *container,
if (bin->child)
(* callback) (bin->child, callback_data);
if (include_internals && menu_item->submenu)
(* callback) (menu_item->submenu, callback_data);
}

View File

@ -70,7 +70,6 @@ struct _GtkMenuItemClass
{
GtkItemClass parent_class;
guint toggle_size;
/* If the following flag is true, then we should always hide
* the menu when the MenuItem is activated. Otherwise, the
* it is up to the caller. For instance, when navigating
@ -79,26 +78,35 @@ struct _GtkMenuItemClass
*/
guint hide_on_activate : 1;
void (* activate) (GtkMenuItem *menu_item);
void (* activate_item) (GtkMenuItem *menu_item);
void (* activate) (GtkMenuItem *menu_item);
void (* activate_item) (GtkMenuItem *menu_item);
void (* toggle_size_request) (GtkMenuItem *menu_item,
guint16 *requisition);
void (* toggle_size_allocate) (GtkMenuItem *menu_item,
guint16 allocation);
};
GtkType gtk_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_menu_item_new (void);
GtkWidget* gtk_menu_item_new_with_label (const gchar *label);
void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
GtkWidget *submenu);
void gtk_menu_item_remove_submenu (GtkMenuItem *menu_item);
void gtk_menu_item_set_placement (GtkMenuItem *menu_item,
GtkSubmenuPlacement placement);
void gtk_menu_item_configure (GtkMenuItem *menu_item,
gint show_toggle_indicator,
gint show_submenu_indicator);
void gtk_menu_item_select (GtkMenuItem *menu_item);
void gtk_menu_item_deselect (GtkMenuItem *menu_item);
void gtk_menu_item_activate (GtkMenuItem *menu_item);
void gtk_menu_item_right_justify (GtkMenuItem *menu_item);
GtkType gtk_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_menu_item_new (void);
GtkWidget* gtk_menu_item_new_with_label (const gchar *label);
void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
GtkWidget *submenu);
void gtk_menu_item_remove_submenu (GtkMenuItem *menu_item);
void gtk_menu_item_set_placement (GtkMenuItem *menu_item,
GtkSubmenuPlacement placement);
void gtk_menu_item_configure (GtkMenuItem *menu_item,
gint show_toggle_indicator,
gint show_submenu_indicator);
void gtk_menu_item_select (GtkMenuItem *menu_item);
void gtk_menu_item_deselect (GtkMenuItem *menu_item);
void gtk_menu_item_activate (GtkMenuItem *menu_item);
void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,
guint16 *requisition);
void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
guint16 allocation);
void gtk_menu_item_right_justify (GtkMenuItem *menu_item);
#ifdef __cplusplus

View File

@ -129,12 +129,17 @@ static void gtk_menu_shell_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_menu_shell_real_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
static void gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell);
static gint gtk_menu_shell_is_item (GtkMenuShell *menu_shell,
GtkWidget *child);
static GtkWidget *gtk_menu_shell_get_item (GtkMenuShell *menu_shell,
GdkEvent *event);
static GtkType gtk_menu_shell_child_type (GtkContainer *container);
static void gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
static void gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell);
static void gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
@ -246,6 +251,8 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
klass->move_current = gtk_real_menu_shell_move_current;
klass->activate_current = gtk_real_menu_shell_activate_current;
klass->cancel = gtk_real_menu_shell_cancel;
klass->select_item = gtk_menu_shell_real_select_item;
klass->insert = gtk_menu_shell_real_insert;
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set,
@ -303,11 +310,24 @@ gtk_menu_shell_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position)
{
GtkMenuShellClass *class;
g_return_if_fail (menu_shell != NULL);
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (child));
class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
if (class->insert)
class->insert (menu_shell, child, position);
}
static void
gtk_menu_shell_real_insert (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position)
{
menu_shell->children = g_list_insert (menu_shell->children, child, position);
gtk_widget_set_parent (child, GTK_WIDGET (menu_shell));
@ -573,7 +593,7 @@ gtk_menu_shell_enter_notify (GtkWidget *widget,
if (!menu_item || !GTK_WIDGET_IS_SENSITIVE (menu_item))
return TRUE;
if ((menu_item->parent == widget) &&
(menu_shell->active_menu_item != menu_item) &&
GTK_IS_MENU_ITEM (menu_item))
@ -704,9 +724,6 @@ gtk_menu_shell_forall (GtkContainer *container,
static void
gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell)
{
g_return_if_fail (menu_shell != NULL);
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
if (menu_shell->active)
{
menu_shell->button = 0;
@ -776,11 +793,24 @@ void
gtk_menu_shell_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item)
{
GtkMenuShellClass *class;
g_return_if_fail (menu_shell != NULL);
g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
if (class->select_item)
class->select_item (menu_shell, menu_item);
}
static void
gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item)
{
gtk_menu_shell_deselect (menu_shell);
menu_shell->active_menu_item = menu_item;

View File

@ -81,6 +81,11 @@ struct _GtkMenuShellClass
void (*activate_current) (GtkMenuShell *menu_shell,
gboolean force_hide);
void (*cancel) (GtkMenuShell *menu_shell);
void (*select_item) (GtkMenuShell *menu_shell,
GtkWidget *menu_item);
void (*insert) (GtkMenuShell *menu_shell,
GtkWidget *child,
gint position);
};

View File

@ -3502,8 +3502,8 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
menu_item = gtk_menu_item_new ();
gtk_widget_lock_accelerators (menu_item);
gtk_container_add (GTK_CONTAINER (menu_item), page->menu_label);
gtk_menu_insert (GTK_MENU (notebook->menu), menu_item,
gtk_notebook_real_page_position (notebook, list));
gtk_menu_shell_insert (GTK_MENU_SHELL (notebook->menu), menu_item,
gtk_notebook_real_page_position (notebook, list));
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (gtk_notebook_menu_switch_page), page);
if (GTK_WIDGET_VISIBLE (page->child))

View File

@ -65,6 +65,7 @@ static void gtk_option_menu_calc_size (GtkOptionMenu *option_menu);
static void gtk_option_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gint *scroll_offet,
gpointer user_data);
static void gtk_option_menu_show_all (GtkWidget *widget);
static void gtk_option_menu_hide_all (GtkWidget *widget);
@ -498,6 +499,7 @@ gtk_option_menu_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkOptionMenu *option_menu;
GtkWidget *menu_item;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), FALSE);
@ -512,6 +514,9 @@ gtk_option_menu_button_press (GtkWidget *widget,
gtk_menu_popup (GTK_MENU (option_menu->menu), NULL, NULL,
gtk_option_menu_position, option_menu,
event->button, event->time);
menu_item = gtk_menu_get_active (GTK_MENU (option_menu->menu));
if (menu_item)
gtk_menu_shell_select_item (GTK_MENU_SHELL (option_menu->menu), menu_item);
return TRUE;
}
@ -523,6 +528,7 @@ gtk_option_menu_key_press (GtkWidget *widget,
GdkEventKey *event)
{
GtkOptionMenu *option_menu;
GtkWidget *menu_item;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), FALSE);
@ -537,6 +543,9 @@ gtk_option_menu_key_press (GtkWidget *widget,
gtk_menu_popup (GTK_MENU (option_menu->menu), NULL, NULL,
gtk_option_menu_position, option_menu,
0, event->time);
menu_item = gtk_menu_get_active (GTK_MENU (option_menu->menu));
if (menu_item)
gtk_menu_shell_select_item (GTK_MENU_SHELL (option_menu->menu), menu_item);
return TRUE;
}
@ -650,6 +659,7 @@ static void
gtk_option_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer user_data)
{
GtkOptionMenu *option_menu;
@ -657,13 +667,10 @@ gtk_option_menu_position (GtkMenu *menu,
GtkWidget *child;
GtkRequisition requisition;
GList *children;
gint shift_menu;
gint screen_width;
gint screen_height;
gint menu_xpos;
gint menu_ypos;
gint width;
gint height;
gint menu_width;
g_return_if_fail (user_data != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (user_data));
@ -671,11 +678,9 @@ gtk_option_menu_position (GtkMenu *menu,
option_menu = GTK_OPTION_MENU (user_data);
gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
width = requisition.width;
height = requisition.height;
menu_width = requisition.width;
active = gtk_menu_get_active (GTK_MENU (option_menu->menu));
children = GTK_MENU_SHELL (option_menu->menu)->children;
gdk_window_get_origin (GTK_WIDGET (option_menu)->window, &menu_xpos, &menu_ypos);
menu_ypos += GTK_WIDGET (option_menu)->allocation.height / 2 - 2;
@ -686,6 +691,7 @@ gtk_option_menu_position (GtkMenu *menu,
menu_ypos -= requisition.height / 2;
}
children = GTK_MENU_SHELL (option_menu->menu)->children;
while (children)
{
child = children->data;
@ -703,35 +709,15 @@ gtk_option_menu_position (GtkMenu *menu,
}
screen_width = gdk_screen_width ();
screen_height = gdk_screen_height ();
shift_menu = FALSE;
if (menu_ypos < 0)
{
menu_ypos = 0;
shift_menu = TRUE;
}
else if ((menu_ypos + height) > screen_height)
{
menu_ypos -= ((menu_ypos + height) - screen_height);
shift_menu = TRUE;
}
if (shift_menu)
{
if ((menu_xpos + GTK_WIDGET (option_menu)->allocation.width + width) <= screen_width)
menu_xpos += GTK_WIDGET (option_menu)->allocation.width;
else
menu_xpos -= width;
}
if (menu_xpos < 0)
menu_xpos = 0;
else if ((menu_xpos + width) > screen_width)
menu_xpos -= ((menu_xpos + width) - screen_width);
else if ((menu_xpos + menu_width) > screen_width)
menu_xpos -= ((menu_xpos + menu_width) - screen_width);
*x = menu_xpos;
*y = menu_ypos;
*push_in = TRUE;
}

View File

@ -121,7 +121,7 @@ build_option_menu (OptionMenuItem items[],
menu_item = gtk_menu_item_new_with_label (items[i].name);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) items[i].func, data);
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
gtk_widget_show (menu_item);
}
@ -2659,7 +2659,7 @@ create_image (void)
*/
static GtkWidget*
create_menu (gint depth, gboolean tearoff)
create_menu (gint depth, gint length, gboolean tearoff)
{
GtkWidget *menu;
GtkWidget *menuitem;
@ -2676,23 +2676,24 @@ create_menu (gint depth, gboolean tearoff)
if (tearoff)
{
menuitem = gtk_tearoff_menu_item_new ();
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
}
for (i = 0, j = 1; i < 5; i++, j++)
for (i = 0, j = 1; i < length; i++, j++)
{
sprintf (buf, "item %2d - %d", depth, j);
menuitem = gtk_radio_menu_item_new_with_label (group, buf);
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
if (depth % 2)
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
if (i == 3)
gtk_widget_set_sensitive (menuitem, FALSE);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, TRUE));
if (i < 5)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5, TRUE));
}
return menu;
@ -2739,7 +2740,7 @@ create_menus (void)
gtk_box_pack_start (GTK_BOX (box1), menubar, FALSE, TRUE, 0);
gtk_widget_show (menubar);
menu = create_menu (2, TRUE);
menu = create_menu (2, 50, TRUE);
menuitem = gtk_menu_item_new_with_label ("test\nline2");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
@ -2747,12 +2748,12 @@ create_menus (void)
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("foo");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3, TRUE));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3, 5, TRUE));
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, TRUE));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, 5, TRUE));
gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem));
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
@ -2762,11 +2763,11 @@ create_menus (void)
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_widget_show (box2);
menu = create_menu (1, FALSE);
menu = create_menu (1, 5, FALSE);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",
@ -2775,7 +2776,7 @@ create_menus (void)
0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_SIGNAL_VISIBLE);
menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",
@ -2784,7 +2785,7 @@ create_menus (void)
0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_check_menu_item_new_with_label ("Accelerators Frozen");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",

View File

@ -121,7 +121,7 @@ build_option_menu (OptionMenuItem items[],
menu_item = gtk_menu_item_new_with_label (items[i].name);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) items[i].func, data);
gtk_menu_append (GTK_MENU (menu), menu_item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
gtk_widget_show (menu_item);
}
@ -2659,7 +2659,7 @@ create_image (void)
*/
static GtkWidget*
create_menu (gint depth, gboolean tearoff)
create_menu (gint depth, gint length, gboolean tearoff)
{
GtkWidget *menu;
GtkWidget *menuitem;
@ -2676,23 +2676,24 @@ create_menu (gint depth, gboolean tearoff)
if (tearoff)
{
menuitem = gtk_tearoff_menu_item_new ();
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
}
for (i = 0, j = 1; i < 5; i++, j++)
for (i = 0, j = 1; i < length; i++, j++)
{
sprintf (buf, "item %2d - %d", depth, j);
menuitem = gtk_radio_menu_item_new_with_label (group, buf);
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
if (depth % 2)
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
if (i == 3)
gtk_widget_set_sensitive (menuitem, FALSE);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, TRUE));
if (i < 5)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5, TRUE));
}
return menu;
@ -2739,7 +2740,7 @@ create_menus (void)
gtk_box_pack_start (GTK_BOX (box1), menubar, FALSE, TRUE, 0);
gtk_widget_show (menubar);
menu = create_menu (2, TRUE);
menu = create_menu (2, 50, TRUE);
menuitem = gtk_menu_item_new_with_label ("test\nline2");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
@ -2747,12 +2748,12 @@ create_menus (void)
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("foo");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3, TRUE));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (3, 5, TRUE));
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, TRUE));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, 5, TRUE));
gtk_menu_item_right_justify (GTK_MENU_ITEM (menuitem));
gtk_menu_bar_append (GTK_MENU_BAR (menubar), menuitem);
gtk_widget_show (menuitem);
@ -2762,11 +2763,11 @@ create_menus (void)
gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_widget_show (box2);
menu = create_menu (1, FALSE);
menu = create_menu (1, 5, FALSE);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",
@ -2775,7 +2776,7 @@ create_menus (void)
0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_SIGNAL_VISIBLE);
menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",
@ -2784,7 +2785,7 @@ create_menus (void)
0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_check_menu_item_new_with_label ("Accelerators Frozen");
gtk_menu_append (GTK_MENU (menu), menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
gtk_widget_add_accelerator (menuitem,
"activate",