From 9d9fc0fe1f2a48630f09af7fe6c76babfb7a09b5 Mon Sep 17 00:00:00 2001 From: lainsce Date: Wed, 21 Aug 2024 00:03:01 -0300 Subject: [PATCH] Fix selected wallpaper accent + mode --- fuses/appearance/Views/AppearanceView.vala | 27 ++++++++++++++-------- fuses/appearance/Widgets/EnsorFlowBox.vala | 12 ++++++---- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/fuses/appearance/Views/AppearanceView.vala b/fuses/appearance/Views/AppearanceView.vala index 717d2a3..bd0b739 100644 --- a/fuses/appearance/Views/AppearanceView.vala +++ b/fuses/appearance/Views/AppearanceView.vala @@ -22,6 +22,7 @@ public class AppearanceView : Gtk.Box { private AccentColorButton purple; private AccentColorButton red; private AccentColorButton yellow; + private EnsorFlowBox ensor_flowbox; public Gtk.ScrolledWindow sw; public Gtk.Stack contrast_stack; @@ -76,14 +77,14 @@ public class AppearanceView : Gtk.Box { // XXX: UNCOMMENT WHEN KIRI LOCK SCREEN IS IMPL'D // // var edit_button = new He.Button ("document-edit-symbolic", "") { - // hexpand = true, - // vexpand = true, - // halign = Gtk.Align.END, - // valign = Gtk.Align.END, - // margin_end = 12, - // margin_bottom = 12, - // is_disclosure = true, - // tooltip_text = _("Customize Lock Screen…") + // hexpand = true, + // vexpand = true, + // halign = Gtk.Align.END, + // valign = Gtk.Align.END, + // margin_end = 12, + // margin_bottom = 12, + // is_disclosure = true, + // tooltip_text = _("Customize Lock Screen…") // }; // var wallpaper_lock_button_overlay = new Gtk.Overlay (); @@ -284,6 +285,9 @@ public class AppearanceView : Gtk.Box { fusebox_appearance_settings.set_boolean ("wallpaper-accent", true); accent_box.sensitive = false; + var sel = fusebox_appearance_settings.get_int ("wallpaper-accent-choice"); + ensor_flowbox.flowbox.select_child (ensor_flowbox.flowbox.get_child_at_index (sel)); + multi.set_active (false); red.set_active (false); yellow.set_active (false); @@ -481,12 +485,15 @@ public class AppearanceView : Gtk.Box { int[] argb_ints = {}; for (int i = 0; i < result.length; i++) { - var value = result.index(i); + var value = result.index (i); if (value != null) { argb_ints += value; } - var ensor_flowbox = new EnsorFlowBox (argb_ints); + ensor_flowbox = new EnsorFlowBox (argb_ints); + + var sel = fusebox_appearance_settings.get_int ("wallpaper-accent-choice"); + ensor_flowbox.flowbox.select_child (ensor_flowbox.flowbox.get_child_at_index (sel)); color_sw.set_child (ensor_flowbox); } diff --git a/fuses/appearance/Widgets/EnsorFlowBox.vala b/fuses/appearance/Widgets/EnsorFlowBox.vala index f9ae5cb..5f6aa47 100644 --- a/fuses/appearance/Widgets/EnsorFlowBox.vala +++ b/fuses/appearance/Widgets/EnsorFlowBox.vala @@ -1,5 +1,5 @@ public class EnsorFlowBox : He.Bin { - private Gtk.FlowBox flowbox; + public Gtk.FlowBox flowbox; public int current_selection; private static GLib.Settings tau_appearance_settings; @@ -25,9 +25,6 @@ public class EnsorFlowBox : He.Bin { flowbox.add_css_class ("ensor-box"); flowbox.child_activated.connect (child_activated_cb); - var sel = fusebox_appearance_settings.get_int ("wallpaper-accent-choice"); - flowbox.select_child (flowbox.get_child_at_index ((sel < 0 || sel > (color.length * 4)) ? 0 : sel)); - for (int i = 0; i < color.length; i++) { make_ensor_set (color[i]); } @@ -35,6 +32,11 @@ public class EnsorFlowBox : He.Bin { this.child = flowbox; } + construct { + var sel = fusebox_appearance_settings.get_int ("wallpaper-accent-choice"); + flowbox.select_child (flowbox.get_child_at_index (sel)); + } + private void child_activated_cb (Gtk.FlowBoxChild child) { var ensor_mode = ((EnsorModeButton) child.get_first_child ()).mode; var ensor_color = ((EnsorModeButton) child.get_first_child ()).colors[0]; @@ -64,4 +66,4 @@ public class EnsorFlowBox : He.Bin { flowbox.append (vibrant); flowbox.append (salad); } -} \ No newline at end of file +}