[gnome-games] game-icon-view: Add a checkbox in an overlay



commit bbf52aa1b963211a024eb81e3c030d484e1ac77d
Author: Neville <nevilleantony98 gmail com>
Date:   Fri Jun 5 19:48:46 2020 +0530

    game-icon-view: Add a checkbox in an overlay
    
    The checkbox will be used in implementing selection-mode of games.
    is_selection_mode prop is used to show the checkboxes in the overlay.

 data/ui/game-icon-view.ui  | 67 +++++++++++++++++++++++++++++++---------------
 src/ui/game-icon-view.vala | 11 ++++++++
 2 files changed, 56 insertions(+), 22 deletions(-)
---
diff --git a/data/ui/game-icon-view.ui b/data/ui/game-icon-view.ui
index 0aaab4bf..44bae01b 100644
--- a/data/ui/game-icon-view.ui
+++ b/data/ui/game-icon-view.ui
@@ -3,27 +3,50 @@
   <requires lib="gtk+" version="3.24"/>
   <template class="GamesGameIconView" parent="GtkFlowBoxChild">
     <property name="visible">True</property>
-    <child>
-      <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GamesGameThumbnail" id="thumbnail">
-            <property name="visible">True</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkLabel" id="title">
-            <property name="visible">True</property>
-            <property name="ellipsize">middle</property>
-            <property name="justify">center</property>
-            <property name="lines">2</property>
-            <property name="max-width-chars">0</property>
-            <property name="wrap">True</property>
-            <property name="wrap-mode">word-char</property>
-          </object>
-        </child>
-      </object>
-    </child>
+      <child>
+        <object class="GtkBox">
+          <property name="visible">True</property>
+          <property name="orientation">vertical</property>
+          <child>
+            <object class="GtkOverlay">
+              <property name="visible">True</property>
+              <child>
+                <object class="GamesGameThumbnail" id="thumbnail">
+                  <property name="visible">True</property>
+                </object>
+              </child>
+              <child type="overlay">
+                <object class="GtkRevealer">
+                  <property name="visible">True</property>
+                  <property name="transition-type">crossfade</property>
+                  <property name="reveal-child" bind-source="GamesGameIconView" 
bind-property="is_selection_mode"/>
+                  <child>
+                    <object class="GtkCheckButton" id="checkbox">
+                      <property name="visible">True</property>
+                      <property name="halign">end</property>
+                      <property name="valign">end</property>
+                      <property name="active" bind-source="GamesGameIconView" bind-property="checked" 
bind-flags="bidirectional"/>
+                      <style>
+                        <class name="check"/>
+                      </style>
+                    </object>
+                  </child>
+                </object>
+              </child>
+            </object>
+          </child>
+          <child>
+            <object class="GtkLabel" id="title">
+              <property name="visible">True</property>
+              <property name="ellipsize">middle</property>
+              <property name="justify">center</property>
+              <property name="lines">2</property>
+              <property name="max-width-chars">0</property>
+              <property name="wrap">True</property>
+              <property name="wrap-mode">word-char</property>
+            </object>
+          </child>
+        </object>
+      </child>
   </template>
 </interface>
diff --git a/src/ui/game-icon-view.vala b/src/ui/game-icon-view.vala
index 5763151e..1b3ba241 100644
--- a/src/ui/game-icon-view.vala
+++ b/src/ui/game-icon-view.vala
@@ -28,6 +28,9 @@ private class Games.GameIconView : Gtk.FlowBoxChild {
                }
        }
 
+       public bool checked { get; set; }
+       public bool is_selection_mode { get; set; }
+
        public GameIconView (Game game) {
                Object (game: game);
        }
@@ -35,4 +38,12 @@ private class Games.GameIconView : Gtk.FlowBoxChild {
        private void game_replaced (Game new_game) {
                game = new_game;
        }
+
+       public static uint hash (GameIconView key) {
+               return Game.hash (key.game);
+       }
+
+       public static bool equal (GameIconView a, GameIconView b) {
+               return Game.equal (a.game, b.game);
+       }
 }


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