Skip to content

Commit 34c59df

Browse files
committed
Use Gtk.GridView
1 parent 872e5ff commit 34c59df

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

src/Views/Wallpaper.vala

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage {
5858

5959
wallpaper_selection = new Gtk.SingleSelection (wallpaper_model);
6060

61-
var wallpaper_view = new Gtk.FlowBox () {
62-
activate_on_single_click = true,
63-
homogeneous = true,
64-
selection_mode = SINGLE,
65-
min_children_per_line = 3,
66-
max_children_per_line = 5
61+
var factory = new Gtk.SignalListItemFactory ();
62+
factory.bind.connect (on_bind);
63+
64+
var wallpaper_view = new Gtk.GridView (wallpaper_selection, factory) {
65+
min_columns = 3,
66+
max_columns = 5,
67+
single_click_activate = true
6768
};
68-
wallpaper_view.bind_model (wallpaper_selection, create_widget_func);
69-
wallpaper_view.add_css_class (Granite.STYLE_CLASS_VIEW);
70-
wallpaper_view.child_activated.connect (update_checked_wallpaper);
69+
wallpaper_view.activate.connect (update_checked_wallpaper);
7170
wallpaper_view.add_controller (drop_target);
7271

72+
7373
var color = gnome_background_settings.get_string ("primary-color");
7474
create_solid_color_container (color);
7575

@@ -125,8 +125,10 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage {
125125
drop_target.drop.connect (on_drag_data_received);
126126
}
127127

128-
private Gtk.Widget create_widget_func (Object object) {
129-
return (WallpaperContainer) object;
128+
private void on_bind (Object obj) {
129+
var list_item = (Gtk.ListItem) obj;
130+
var wallpaper_container = (WallpaperContainer) list_item.item;
131+
list_item.child = wallpaper_container;
130132
}
131133

132134
private void show_wallpaper_chooser () {
@@ -196,8 +198,8 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage {
196198
gnome_background_settings.set_string ("picture-uri-dark", "");
197199
}
198200

199-
private void update_checked_wallpaper (Gtk.FlowBox box, Gtk.FlowBoxChild child) {
200-
var children = (WallpaperContainer) wallpaper_selection.get_selected_item ();
201+
private void update_checked_wallpaper (uint position) {
202+
var children = (WallpaperContainer) wallpaper_selection.get_item (position);
201203

202204
if (!(children is SolidColorContainer)) {
203205
current_wallpaper_path = children.uri;

0 commit comments

Comments
 (0)