#define GTK_MENU_INTERNALS
-#include <config.h>
+#include "config.h"
#include "gdk/gdkkeysyms.h"
#include "gtkbindings.h"
#include "gtkmain.h"
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_MENU_BAR, GtkMenuBarPrivate))
-static void gtk_menu_bar_class_init (GtkMenuBarClass *klass);
static void gtk_menu_bar_set_property (GObject *object,
guint prop_id,
const GValue *value,
static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell);
static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
GtkMenuDirectionType direction);
-
static GtkShadowType get_shadow_type (GtkMenuBar *menubar);
-static GtkMenuShellClass *parent_class = NULL;
-
-GType
-gtk_menu_bar_get_type (void)
-{
- static GType menu_bar_type = 0;
-
- if (!menu_bar_type)
- menu_bar_type = g_type_register_static_simple (GTK_TYPE_MENU_SHELL,
- I_("GtkMenuBar"),
- sizeof (GtkMenuBarClass),
- gtk_menu_bar_class_init,
- sizeof (GtkMenuBar),
- NULL, 0);
-
- return menu_bar_type;
-}
+G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
static void
gtk_menu_bar_class_init (GtkMenuBarClass *class)
GtkBindingSet *binding_set;
- parent_class = g_type_class_peek_parent (class);
-
gobject_class = (GObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
menu_shell_class = (GtkMenuShellClass*) class;
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set,
GDK_Left, 0,
- "move_current", 1,
+ "move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PREV);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Left, 0,
- "move_current", 1,
+ "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,
+ "move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_NEXT);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Right, 0,
- "move_current", 1,
+ "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,
+ "move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_PARENT);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Up, 0,
- "move_current", 1,
+ "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,
+ "move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_CHILD);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Down, 0,
- "move_current", 1,
+ "move-current", 1,
GTK_TYPE_MENU_DIRECTION_TYPE,
GTK_MENU_DIR_CHILD);
/**
* GtkMenuBar:child-pack-direction:
*
- * The pack direction of the menubar. It determines how
+ * The child pack direction of the menubar. It determines how
* the widgets contained in child menuitems are arranged.
*
* Since: 2.8
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
}
-
+
+static void
+gtk_menu_bar_init (GtkMenuBar *object)
+{
+}
+
GtkWidget*
gtk_menu_bar_new (void)
{
}
static void
-gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area)
+gtk_menu_bar_paint (GtkWidget *widget,
+ GdkRectangle *area)
{
g_return_if_fail (GTK_IS_MENU_BAR (widget));
{
gtk_menu_bar_paint (widget, &event->area);
- (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
+ GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->expose_event (widget, event);
}
return FALSE;
gboolean retval = FALSE;
g_object_get (gtk_widget_get_settings (widget),
- "gtk-menu-bar-accel",
- &accel,
+ "gtk-menu-bar-accel", &accel,
NULL);
- if (accel)
+ if (accel && *accel)
{
guint keyval = 0;
GdkModifierType mods = 0;
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
+ _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
_gtk_menu_shell_activate (menu_shell);
gtk_menu_shell_select_first (menu_shell, FALSE);
retval = TRUE;
}
}
-
- g_free (accel);
}
+ g_free (accel);
+
return retval;
}
if (!menubars)
{
g_signal_connect (window,
- "key_press_event",
+ "key-press-event",
G_CALLBACK (window_key_press_handler),
NULL);
}
{
GList *menubars = get_menu_bars (window);
- menubars = g_object_get_data (G_OBJECT (window),
- "gtk-menu-bar-list");
-
menubars = g_list_remove (menubars, menubar);
if (!menubars)
if (old_toplevel)
remove_from_window (GTK_WINDOW (old_toplevel), menubar);
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
add_to_window (GTK_WINDOW (toplevel), menubar);
}
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar));
GtkMenuItem *to_activate = NULL;
- if (GTK_WIDGET_TOPLEVEL (toplevel))
+ if (gtk_widget_is_toplevel (toplevel))
{
GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (toplevel));
GList *menubars;
static void
gtk_menu_bar_move_current (GtkMenuShell *menu_shell,
- GtkMenuDirectionType direction)
+ GtkMenuDirectionType direction)
{
GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
GtkTextDirection text_dir;
}
}
- GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction);
+ GTK_MENU_SHELL_CLASS (gtk_menu_bar_parent_class)->move_current (menu_shell, direction);
}
/**
* gtk_menu_bar_get_pack_direction:
* @menubar: a #GtkMenuBar
*
- * Retrieves the current pack direction of the menubar. See
- * gtk_menu_bar_set_pack_direction().
+ * Retrieves the current pack direction of the menubar.
+ * See gtk_menu_bar_set_pack_direction().
*
* Return value: the pack direction
*
* Since: 2.8
- **/
+ */
GtkPackDirection
gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
{
/**
* gtk_menu_bar_set_pack_direction:
- * @menubar: a #GtkMenuBar.
- * @pack_dir: a new #GtkPackDirection.
+ * @menubar: a #GtkMenuBar
+ * @pack_dir: a new #GtkPackDirection
*
* Sets how items should be packed inside a menubar.
*
* Since: 2.8
- **/
-void gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
- GtkPackDirection pack_dir)
+ */
+void
+gtk_menu_bar_set_pack_direction (GtkMenuBar *menubar,
+ GtkPackDirection pack_dir)
{
GtkMenuBarPrivate *priv;
GList *l;
* gtk_menu_bar_get_child_pack_direction:
* @menubar: a #GtkMenuBar
*
- * Retrieves the current child pack direction of the menubar. See
- * gtk_menu_bar_set_child_pack_direction().
+ * Retrieves the current child pack direction of the menubar.
+ * See gtk_menu_bar_set_child_pack_direction().
*
* Return value: the child pack direction
*
* Since: 2.8
- **/
+ */
GtkPackDirection
gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
{
/**
* gtk_menu_bar_set_child_pack_direction:
- * @menubar: a #GtkMenuBar.
- * @child_pack_dir: a new #GtkPackDirection.
+ * @menubar: a #GtkMenuBar
+ * @child_pack_dir: a new #GtkPackDirection
*
* Sets how widgets should be packed inside the children of a menubar.
*
* Since: 2.8
- **/
-void gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
- GtkPackDirection child_pack_dir)
+ */
+void
+gtk_menu_bar_set_child_pack_direction (GtkMenuBar *menubar,
+ GtkPackDirection child_pack_dir)
{
GtkMenuBarPrivate *priv;
GList *l;