+
+static void
+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;
+ default: ;
+ }
+ }
+ }
+ else
+ {
+ 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: ;
+ }
+ }
+
+ 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().
+ *
+ * Return value: the pack direction
+ *
+ * Since: 2.8
+ */
+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.
+ *
+ * Since: 2.8
+ */
+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().
+ *
+ * Return value: the child pack direction
+ *
+ * Since: 2.8
+ */
+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.
+ *
+ * Since: 2.8
+ */
+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
+ *
+ * Creates a new #GtkMenuBar and populates it with menu items
+ * and submenus according to @model.
+ *
+ * The created menu items are connected to actions found in the
+ * #GtkApplicationWindow to which the menu bar belongs - typically
+ * by means of being contained within the #GtkApplicationWindows
+ * widget hierarchy.
+ *
+ * Returns: a new #GtkMenuBar
+ *
+ * Since: 3.4
+ */
+GtkWidget *
+gtk_menu_bar_new_from_model (GMenuModel *model)
+{
+ GtkWidget *menubar;
+
+ g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL);
+
+ menubar = gtk_menu_bar_new ();
+ gtk_menu_shell_bind_model (GTK_MENU_SHELL (menubar), model, NULL, FALSE);
+
+ return menubar;
+}