[gtk/wip/otte/toolbar: 1/6] gtk-demo: Get rid of toolbars



commit 0ae8f3cde1e29176671d3fa412ee52a9ba33ca18
Author: Benjamin Otte <otte redhat com>
Date:   Mon Feb 3 04:52:15 2020 +0100

    gtk-demo: Get rid of toolbars

 demos/gtk-demo/application.c  |  8 ++++----
 demos/gtk-demo/application.ui | 13 +++++--------
 demos/gtk-demo/builder.c      |  4 ----
 demos/gtk-demo/css_shadows.c  | 19 ++++++++-----------
 demos/gtk-demo/demo.ui        | 17 ++++++++---------
 demos/gtk-demo/iconview.c     | 24 ++++++++----------------
 6 files changed, 33 insertions(+), 52 deletions(-)
---
diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c
index 92034b5e43..783966dfd8 100644
--- a/demos/gtk-demo/application.c
+++ b/demos/gtk-demo/application.c
@@ -14,7 +14,7 @@ typedef struct {
   GtkWidget *message;
   GtkWidget *infobar;
   GtkWidget *status;
-  GtkWidget *menutool;
+  GtkWidget *menubutton;
   GMenuModel *toolmenu;
   GtkTextBuffer *buffer;
 
@@ -428,8 +428,8 @@ demo_application_window_init (DemoApplicationWindow *window)
 
   gtk_widget_init_template (GTK_WIDGET (window));
 
-  popover = gtk_popover_menu_new_from_model (window->menutool, window->toolmenu);
-  gtk_menu_tool_button_set_popover (GTK_MENU_TOOL_BUTTON (window->menutool), popover);
+  popover = gtk_popover_menu_new_from_model (window->menubutton, window->toolmenu);
+  gtk_menu_button_set_popover (GTK_MENU_BUTTON (window->menubutton), popover);
 
   g_action_map_add_action_entries (G_ACTION_MAP (window),
                                    win_entries, G_N_ELEMENTS (win_entries),
@@ -528,7 +528,7 @@ demo_application_window_class_init (DemoApplicationWindowClass *class)
   gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, infobar);
   gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, status);
   gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, buffer);
-  gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menutool);
+  gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, menubutton);
   gtk_widget_class_bind_template_child (widget_class, DemoApplicationWindow, toolmenu);
   gtk_widget_class_bind_template_callback (widget_class, clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, update_statusbar);
diff --git a/demos/gtk-demo/application.ui b/demos/gtk-demo/application.ui
index f457d89f32..12468c11ef 100644
--- a/demos/gtk-demo/application.ui
+++ b/demos/gtk-demo/application.ui
@@ -8,27 +8,24 @@
     <child>
       <object class="GtkGrid">
         <child>
-          <object class="GtkToolbar">
+          <object class="GtkBox">
             <property name="hexpand">1</property>
-            <style>
-              <class name="primary-toolbar"/>
-            </style>
             <child>
-              <object class="GtkMenuToolButton" id="menutool">
+              <object class="GtkMenuButton" id="menubutton">
                 <property name="icon-name">document-open</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="icon-name">application-exit</property>
                 <property name="action-name">app.quit</property>
               </object>
             </child>
             <child>
-              <object class="GtkSeparatorToolItem"/>
+              <object class="GtkSeparator"/>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="icon-name">applications-other</property>
                 <property name="action-name">win.logo</property>
               </object>
diff --git a/demos/gtk-demo/builder.c b/demos/gtk-demo/builder.c
index a04088a9bd..35714f2351 100644
--- a/demos/gtk-demo/builder.c
+++ b/demos/gtk-demo/builder.c
@@ -63,7 +63,6 @@ GtkWidget *
 do_builder (GtkWidget *do_widget)
 {
   static GtkWidget *window = NULL;
-  GtkWidget *toolbar;
   GActionGroup *actions;
 
   if (!window)
@@ -77,9 +76,6 @@ do_builder (GtkWidget *do_widget)
                               gtk_widget_get_display (do_widget));
       g_signal_connect (window, "destroy",
                         G_CALLBACK (gtk_widget_destroyed), &window);
-      toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "toolbar1"));
-      gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
-                                   "primary-toolbar");
       actions = (GActionGroup*)g_simple_action_group_new ();
       g_action_map_add_action_entries (G_ACTION_MAP (actions),
                                        win_entries, G_N_ELEMENTS (win_entries),
diff --git a/demos/gtk-demo/css_shadows.c b/demos/gtk-demo/css_shadows.c
index 318141c896..a61bd3bd03 100644
--- a/demos/gtk-demo/css_shadows.c
+++ b/demos/gtk-demo/css_shadows.c
@@ -62,22 +62,19 @@ GtkWidget *
 create_toolbar (void)
 {
   GtkWidget *toolbar;
-  GtkToolItem *item;
+  GtkWidget *item;
 
-  toolbar = gtk_toolbar_new ();
+  toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
   gtk_widget_set_valign (toolbar, GTK_ALIGN_CENTER);
 
-  item = gtk_tool_button_new (NULL, NULL);
-  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
-  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+  item = gtk_button_new_from_icon_name ("go-next");
+  gtk_container_add (GTK_CONTAINER (toolbar), item);
 
-  item = gtk_tool_button_new (NULL, NULL);
-  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
-  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+  item = gtk_button_new_from_icon_name ("go-previous");
+  gtk_container_add (GTK_CONTAINER (toolbar), item);
 
-  item = gtk_tool_button_new (NULL, "Hello World");
-  gtk_tool_item_set_is_important (item, TRUE);
-  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+  item = gtk_button_new_with_label ("Hello World");
+  gtk_container_add (GTK_CONTAINER (toolbar), item);
 
   return toolbar;
 }
diff --git a/demos/gtk-demo/demo.ui b/demos/gtk-demo/demo.ui
index 7520467155..b020232523 100644
--- a/demos/gtk-demo/demo.ui
+++ b/demos/gtk-demo/demo.ui
@@ -111,53 +111,52 @@
           </object>
         </child>
         <child>
-          <object class="GtkToolbar" id="toolbar1">
+          <object class="GtkBox" id="toolbar1">
             <child internal-child="accessible">
               <object class="AtkObject" id="a11y-toolbar">
                 <property name="AtkObject::accessible-name">The toolbar</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">New</property>
                 <property name="tooltip-text" translatable="yes">Create a new file</property>
                 <property name="icon-name">document-new</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">Open</property>
                 <property name="tooltip-text" translatable="yes">Open a file</property>
                 <property name="icon-name">document-open</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">Save</property>
                 <property name="tooltip-text" translatable="yes">Save a file</property>
                 <property name="icon-name">document-save</property>
-                <property name="is-important">1</property>
               </object>
             </child>
             <child>
-              <object class="GtkSeparatorToolItem"/>
+              <object class="GtkSeparator"/>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">Copy</property>
                 <property name="tooltip-text" translatable="yes">Copy selected object into the 
clipboard</property>
                 <property name="icon-name">edit-copy</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">Cut</property>
                 <property name="tooltip-text" translatable="yes">Cut selected object into the 
clipboard</property>
                 <property name="icon-name">edit-cut</property>
               </object>
             </child>
             <child>
-              <object class="GtkToolButton">
+              <object class="GtkButton">
                 <property name="label" translatable="yes">Paste</property>
                 <property name="tooltip-text" translatable="yes">Paste object from the clipboard</property>
                 <property name="icon-name">edit-paste</property>
diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c
index d252ef36ec..7e0e15d4e2 100644
--- a/demos/gtk-demo/iconview.c
+++ b/demos/gtk-demo/iconview.c
@@ -26,7 +26,7 @@ enum
 
 static GdkPixbuf *file_pixbuf, *folder_pixbuf;
 gchar *parent;
-GtkToolItem *up_button;
+GtkWidget *up_button;
 
 /* Loads the images for the demo and returns whether the operation succeeded */
 static void
@@ -248,7 +248,7 @@ do_iconview (GtkWidget *do_widget)
       GtkListStore *store;
       GtkWidget *vbox;
       GtkWidget *tool_bar;
-      GtkToolItem *home_button;
+      GtkWidget *home_button;
 
       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
       gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
@@ -265,23 +265,15 @@ do_iconview (GtkWidget *do_widget)
       vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
       gtk_container_add (GTK_CONTAINER (window), vbox);
 
-      tool_bar = gtk_toolbar_new ();
+      tool_bar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
       gtk_container_add (GTK_CONTAINER (vbox), tool_bar);
 
-      up_button = gtk_tool_button_new (NULL, NULL);
-      gtk_tool_button_set_label (GTK_TOOL_BUTTON (up_button), _("_Up"));
-      gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (up_button), TRUE);
-      gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (up_button), "go-up");
-      gtk_tool_item_set_is_important (up_button, TRUE);
+      up_button = gtk_button_new_with_mnemonic ("_Up");
       gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
-      gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), up_button, -1);
-
-      home_button = gtk_tool_button_new (NULL, NULL);
-      gtk_tool_button_set_label (GTK_TOOL_BUTTON (home_button), _("_Home"));
-      gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (home_button), TRUE);
-      gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (home_button), "go-home");
-      gtk_tool_item_set_is_important (home_button, TRUE);
-      gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), home_button, -1);
+      gtk_container_add (GTK_CONTAINER (tool_bar), up_button);
+
+      home_button = gtk_button_new_with_mnemonic ("_Home");
+      gtk_container_add (GTK_CONTAINER (tool_bar), home_button);
 
 
       sw = gtk_scrolled_window_new (NULL, NULL);


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