[gtk/wip/otte/menu: 2/5] menubar: Remove pack direction



commit cdae56f42ef310f8bce938ad7f75cbeaeab568dd
Author: Benjamin Otte <otte redhat com>
Date:   Sat Apr 13 11:58:38 2019 +0200

    menubar: Remove pack direction

 demos/gtk-demo/menus.c               |   6 -
 docs/reference/gtk/gtk4-sections.txt |   5 -
 gtk/gtkenums.h                       |  18 --
 gtk/gtkmenubar.c                     | 425 +++++------------------------------
 gtk/gtkmenubar.h                     |  14 --
 gtk/gtkmenuitem.c                    |  25 +--
 gtk/gtkmenushell.c                   |  24 +-
 7 files changed, 62 insertions(+), 455 deletions(-)
---
diff --git a/demos/gtk-demo/menus.c b/demos/gtk-demo/menus.c
index f56fbf29ad..47785300f8 100644
--- a/demos/gtk-demo/menus.c
+++ b/demos/gtk-demo/menus.c
@@ -70,12 +70,6 @@ change_orientation (GtkWidget *button,
   parent = gtk_widget_get_parent (menubar);
   orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (parent));
   gtk_orientable_set_orientation (GTK_ORIENTABLE (parent), 1 - orientation);
-
-  if (orientation == GTK_ORIENTATION_VERTICAL)
-    g_object_set (menubar, "pack-direction", GTK_PACK_DIRECTION_TTB, NULL);
-  else
-    g_object_set (menubar, "pack-direction", GTK_PACK_DIRECTION_LTR, NULL);
-
 }
 
 static GtkWidget *window = NULL;
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 91aad5becd..458085c57e 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1821,11 +1821,6 @@ gtk_menu_get_type
 GtkMenuBar
 gtk_menu_bar_new
 gtk_menu_bar_new_from_model
-GtkPackDirection
-gtk_menu_bar_set_pack_direction
-gtk_menu_bar_get_pack_direction
-gtk_menu_bar_set_child_pack_direction
-gtk_menu_bar_get_child_pack_direction
 <SUBSECTION Standard>
 GTK_MENU_BAR
 GTK_IS_MENU_BAR
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index dc097d2853..d18f3f995d 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -549,24 +549,6 @@ typedef enum
   GTK_SORT_DESCENDING
 } GtkSortType;
 
-/**
- * GtkPackDirection:
- * @GTK_PACK_DIRECTION_LTR: Widgets are packed left-to-right
- * @GTK_PACK_DIRECTION_RTL: Widgets are packed right-to-left
- * @GTK_PACK_DIRECTION_TTB: Widgets are packed top-to-bottom
- * @GTK_PACK_DIRECTION_BTT: Widgets are packed bottom-to-top
- *
- * Determines how widgets should be packed inside menubars
- * and menuitems contained in menubars.
- */
-typedef enum
-{
-  GTK_PACK_DIRECTION_LTR,
-  GTK_PACK_DIRECTION_RTL,
-  GTK_PACK_DIRECTION_TTB,
-  GTK_PACK_DIRECTION_BTT
-} GtkPackDirection;
-
 /**
  * GtkPrintPages:
  * @GTK_PRINT_PAGES_ALL: All pages.
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index 0a5cbca1d1..55cd5955db 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -58,28 +58,6 @@
 
 #define MENU_BAR_POPUP_DELAY 0
 
-/* Properties */
-enum {
-  PROP_0,
-  PROP_PACK_DIRECTION,
-  PROP_CHILD_PACK_DIRECTION
-};
-
-struct _GtkMenuBarPrivate
-{
-  GtkPackDirection pack_direction;
-  GtkPackDirection child_pack_direction;
-};
-
-
-static void gtk_menu_bar_set_property      (GObject             *object,
-                                           guint                prop_id,
-                                           const GValue        *value,
-                                           GParamSpec          *pspec);
-static void gtk_menu_bar_get_property      (GObject             *object,
-                                           guint                prop_id,
-                                           GValue              *value,
-                                           GParamSpec          *pspec);
 static void gtk_menu_bar_measure (GtkWidget     *widget,
                                   GtkOrientation  orientation,
                                   int             for_size,
@@ -97,24 +75,16 @@ static gint gtk_menu_bar_get_popup_delay   (GtkMenuShell    *menu_shell);
 static void gtk_menu_bar_move_current      (GtkMenuShell     *menu_shell,
                                             GtkMenuDirectionType direction);
 
-G_DEFINE_TYPE_WITH_PRIVATE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
+G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL)
 
 static void
 gtk_menu_bar_class_init (GtkMenuBarClass *class)
 {
-  GObjectClass *gobject_class;
-  GtkWidgetClass *widget_class;
-  GtkMenuShellClass *menu_shell_class;
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+  GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_CLASS (class);
 
   GtkBindingSet *binding_set;
 
-  gobject_class = (GObjectClass*) class;
-  widget_class = (GtkWidgetClass*) class;
-  menu_shell_class = (GtkMenuShellClass*) class;
-
-  gobject_class->get_property = gtk_menu_bar_get_property;
-  gobject_class->set_property = gtk_menu_bar_set_property;
-
   widget_class->measure = gtk_menu_bar_measure;
   widget_class->size_allocate = gtk_menu_bar_size_allocate;
   widget_class->root = gtk_menu_bar_root;
@@ -166,36 +136,6 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
                                GTK_TYPE_MENU_DIRECTION_TYPE,
                                GTK_MENU_DIR_CHILD);
 
-  /**
-   * GtkMenuBar:pack-direction:
-   *
-   * The pack direction of the menubar. It determines how
-   * menuitems are arranged in the menubar.
-   */
-  g_object_class_install_property (gobject_class,
-                                   PROP_PACK_DIRECTION,
-                                   g_param_spec_enum ("pack-direction",
-                                                      P_("Pack direction"),
-                                                      P_("The pack direction of the menubar"),
-                                                      GTK_TYPE_PACK_DIRECTION,
-                                                      GTK_PACK_DIRECTION_LTR,
-                                                      GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-  
-  /**
-   * GtkMenuBar:child-pack-direction:
-   *
-   * The child pack direction of the menubar. It determines how
-   * the widgets contained in child menuitems are arranged.
-   */
-  g_object_class_install_property (gobject_class,
-                                   PROP_CHILD_PACK_DIRECTION,
-                                   g_param_spec_enum ("child-pack-direction",
-                                                      P_("Child Pack direction"),
-                                                      P_("The child pack direction of the menubar"),
-                                                      GTK_TYPE_PACK_DIRECTION,
-                                                      GTK_PACK_DIRECTION_LTR,
-                                                      GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_MENU_BAR);
   gtk_widget_class_set_css_name (widget_class, I_("menubar"));
 }
@@ -203,7 +143,6 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
 static void
 gtk_menu_bar_init (GtkMenuBar *menu_bar)
 {
-  menu_bar->priv = gtk_menu_bar_get_instance_private (menu_bar);
 }
 
 /**
@@ -219,50 +158,6 @@ gtk_menu_bar_new (void)
   return g_object_new (GTK_TYPE_MENU_BAR, NULL);
 }
 
-static void
-gtk_menu_bar_set_property (GObject      *object,
-                          guint         prop_id,
-                          const GValue *value,
-                          GParamSpec   *pspec)
-{
-  GtkMenuBar *menubar = GTK_MENU_BAR (object);
-  
-  switch (prop_id)
-    {
-    case PROP_PACK_DIRECTION:
-      gtk_menu_bar_set_pack_direction (menubar, g_value_get_enum (value));
-      break;
-    case PROP_CHILD_PACK_DIRECTION:
-      gtk_menu_bar_set_child_pack_direction (menubar, g_value_get_enum (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static void
-gtk_menu_bar_get_property (GObject    *object,
-                          guint       prop_id,
-                          GValue     *value,
-                          GParamSpec *pspec)
-{
-  GtkMenuBar *menubar = GTK_MENU_BAR (object);
-  
-  switch (prop_id)
-    {
-    case PROP_PACK_DIRECTION:
-      g_value_set_enum (value, gtk_menu_bar_get_pack_direction (menubar));
-      break;
-    case PROP_CHILD_PACK_DIRECTION:
-      g_value_set_enum (value, gtk_menu_bar_get_child_pack_direction (menubar));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
 static void
 gtk_menu_bar_measure (GtkWidget      *widget,
                       GtkOrientation  orientation,
@@ -272,8 +167,6 @@ gtk_menu_bar_measure (GtkWidget      *widget,
                       int            *minimum_baseline,
                       int            *natural_baseline)
 {
-  GtkMenuBar *menu_bar;
-  GtkMenuBarPrivate *priv;
   GtkMenuShell *menu_shell;
   GtkWidget *child;
   GList *children;
@@ -283,23 +176,12 @@ gtk_menu_bar_measure (GtkWidget      *widget,
   *minimum = 0;
   *natural = 0;
 
-  menu_bar = GTK_MENU_BAR (widget);
   menu_shell = GTK_MENU_SHELL (widget);
-  priv = menu_bar->priv;
 
   children = menu_shell->priv->children;
 
-  if (priv->child_pack_direction == GTK_PACK_DIRECTION_LTR ||
-      priv->child_pack_direction == GTK_PACK_DIRECTION_RTL)
-    use_toggle_size = (orientation == GTK_ORIENTATION_HORIZONTAL);
-  else
-    use_toggle_size = (orientation == GTK_ORIENTATION_VERTICAL);
-
-  if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
-      priv->pack_direction == GTK_PACK_DIRECTION_RTL)
-    use_maximize = (orientation == GTK_ORIENTATION_VERTICAL);
-  else
-    use_maximize = (orientation == GTK_ORIENTATION_HORIZONTAL);
+  use_toggle_size = (orientation == GTK_ORIENTATION_HORIZONTAL);
+  use_maximize = (orientation == GTK_ORIENTATION_VERTICAL);
 
   while (children)
     {
@@ -345,8 +227,6 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
                             int        height,
                             int        baseline)
 {
-  GtkMenuBar *menu_bar = GTK_MENU_BAR (widget);
-  GtkMenuBarPrivate *priv = menu_bar->priv;
   GtkMenuShell *menu_shell;
   GtkWidget *child;
   GList *children;
@@ -354,6 +234,8 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
   GArray *requested_sizes;
   gint toggle_size;
   guint i;
+  int size;
+  gboolean ltr = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR);
 
   menu_shell = GTK_MENU_SHELL (widget);
 
@@ -362,115 +244,55 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
 
   remaining_space = (GtkAllocation) {0, 0, width, height};
   requested_sizes = g_array_new (FALSE, FALSE, sizeof (GtkRequestedSize));
+  size = remaining_space.width;
 
-  if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
-      priv->pack_direction == GTK_PACK_DIRECTION_RTL)
+  for (children = menu_shell->priv->children; children; children = children->next)
     {
-      int size = remaining_space.width;
-      gboolean ltr = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) == (priv->pack_direction == 
GTK_PACK_DIRECTION_LTR);
-
-      for (children = menu_shell->priv->children; children; children = children->next)
-        {
-          GtkRequestedSize request;
-          child = children->data;
-
-          if (!gtk_widget_get_visible (child))
-            continue;
-
-          request.data = child;
-          gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL,
-                              remaining_space.height,
-                              &request.minimum_size, &request.natural_size,
-                              NULL, NULL);
-          gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
-                                             &toggle_size);
-          request.minimum_size += toggle_size;
-          request.natural_size += toggle_size;
-
-          gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child), toggle_size);
-
-          g_array_append_val (requested_sizes, request);
-
-          size -= request.minimum_size;
-        }
+      GtkRequestedSize request;
+      child = children->data;
 
-      size = gtk_distribute_natural_allocation (size,
-                                                requested_sizes->len,
-                                                (GtkRequestedSize *) requested_sizes->data);
+      if (!gtk_widget_get_visible (child))
+        continue;
 
-      for (i = 0; i < requested_sizes->len; i++)
-        {
-          GtkAllocation child_allocation = remaining_space;
-          GtkRequestedSize *request = &g_array_index (requested_sizes, GtkRequestedSize, i);
+      request.data = child;
+      gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL,
+                          remaining_space.height,
+                          &request.minimum_size, &request.natural_size,
+                          NULL, NULL);
+      gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
+                                         &toggle_size);
+      request.minimum_size += toggle_size;
+      request.natural_size += toggle_size;
 
-          child_allocation.width = request->minimum_size;
-          remaining_space.width -= request->minimum_size;
+      gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child), toggle_size);
 
-          if (i + 1 == requested_sizes->len && GTK_IS_MENU_ITEM (request->data) &&
-              GTK_MENU_ITEM (request->data)->priv->right_justify)
-            ltr = !ltr;
+      g_array_append_val (requested_sizes, request);
 
-          if (ltr)
-            remaining_space.x += request->minimum_size;
-          else
-            child_allocation.x += remaining_space.width;
-
-          gtk_widget_size_allocate (request->data, &child_allocation, -1);
-        }
+      size -= request.minimum_size;
     }
-  else
-    {
-      int size = remaining_space.height;
-      gboolean ttb = (priv->pack_direction == GTK_PACK_DIRECTION_TTB);
-
-      for (children = menu_shell->priv->children; children; children = children->next)
-        {
-          GtkRequestedSize request;
-          child = children->data;
-
-          if (!gtk_widget_get_visible (child))
-            continue;
-
-          request.data = child;
-          gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL,
-                              remaining_space.width,
-                              &request.minimum_size, &request.natural_size,
-                              NULL, NULL);
-          gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
-                                             &toggle_size);
-          request.minimum_size += toggle_size;
-          request.natural_size += toggle_size;
 
-          gtk_menu_item_toggle_size_allocate (GTK_MENU_ITEM (child), toggle_size);
+  size = gtk_distribute_natural_allocation (size,
+                                            requested_sizes->len,
+                                            (GtkRequestedSize *) requested_sizes->data);
 
-          g_array_append_val (requested_sizes, request);
-
-          size -= request.minimum_size;
-        }
-
-      size = gtk_distribute_natural_allocation (size,
-                                                requested_sizes->len,
-                                                (GtkRequestedSize *) requested_sizes->data);
-
-      for (i = 0; i < requested_sizes->len; i++)
-        {
-          GtkAllocation child_allocation = remaining_space;
-          GtkRequestedSize *request = &g_array_index (requested_sizes, GtkRequestedSize, i);
+  for (i = 0; i < requested_sizes->len; i++)
+    {
+      GtkAllocation child_allocation = remaining_space;
+      GtkRequestedSize *request = &g_array_index (requested_sizes, GtkRequestedSize, i);
 
-          child_allocation.height = request->minimum_size;
-          remaining_space.height -= request->minimum_size;
+      child_allocation.width = request->minimum_size;
+      remaining_space.width -= request->minimum_size;
 
-          if (i + 1 == requested_sizes->len && GTK_IS_MENU_ITEM (request->data) &&
-              GTK_MENU_ITEM (request->data)->priv->right_justify)
-            ttb = !ttb;
+      if (i + 1 == requested_sizes->len && GTK_IS_MENU_ITEM (request->data) &&
+          GTK_MENU_ITEM (request->data)->priv->right_justify)
+        ltr = !ltr;
 
-          if (ttb)
-            remaining_space.y += request->minimum_size;
-          else
-            child_allocation.y += remaining_space.height;
+      if (ltr)
+        remaining_space.x += request->minimum_size;
+      else
+        child_allocation.x += remaining_space.width;
 
-          gtk_widget_size_allocate (request->data, &child_allocation, -1);
-        }
+      gtk_widget_size_allocate (request->data, &child_allocation, -1);
     }
 
   g_array_free (requested_sizes, TRUE);
@@ -620,164 +442,27 @@ gtk_menu_bar_move_current (GtkMenuShell         *menu_shell,
                           GtkMenuDirectionType  direction)
 {
   GtkMenuBar *menubar = GTK_MENU_BAR (menu_shell);
-  GtkTextDirection text_dir;
-  GtkPackDirection pack_dir;
 
-  text_dir = gtk_widget_get_direction (GTK_WIDGET (menubar));
-  pack_dir = gtk_menu_bar_get_pack_direction (menubar);
-  
-  if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
-     {
-      if ((text_dir == GTK_TEXT_DIR_RTL) == (pack_dir == GTK_PACK_DIRECTION_LTR))
-       {
-         switch (direction) 
-           {      
-           case GTK_MENU_DIR_PREV:
-             direction = GTK_MENU_DIR_NEXT;
-             break;
-           case GTK_MENU_DIR_NEXT:
-             direction = GTK_MENU_DIR_PREV;
-             break;
-           case GTK_MENU_DIR_PARENT:
-           case GTK_MENU_DIR_CHILD:
-           default:
-              break;
-           }
-       }
-    }
-  else
+  if (gtk_widget_get_direction (GTK_WIDGET (menubar)) == GTK_TEXT_DIR_RTL)
     {
       switch (direction) 
-       {
-       case GTK_MENU_DIR_PARENT:
-         if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
-           direction = GTK_MENU_DIR_PREV;
-         else
-           direction = GTK_MENU_DIR_NEXT;
-         break;
-       case GTK_MENU_DIR_CHILD:
-         if ((text_dir == GTK_TEXT_DIR_LTR) == (pack_dir == GTK_PACK_DIRECTION_TTB))
-           direction = GTK_MENU_DIR_NEXT;
-         else
-           direction = GTK_MENU_DIR_PREV;
-         break;
-       case GTK_MENU_DIR_PREV:
-         if (text_dir == GTK_TEXT_DIR_RTL)       
-           direction = GTK_MENU_DIR_CHILD;
-         else
-           direction = GTK_MENU_DIR_PARENT;
-         break;
-       case GTK_MENU_DIR_NEXT:
-         if (text_dir == GTK_TEXT_DIR_RTL)       
-           direction = GTK_MENU_DIR_PARENT;
-         else
-           direction = GTK_MENU_DIR_CHILD;
-         break;
-       default: ;
-       }
+        {      
+        case GTK_MENU_DIR_PREV:
+          direction = GTK_MENU_DIR_NEXT;
+          break;
+        case GTK_MENU_DIR_NEXT:
+          direction = GTK_MENU_DIR_PREV;
+          break;
+        case GTK_MENU_DIR_PARENT:
+        case GTK_MENU_DIR_CHILD:
+        default:
+          break;
+        }
     }
   
   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().
- *
- * Returns: the pack direction
- */
-GtkPackDirection
-gtk_menu_bar_get_pack_direction (GtkMenuBar *menubar)
-{
-  g_return_val_if_fail (GTK_IS_MENU_BAR (menubar), 
-                       GTK_PACK_DIRECTION_LTR);
-
-  return menubar->priv->pack_direction;
-}
-
-/**
- * gtk_menu_bar_set_pack_direction:
- * @menubar: a #GtkMenuBar
- * @pack_dir: a new #GtkPackDirection
- * 
- * Sets how items should be packed inside a menubar.
- */
-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));
-
-  priv = menubar->priv;
-
-  if (priv->pack_direction != pack_dir)
-    {
-      priv->pack_direction = pack_dir;
-
-      gtk_widget_queue_resize (GTK_WIDGET (menubar));
-
-      for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
-       gtk_widget_queue_resize (GTK_WIDGET (l->data));
-
-      g_object_notify (G_OBJECT (menubar), "pack-direction");
-    }
-}
-
-/**
- * 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().
- *
- * Returns: the child pack direction
- */
-GtkPackDirection
-gtk_menu_bar_get_child_pack_direction (GtkMenuBar *menubar)
-{
-  g_return_val_if_fail (GTK_IS_MENU_BAR (menubar), 
-                       GTK_PACK_DIRECTION_LTR);
-
-  return menubar->priv->child_pack_direction;
-}
-
-/**
- * gtk_menu_bar_set_child_pack_direction:
- * @menubar: a #GtkMenuBar
- * @child_pack_dir: a new #GtkPackDirection
- * 
- * Sets how widgets should be packed inside the children of a menubar.
- */
-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));
-
-  priv = menubar->priv;
-
-  if (priv->child_pack_direction != child_pack_dir)
-    {
-      priv->child_pack_direction = child_pack_dir;
-
-      gtk_widget_queue_resize (GTK_WIDGET (menubar));
-
-      for (l = GTK_MENU_SHELL (menubar)->priv->children; l; l = l->next)
-       gtk_widget_queue_resize (GTK_WIDGET (l->data));
-
-      g_object_notify (G_OBJECT (menubar), "child-pack-direction");
-    }
-}
-
 /**
  * gtk_menu_bar_new_from_model:
  * @model: a #GMenuModel
diff --git a/gtk/gtkmenubar.h b/gtk/gtkmenubar.h
index c63ef19659..4ec2e900de 100644
--- a/gtk/gtkmenubar.h
+++ b/gtk/gtkmenubar.h
@@ -50,9 +50,6 @@ typedef struct _GtkMenuBarClass    GtkMenuBarClass;
 struct _GtkMenuBar
 {
   GtkMenuShell menu_shell;
-
-  /*< private >*/
-  GtkMenuBarPrivate *priv;
 };
 
 struct _GtkMenuBarClass
@@ -74,17 +71,6 @@ GtkWidget* gtk_menu_bar_new             (void);
 GDK_AVAILABLE_IN_ALL
 GtkWidget* gtk_menu_bar_new_from_model  (GMenuModel *model);
 
-GDK_AVAILABLE_IN_ALL
-GtkPackDirection gtk_menu_bar_get_pack_direction (GtkMenuBar       *menubar);
-GDK_AVAILABLE_IN_ALL
-void             gtk_menu_bar_set_pack_direction (GtkMenuBar       *menubar,
-                                                 GtkPackDirection  pack_dir);
-GDK_AVAILABLE_IN_ALL
-GtkPackDirection gtk_menu_bar_get_child_pack_direction (GtkMenuBar       *menubar);
-GDK_AVAILABLE_IN_ALL
-void             gtk_menu_bar_set_child_pack_direction (GtkMenuBar       *menubar,
-                                                       GtkPackDirection  child_pack_dir);
-
 /* Private functions */
 void _gtk_menu_bar_cycle_focus (GtkMenuBar       *menubar,
                                GtkDirectionType  dir);
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 61519beccc..02fe94a678 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -264,7 +264,6 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
   GtkMenuItemPrivate *priv = menu_item->priv;
   GtkAllocation child_allocation;
   GtkTextDirection direction;
-  GtkPackDirection child_pack_dir;
   GtkWidget *child;
   GtkWidget *parent;
 
@@ -273,33 +272,15 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
   direction = gtk_widget_get_direction (widget);
 
   parent = gtk_widget_get_parent (widget);
-  if (GTK_IS_MENU_BAR (parent))
-    {
-      child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
-    }
-  else
-    {
-      child_pack_dir = GTK_PACK_DIRECTION_LTR;
-    }
 
   child = gtk_bin_get_child (GTK_BIN (widget));
   if (child)
     {
       child_allocation = (GtkAllocation) {0, 0, width, height};
 
-      if (child_pack_dir == GTK_PACK_DIRECTION_LTR ||
-          child_pack_dir == GTK_PACK_DIRECTION_RTL)
-        {
-          if ((direction == GTK_TEXT_DIR_LTR) == (child_pack_dir != GTK_PACK_DIRECTION_RTL))
-            child_allocation.x += priv->toggle_size;
-          child_allocation.width -= priv->toggle_size;
-        }
-      else
-        {
-          if ((direction == GTK_TEXT_DIR_LTR) == (child_pack_dir != GTK_PACK_DIRECTION_BTT))
-            child_allocation.y += priv->toggle_size;
-          child_allocation.height -= priv->toggle_size;
-        }
+      if (direction == GTK_TEXT_DIR_LTR)
+        child_allocation.x += priv->toggle_size;
+      child_allocation.width -= priv->toggle_size;
 
       if ((priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
        {
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index b538c5e011..de698d8463 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -85,11 +85,6 @@
 #define MENU_POPUP_DELAY     225
 #define MENU_POPDOWN_DELAY   1000
 
-#define PACK_DIRECTION(m)                                 \
-   (GTK_IS_MENU_BAR (m)                                   \
-     ? gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (m)) \
-     : GTK_PACK_DIRECTION_LTR)
-
 enum {
   DEACTIVATE,
   SELECTION_DONE,
@@ -1080,7 +1075,6 @@ gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
                                  GtkWidget    *menu_item)
 {
   GtkMenuShellPrivate *priv = menu_shell->priv;
-  GtkPackDirection pack_dir = PACK_DIRECTION (menu_shell);
 
   if (priv->active_menu_item)
     {
@@ -1098,12 +1092,8 @@ gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
   gtk_menu_shell_activate (menu_shell);
 
   priv->active_menu_item = menu_item;
-  if (pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT)
-    _gtk_menu_item_set_placement (GTK_MENU_ITEM (priv->active_menu_item),
-                                  GTK_LEFT_RIGHT);
-  else
-    _gtk_menu_item_set_placement (GTK_MENU_ITEM (priv->active_menu_item),
-                                  GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement);
+  _gtk_menu_item_set_placement (GTK_MENU_ITEM (priv->active_menu_item),
+                                GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement);
   gtk_menu_item_select (GTK_MENU_ITEM (priv->active_menu_item));
 
   _gtk_menu_shell_update_mnemonics (menu_shell);
@@ -1387,10 +1377,7 @@ gtk_real_menu_shell_move_current (GtkMenuShell         *menu_shell,
             gtk_menu_shell_deselect (menu_shell);
           else
             {
-              if (PACK_DIRECTION (parent_menu_shell) == GTK_PACK_DIRECTION_LTR)
-                gtk_menu_shell_move_selected (parent_menu_shell, -1);
-              else
-                gtk_menu_shell_move_selected (parent_menu_shell, 1);
+              gtk_menu_shell_move_selected (parent_menu_shell, -1);
               gtk_menu_shell_select_submenu_first (parent_menu_shell);
             }
         }
@@ -1429,10 +1416,7 @@ gtk_real_menu_shell_move_current (GtkMenuShell         *menu_shell,
 
       if (parent_menu_shell)
         {
-          if (PACK_DIRECTION (parent_menu_shell) == GTK_PACK_DIRECTION_LTR)
-            gtk_menu_shell_move_selected (parent_menu_shell, 1);
-          else
-            gtk_menu_shell_move_selected (parent_menu_shell, -1);
+          gtk_menu_shell_move_selected (parent_menu_shell, 1);
 
           gtk_menu_shell_select_submenu_first (parent_menu_shell);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]