]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmenubar.c
Deprecate flag macros for toplevel, state, no window and composite child
[~andy/gtk] / gtk / gtkmenubar.c
index 5df2c725e445872b4ecaa4e149988423e359bf23..d051e3b79a76161bcfae8a3c6d9f24eb6f572f1e 100644 (file)
@@ -26,7 +26,7 @@
 
 #define GTK_MENU_INTERNALS
 
-#include <config.h>
+#include "config.h"
 #include "gdk/gdkkeysyms.h"
 #include "gtkbindings.h"
 #include "gtkmain.h"
@@ -61,7 +61,6 @@ struct _GtkMenuBarPrivate
   (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,
@@ -83,27 +82,10 @@ static void gtk_menu_bar_hierarchy_changed (GtkWidget       *widget,
 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)
@@ -114,8 +96,6 @@ 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;
@@ -135,42 +115,42 @@ gtk_menu_bar_class_init (GtkMenuBarClass *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);
 
@@ -194,7 +174,7 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
   /**
    * 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
@@ -236,7 +216,12 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
 
   g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));  
 }
+
+static void
+gtk_menu_bar_init (GtkMenuBar *object)
+{
+}
+
 GtkWidget*
 gtk_menu_bar_new (void)
 {
@@ -519,7 +504,8 @@ gtk_menu_bar_size_allocate (GtkWidget     *widget,
 }
 
 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));
 
@@ -551,7 +537,7 @@ gtk_menu_bar_expose (GtkWidget      *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;
@@ -607,11 +593,10 @@ window_key_press_handler (GtkWidget   *widget,
   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;
@@ -640,6 +625,7 @@ window_key_press_handler (GtkWidget   *widget,
            {
              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);
              
@@ -648,10 +634,10 @@ window_key_press_handler (GtkWidget   *widget,
              retval = TRUE;          
            }
         }
-
-      g_free (accel);
     }
 
+  g_free (accel);
+
   return retval;
 }
 
@@ -664,7 +650,7 @@ add_to_window (GtkWindow  *window,
   if (!menubars)
     {
       g_signal_connect (window,
-                       "key_press_event",
+                       "key-press-event",
                        G_CALLBACK (window_key_press_handler),
                        NULL);
     }
@@ -678,9 +664,6 @@ remove_from_window (GtkWindow  *window,
 {
   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)
@@ -707,7 +690,7 @@ gtk_menu_bar_hierarchy_changed (GtkWidget *widget,
   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);
 }
 
@@ -725,7 +708,7 @@ _gtk_menu_bar_cycle_focus (GtkMenuBar       *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;
@@ -782,7 +765,7 @@ gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell)
 
 static void
 gtk_menu_bar_move_current (GtkMenuShell         *menu_shell,
-                          GtkMenuDirectionType direction)
+                          GtkMenuDirectionType  direction)
 {
   GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
   GtkTextDirection text_dir;
@@ -839,20 +822,20 @@ gtk_menu_bar_move_current (GtkMenuShell         *menu_shell,
        }
     }
   
-  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)
 {
@@ -868,15 +851,16 @@ 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;
@@ -902,13 +886,13 @@ void gtk_menu_bar_set_pack_direction (GtkMenuBar       *menubar,
  * 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)
 {
@@ -924,15 +908,16 @@ 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;