gtk2/gtk/gtkmenubar.c

403 lines
10 KiB
C
Raw Normal View History

1997-11-24 22:37:52 +00:00
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
1997-11-24 22:37:52 +00:00
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
1997-11-24 22:37:52 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
1997-11-24 22:37:52 +00:00
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
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 "gdk/gdkkeysyms.h"
#include "gtkbindings.h"
1997-11-24 22:37:52 +00:00
#include "gtkmain.h"
#include "gtkmenubar.h"
#include "gtkmenuitem.h"
enum {
ARG_0,
ARG_SHADOW
};
1997-11-24 22:37:52 +00:00
#define BORDER_SPACING 0
1997-11-24 22:37:52 +00:00
#define CHILD_SPACING 3
static void gtk_menu_bar_class_init (GtkMenuBarClass *klass);
static void gtk_menu_bar_init (GtkMenuBar *menu_bar);
static void gtk_menu_bar_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_menu_bar_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
1997-11-24 22:37:52 +00:00
static void gtk_menu_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_menu_bar_paint (GtkWidget *widget,
GdkRectangle *area);
1997-11-24 22:37:52 +00:00
static gint gtk_menu_bar_expose (GtkWidget *widget,
GdkEventExpose *event);
GtkType
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
1998-05-03 22:41:32 +00:00
gtk_menu_bar_get_type (void)
1997-11-24 22:37:52 +00:00
{
static GtkType menu_bar_type = 0;
1997-11-24 22:37:52 +00:00
if (!menu_bar_type)
{
static const GtkTypeInfo menu_bar_info =
1997-11-24 22:37:52 +00:00
{
"GtkMenuBar",
sizeof (GtkMenuBar),
sizeof (GtkMenuBarClass),
(GtkClassInitFunc) gtk_menu_bar_class_init,
(GtkObjectInitFunc) gtk_menu_bar_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
call the base class init fucntions from all parent types upon class Sun Jun 28 04:29:10 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.c (gtk_type_class_init): call the base class init fucntions from all parent types upon class initialization. * gtk/gtkcontainer.c: (gtk_container_get_type): announce gtk_container_base_class_init to the type system. (gtk_container_base_class_init): new function to feature base class initialization. (gtk_container_get_child_arg): (gtk_container_set_child_arg): call the GtkContainerClass get_child_arg and set_child_arg methods of the class indicated through the argument name. * gtk/gtkobject.c: (gtk_object_base_class_init): new function to feature base class initialization. (gtk_object_init_type): announce gtk_object_base_class_init to the type system. (gtk_object_class_init): setup the get_arg and set_arg pointers for GtkObjectClass. (gtk_object_setv): (gtk_object_getv): call the GtkObjectClass get_arg and set_arg methods, instead of bothering the type system with this. * gtk/gtkaccellabel.c: * gtk/gtkbutton.c: * gtk/gtkradiobutton.c: * gtk/gtktable.c: * gtk/gtktogglebutton.c: * gtk/gtktipsquery.c: * gtk/gtkbox.c: * gtk/gtkpacker.c: * gtk/gtkwidget.c: * gtk/gtkwindow.c: * gtk/gtkframe.c: * gtk/gtkmisc.c: * gtk/gtklabel.c: set the object_class->{g|s}et_arg pointers to the corresponding gtk_*_{g|s]et_arg functions and updated the gtk_*_get_type functions wrt GtkTypeInfo initialization. changed a lot of the set/get arg functions to take a GtkObject argument. gtk/gtkadjustment.c: gtk/gtkalignment.c: gtk/gtkarrow.c: gtk/gtkaspectframe.c: gtk/gtkbbox.c: gtk/gtkbin.c: gtk/gtkcheckbutton.c: gtk/gtkcheckmenuitem.c: gtk/gtkclist.c: gtk/gtkcolorsel.c: gtk/gtkcombo.c: gtk/gtkctree.c: gtk/gtkcurve.c: gtk/gtkdata.c: gtk/gtkdialog.c: gtk/gtkdrawingarea.c: gtk/gtkeditable.c: gtk/gtkentry.c: gtk/gtkeventbox.c: gtk/gtkfilesel.c: gtk/gtkfixed.c: gtk/gtkfontsel.c: gtk/gtkgamma.c: gtk/gtkhandlebox.c: gtk/gtkhbbox.c: gtk/gtkhbox.c: gtk/gtkhpaned.c: gtk/gtkhruler.c: gtk/gtkhscale.c: gtk/gtkhscrollbar.c: gtk/gtkhseparator.c: gtk/gtkimage.c: gtk/gtkinputdialog.c: gtk/gtkitem.c: gtk/gtkitemfactory.c: gtk/gtklist.c: gtk/gtklistitem.c: gtk/gtkmenu.c: gtk/gtkmenubar.c: gtk/gtkmenuitem.c: gtk/gtkmenushell.c: gtk/gtknotebook.c: gtk/gtkoptionmenu.c: gtk/gtkpaned.c: gtk/gtkpixmap.c: gtk/gtkpreview.c: gtk/gtkprogressbar.c: gtk/gtkradiomenuitem.c: gtk/gtkrange.c: gtk/gtkruler.c: gtk/gtkscale.c: gtk/gtkscrollbar.c: gtk/gtkscrolledwindow.c: gtk/gtkseparator.c: gtk/gtkspinbutton.c: gtk/gtkstatusbar.c: gtk/gtktext.c: gtk/gtktoolbar.c: gtk/gtktooltips.c: gtk/gtktree.c: gtk/gtktreeitem.c: gtk/gtkvbbox.c: gtk/gtkvbox.c: gtk/gtkviewport.c: gtk/gtkvpaned.c: gtk/gtkvruler.c: gtk/gtkvscale.c: gtk/gtkvscrollbar.c: gtk/gtkvseparator.c: updated the GtkTypeInfo initialization code to match the modified GtkTypeInfo structure.
1998-06-28 07:46:10 +00:00
(GtkClassInitFunc) NULL,
1997-11-24 22:37:52 +00:00
};
menu_bar_type = gtk_type_unique (gtk_menu_shell_get_type (), &menu_bar_info);
}
return menu_bar_type;
}
static void
gtk_menu_bar_class_init (GtkMenuBarClass *class)
{
GtkObjectClass *object_class;
1997-11-24 22:37:52 +00:00
GtkWidgetClass *widget_class;
GtkMenuShellClass *menu_shell_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;
object_class = (GtkObjectClass*) class;
1997-11-24 22:37:52 +00:00
widget_class = (GtkWidgetClass*) class;
menu_shell_class = (GtkMenuShellClass*) class;
gtk_object_add_arg_type ("GtkMenuBar::shadow", GTK_TYPE_SHADOW_TYPE, GTK_ARG_READWRITE, ARG_SHADOW);
object_class->set_arg = gtk_menu_bar_set_arg;
object_class->get_arg = gtk_menu_bar_get_arg;
Remove "draw" virtual method and signal 2000-12-02 Havoc Pennington <hp@pobox.com> * gtk/gtkwidget.h (struct _GtkWidgetClass): Remove "draw" virtual method and signal * gtk/gtkwidget.c (gtk_widget_draw): Now just queues a draw then calls gdk_window_process_updates() to push the exposes through (gtk_widget_class_init): No more draw signal, no gtk_widget_real_draw() * gtk/gtkbin.c (gtk_bin_draw): remove * gtk/gtkbox.c (gtk_box_draw): remove * gtk/gtkbutton.c (gtk_button_draw): remove * gtk/gtkcalendar.c (gtk_calendar_draw): remove * gtk/gtkcheckbutton.c (gtk_check_button_draw): remove * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_draw): remove * gtk/gtkclist.c (gtk_clist_draw): remove * gtk/gtkentry.c (gtk_entry_draw): remove * gtk/gtkeventbox.c (gtk_event_box_draw): remove * gtk/gtkfixed.c (gtk_fixed_draw): remove * gtk/gtkframe.c (gtk_frame_draw): remove * gtk/gtkhandlebox.c (gtk_handle_box_draw): remove * gtk/gtkhpaned.c (gtk_hpaned_draw): remove * gtk/gtklayout.c (gtk_layout_draw): remove * gtk/gtklist.c (gtk_list_draw): remove * gtk/gtklistitem.c (gtk_list_item_draw): remove * gtk/gtkmenu.c (gtk_menu_draw): remove * gtk/gtkmenubar.c (gtk_menu_bar_draw): remove * gtk/gtkmenuitem.c (gtk_menu_item_draw): remove * gtk/gtknotebook.c (gtk_notebook_draw): remove * gtk/gtkoptionmenu.c (gtk_option_menu_draw): remove * gtk/gtkpacker.c (gtk_packer_draw): remove * gtk/gtkrange.c (gtk_range_draw): remove * gtk/gtkscrolledwindow.c (gtk_scrolled_window_draw): remove * gtk/gtkspinbutton.c (gtk_spin_button_draw): remove * gtk/gtktable.c (gtk_table_draw): remove * gtk/gtktearoffmenuitem.c (gtk_tearoff_menu_item_draw): remove * gtk/gtktext.c (gtk_text_draw): remove * gtk/gtktextview.c (gtk_text_view_draw): remove * gtk/gtktogglebutton.c (gtk_toggle_button_draw): remove * gtk/gtktoolbar.c (gtk_toolbar_draw): remove * gtk/gtktree.c (gtk_tree_draw): remove * gtk/gtktreeitem.c (gtk_tree_item_draw): remove * gtk/gtktreeview.c (gtk_tree_view_draw): remove * gtk/gtkviewport.c (gtk_viewport_draw): remove * gtk/gtkvpaned.c (gtk_vpaned_draw): remove * gtk/gtkvscale.c (gtk_vscale_draw): remove * gtk/gtkwindow.c (gtk_window_draw): remove
2000-12-04 01:15:37 +00:00
1997-11-24 22:37:52 +00:00
widget_class->size_request = gtk_menu_bar_size_request;
widget_class->size_allocate = gtk_menu_bar_size_allocate;
widget_class->expose_event = gtk_menu_bar_expose;
menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
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,
GDK_Left, 0,
"move_current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PREV);
gtk_binding_entry_add_signal (binding_set,
GDK_Right, 0,
"move_current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_NEXT);
gtk_binding_entry_add_signal (binding_set,
GDK_Up, 0,
"move_current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PARENT);
gtk_binding_entry_add_signal (binding_set,
GDK_Down, 0,
"move_current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_CHILD);
1997-11-24 22:37:52 +00:00
}
static void
gtk_menu_bar_init (GtkMenuBar *menu_bar)
{
menu_bar->shadow_type = GTK_SHADOW_OUT;
}
static void
gtk_menu_bar_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkMenuBar *menu_bar;
menu_bar = GTK_MENU_BAR (object);
switch (arg_id)
{
case ARG_SHADOW:
gtk_menu_bar_set_shadow_type (menu_bar, GTK_VALUE_ENUM (*arg));
break;
default:
break;
}
1997-11-24 22:37:52 +00:00
}
static void
gtk_menu_bar_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkMenuBar *menu_bar;
menu_bar = GTK_MENU_BAR (object);
switch (arg_id)
{
case ARG_SHADOW:
GTK_VALUE_ENUM (*arg) = menu_bar->shadow_type;
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
1997-11-24 22:37:52 +00:00
GtkWidget*
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
1998-05-03 22:41:32 +00:00
gtk_menu_bar_new (void)
1997-11-24 22:37:52 +00:00
{
return GTK_WIDGET (gtk_type_new (gtk_menu_bar_get_type ()));
}
void
gtk_menu_bar_append (GtkMenuBar *menu_bar,
GtkWidget *child)
{
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), child);
}
void
gtk_menu_bar_prepend (GtkMenuBar *menu_bar,
GtkWidget *child)
{
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu_bar), child);
}
void
gtk_menu_bar_insert (GtkMenuBar *menu_bar,
GtkWidget *child,
gint position)
{
gtk_menu_shell_insert (GTK_MENU_SHELL (menu_bar), child, position);
}
static void
gtk_menu_bar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkMenuBar *menu_bar;
GtkMenuShell *menu_shell;
GtkWidget *child;
GList *children;
gint nchildren;
GtkRequisition child_requisition;
1997-11-24 22:37:52 +00:00
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
g_return_if_fail (requisition != NULL);
requisition->width = 0;
requisition->height = 0;
if (GTK_WIDGET_VISIBLE (widget))
{
menu_bar = GTK_MENU_BAR (widget);
menu_shell = GTK_MENU_SHELL (widget);
nchildren = 0;
children = menu_shell->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_VISIBLE (child))
{
GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
gtk_widget_size_request (child, &child_requisition);
1997-11-24 22:37:52 +00:00
requisition->width += child_requisition.width;
requisition->height = MAX (requisition->height, child_requisition.height);
/* Support for the right justified help menu */
if ((children == NULL) && GTK_IS_MENU_ITEM(child) &&
GTK_MENU_ITEM(child)->right_justify)
{
requisition->width += CHILD_SPACING;
}
1997-11-24 22:37:52 +00:00
nchildren += 1;
}
}
requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
Make this compile without framebuffer enabled 2000-06-20 Havoc Pennington <hp@redhat.com> * modules/linux-fb/Makefile.am: Make this compile without framebuffer enabled * gdk/linux-fb/Makefile.am: Add conditional to not build framebuffer unless specified in configure * gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting the size of the target instead of source if -1 was passed for width/height * gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix width/height confusion. 2000-06-19 Havoc Pennington <hp@redhat.com> * gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be GDK_DRAWABLE_XID. In the future, we probably want to make it faster with G_DISABLE_CHECKS turned on. 2000-06-14 Havoc Pennington <hp@redhat.com> * gdk/Makefile.am: add gdkpixmap.c * gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/ s/gdk_image_init/_gdk_windowing_image_init * gdk/gdkcolor.c: make ref/unref compat wrappers for GObject ref/unref * gdk/gdkcolor.h: make GdkColormap a GObject subclass * gdk/gdkcompat.h: remove GdkWindowType compat, since GdkWindowType is now non-deprecated; change gdk_window_get_type() compat to be gdk_window_get_window_type(). * gdk/gdkdnd.h: make GdkDragContext a GObject. * gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure virtual GObject. Make all functions call into the vtable. Move gdk_image_put() guts in here. Remove GdkDrawableType and gdk_drawable_get_type(), these are now GdkWindow-specific. draw_image, get_depth, get_size, set_colormap, get_colormap, get_visual added to the vtable. * gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual GObject. Virtualize everything. (gdk_gc_new_with_values): remove check for destroyed window, because now GdkWindow::create_gc will check this. (gdk_gc_set_values): New function to set GC values, this was already implemented but wasn't in the header * gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject. * gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove _gdk_window_draw_image(), remove _gdk_windowing_window_class, remove _gdk_window_class; add _gdk_window_impl_get_type() and _gdk_pixmap_impl_get_type(). Rename gdk_window_init to _gdk_windowing_window_init, rename gdk_image_init to _gdk_windowing_image_init. * gdk/gdkpango.c: Reflect GObject-ification of PangoContext. (gdk_draw_layout): Remove check for destroyed window, because all the drawable methods already check it. * gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject. Add gdkpixmap.c which contains implementation of GdkDrawable virtual table (by chaining to a platform-specific implementation object). * gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP, GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate, GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate, GdkColormapPrivate. * gdk/gdktypes.h: #include <glib-object.h> * gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject. Move most functionality to platform-specific implementation object. GdkWindow itself now handles the backing store, then chains to the platform-specific implementation. (gdk_window_get_window_type): return GdkWindowType of the window. (gdk_window_peek_children): New routine, returns the children of a GdkWindow (gdk_window_get_children): Was in X11-specific code and did XQueryTree. Changed to simply return a copy of window->children; so it can go in cross-platform code. * gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path * gdk/x11/gdkcolor-x11.c: implement X-specific parts of GdkColormap; just changed to use the new private data instead of casting to GdkColormapPrivate. * gdk/x11/gdkcursor-x11.c: added a couple typechecks to gdk_cursor_new(). * gdk/x11/gdkdnd-x11.c: Change the way we access private fields (private data member in the GObject). (xdnd_manager_source_filter): Function had broken error handling, fix it (use gdk_error_trap_push). * gdk/x11/gdkdrawable-x11.c: This file now implements a base class for GdkWindowImplX11/GdkPixmapImplX11. This base class is purely for the convenience of the X port, and not part of the interface to cross-platform GDK. * gdk/x11/gdkevents-x11.c: Reflect various renamings. * gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's specific to X, and returned by the create_gc virtual method of GdkDrawableImplX11. (gdk_x11_gc_set_dashes): Change this to take an array of gint8 rather than gchar, this was also changed in the GdkGC vtable. (gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the mask is 0, return immediately, instead of checking every flag. This is faster, and keeps us from segfaulting if values is NULL and the mask contains some nonzero flags. * gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of GdkWindow. * gdk/x11/gdkglobals-x11.c: change type of grab window, since GdkWindowPrivate is gone. * gdk/x11/gdkim-x11.c: rename things that got renamed. * gdk/x11/gdkimage-x11.c: implement in terms of GObject, and remove the image_put stuff that got transferred to GdkDrawable. * gdk/x11/gdkinput.c: renamings * gdk/x11/gdkmain-x11.c: #include <pango/pangox.h> * gdk/x11/gdkpixmap-x11.c: GObject conversion * gdk/x11/gdkprivate-x11.h: indentation fixes * gdk/x11/gdkproperty-x11.c: renamings * gdk/x11/gdkselection-x11.c: renamings * gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now implements the platform-specific "impl" object. Moved gdk_window_get_children to gdk/gdkwindow.c * gdk/x11/gdkx.h: Remove all the private structs and private datas that no longer exist. Add declaration of GdkGCX11 object here. Fix all the macros to still work. * gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow, GdkDragContext from the boxed types since they are now GObjects. * gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject, moved xthickness/ythickness into the instance. GtkStyleClass functions are now in the standard vtable for GtkStyle, so you have to create a GObject subclass to write a theme engine. (gtk_style_copy): fixed a leaked PangoFontDescription (gtk_style_init): renamed gtk_style_realize, so gtk_style_init can be the standard GObject function. * Throughout GTK: s/style->klass->[xy]thickness/style->[xy]thickness s/pango_layout_unref/g_object_unref/ * gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject. * gtk/gtksocket.c: Use gdk_window_get_user_data() instead of accessing GDK internals. * gtk/gtkwidget.c: Use gdk_window_peek_children() instead of accessing GDK internals.
2000-06-20 21:04:44 +00:00
widget->style->xthickness +
1997-11-24 22:37:52 +00:00
BORDER_SPACING) * 2;
requisition->height += (GTK_CONTAINER (menu_bar)->border_width +
Make this compile without framebuffer enabled 2000-06-20 Havoc Pennington <hp@redhat.com> * modules/linux-fb/Makefile.am: Make this compile without framebuffer enabled * gdk/linux-fb/Makefile.am: Add conditional to not build framebuffer unless specified in configure * gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting the size of the target instead of source if -1 was passed for width/height * gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix width/height confusion. 2000-06-19 Havoc Pennington <hp@redhat.com> * gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be GDK_DRAWABLE_XID. In the future, we probably want to make it faster with G_DISABLE_CHECKS turned on. 2000-06-14 Havoc Pennington <hp@redhat.com> * gdk/Makefile.am: add gdkpixmap.c * gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/ s/gdk_image_init/_gdk_windowing_image_init * gdk/gdkcolor.c: make ref/unref compat wrappers for GObject ref/unref * gdk/gdkcolor.h: make GdkColormap a GObject subclass * gdk/gdkcompat.h: remove GdkWindowType compat, since GdkWindowType is now non-deprecated; change gdk_window_get_type() compat to be gdk_window_get_window_type(). * gdk/gdkdnd.h: make GdkDragContext a GObject. * gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure virtual GObject. Make all functions call into the vtable. Move gdk_image_put() guts in here. Remove GdkDrawableType and gdk_drawable_get_type(), these are now GdkWindow-specific. draw_image, get_depth, get_size, set_colormap, get_colormap, get_visual added to the vtable. * gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual GObject. Virtualize everything. (gdk_gc_new_with_values): remove check for destroyed window, because now GdkWindow::create_gc will check this. (gdk_gc_set_values): New function to set GC values, this was already implemented but wasn't in the header * gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject. * gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove _gdk_window_draw_image(), remove _gdk_windowing_window_class, remove _gdk_window_class; add _gdk_window_impl_get_type() and _gdk_pixmap_impl_get_type(). Rename gdk_window_init to _gdk_windowing_window_init, rename gdk_image_init to _gdk_windowing_image_init. * gdk/gdkpango.c: Reflect GObject-ification of PangoContext. (gdk_draw_layout): Remove check for destroyed window, because all the drawable methods already check it. * gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject. Add gdkpixmap.c which contains implementation of GdkDrawable virtual table (by chaining to a platform-specific implementation object). * gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP, GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate, GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate, GdkColormapPrivate. * gdk/gdktypes.h: #include <glib-object.h> * gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject. Move most functionality to platform-specific implementation object. GdkWindow itself now handles the backing store, then chains to the platform-specific implementation. (gdk_window_get_window_type): return GdkWindowType of the window. (gdk_window_peek_children): New routine, returns the children of a GdkWindow (gdk_window_get_children): Was in X11-specific code and did XQueryTree. Changed to simply return a copy of window->children; so it can go in cross-platform code. * gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path * gdk/x11/gdkcolor-x11.c: implement X-specific parts of GdkColormap; just changed to use the new private data instead of casting to GdkColormapPrivate. * gdk/x11/gdkcursor-x11.c: added a couple typechecks to gdk_cursor_new(). * gdk/x11/gdkdnd-x11.c: Change the way we access private fields (private data member in the GObject). (xdnd_manager_source_filter): Function had broken error handling, fix it (use gdk_error_trap_push). * gdk/x11/gdkdrawable-x11.c: This file now implements a base class for GdkWindowImplX11/GdkPixmapImplX11. This base class is purely for the convenience of the X port, and not part of the interface to cross-platform GDK. * gdk/x11/gdkevents-x11.c: Reflect various renamings. * gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's specific to X, and returned by the create_gc virtual method of GdkDrawableImplX11. (gdk_x11_gc_set_dashes): Change this to take an array of gint8 rather than gchar, this was also changed in the GdkGC vtable. (gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the mask is 0, return immediately, instead of checking every flag. This is faster, and keeps us from segfaulting if values is NULL and the mask contains some nonzero flags. * gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of GdkWindow. * gdk/x11/gdkglobals-x11.c: change type of grab window, since GdkWindowPrivate is gone. * gdk/x11/gdkim-x11.c: rename things that got renamed. * gdk/x11/gdkimage-x11.c: implement in terms of GObject, and remove the image_put stuff that got transferred to GdkDrawable. * gdk/x11/gdkinput.c: renamings * gdk/x11/gdkmain-x11.c: #include <pango/pangox.h> * gdk/x11/gdkpixmap-x11.c: GObject conversion * gdk/x11/gdkprivate-x11.h: indentation fixes * gdk/x11/gdkproperty-x11.c: renamings * gdk/x11/gdkselection-x11.c: renamings * gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now implements the platform-specific "impl" object. Moved gdk_window_get_children to gdk/gdkwindow.c * gdk/x11/gdkx.h: Remove all the private structs and private datas that no longer exist. Add declaration of GdkGCX11 object here. Fix all the macros to still work. * gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow, GdkDragContext from the boxed types since they are now GObjects. * gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject, moved xthickness/ythickness into the instance. GtkStyleClass functions are now in the standard vtable for GtkStyle, so you have to create a GObject subclass to write a theme engine. (gtk_style_copy): fixed a leaked PangoFontDescription (gtk_style_init): renamed gtk_style_realize, so gtk_style_init can be the standard GObject function. * Throughout GTK: s/style->klass->[xy]thickness/style->[xy]thickness s/pango_layout_unref/g_object_unref/ * gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject. * gtk/gtksocket.c: Use gdk_window_get_user_data() instead of accessing GDK internals. * gtk/gtkwidget.c: Use gdk_window_peek_children() instead of accessing GDK internals.
2000-06-20 21:04:44 +00:00
widget->style->ythickness +
1997-11-24 22:37:52 +00:00
BORDER_SPACING) * 2;
if (nchildren > 0)
requisition->width += 2 * CHILD_SPACING * (nchildren - 1);
}
}
static void
gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkMenuBar *menu_bar;
GtkMenuShell *menu_shell;
GtkWidget *child;
GList *children;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
1997-11-24 22:37:52 +00:00
guint offset;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
g_return_if_fail (allocation != NULL);
menu_bar = GTK_MENU_BAR (widget);
menu_shell = GTK_MENU_SHELL (widget);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
allocation->x, allocation->y,
allocation->width, allocation->height);
if (menu_shell->children)
{
child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width +
Make this compile without framebuffer enabled 2000-06-20 Havoc Pennington <hp@redhat.com> * modules/linux-fb/Makefile.am: Make this compile without framebuffer enabled * gdk/linux-fb/Makefile.am: Add conditional to not build framebuffer unless specified in configure * gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting the size of the target instead of source if -1 was passed for width/height * gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix width/height confusion. 2000-06-19 Havoc Pennington <hp@redhat.com> * gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be GDK_DRAWABLE_XID. In the future, we probably want to make it faster with G_DISABLE_CHECKS turned on. 2000-06-14 Havoc Pennington <hp@redhat.com> * gdk/Makefile.am: add gdkpixmap.c * gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/ s/gdk_image_init/_gdk_windowing_image_init * gdk/gdkcolor.c: make ref/unref compat wrappers for GObject ref/unref * gdk/gdkcolor.h: make GdkColormap a GObject subclass * gdk/gdkcompat.h: remove GdkWindowType compat, since GdkWindowType is now non-deprecated; change gdk_window_get_type() compat to be gdk_window_get_window_type(). * gdk/gdkdnd.h: make GdkDragContext a GObject. * gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure virtual GObject. Make all functions call into the vtable. Move gdk_image_put() guts in here. Remove GdkDrawableType and gdk_drawable_get_type(), these are now GdkWindow-specific. draw_image, get_depth, get_size, set_colormap, get_colormap, get_visual added to the vtable. * gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual GObject. Virtualize everything. (gdk_gc_new_with_values): remove check for destroyed window, because now GdkWindow::create_gc will check this. (gdk_gc_set_values): New function to set GC values, this was already implemented but wasn't in the header * gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject. * gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove _gdk_window_draw_image(), remove _gdk_windowing_window_class, remove _gdk_window_class; add _gdk_window_impl_get_type() and _gdk_pixmap_impl_get_type(). Rename gdk_window_init to _gdk_windowing_window_init, rename gdk_image_init to _gdk_windowing_image_init. * gdk/gdkpango.c: Reflect GObject-ification of PangoContext. (gdk_draw_layout): Remove check for destroyed window, because all the drawable methods already check it. * gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject. Add gdkpixmap.c which contains implementation of GdkDrawable virtual table (by chaining to a platform-specific implementation object). * gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP, GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate, GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate, GdkColormapPrivate. * gdk/gdktypes.h: #include <glib-object.h> * gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject. Move most functionality to platform-specific implementation object. GdkWindow itself now handles the backing store, then chains to the platform-specific implementation. (gdk_window_get_window_type): return GdkWindowType of the window. (gdk_window_peek_children): New routine, returns the children of a GdkWindow (gdk_window_get_children): Was in X11-specific code and did XQueryTree. Changed to simply return a copy of window->children; so it can go in cross-platform code. * gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path * gdk/x11/gdkcolor-x11.c: implement X-specific parts of GdkColormap; just changed to use the new private data instead of casting to GdkColormapPrivate. * gdk/x11/gdkcursor-x11.c: added a couple typechecks to gdk_cursor_new(). * gdk/x11/gdkdnd-x11.c: Change the way we access private fields (private data member in the GObject). (xdnd_manager_source_filter): Function had broken error handling, fix it (use gdk_error_trap_push). * gdk/x11/gdkdrawable-x11.c: This file now implements a base class for GdkWindowImplX11/GdkPixmapImplX11. This base class is purely for the convenience of the X port, and not part of the interface to cross-platform GDK. * gdk/x11/gdkevents-x11.c: Reflect various renamings. * gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's specific to X, and returned by the create_gc virtual method of GdkDrawableImplX11. (gdk_x11_gc_set_dashes): Change this to take an array of gint8 rather than gchar, this was also changed in the GdkGC vtable. (gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the mask is 0, return immediately, instead of checking every flag. This is faster, and keeps us from segfaulting if values is NULL and the mask contains some nonzero flags. * gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of GdkWindow. * gdk/x11/gdkglobals-x11.c: change type of grab window, since GdkWindowPrivate is gone. * gdk/x11/gdkim-x11.c: rename things that got renamed. * gdk/x11/gdkimage-x11.c: implement in terms of GObject, and remove the image_put stuff that got transferred to GdkDrawable. * gdk/x11/gdkinput.c: renamings * gdk/x11/gdkmain-x11.c: #include <pango/pangox.h> * gdk/x11/gdkpixmap-x11.c: GObject conversion * gdk/x11/gdkprivate-x11.h: indentation fixes * gdk/x11/gdkproperty-x11.c: renamings * gdk/x11/gdkselection-x11.c: renamings * gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now implements the platform-specific "impl" object. Moved gdk_window_get_children to gdk/gdkwindow.c * gdk/x11/gdkx.h: Remove all the private structs and private datas that no longer exist. Add declaration of GdkGCX11 object here. Fix all the macros to still work. * gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow, GdkDragContext from the boxed types since they are now GObjects. * gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject, moved xthickness/ythickness into the instance. GtkStyleClass functions are now in the standard vtable for GtkStyle, so you have to create a GObject subclass to write a theme engine. (gtk_style_copy): fixed a leaked PangoFontDescription (gtk_style_init): renamed gtk_style_realize, so gtk_style_init can be the standard GObject function. * Throughout GTK: s/style->klass->[xy]thickness/style->[xy]thickness s/pango_layout_unref/g_object_unref/ * gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject. * gtk/gtksocket.c: Use gdk_window_get_user_data() instead of accessing GDK internals. * gtk/gtkwidget.c: Use gdk_window_peek_children() instead of accessing GDK internals.
2000-06-20 21:04:44 +00:00
widget->style->xthickness +
1997-11-24 22:37:52 +00:00
BORDER_SPACING);
offset = child_allocation.x; /* Window edge to menubar start */
child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width +
Make this compile without framebuffer enabled 2000-06-20 Havoc Pennington <hp@redhat.com> * modules/linux-fb/Makefile.am: Make this compile without framebuffer enabled * gdk/linux-fb/Makefile.am: Add conditional to not build framebuffer unless specified in configure * gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting the size of the target instead of source if -1 was passed for width/height * gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix width/height confusion. 2000-06-19 Havoc Pennington <hp@redhat.com> * gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be GDK_DRAWABLE_XID. In the future, we probably want to make it faster with G_DISABLE_CHECKS turned on. 2000-06-14 Havoc Pennington <hp@redhat.com> * gdk/Makefile.am: add gdkpixmap.c * gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/ s/gdk_image_init/_gdk_windowing_image_init * gdk/gdkcolor.c: make ref/unref compat wrappers for GObject ref/unref * gdk/gdkcolor.h: make GdkColormap a GObject subclass * gdk/gdkcompat.h: remove GdkWindowType compat, since GdkWindowType is now non-deprecated; change gdk_window_get_type() compat to be gdk_window_get_window_type(). * gdk/gdkdnd.h: make GdkDragContext a GObject. * gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure virtual GObject. Make all functions call into the vtable. Move gdk_image_put() guts in here. Remove GdkDrawableType and gdk_drawable_get_type(), these are now GdkWindow-specific. draw_image, get_depth, get_size, set_colormap, get_colormap, get_visual added to the vtable. * gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual GObject. Virtualize everything. (gdk_gc_new_with_values): remove check for destroyed window, because now GdkWindow::create_gc will check this. (gdk_gc_set_values): New function to set GC values, this was already implemented but wasn't in the header * gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject. * gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove _gdk_window_draw_image(), remove _gdk_windowing_window_class, remove _gdk_window_class; add _gdk_window_impl_get_type() and _gdk_pixmap_impl_get_type(). Rename gdk_window_init to _gdk_windowing_window_init, rename gdk_image_init to _gdk_windowing_image_init. * gdk/gdkpango.c: Reflect GObject-ification of PangoContext. (gdk_draw_layout): Remove check for destroyed window, because all the drawable methods already check it. * gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject. Add gdkpixmap.c which contains implementation of GdkDrawable virtual table (by chaining to a platform-specific implementation object). * gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP, GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate, GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate, GdkColormapPrivate. * gdk/gdktypes.h: #include <glib-object.h> * gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject. Move most functionality to platform-specific implementation object. GdkWindow itself now handles the backing store, then chains to the platform-specific implementation. (gdk_window_get_window_type): return GdkWindowType of the window. (gdk_window_peek_children): New routine, returns the children of a GdkWindow (gdk_window_get_children): Was in X11-specific code and did XQueryTree. Changed to simply return a copy of window->children; so it can go in cross-platform code. * gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path * gdk/x11/gdkcolor-x11.c: implement X-specific parts of GdkColormap; just changed to use the new private data instead of casting to GdkColormapPrivate. * gdk/x11/gdkcursor-x11.c: added a couple typechecks to gdk_cursor_new(). * gdk/x11/gdkdnd-x11.c: Change the way we access private fields (private data member in the GObject). (xdnd_manager_source_filter): Function had broken error handling, fix it (use gdk_error_trap_push). * gdk/x11/gdkdrawable-x11.c: This file now implements a base class for GdkWindowImplX11/GdkPixmapImplX11. This base class is purely for the convenience of the X port, and not part of the interface to cross-platform GDK. * gdk/x11/gdkevents-x11.c: Reflect various renamings. * gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's specific to X, and returned by the create_gc virtual method of GdkDrawableImplX11. (gdk_x11_gc_set_dashes): Change this to take an array of gint8 rather than gchar, this was also changed in the GdkGC vtable. (gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the mask is 0, return immediately, instead of checking every flag. This is faster, and keeps us from segfaulting if values is NULL and the mask contains some nonzero flags. * gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of GdkWindow. * gdk/x11/gdkglobals-x11.c: change type of grab window, since GdkWindowPrivate is gone. * gdk/x11/gdkim-x11.c: rename things that got renamed. * gdk/x11/gdkimage-x11.c: implement in terms of GObject, and remove the image_put stuff that got transferred to GdkDrawable. * gdk/x11/gdkinput.c: renamings * gdk/x11/gdkmain-x11.c: #include <pango/pangox.h> * gdk/x11/gdkpixmap-x11.c: GObject conversion * gdk/x11/gdkprivate-x11.h: indentation fixes * gdk/x11/gdkproperty-x11.c: renamings * gdk/x11/gdkselection-x11.c: renamings * gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now implements the platform-specific "impl" object. Moved gdk_window_get_children to gdk/gdkwindow.c * gdk/x11/gdkx.h: Remove all the private structs and private datas that no longer exist. Add declaration of GdkGCX11 object here. Fix all the macros to still work. * gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow, GdkDragContext from the boxed types since they are now GObjects. * gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject, moved xthickness/ythickness into the instance. GtkStyleClass functions are now in the standard vtable for GtkStyle, so you have to create a GObject subclass to write a theme engine. (gtk_style_copy): fixed a leaked PangoFontDescription (gtk_style_init): renamed gtk_style_realize, so gtk_style_init can be the standard GObject function. * Throughout GTK: s/style->klass->[xy]thickness/style->[xy]thickness s/pango_layout_unref/g_object_unref/ * gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject. * gtk/gtksocket.c: Use gdk_window_get_user_data() instead of accessing GDK internals. * gtk/gtkwidget.c: Use gdk_window_peek_children() instead of accessing GDK internals.
2000-06-20 21:04:44 +00:00
widget->style->ythickness +
1997-11-24 22:37:52 +00:00
BORDER_SPACING);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
1997-11-24 22:37:52 +00:00
children = menu_shell->children;
while (children)
{
child = children->data;
children = children->next;
gtk_widget_get_child_requisition (child, &child_requisition);
1997-11-24 22:37:52 +00:00
/* Support for the right justified help menu */
if ( (children == NULL) && (GTK_IS_MENU_ITEM(child))
&& (GTK_MENU_ITEM(child)->right_justify))
{
child_allocation.x = allocation->width -
child_requisition.width - CHILD_SPACING - offset;
}
1997-11-24 22:37:52 +00:00
if (GTK_WIDGET_VISIBLE (child))
{
child_allocation.width = child_requisition.width;
1997-11-24 22:37:52 +00:00
gtk_widget_size_allocate (child, &child_allocation);
child_allocation.x += child_allocation.width + CHILD_SPACING * 2;
}
}
}
}
void
gtk_menu_bar_set_shadow_type (GtkMenuBar *menu_bar,
GtkShadowType type)
{
g_return_if_fail (menu_bar != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (menu_bar));
if ((GtkShadowType) menu_bar->shadow_type != type)
{
menu_bar->shadow_type = type;
if (GTK_WIDGET_DRAWABLE (menu_bar))
{
gtk_widget_queue_clear (GTK_WIDGET (menu_bar));
}
gtk_widget_queue_resize (GTK_WIDGET (menu_bar));
}
}
1997-11-24 22:37:52 +00:00
static void
gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
1997-11-24 22:37:52 +00:00
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MENU_BAR (widget));
if (GTK_WIDGET_DRAWABLE (widget))
{
gtk_paint_box (widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_MENU_BAR (widget)->shadow_type,
area, widget, "menubar",
0, 0,
-1,-1);
1997-11-24 22:37:52 +00:00
}
}
static gint
gtk_menu_bar_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkMenuShell *menu_shell;
GdkEventExpose child_event;
GList *children;
GtkWidget *child;
1997-11-24 22:37:52 +00:00
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE (widget))
{
gtk_menu_bar_paint (widget, &event->area);
1997-11-24 22:37:52 +00:00
menu_shell = GTK_MENU_SHELL (widget);
child_event = *event;
children = menu_shell->children;
while (children)
{
child = children->data;
children = children->next;
if (GTK_WIDGET_NO_WINDOW (child) &&
gtk_widget_intersect (child, &event->area, &child_event.area))
gtk_widget_event (child, (GdkEvent*) &child_event);
}
}
return FALSE;
}