[gtk/matthiasc/for-master: 3/7] docs: Add GtkPopoverMenuBar to the gallery




commit bed3616bf0886c74305a426e817ddeee8d1b21cb
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 25 23:57:12 2020 -0400

    docs: Add GtkPopoverMenuBar to the gallery

 docs/reference/gtk/images/menubar.png | Bin 3103 -> 3709 bytes
 docs/reference/gtk/visual_index.xml   |   1 +
 docs/tools/widgets.c                  |  52 ++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
---
diff --git a/docs/reference/gtk/images/menubar.png b/docs/reference/gtk/images/menubar.png
index 26304f23c0..237ffb6ce4 100644
Binary files a/docs/reference/gtk/images/menubar.png and b/docs/reference/gtk/images/menubar.png differ
diff --git a/docs/reference/gtk/visual_index.xml b/docs/reference/gtk/visual_index.xml
index 80daea4717..8c8329b2c0 100644
--- a/docs/reference/gtk/visual_index.xml
+++ b/docs/reference/gtk/visual_index.xml
@@ -24,6 +24,7 @@
     <link linkend="GtkMediaControls"><inlinegraphic fileref="media-controls.png" 
format="PNG"></inlinegraphic></link>
     <link linkend="GtkWindowControls"><inlinegraphic fileref="windowcontrols.png" 
format="PNG"></inlinegraphic></link>
     <link linkend="GtkEmojiChooser"><inlinegraphic fileref="emojichooser.png" 
format="PNG"></inlinegraphic></link>
+    <link linkend="GtkPopoverMenu"><inlinegraphic fileref="menubar.png" format="PNG"></inlinegraphic></link>
   </para>
 </section>
 
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 9370c06798..6b589bcc9e 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -1589,6 +1589,57 @@ create_expander (void)
   return new_widget_info ("expander", widget, SMALL);
 }
 
+static void
+mapped_cb (GtkWidget *widget)
+{
+  gtk_widget_child_focus (widget, GTK_DIR_RIGHT);
+}
+
+static WidgetInfo *
+create_menu_bar (void)
+{
+  GtkWidget *widget;
+  GtkWidget *vbox;
+  GMenu *menu, *menu1;
+  GMenuItem *item;
+
+  menu = g_menu_new ();
+  menu1 = g_menu_new ();
+  item = g_menu_item_new ("Item", "action");
+  g_menu_append_item (menu1, item);
+  g_menu_append_submenu (menu, "File", G_MENU_MODEL (menu1));
+  g_object_unref (item);
+  g_object_unref (menu1);
+  menu1 = g_menu_new ();
+  item = g_menu_item_new ("Item", "action");
+  g_menu_append_item (menu1, item);
+  g_menu_append_submenu (menu, "Edit", G_MENU_MODEL (menu1));
+  g_object_unref (item);
+  g_object_unref (menu1);
+  menu1 = g_menu_new ();
+  item = g_menu_item_new ("Item", "action");
+  g_menu_append_item (menu1, item);
+  g_menu_append_submenu (menu, "View", G_MENU_MODEL (menu1));
+  g_object_unref (item);
+  g_object_unref (menu1);
+
+  widget = gtk_popover_menu_bar_new_from_model (G_MENU_MODEL (menu));
+
+  g_object_unref (menu);
+
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+  gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+  gtk_box_append (GTK_BOX (vbox), widget);
+  gtk_box_append (GTK_BOX (vbox), gtk_label_new ("Menu Bar"));
+
+  add_margin (vbox);
+
+  g_signal_connect (widget, "map", G_CALLBACK (mapped_cb), NULL);
+
+  return new_widget_info ("menubar", vbox, SMALL);
+}
+
 GList *
 get_all_widgets (void)
 {
@@ -1658,6 +1709,7 @@ get_all_widgets (void)
   retval = g_list_prepend (retval, create_calendar ());
   retval = g_list_prepend (retval, create_emojichooser ());
   retval = g_list_prepend (retval, create_expander ());
+  retval = g_list_prepend (retval, create_menu_bar ());
 
   return retval;
 }


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