[gtk/no-app-menu: 14/17] examples: Stop using appmenu apis



commit 6c31092c69c3dd379c73d8351ccc82e7de1fa4fb
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 22 16:36:20 2020 -0400

    examples: Stop using appmenu apis
    
    The appmenu-related GtkApplication apis are going away.

 examples/plugman.c | 42 ++++++++++++++++++++++--------------------
 examples/sunny.c   | 39 +++++++++++++++++++++------------------
 2 files changed, 43 insertions(+), 38 deletions(-)
---
diff --git a/examples/plugman.c b/examples/plugman.c
index 0e0882fcb5..9e9c683242 100644
--- a/examples/plugman.c
+++ b/examples/plugman.c
@@ -4,12 +4,12 @@
 
 
 static const char *red_css =
-"textview>text {"
+"textview {"
 "  color: red;"
 "}";
 
 static const char *black_css =
-"textview>text {"
+"textview {"
 "  color: black;"
 "}";
 
@@ -81,6 +81,7 @@ new_window (GApplication *app,
   gtk_window_set_default_size ((GtkWindow*)window, 640, 480);
   g_action_map_add_action_entries (G_ACTION_MAP (window), win_entries, G_N_ELEMENTS (win_entries), window);
   gtk_window_set_title (GTK_WINDOW (window), "Plugman");
+  gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), TRUE);
 
   grid = gtk_grid_new ();
   gtk_window_set_child (GTK_WINDOW (window), grid);
@@ -334,9 +335,10 @@ configure_plugins (GSimpleAction *action,
                                "<interface>"
                                "  <object class='GtkDialog' id='plugin-dialog'>"
                                "    <property name='title'>Plugins</property>"
-                               "    <child internal-child='vbox'>"
+                               "    <child internal-child='content_area'>"
                                "      <object class='GtkBox' id='content-area'>"
                                "        <property name='visible'>True</property>"
+                               "        <property name='orientation'>vertical</property>"
                                "        <child>"
                                "          <object class='GtkCheckButton' id='red-plugin'>"
                                "            <property name='label' translatable='yes'>Red Plugin - turn your 
text red</property>"
@@ -352,7 +354,7 @@ configure_plugins (GSimpleAction *action,
                                "      </object>"
                                "    </child>"
                                "    <child internal-child='action_area'>"
-                               "      <object class='GtkButtonBox' id='action-area'>"
+                               "      <object class='GtkBox' id='action-area'>"
                                "        <property name='visible'>True</property>"
                                "        <child>"
                                "          <object class='GtkButton' id='close-button'>"
@@ -409,23 +411,24 @@ plug_man_startup (GApplication *application)
   builder = gtk_builder_new ();
   gtk_builder_add_from_string (builder,
                                "<interface>"
-                               "  <menu id='app-menu'>"
-                               "    <section>"
-                               "      <item>"
-                               "        <attribute name='label' translatable='yes'>_About 
Plugman</attribute>"
-                               "        <attribute name='action'>app.about</attribute>"
-                               "      </item>"
-                               "    </section>"
-                               "    <section>"
-                               "      <item>"
-                               "        <attribute name='label' translatable='yes'>_Quit</attribute>"
-                               "        <attribute name='action'>app.quit</attribute>"
-                               "        <attribute name='accel'>&lt;Primary&gt;q</attribute>"
-                               "      </item>"
-                               "    </section>"
-                               "  </menu>"
                                "  <menu id='menubar'>"
                                "    <submenu>"
+                               "      <attribute name='label' translatable='yes'>_Plugman</attribute>"
+                               "      <section>"
+                               "        <item>"
+                               "          <attribute name='label' translatable='yes'>_About 
Plugman</attribute>"
+                               "          <attribute name='action'>app.about</attribute>"
+                               "        </item>"
+                               "      </section>"
+                               "      <section>"
+                               "        <item>"
+                               "          <attribute name='label' translatable='yes'>_Quit</attribute>"
+                               "          <attribute name='action'>app.quit</attribute>"
+                               "          <attribute name='accel'>&lt;Primary&gt;q</attribute>"
+                               "        </item>"
+                               "      </section>"
+                               "    </submenu>"
+                               "    <submenu>"
                                "      <attribute name='label' translatable='yes'>_Edit</attribute>"
                                "      <section>"
                                "        <item>"
@@ -457,7 +460,6 @@ plug_man_startup (GApplication *application)
                                "    </submenu>"
                                "  </menu>"
                                "</interface>", -1, NULL);
-  gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object 
(builder, "app-menu")));
   gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, 
"menubar")));
   g_object_set_data_full (G_OBJECT (application), "plugin-menu", gtk_builder_get_object (builder, 
"plugins"), g_object_unref);
   g_object_unref (builder);
diff --git a/examples/sunny.c b/examples/sunny.c
index 1bb3284eeb..43757023a0 100644
--- a/examples/sunny.c
+++ b/examples/sunny.c
@@ -9,7 +9,7 @@ new_window (GApplication *app,
   GtkWidget *header;
 
   window = gtk_application_window_new (GTK_APPLICATION (app));
-  gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
+  gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), TRUE);
   gtk_window_set_default_size ((GtkWindow*)window, 640, 480);
   gtk_window_set_title (GTK_WINDOW (window), "Sunny");
   gtk_window_set_icon_name (GTK_WINDOW (window), "sunny");
@@ -138,25 +138,28 @@ startup (GApplication *application)
   builder = gtk_builder_new ();
   gtk_builder_add_from_string (builder,
                                "<interface>"
-                               "  <menu id='app-menu'>"
-                               "    <section>"
-                               "      <item>"
-                               "        <attribute name='label' translatable='yes'>_New Window</attribute>"
-                               "        <attribute name='action'>app.new</attribute>"
-                               "      </item>"
-                               "      <item>"
-                               "        <attribute name='label' translatable='yes'>_About Sunny</attribute>"
-                               "        <attribute name='action'>app.about</attribute>"
-                               "      </item>"
-                               "      <item>"
-                               "        <attribute name='label' translatable='yes'>_Quit</attribute>"
-                               "        <attribute name='action'>app.quit</attribute>"
-                               "        <attribute name='accel'>&lt;Primary&gt;q</attribute>"
-                               "      </item>"
-                               "    </section>"
+                               "  <menu id='menubar'>"
+                               "    <submenu>"
+                               "      <attribute name='label' translatable='yes'>Sunny</attribute>"
+                               "      <section>"
+                               "        <item>"
+                               "          <attribute name='label' translatable='yes'>_New Window</attribute>"
+                               "          <attribute name='action'>app.new</attribute>"
+                               "        </item>"
+                               "        <item>"
+                               "          <attribute name='label' translatable='yes'>_About 
Sunny</attribute>"
+                               "          <attribute name='action'>app.about</attribute>"
+                               "        </item>"
+                               "        <item>"
+                               "          <attribute name='label' translatable='yes'>_Quit</attribute>"
+                               "          <attribute name='action'>app.quit</attribute>"
+                               "          <attribute name='accel'>&lt;Primary&gt;q</attribute>"
+                               "        </item>"
+                               "      </section>"
+                               "    </submenu>"
                                "  </menu>"
                                "</interface>", -1, NULL);
-  gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object 
(builder, "app-menu")));
+  gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, 
"menubar")));
   g_object_unref (builder);
 }
 


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