[gnome-software] overview: Use GtkFlowBox for software categories



commit 472cc675f7079833ba0b9874ea819b43eb654a96
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date:   Tue Oct 7 10:06:45 2014 +0200

    overview: Use GtkFlowBox for software categories
    
    Size of the category tiles depends on their localized names.
    With this approach the tiles will automagically arrange for
    any screen size. This is required to fit on small displays.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735994

 configure.ac             |    2 +-
 src/gs-shell-overview.c  |   13 ++++++-------
 src/gs-shell-overview.ui |   13 +++++++------
 3 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 233133f..07f81a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,7 +59,7 @@ GLIB_GSETTINGS
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.17.7 gio-unix-2.0)
+PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.18.2 gio-unix-2.0)
 PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= 1.0.9)
 PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.5.2)
 PKG_CHECK_MODULES(SQLITE, sqlite3)
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index 9bfa665..cb883b0 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -55,7 +55,7 @@ typedef struct
        GtkWidget               *box_popular_rotating;
        GtkWidget               *category_heading;
        GtkWidget               *featured_heading;
-       GtkWidget               *grid_categories;
+       GtkWidget               *flowbox_categories;
        GtkWidget               *popular_heading;
        GtkWidget               *popular_rotating_heading;
        GtkWidget               *scrolledwindow_overview;
@@ -307,7 +307,6 @@ gs_shell_overview_get_categories_cb (GObject *source_object,
        GsShellOverview *self = GS_SHELL_OVERVIEW (user_data);
        GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
-       gint i;
        GList *l;
        GsCategory *cat;
        GtkWidget *tile;
@@ -321,17 +320,17 @@ gs_shell_overview_get_categories_cb (GObject *source_object,
                        g_warning ("failed to get categories: %s", error->message);
                goto out;
        }
-       gs_container_remove_all (GTK_CONTAINER (priv->grid_categories));
+       gs_container_remove_all (GTK_CONTAINER (priv->flowbox_categories));
 
-       for (l = list, i = 0; l; l = l->next) {
+       for (l = list; l; l = l->next) {
                cat = GS_CATEGORY (l->data);
                if (gs_category_get_size (cat) == 0)
                        continue;
                tile = gs_category_tile_new (cat);
                g_signal_connect (tile, "clicked",
                                  G_CALLBACK (category_tile_clicked), self);
-               gtk_grid_attach (GTK_GRID (priv->grid_categories), tile, i % 4, i / 4, 1, 1);
-               i++;
+               gtk_flow_box_insert (GTK_FLOW_BOX (priv->flowbox_categories), tile, -1);
+               gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);
                has_category = TRUE;
        }
 out:
@@ -588,7 +587,7 @@ gs_shell_overview_class_init (GsShellOverviewClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, box_popular_rotating);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, category_heading);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, featured_heading);
-       gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, grid_categories);
+       gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, flowbox_categories);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, popular_heading);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, 
popular_rotating_heading);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellOverview, scrolledwindow_overview);
diff --git a/src/gs-shell-overview.ui b/src/gs-shell-overview.ui
index 2165a02..d3f7483 100644
--- a/src/gs-shell-overview.ui
+++ b/src/gs-shell-overview.ui
@@ -163,7 +163,7 @@
                         <property name="margin-start">12</property>
                         <property name="margin-end">24</property>
                         <accessibility>
-                          <relation target="grid_categories" type="label-for"/>
+                          <relation target="flowbox_categories" type="label-for"/>
                         </accessibility>
                         <style>
                           <class name="index-title-alignment-software"/>
@@ -176,16 +176,17 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkGrid" id="grid_categories">
+                      <object class="GtkFlowBox" id="flowbox_categories">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="margin_start">12</property>
                         <property name="margin_end">12</property>
                         <property name="margin-bottom">24</property>
-                        <property name="row_spacing">14</property>
-                        <property name="column_spacing">14</property>
-                        <property name="row_homogeneous">True</property>
-                        <property name="column_homogeneous">True</property>
+                        <property name="row_spacing">8</property>
+                        <property name="column_spacing">8</property>
+                        <property name="homogeneous">True</property>
+                        <property name="max_children_per_line">4</property>
+                        <property name="selection_mode">none</property>
                         <accessibility>
                           <relation target="category_heading" type="labelled-by"/>
                         </accessibility>


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