From 2aaba383e4f199c8b337131fcab45bdc3bd789d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 9 Jan 2026 09:35:43 -0800 Subject: [PATCH 1/2] Wallpaper: create wallpaper list model --- src/Views/Wallpaper.vala | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index f836959bc..b1f2e4946 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -28,6 +28,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { private Gtk.ComboBoxText combo; private Gtk.ColorButton color_button; + private GLib.ListStore wallpaper_model; private WallpaperContainer active_wallpaper = null; private SolidColorContainer solid_color = null; private WallpaperContainer wallpaper_for_removal = null; @@ -53,6 +54,8 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { construct { var drop_target = new Gtk.DropTarget (typeof (Gdk.FileList), Gdk.DragAction.COPY); + wallpaper_model = new GLib.ListStore (typeof (WallpaperContainer)); + wallpaper_view = new Gtk.FlowBox () { activate_on_single_click = true, homogeneous = true, @@ -60,6 +63,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { min_children_per_line = 3, max_children_per_line = 5 }; + wallpaper_view.bind_model (wallpaper_model, create_widget_func); wallpaper_view.add_css_class (Granite.STYLE_CLASS_VIEW); wallpaper_view.child_activated.connect (update_checked_wallpaper); wallpaper_view.set_sort_func (wallpapers_sort_function); @@ -120,6 +124,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 show_wallpaper_chooser () { var filter = new Gtk.FileFilter (); filter.add_mime_type ("image/*"); @@ -220,7 +228,9 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { if (finished) { set_combo_disabled_if_necessary (); create_solid_color_container (color_button.rgba.to_string ()); - wallpaper_view.append (solid_color); + + wallpaper_model.append (solid_color); + wallpaper_view.select_child (solid_color); if (active_wallpaper != null) { @@ -324,7 +334,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { if (toplevel_folder) { create_solid_color_container (color_button.rgba.to_string ()); - wallpaper_view.append (solid_color); + wallpaper_model.append (solid_color); finished = true; if (gnome_background_settings.get_string ("picture-options") == "none") { @@ -349,7 +359,12 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { private void create_solid_color_container (string color) { if (solid_color != null) { wallpaper_view.unselect_child (solid_color); - wallpaper_view.remove (solid_color); + + uint pos = -1; + if (wallpaper_model.find (solid_color, out pos)) { + wallpaper_model.remove (pos); + } + solid_color.destroy (); } @@ -357,10 +372,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } private void clean_wallpapers () { - while (wallpaper_view.get_first_child () != null) { - wallpaper_view.remove (wallpaper_view.get_first_child ()); - } - + wallpaper_model.remove_all (); solid_color = null; } @@ -391,7 +403,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_view.append (wallpaper); + wallpaper_model.append (wallpaper); wallpaper.trash.connect (() => { send_undo_toast (); @@ -486,8 +498,11 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } private void mark_for_removal (WallpaperContainer wallpaper) { - wallpaper_view.remove (wallpaper); - wallpaper_for_removal = wallpaper; + uint pos = -1; + if (wallpaper_model.find (wallpaper, out pos)) { + wallpaper_model.remove (pos); + wallpaper_for_removal = wallpaper; + } } public void confirm_removal () { @@ -502,7 +517,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } private void undo_removal () { - wallpaper_view.append (wallpaper_for_removal); + wallpaper_model.append (wallpaper_for_removal); wallpaper_for_removal = null; } } From 6746fd5d3ecf2086755f77b9db2a6ecba3bd1425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 9 Jan 2026 09:39:03 -0800 Subject: [PATCH 2/2] Wallpaper: sort in model, not flowbox --- src/Views/Wallpaper.vala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Views/Wallpaper.vala b/src/Views/Wallpaper.vala index b1f2e4946..e0a379156 100644 --- a/src/Views/Wallpaper.vala +++ b/src/Views/Wallpaper.vala @@ -66,7 +66,6 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { wallpaper_view.bind_model (wallpaper_model, create_widget_func); wallpaper_view.add_css_class (Granite.STYLE_CLASS_VIEW); wallpaper_view.child_activated.connect (update_checked_wallpaper); - wallpaper_view.set_sort_func (wallpapers_sort_function); wallpaper_view.add_controller (drop_target); var color = gnome_background_settings.get_string ("primary-color"); @@ -229,7 +228,7 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { set_combo_disabled_if_necessary (); create_solid_color_container (color_button.rgba.to_string ()); - wallpaper_model.append (solid_color); + wallpaper_model.insert_sorted (solid_color, wallpapers_sort_function); wallpaper_view.select_child (solid_color); @@ -403,7 +402,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.append (wallpaper); + wallpaper_model.insert_sorted (wallpaper, wallpapers_sort_function); wallpaper.trash.connect (() => { send_undo_toast (); @@ -430,9 +429,9 @@ public class PantheonShell.Wallpaper : Switchboard.SettingsPage { } } - private int wallpapers_sort_function (Gtk.FlowBoxChild _child1, Gtk.FlowBoxChild _child2) { - var child1 = (WallpaperContainer) _child1; - var child2 = (WallpaperContainer) _child2; + private int wallpapers_sort_function (Object object1, Object object2) { + var child1 = (WallpaperContainer) object1; + var child2 = (WallpaperContainer) object2; var uri1 = child1.uri; var uri2 = child2.uri;