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



commit db4eca8bfbeab4c2aba3d016c856f4d8f00a9c5a
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/input-mode-switcher.ui          | 14 ++------------
 data/ui/media-menu-button.ui            |  8 --------
 data/ui/preferences-subpage-gamepad.ui  | 11 +----------
 data/ui/preferences-subpage-keyboard.ui | 11 +----------
 data/ui/preferences-window.ui           | 11 +----------
 src/ui/media-menu-button.vala           |  5 +----
 9 files changed, 13 insertions(+), 120 deletions(-)
---
diff --git a/data/ui/collection-box.ui b/data/ui/collection-box.ui
index bab24792..b620660c 100644
--- a/data/ui/collection-box.ui
+++ b/data/ui/collection-box.ui
@@ -90,8 +90,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"/>
@@ -108,8 +107,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 a8942d2c..279c1ebe 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/input-mode-switcher.ui b/data/ui/input-mode-switcher.ui
index 12270121..8c452a02 100644
--- a/data/ui/input-mode-switcher.ui
+++ b/data/ui/input-mode-switcher.ui
@@ -10,18 +10,13 @@
         <property name="visible">True</property>
         <property name="draw-indicator">False</property>
         <property name="can-focus">False</property>
+        <property name="icon-name">input-gaming-symbolic</property>
         <signal name="toggled" handler="on_gamepad_button_toggled"/>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-gamepad-input">
             <property name="accessible-name" translatable="yes">Gamepad Input</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="gamepad_image">
-            <property name="visible">True</property>
-            <property name="icon-name">input-gaming-symbolic</property>
-          </object>
-        </child>
       </object>
     </child>
     <child>
@@ -30,18 +25,13 @@
         <property name="draw-indicator">False</property>
         <property name="can-focus">False</property>
         <property name="group">gamepad_mode</property>
+        <property name="icon-name">input-keyboard-symbolic</property>
         <signal name="toggled" handler="on_keyboard_button_toggled"/>
         <child internal-child="accessible">
           <object class="AtkObject" id="a11y-keyboard-input">
             <property name="accessible-name" translatable="yes">Keyboard Input</property>
           </object>
         </child>
-        <child>
-          <object class="GtkImage" id="keyboard_image">
-            <property name="visible">True</property>
-            <property name="icon-name">input-keyboard-symbolic</property>
-          </object>
-        </child>
       </object>
     </child>
   </template>
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/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 2a227dc9..c0deeebf 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -43,22 +43,13 @@
                     <child>
                       <object class="GtkButton" id="back_button">
                         <property name="visible">False</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]