Commit 472cc675 authored by Rafał Lużyński's avatar Rafał Lużyński Committed by Kalev Lember

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
parent 8fe15f10
......@@ -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)
......
......@@ -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);
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment