From 872e5ff0cd863df58ac64543a34b5bfc64a51fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 9 Jan 2026 09:56:30 -0800 Subject: [PATCH 1/5] Use GtkSelection --- src/Views/Wallpaper.vala | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index e0a37915..3eff0cc0 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -23,12 +23,12 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { private static GLib.Settings gnome_background_settings; private Gtk.ScrolledWindow wallpaper_scrolled_window; - private Gtk.FlowBox wallpaper_view; private Gtk.Overlay view_overlay; private Gtk.ComboBoxText combo; private Gtk.ColorButton color_button; private GLib.ListStore wallpaper_model; + private Gtk.SingleSelection wallpaper_selection; private WallpaperContainer active_wallpaper = null; private SolidColorContainer solid_color = null; private WallpaperContainer wallpaper_for_removal = null; @@ -56,14 +56,16 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { wallpaper_model = new GLib.ListStore (typeof (WallpaperContainer)); - wallpaper_view = new Gtk.FlowBox () { + wallpaper_selection = new Gtk.SingleSelection (wallpaper_model); + + var wallpaper_view = new Gtk.FlowBox () { activate_on_single_click = true, homogeneous = true, selection_mode = SINGLE, min_children_per_line = 3, max_children_per_line = 5 }; - wallpaper_view.bind_model (wallpaper_model, create_widget_func); + wallpaper_view.bind_model (wallpaper_selection, create_widget_func); wallpaper_view.add_css_class (Granite.STYLE_CLASS_VIEW); wallpaper_view.child_activated.connect (update_checked_wallpaper); wallpaper_view.add_controller (drop_target); @@ -195,7 +197,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } private void update_checked_wallpaper (Gtk.FlowBox box, Gtk.FlowBoxChild child) { - var children = (WallpaperContainer) wallpaper_view.get_selected_children ().data; + var children = (WallpaperContainer) wallpaper_selection.get_selected_item (); if (!(children is SolidColorContainer)) { current_wallpaper_path = children.uri; @@ -228,9 +230,8 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { set_combo_disabled_if_necessary (); create_solid_color_container (color_button.rgba.to_string ()); - wallpaper_model.insert_sorted (solid_color, wallpapers_sort_function); - - wallpaper_view.select_child (solid_color); + var pos = wallpaper_model.insert_sorted (solid_color, wallpapers_sort_function); + wallpaper_selection.set_selected (pos); if (active_wallpaper != null) { active_wallpaper.checked = false; @@ -251,17 +252,17 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { if (active_wallpaper == solid_color) { active_wallpaper.checked = false; - var child = wallpaper_view.get_first_child (); - while (child != null) { + var child = wallpaper_selection.get_item (0); + for (var pos = 0; child != null; pos++) { var container = (WallpaperContainer) child; if (container.uri == current_wallpaper_path) { container.checked = true; - wallpaper_view.select_child (container); + wallpaper_selection.set_selected (pos); active_wallpaper = container; break; } - child = child.get_next_sibling (); + child = wallpaper_selection.get_item (pos); } } } else { @@ -337,9 +338,12 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { finished = true; if (gnome_background_settings.get_string ("picture-options") == "none") { - wallpaper_view.select_child (solid_color); - solid_color.checked = true; - active_wallpaper = solid_color; + uint pos = -1; + if (wallpaper_model.find (solid_color, out pos)) { + wallpaper_selection.set_selected (pos); + solid_color.checked = true; + active_wallpaper = solid_color; + } } if (active_wallpaper != null) { @@ -356,14 +360,9 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } private void create_solid_color_container (string color) { - if (solid_color != null) { - wallpaper_view.unselect_child (solid_color); - - uint pos = -1; - if (wallpaper_model.find (solid_color, out pos)) { - wallpaper_model.remove (pos); - } - + uint pos = -1; + if (solid_color != null && wallpaper_model.find (solid_color, out pos)) { + wallpaper_model.remove (pos); solid_color.destroy (); } @@ -402,7 +401,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { var thumb_path = info.get_attribute_as_string (FileAttribute.THUMBNAIL_PATH); var thumb_valid = info.get_attribute_boolean (FileAttribute.THUMBNAIL_IS_VALID); var wallpaper = new WallpaperContainer (uri, thumb_path, thumb_valid); - wallpaper_model.insert_sorted (wallpaper, wallpapers_sort_function); + var pos = wallpaper_model.insert_sorted (wallpaper, wallpapers_sort_function); wallpaper.trash.connect (() => { send_undo_toast (); @@ -411,7 +410,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { // Select the wallpaper if it is the current wallpaper if (current_wallpaper_path.has_suffix (uri) && gnome_background_settings.get_string ("picture-options") != "none") { - this.wallpaper_view.select_child (wallpaper); + wallpaper_selection.set_selected (pos); // Set the widget activated without activating it wallpaper.checked = true; active_wallpaper = wallpaper; @@ -419,8 +418,6 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } catch (Error e) { critical ("Unable to add wallpaper: %s", e.message); } - - wallpaper_view.invalidate_sort (); } public void cancel_thumbnail_generation () { From 34c59dfc5b7011c6cd6e91527de3249323d23a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 9 Jan 2026 10:05:53 -0800 Subject: [PATCH 2/5] Use Gtk.GridView --- src/Views/Wallpaper.vala | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index 3eff0cc0..7e26035b 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -58,18 +58,18 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { wallpaper_selection = new Gtk.SingleSelection (wallpaper_model); - var wallpaper_view = new Gtk.FlowBox () { - activate_on_single_click = true, - homogeneous = true, - selection_mode = SINGLE, - min_children_per_line = 3, - max_children_per_line = 5 + var factory = new Gtk.SignalListItemFactory (); + factory.bind.connect (on_bind); + + var wallpaper_view = new Gtk.GridView (wallpaper_selection, factory) { + min_columns = 3, + max_columns = 5, + single_click_activate = true }; - wallpaper_view.bind_model (wallpaper_selection, create_widget_func); - wallpaper_view.add_css_class (Granite.STYLE_CLASS_VIEW); - wallpaper_view.child_activated.connect (update_checked_wallpaper); + wallpaper_view.activate.connect (update_checked_wallpaper); wallpaper_view.add_controller (drop_target); + var color = gnome_background_settings.get_string ("primary-color"); create_solid_color_container (color); @@ -125,8 +125,10 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { drop_target.drop.connect (on_drag_data_received); } - private Gtk.Widget create_widget_func (Object object) { - return (WallpaperContainer) object; + private void on_bind (Object obj) { + var list_item = (Gtk.ListItem) obj; + var wallpaper_container = (WallpaperContainer) list_item.item; + list_item.child = wallpaper_container; } private void show_wallpaper_chooser () { @@ -196,8 +198,8 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { gnome_background_settings.set_string ("picture-uri-dark", ""); } - private void update_checked_wallpaper (Gtk.FlowBox box, Gtk.FlowBoxChild child) { - var children = (WallpaperContainer) wallpaper_selection.get_selected_item (); + private void update_checked_wallpaper (uint position) { + var children = (WallpaperContainer) wallpaper_selection.get_item (position); if (!(children is SolidColorContainer)) { current_wallpaper_path = children.uri; From 937857ea334941d346bb02b59efe64cb0fb1b8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 13 Jan 2026 11:27:55 -0800 Subject: [PATCH 3/5] Replace deprecated allocation --- src/Views/Wallpaper.vala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index 7e26035b..0b296192 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -28,6 +28,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { private Gtk.ColorButton color_button; private GLib.ListStore wallpaper_model; + private Gtk.GridView wallpaper_view; private Gtk.SingleSelection wallpaper_selection; private WallpaperContainer active_wallpaper = null; private SolidColorContainer solid_color = null; @@ -61,7 +62,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { var factory = new Gtk.SignalListItemFactory (); factory.bind.connect (on_bind); - var wallpaper_view = new Gtk.GridView (wallpaper_selection, factory) { + wallpaper_view = new Gtk.GridView (wallpaper_selection, factory) { min_columns = 3, max_columns = 5, single_click_activate = true @@ -348,10 +349,9 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } } - if (active_wallpaper != null) { - Gtk.Allocation alloc; - active_wallpaper.get_allocation (out alloc); - wallpaper_scrolled_window.get_vadjustment ().value = alloc.y; + uint pos = -1; + if (active_wallpaper != null && wallpaper_model.find (active_wallpaper, out pos)) { + wallpaper_view.scroll_to (pos, NONE, null); } } } catch (Error err) { From 21dbbfffad73bcffb13912e726dd0d234b853528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 13 Jan 2026 11:35:33 -0800 Subject: [PATCH 4/5] Fix margins --- data/plug.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/plug.css b/data/plug.css index 9e485f6f..528d65f6 100644 --- a/data/plug.css +++ b/data/plug.css @@ -53,9 +53,9 @@ background-position: calc(100% + 24px) calc(100% + 24px), 0; } -.wallpaper-container { - background-color: transparent; +gridview child { margin: 1em; + border-radius: 0.75em; } .wallpaper-container picture { From 777e89ca71fd3d63683e81207fbbd03ed4052494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 14 Jan 2026 09:50:26 -0800 Subject: [PATCH 5/5] use aspect frame --- data/plug.css | 2 +- src/Views/Wallpaper.vala | 8 +++----- src/Widgets/WallpaperContainer.vala | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/data/plug.css b/data/plug.css index 47450fb0..5b65d8cf 100644 --- a/data/plug.css +++ b/data/plug.css @@ -55,7 +55,7 @@ .wallpaper gridview child { border-radius: 0.75em; - margin: 1em; + margin: 0.5em; } .wallpaper gridview child picture { diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index ef0a2a5f..23e94d64 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -22,13 +22,12 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { private static GLib.Settings gnome_background_settings; - private Gtk.ScrolledWindow wallpaper_scrolled_window; + private Gtk.GridView wallpaper_view; private Gtk.Overlay view_overlay; private Gtk.ComboBoxText combo; private Gtk.ColorButton color_button; private GLib.ListStore wallpaper_model; - private Gtk.GridView wallpaper_view; private Gtk.SingleSelection wallpaper_selection; private WallpaperContainer active_wallpaper = null; private SolidColorContainer solid_color = null; @@ -63,18 +62,16 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { factory.bind.connect (on_bind); wallpaper_view = new Gtk.GridView (wallpaper_selection, factory) { - min_columns = 3, max_columns = 5, single_click_activate = true }; wallpaper_view.activate.connect (update_checked_wallpaper); wallpaper_view.add_controller (drop_target); - var color = gnome_background_settings.get_string ("primary-color"); create_solid_color_container (color); - wallpaper_scrolled_window = new Gtk.ScrolledWindow () { + var wallpaper_scrolled_window = new Gtk.ScrolledWindow () { child = wallpaper_view, hscrollbar_policy = NEVER, hexpand = true, @@ -237,6 +234,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { create_solid_color_container (color_button.rgba.to_string ()); var pos = wallpaper_model.insert_sorted (solid_color, wallpapers_sort_function); + wallpaper_selection.set_selected (pos); if (active_wallpaper != null) { diff --git a/src/Widgets/WallpaperContainer.vala b/src/Widgets/WallpaperContainer.vala index 90da0452..9e4a5b38 100644 --- a/src/Widgets/WallpaperContainer.vala +++ b/src/Widgets/WallpaperContainer.vala @@ -25,7 +25,8 @@ public class PantheonShell.WallpaperContainer : Granite.Bin { protected const int THUMB_HEIGHT = 144; protected Gtk.Picture image; - private Gtk.Box card_box; + private static float monitor_ratio; + private Gtk.Revealer check_revealer; public string? thumb_path { get; construct set; } @@ -53,10 +54,18 @@ public class PantheonShell.WallpaperContainer : Granite.Bin { Object (uri: uri, thumb_path: thumb_path, thumb_valid: thumb_valid); } + static construct { + var monitor = Gdk.Display.get_default ().get_monitor_at_surface ( + (((Gtk.Application) Application.get_default ()).active_window).get_surface () + ); + + monitor_ratio = (float) monitor.geometry.width / monitor.geometry.height; + } + construct { image = new Gtk.Picture () { - content_fit = COVER, - height_request = THUMB_HEIGHT + can_shrink = false, + content_fit = COVER }; image.add_css_class (Granite.CssClass.CARD); @@ -78,10 +87,12 @@ public class PantheonShell.WallpaperContainer : Granite.Bin { }; overlay.add_overlay (check_revealer); - halign = CENTER; - valign = CENTER; + var frame = new Gtk.AspectFrame (0.5f, 0.5f, monitor_ratio, false) { + child = overlay + }; - child = overlay; + child = frame; + height_request = THUMB_HEIGHT; if (uri != null) { var remove_wallpaper_action = new SimpleAction ("trash", null);