[gnome-games/wip/exalm/gtk4: 39/42] ui: Use 'icon-name' property of GtkButton



commit 2ff3e6916dbdb7facf26178110ba4b321c433ded
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Jul 29 14:59:48 2018 +0500

    ui: Use 'icon-name' property of GtkButton
    
    This sets 'image-button' style class implicitly and also allows to remove
    GtkImage children.

 data/ui/collection-box.ui        |  7 +------
 data/ui/collection-header-bar.ui | 33 +++------------------------------
 data/ui/display-header-bar.ui    | 33 +++------------------------------
 data/ui/gamepad-configurer.ui    | 11 +----------
 data/ui/keyboard-configurer.ui   | 11 +----------
 data/ui/media-menu-button.ui     |  8 --------
 src/ui/media-menu-button.vala    |  5 +----
 7 files changed, 10 insertions(+), 98 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index 5864ab3b..4c0237b0 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -87,8 +87,7 @@
                   <object class="GtkButton">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="image">close_icon</property>
-                    <property name="always_show_image">True</property>
+                    <property name="icon-name">window-close-symbolic</property>
                     <signal name="clicked" handler="on_loading_notification_closed"/>
                     <style>
                       <class name="flat"/>
@@ -105,8 +104,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkImage" id="close_icon">
-    <property name="visible">True</property>
-    <property name="icon_name">window-close-symbolic</property>
-  </object>
 </interface>
diff --git a/data/ui/collection-header-bar.ui b/data/ui/collection-header-bar.ui
index 9c50a47a..73d13bad 100644
--- a/data/ui/collection-header-bar.ui
+++ b/data/ui/collection-header-bar.ui
@@ -9,21 +9,12 @@
         <property name="valign">center</property>
         <property name="use-underline">True</property>
         <property name="action-name">app.add-game-files</property>
-        <style>
-          <class name="image-button"/>
-        </style>
+        <property name="icon-name">list-add-symbolic</property>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-back">
             <property name="accessible-name" translatable="yes">Add game files…</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="add_game_image">
-            <property name="visible">True</property>
-            <property name="icon-name">list-add-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">start</property>
@@ -37,16 +28,7 @@
         <property name="use-underline">True</property>
         <property name="valign">center</property>
         <property name="visible">True</property>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child>
-          <object class="GtkImage" id="menu_image">
-            <property name="visible">True</property>
-            <property name="icon-name">open-menu-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
+        <property name="icon-name">open-menu-symbolic</property>
       </object>
       <packing>
         <property name="pack-type">end</property>
@@ -77,21 +59,12 @@
         <property name="visible">True</property>
         <property name="valign">center</property>
         <property name="use-underline">True</property>
-        <style>
-          <class name="image-button"/>
-        </style>
+        <property name="icon-name">edit-find-symbolic</property>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-search">
             <property name="accessible-name" translatable="yes">Search</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="search_image">
-            <property name="visible">True</property>
-            <property name="icon-name">edit-find-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">end</property>
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index 972bf0dc..cb724dfc 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -11,22 +11,13 @@
         <property name="visible">True</property>
         <property name="valign">center</property>
         <property name="use-underline">True</property>
+        <property name="icon-name">go-previous-symbolic</property>
         <signal name="clicked" handler="on_back_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-back">
             <property name="accessible-name" translatable="yes">Back</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="back_image">
-            <property name="visible">True</property>
-            <property name="icon-name">go-previous-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
     </child>
     <child>
@@ -34,22 +25,13 @@
         <property name="visible">False</property>
         <property name="valign">center</property>
         <property name="use-underline">True</property>
+        <property name="icon-name">view-fullscreen-symbolic</property>
         <signal name="clicked" handler="on_fullscreen_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-fullscreen">
             <property name="accessible-name" translatable="yes">Fullscreen</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="fullscreen_image">
-            <property name="visible">True</property>
-            <property name="icon-name">view-fullscreen-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">end</property>
@@ -60,22 +42,13 @@
         <property name="visible">False</property>
         <property name="valign">center</property>
         <property name="use-underline">True</property>
+        <property name="icon-name">view-restore-symbolic</property>
         <signal name="clicked" handler="on_restore_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-restore">
             <property name="accessible-name" translatable="yes">Restore</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="restore_image">
-            <property name="visible">True</property>
-            <property name="icon-name">view-restore-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">end</property>
diff --git a/data/ui/gamepad-configurer.ui b/data/ui/gamepad-configurer.ui
index b4ce0a00..8300da5a 100644
--- a/data/ui/gamepad-configurer.ui
+++ b/data/ui/gamepad-configurer.ui
@@ -64,22 +64,13 @@
     <child>
       <object class="GtkButton" id="back_button">
         <property name="visible">True</property>
+        <property name="icon-name">go-previous-symbolic</property>
         <signal name="clicked" handler="on_back_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-back">
             <property name="accessible-name" translatable="yes">Back</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="back_image">
-            <property name="visible">True</property>
-            <property name="icon-name">go-previous-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">start</property>
diff --git a/data/ui/keyboard-configurer.ui b/data/ui/keyboard-configurer.ui
index 4648cac0..288b3d22 100644
--- a/data/ui/keyboard-configurer.ui
+++ b/data/ui/keyboard-configurer.ui
@@ -65,22 +65,13 @@
     <child>
       <object class="GtkButton" id="back_button">
         <property name="visible">True</property>
+        <property name="icon-name">go-previous-symbolic</property>
         <signal name="clicked" handler="on_back_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-back">
             <property name="accessible-name" translatable="yes">Back</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="back_image">
-            <property name="visible">True</property>
-            <property name="icon-name">go-previous-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
       </object>
       <packing>
         <property name="pack-type">start</property>
diff --git a/data/ui/media-menu-button.ui b/data/ui/media-menu-button.ui
index 8c3fcf90..40da30ee 100644
--- a/data/ui/media-menu-button.ui
+++ b/data/ui/media-menu-button.ui
@@ -2,19 +2,11 @@
 <interface>
   <requires lib="gtk+" version="3.16"/>
   <template class="GamesMediaMenuButton" parent="GtkMenuButton">
-    <style>
-      <class name="image-button"/>
-    </style>
     <signal name="notify::media-set" handler="on_media_set_changed"/>
     <child internal-child="accessible">
       <object class="AtkObject" id="a11y-display-discs">
         <property name="accessible-name" translatable="yes">Media</property>
       </object>
     </child>
-    <child>
-      <object class="GtkImage" id="media_image">
-        <property name="visible">True</property>
-      </object>
-    </child>
   </template>
 </interface>
diff --git a/src/ui/media-menu-button.vala b/src/ui/media-menu-button.vala
index 46b4c4ec..da3ab3cf 100644
--- a/src/ui/media-menu-button.vala
+++ b/src/ui/media-menu-button.vala
@@ -4,9 +4,6 @@
 private class Games.MediaMenuButton : Gtk.MenuButton {
        public MediaSet media_set { set; get; }
 
-       [GtkChild]
-       private Gtk.Image media_image;
-
        [GtkCallback]
        private void on_media_set_changed () {
                if (media_set == null || media_set.get_size () < 2) {
@@ -15,7 +12,7 @@ private class Games.MediaMenuButton : Gtk.MenuButton {
                        return;
                }
 
-               media_image.set_from_gicon (media_set.icon);
+               icon_name = media_set.icon.to_string ();
 
                show ();
        }


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