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



commit 314c825b7ad245506707c913ab6af1468b6f81b4
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/media-menu-button.ui            |  8 --------
 data/ui/preferences-subpage-gamepad.ui  | 11 +----------
 data/ui/preferences-subpage-keyboard.ui | 11 +----------
 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 12c4c1c4..807d0997 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 20c043e8..0f3b3030 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/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/data/ui/preferences-subpage-gamepad.ui b/data/ui/preferences-subpage-gamepad.ui
index 78f93415..d34912ea 100644
--- a/data/ui/preferences-subpage-gamepad.ui
+++ b/data/ui/preferences-subpage-gamepad.ui
@@ -73,22 +73,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/preferences-subpage-keyboard.ui b/data/ui/preferences-subpage-keyboard.ui
index a6baa696..f35e6a2a 100644
--- a/data/ui/preferences-subpage-keyboard.ui
+++ b/data/ui/preferences-subpage-keyboard.ui
@@ -74,22 +74,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/src/ui/media-menu-button.vala b/src/ui/media-menu-button.vala
index 57f7c52f..5af0f80d 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 { get; set; }
 
-       [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]