[gnome-software: 10/15] gs-app-context-bar: Hook up the context dialogues to the tiles




commit 95b40476e7048c94e9afe80b9ee301c71d2223f3
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Jul 15 16:39:38 2021 +0100

    gs-app-context-bar: Hook up the context dialogues to the tiles
    
    This will show the dialogues when the tiles are clicked.
    
    There is no dialogue for the ‘download’ tile in the design:
    https://gitlab.gnome.org/Teams/Design/software-mockups/-/raw/master/adaptive/context-tiles.png.
    
    The indentation in `gs-app-context-bar.ui` is incorrect, to make review
    easier. It will be fixed in the next commit.
    
    Includes significant work by Adrien Plazas.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1111

 src/gs-app-context-bar.c  | 32 +++++++++++++++++++++++++++++
 src/gs-app-context-bar.ui | 52 +++++++++++++++++++++++++++++++++++++----------
 2 files changed, 73 insertions(+), 11 deletions(-)
---
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 0078a9203..5a6f6d61a 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -33,11 +33,15 @@
 #include <handy.h>
 #include <locale.h>
 
+#include "gs-age-rating-context-dialog.h"
 #include "gs-app.h"
 #include "gs-app-context-bar.h"
+#include "gs-hardware-support-context-dialog.h"
+#include "gs-safety-context-dialog.h"
 
 typedef struct
 {
+       GtkWidget       *tile;
        GtkWidget       *lozenge;
        GtkWidget       *lozenge_content;
        GtkLabel        *title;
@@ -905,6 +909,29 @@ app_notify_cb (GObject    *obj,
        update_tiles (self);
 }
 
+static void
+tile_clicked_cb (GtkWidget *widget,
+                 gpointer   user_data)
+{
+       GsAppContextBar *self = GS_APP_CONTEXT_BAR (user_data);
+       GtkWindow *dialog;
+       GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+
+       if (GTK_IS_WINDOW (toplevel)) {
+               if (widget == self->tiles[SAFETY_TILE].tile)
+                       dialog = GTK_WINDOW (gs_safety_context_dialog_new (self->app));
+               else if (widget == self->tiles[HARDWARE_SUPPORT_TILE].tile)
+                       dialog = GTK_WINDOW (gs_hardware_support_context_dialog_new (self->app));
+               else if (widget == self->tiles[AGE_RATING_TILE].tile)
+                       dialog = GTK_WINDOW (gs_age_rating_context_dialog_new (self->app));
+               else
+                       g_assert_not_reached ();
+
+               gtk_window_set_transient_for (dialog, GTK_WINDOW (toplevel));
+               gtk_widget_show (GTK_WIDGET (dialog));
+       }
+}
+
 static void
 gs_app_context_bar_init (GsAppContextBar *self)
 {
@@ -992,22 +1019,27 @@ gs_app_context_bar_class_init (GsAppContextBarClass *klass)
        gtk_widget_class_set_css_name (widget_class, "app-context-bar");
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Software/gs-app-context-bar.ui");
 
+       gtk_widget_class_bind_template_child_full (widget_class, "storage_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[STORAGE_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].lozenge));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_title", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[STORAGE_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "storage_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[STORAGE_TILE].description));
+       gtk_widget_class_bind_template_child_full (widget_class, "safety_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[SAFETY_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].lozenge));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_title", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[SAFETY_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "safety_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[SAFETY_TILE].description));
+       gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].lozenge));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_lozenge_content", 
FALSE, G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_title", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "hardware_support_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[HARDWARE_SUPPORT_TILE].description));
+       gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile", FALSE, G_STRUCT_OFFSET 
(GsAppContextBar, tiles[AGE_RATING_TILE].tile));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_lozenge", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].lozenge));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_lozenge_content", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].lozenge_content));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_title", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].title));
        gtk_widget_class_bind_template_child_full (widget_class, "age_rating_tile_description", FALSE, 
G_STRUCT_OFFSET (GsAppContextBar, tiles[AGE_RATING_TILE].description));
+       gtk_widget_class_bind_template_callback (widget_class, tile_clicked_cb);
 }
 
 /**
diff --git a/src/gs-app-context-bar.ui b/src/gs-app-context-bar.ui
index 02699155f..6f72e3ede 100644
--- a/src/gs-app-context-bar.ui
+++ b/src/gs-app-context-bar.ui
@@ -3,11 +3,14 @@
   <requires lib="gtk+" version="3.10"/>
   <template class="GsAppContextBar" parent="GtkGrid">
     <property name="column-homogeneous">True</property>
-    <property name="column-spacing">12</property>
+    <property name="column-spacing">0</property>
     <property name="row-homogeneous">True</property>
-    <property name="row-spacing">12</property>
+    <property name="row-spacing">0</property>
     <property name="visible">True</property>
     <property name="can-focus">True</property>
+    <style>
+      <class name="linked"/>
+    </style>
 
     <child>
       <object class="GtkBox" id="storage_tile">
@@ -84,13 +87,20 @@
     </child>
 
     <child>
-      <object class="GtkBox" id="safety_tile">
-        <property name="orientation">vertical</property>
-        <property name="spacing">8</property>
+      <object class="GtkButton" id="safety_tile">
         <property name="visible">True</property>
+        <signal name="clicked" handler="tile_clicked_cb"/>
         <style>
           <class name="context-tile"/>
+          <class name="flat"/>
         </style>
+
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="spacing">8</property>
+        <property name="visible">True</property>
+
         <child>
           <object class="GtkBox" id="safety_tile_lozenge">
             <property name="halign">center</property>
@@ -150,6 +160,8 @@
           </object>
         </child>
       </object>
+    </child>
+      </object>
       <packing>
         <property name="left-attach">1</property>
         <property name="top-attach">0</property>
@@ -157,13 +169,20 @@
     </child>
 
     <child>
-      <object class="GtkBox" id="hardware_support_tile">
-        <property name="orientation">vertical</property>
-        <property name="spacing">8</property>
+      <object class="GtkButton" id="hardware_support_tile">
         <property name="visible">True</property>
+        <signal name="clicked" handler="tile_clicked_cb"/>
         <style>
           <class name="context-tile"/>
+          <class name="flat"/>
         </style>
+
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="spacing">8</property>
+        <property name="visible">True</property>
+
         <child>
           <object class="GtkBox" id="hardware_support_tile_lozenge">
             <property name="halign">center</property>
@@ -225,6 +244,8 @@
           </object>
         </child>
       </object>
+    </child>
+      </object>
       <packing>
         <property name="left-attach">2</property>
         <property name="top-attach">0</property>
@@ -232,13 +253,20 @@
     </child>
 
     <child>
-      <object class="GtkBox" id="age_rating_tile">
-        <property name="orientation">vertical</property>
-        <property name="spacing">8</property>
+      <object class="GtkButton" id="age_rating_tile">
         <property name="visible">True</property>
+        <signal name="clicked" handler="tile_clicked_cb"/>
         <style>
           <class name="context-tile"/>
+          <class name="flat"/>
         </style>
+
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="spacing">8</property>
+        <property name="visible">True</property>
+
         <child>
           <object class="GtkBox" id="age_rating_tile_lozenge">
             <property name="halign">center</property>
@@ -299,6 +327,8 @@
           </object>
         </child>
       </object>
+    </child>
+      </object>
       <packing>
         <property name="left-attach">3</property>
         <property name="top-attach">0</property>


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