]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmenubar.c
Display an error when we come to the root.
[~andy/gtk] / gtk / gtkmenubar.c
index d3b2195fc6981feb26bac8e5f7a0e645902f8910..ad8fc2e68b876cfba1d112ef8791dfad2fed2695 100644 (file)
@@ -87,49 +87,23 @@ static void gtk_menu_bar_move_current      (GtkMenuShell     *menu_shell,
 
 static GtkShadowType get_shadow_type   (GtkMenuBar      *menubar);
 
-static GtkMenuShellClass *parent_class = NULL;
+G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
 
-GType
-gtk_menu_bar_get_type (void)
+static void
+gtk_menu_bar_init (GtkMenuBar *object)
 {
-  static GType menu_bar_type = 0;
-
-  if (!menu_bar_type)
-    {
-      static const GTypeInfo menu_bar_info =
-      {
-       sizeof (GtkMenuBarClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) gtk_menu_bar_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (GtkMenuBar),
-       0,              /* n_preallocs */
-       NULL,           /* instance_init */
-      };
-
-      menu_bar_type = g_type_register_static (GTK_TYPE_MENU_SHELL, "GtkMenuBar",
-                                             &menu_bar_info, 0);
-    }
-
-  return menu_bar_type;
 }
 
 static void
 gtk_menu_bar_class_init (GtkMenuBarClass *class)
 {
   GObjectClass *gobject_class;
-  GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
   GtkMenuShellClass *menu_shell_class;
 
   GtkBindingSet *binding_set;
 
-  parent_class = g_type_class_peek_parent (class);
-  
   gobject_class = (GObjectClass*) class;
-  object_class = (GtkObjectClass*) class;
   widget_class = (GtkWidgetClass*) class;
   menu_shell_class = (GtkMenuShellClass*) class;
 
@@ -363,7 +337,7 @@ gtk_menu_bar_size_request (GtkWidget      *widget,
            }
        }
 
-      gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+      gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
       
       requisition->width += (GTK_CONTAINER (menu_bar)->border_width +
                              ipadding + 
@@ -411,7 +385,7 @@ gtk_menu_bar_size_allocate (GtkWidget     *widget,
                            allocation->x, allocation->y,
                            allocation->width, allocation->height);
 
-  gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL);
+  gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
   
   if (menu_shell->children)
     {
@@ -564,7 +538,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;
@@ -608,7 +582,7 @@ static void
 set_menu_bars (GtkWindow *window,
               GList     *menubars)
 {
-  g_object_set_data (G_OBJECT (window), "gtk-menu-bar-list", menubars);
+  g_object_set_data (G_OBJECT (window), I_("gtk-menu-bar-list"), menubars);
 }
 
 static gboolean
@@ -620,11 +594,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;
@@ -775,7 +748,7 @@ get_shadow_type (GtkMenuBar *menubar)
   GtkShadowType shadow_type = GTK_SHADOW_OUT;
   
   gtk_widget_style_get (GTK_WIDGET (menubar),
-                       "shadow_type", &shadow_type,
+                       "shadow-type", &shadow_type,
                        NULL);
 
   return shadow_type;
@@ -852,7 +825,7 @@ 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);
 }
 
 /**
@@ -892,6 +865,7 @@ void gtk_menu_bar_set_pack_direction (GtkMenuBar       *menubar,
                                      GtkPackDirection  pack_dir)
 {
   GtkMenuBarPrivate *priv;
+  GList *l;
 
   g_return_if_fail (GTK_IS_MENU_BAR (menubar));
 
@@ -902,6 +876,10 @@ void gtk_menu_bar_set_pack_direction (GtkMenuBar       *menubar,
       priv->pack_direction = pack_dir;
 
       gtk_widget_queue_resize (GTK_WIDGET (menubar));
+
+      for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
+       gtk_widget_queue_resize (GTK_WIDGET (l->data));
+
       g_object_notify (G_OBJECT (menubar), "pack-direction");
     }
 }
@@ -943,6 +921,7 @@ void gtk_menu_bar_set_child_pack_direction (GtkMenuBar       *menubar,
                                            GtkPackDirection  child_pack_dir)
 {
   GtkMenuBarPrivate *priv;
+  GList *l;
 
   g_return_if_fail (GTK_IS_MENU_BAR (menubar));
 
@@ -953,6 +932,10 @@ void gtk_menu_bar_set_child_pack_direction (GtkMenuBar       *menubar,
       priv->child_pack_direction = child_pack_dir;
 
       gtk_widget_queue_resize (GTK_WIDGET (menubar));
+
+      for (l = GTK_MENU_SHELL (menubar)->children; l; l = l->next)
+       gtk_widget_queue_resize (GTK_WIDGET (l->data));
+
       g_object_notify (G_OBJECT (menubar), "child-pack-direction");
     }
 }