[gnome-games/wip/exalm/issue98-330: 4/4] collection-icon-view: Set children size via CSS
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/issue98-330: 4/4] collection-icon-view: Set children size via CSS
- Date: Sun, 23 Sep 2018 09:58:40 +0000 (UTC)
commit 229c0612c25b91b25658fbbe6cf53d879a13fd25
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sun Sep 23 14:47:53 2018 +0500
collection-icon-view: Set children size via CSS
Avoid manually setting width-request within size_allocate() handler.
Use CSS 'min-width' property for sizing and just dynamically add/remove a
style class.
data/gtk-style.css | 8 ++++++++
src/ui/collection-icon-view.vala | 27 ++-------------------------
2 files changed, 10 insertions(+), 25 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 83ae1888..bba91090 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -30,3 +30,11 @@ gamesgamethumbnail {
@theme_unfocused_bg_color;
border-color: @unfocused_borders;
}
+
+gamescollectioniconview flowboxchild {
+ min-width: 128px;
+}
+
+gamescollectioniconview.large flowboxchild {
+ min-width: 256px;
+}
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
index 17c8cc59..dd1b8dbb 100644
--- a/src/ui/collection-icon-view.vala
+++ b/src/ui/collection-icon-view.vala
@@ -78,9 +78,6 @@ private class Games.CollectionIconView : Gtk.Bin {
[GtkChild]
private GamepadBrowse gamepad_browse;
- // Current size used by the thumbnails.
- private int game_view_size;
-
static construct {
set_css_name ("gamescollectioniconview");
}
@@ -215,7 +212,6 @@ private class Games.CollectionIconView : Gtk.Bin {
var child = new Gtk.FlowBoxChild ();
game_view.visible = true;
- game_view.width_request = game_view_size;
child.visible = true;
child.add (game_view);
@@ -275,27 +271,8 @@ private class Games.CollectionIconView : Gtk.Bin {
// them rather than a few huge thumbnails, making Games more usable on
// small screens.
if (allocation.width < 960)
- set_size (128);
+ get_style_context ().remove_class ("large");
else
- set_size (256);
- }
-
- private void set_size (int size) {
- if (game_view_size == size)
- return;
-
- game_view_size = size;
-
- flow_box.forall ((child) => {
- var flow_box_child = child as Gtk.FlowBoxChild;
-
- assert (flow_box_child != null);
-
- var game_view = flow_box_child.get_child () as GameIconView;
-
- assert (game_view != null);
-
- game_view.width_request = size;
- });
+ get_style_context ().add_class ("large");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]