[gtk/no-app-menu: 20/24] gtk-demo: Stop using appmenu apis
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/no-app-menu: 20/24] gtk-demo: Stop using appmenu apis
- Date: Fri, 22 May 2020 21:08:38 +0000 (UTC)
commit cadc63d4ce030b90e71e5dbbc444896e993c5461
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 22 16:19:49 2020 -0400
gtk-demo: Stop using appmenu apis
The appmenu-related GtkApplication apis are going away.
demos/gtk-demo/application.c | 10 ++-----
demos/gtk-demo/appmenu.ui | 18 -----------
demos/gtk-demo/demo.gresource.xml | 1 -
demos/gtk-demo/main.c | 18 -----------
demos/gtk-demo/menus.ui | 63 ++++++++++++++++++++-------------------
5 files changed, 35 insertions(+), 75 deletions(-)
---
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 64cf105a4e..cef94fca28 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -328,19 +328,14 @@ static void
startup (GApplication *app)
{
GtkBuilder *builder;
- GMenuModel *appmenu;
- GMenuModel *menubar;
G_APPLICATION_CLASS (demo_application_parent_class)->startup (app);
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder, "/application_demo/menus.ui", NULL);
- appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
- menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");
-
- gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
- gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
+ gtk_application_set_menubar (GTK_APPLICATION (app),
+ G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
g_object_unref (builder);
}
@@ -353,6 +348,7 @@ create_window (GApplication *app,
window = (DemoApplicationWindow *)g_object_new (demo_application_window_get_type (),
"application", app,
+ "show-menubar", TRUE,
NULL);
if (content)
gtk_text_buffer_set_text (window->buffer, content, -1);
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 19a2f8a168..0563e27116 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/ui">
<file preprocess="xml-stripblanks">main.ui</file>
- <file preprocess="xml-stripblanks">appmenu.ui</file>
</gresource>
<gresource prefix="/application_demo">
<file>application.c</file>
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index f8ef62d915..653e7a2f4a 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -972,23 +972,6 @@ populate_model (GtkTreeModel *model)
}
-static void
-startup (GApplication *app)
-{
- GtkBuilder *builder;
- GMenuModel *appmenu;
- const char *ids[] = { "appmenu", NULL };
-
- builder = gtk_builder_new ();
- gtk_builder_add_objects_from_resource (builder, "/ui/appmenu.ui", ids, NULL);
-
- appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
-
- gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
-
- g_object_unref (builder);
-}
-
static void
row_activated_cb (GtkWidget *tree_view,
GtkTreePath *path,
@@ -1219,7 +1202,6 @@ main (int argc, char **argv)
g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples",
NULL);
g_application_add_main_option (G_APPLICATION (app), "autoquit", 0, 0, G_OPTION_ARG_NONE, "Quit after a
delay", NULL);
- g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
g_signal_connect (app, "handle-local-options", G_CALLBACK (local_options), NULL);
diff --git a/demos/gtk-demo/menus.ui b/demos/gtk-demo/menus.ui
index 0fe4bd946a..f67180b9b4 100644
--- a/demos/gtk-demo/menus.ui
+++ b/demos/gtk-demo/menus.ui
@@ -1,38 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="appmenu">
- <section>
- <item>
- <attribute name="label" translatable="yes">_New</attribute>
- <attribute name="action">app.new</attribute>
- <attribute name="accel"><Control>n</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Open</attribute>
- <attribute name="action">app.open</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Save</attribute>
- <attribute name="action">app.save</attribute>
- <attribute name="accel"><Control>s</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Save _As...</attribute>
- <attribute name="action">app.save-as</attribute>
- <attribute name="accel"><Control>s</attribute>
- </item>
- </section>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Quit</attribute>
- <attribute name="action">app.quit</attribute>
- <attribute name="accel"><Control>q</attribute>
- </item>
- </section>
- </menu>
<menu id="menubar">
<submenu>
- <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="label" translatable="yes">_Application</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_New</attribute>
+ <attribute name="action">app.new</attribute>
+ <attribute name="accel"><Control>n</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Open</attribute>
+ <attribute name="action">app.open</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Save</attribute>
+ <attribute name="action">app.save</attribute>
+ <attribute name="accel"><Control>s</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Save _As...</attribute>
+ <attribute name="action">app.save-as</attribute>
+ <attribute name="accel"><Control>s</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ <attribute name="accel"><Control>q</attribute>
+ </item>
+ </section>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">_File</attribute>
<section>
<item>
<attribute name="label" translatable="yes">_Prefer Dark Theme</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]