[gtk/matthiasc/for-master: 5/7] docs: Add GtkPopoverMenu to the widget gallery
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 5/7] docs: Add GtkPopoverMenu to the widget gallery
- Date: Mon, 26 Oct 2020 05:12:31 +0000 (UTC)
commit d9259fc958ca3629a0ab8d9b2170639e84a8f533
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 26 00:30:24 2020 -0400
docs: Add GtkPopoverMenu to the widget gallery
docs/reference/gtk/images/menu.png | Bin 0 -> 6760 bytes
docs/reference/gtk/meson.build | 1 +
docs/reference/gtk/visual_index.xml | 3 +-
docs/tools/widgets.c | 64 ++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/gtk/images/menu.png b/docs/reference/gtk/images/menu.png
new file mode 100644
index 0000000000..d6096a5b8a
Binary files /dev/null and b/docs/reference/gtk/images/menu.png differ
diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build
index 4ccd9c4e01..8b2a8115d3 100644
--- a/docs/reference/gtk/meson.build
+++ b/docs/reference/gtk/meson.build
@@ -327,6 +327,7 @@ images = [
'images/lockbutton-sorry.png',
'images/lockbutton-unlocked.png',
'images/media-controls.png',
+ 'images/menu.png',
'images/menubar.png',
'images/menu-button.png',
'images/messagedialog.png',
diff --git a/docs/reference/gtk/visual_index.xml b/docs/reference/gtk/visual_index.xml
index 9c5e368c49..bac57788ab 100644
--- a/docs/reference/gtk/visual_index.xml
+++ b/docs/reference/gtk/visual_index.xml
@@ -24,7 +24,8 @@
<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>
+ <link linkend="GtkPopoverMenu"><inlinegraphic fileref="menu.png" format="PNG"></inlinegraphic></link>
+ <link linkend="GtkPopoverMenuBar"><inlinegraphic fileref="menubar.png"
format="PNG"></inlinegraphic></link>
</para>
</section>
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 6a5ac3f18f..6500291b0a 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -1663,6 +1663,69 @@ create_popover (void)
return info;
}
+static WidgetInfo *
+create_menu (void)
+{
+ GtkWidget *widget;
+ GMenu *menu, *menu1;
+ GMenuItem *item;
+ GSimpleActionGroup *group;
+ GSimpleAction *action;
+ GtkEventController *controller;
+ GtkShortcut *shortcut;
+
+ 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, "Style", G_MENU_MODEL (menu1));
+ g_object_unref (item);
+ g_object_unref (menu1);
+ item = g_menu_item_new ("Transition", "menu.transition");
+ g_menu_append_item (menu, item);
+ g_object_unref (item);
+
+ menu1 = g_menu_new ();
+ item = g_menu_item_new ("Inspector", "menu.inspector");
+ g_menu_append_item (menu1, item);
+ g_object_unref (item);
+ item = g_menu_item_new ("About", "menu.about");
+ g_menu_append_item (menu1, item);
+ g_object_unref (item);
+ g_menu_append_section (menu, NULL, G_MENU_MODEL (menu1));
+ g_object_unref (menu1);
+
+ widget = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
+
+ g_object_unref (menu);
+
+ group = g_simple_action_group_new ();
+ action = g_simple_action_new_stateful ("transition", NULL, g_variant_new_boolean (TRUE));
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_object_unref (action);
+ action = g_simple_action_new ("inspector", NULL);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_object_unref (action);
+ action = g_simple_action_new ("about", NULL);
+ g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
+ g_object_unref (action);
+
+ gtk_widget_insert_action_group (widget, "menu", G_ACTION_GROUP (group));
+
+ g_object_unref (group);
+
+ g_object_set (widget, "autohide", FALSE, NULL);
+
+ controller = gtk_shortcut_controller_new ();
+ shortcut = gtk_shortcut_new (gtk_keyval_trigger_new (GDK_KEY_F1, 0),
+ gtk_named_action_new ("menu.about"));
+ gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (controller), shortcut);
+
+ gtk_widget_add_controller (widget, controller);
+
+ return new_widget_info ("menu", widget, ASIS);
+}
+
GList *
get_all_widgets (void)
{
@@ -1734,6 +1797,7 @@ get_all_widgets (void)
retval = g_list_prepend (retval, create_expander ());
retval = g_list_prepend (retval, create_menu_bar ());
retval = g_list_prepend (retval, create_popover ());
+ retval = g_list_prepend (retval, create_menu ());
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]