From 4c67c4bd772e99ba5098939626b1815616e3cb76 Mon Sep 17 00:00:00 2001 From: lainsce Date: Mon, 19 Aug 2024 14:21:03 -0300 Subject: [PATCH] This ought be a good stopping point --- fuses/appearance/AppearanceView.vala | 61 ++++++------------- fuses/appearance/Widgets/EnsorFlowBox.vala | 52 ++++++++++++++++ .../{Utils => Widgets}/EnsorModeButton.vala | 0 fuses/appearance/meson.build | 3 +- 4 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 fuses/appearance/Widgets/EnsorFlowBox.vala rename fuses/appearance/{Utils => Widgets}/EnsorModeButton.vala (100%) diff --git a/fuses/appearance/AppearanceView.vala b/fuses/appearance/AppearanceView.vala index ff08e47..b2344ea 100644 --- a/fuses/appearance/AppearanceView.vala +++ b/fuses/appearance/AppearanceView.vala @@ -11,7 +11,6 @@ public class AppearanceView : Gtk.Box { private Gtk.CheckButton prefer_dark_radio; private Gtk.CheckButton prefer_default_radio; private Gtk.CheckButton prefer_light_radio; - private Gtk.FlowBoxChild current_emb; private Gtk.Stack color_stack; private Gtk.ToggleButton basic_type_button; private He.SegmentedButton color_type_button; @@ -198,7 +197,7 @@ public class AppearanceView : Gtk.Box { accent_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12) { halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER, + valign = Gtk.Align.START, homogeneous = true, hexpand = true }; @@ -234,14 +233,17 @@ public class AppearanceView : Gtk.Box { carousel_box.append (color_carousel); carousel_box.append (color_carousel_dots); - color_stack = new Gtk.Stack (); + color_stack = new Gtk.Stack () { + transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT, + transition_duration = 400 + }; color_stack.add_titled (accent_box, "basic", "Basic Colors"); color_stack.add_titled (carousel_box, "wallpaper", "Wallpaper Colors"); if (wallpaper_type_button.active) { color_stack.set_visible_child_name ("wallpaper"); - accent_setup.begin (); accent_box.sensitive = false; + accent_setup.begin (); multi.set_active (false); red.set_active (false); @@ -263,7 +265,6 @@ public class AppearanceView : Gtk.Box { wallpaper_type_button.toggled.connect (() => { color_stack.set_visible_child_name ("wallpaper"); fusebox_appearance_settings.set_boolean ("wallpaper-accent", true); - accent_setup.begin (); accent_box.sensitive = false; multi.set_active (false); @@ -275,10 +276,6 @@ public class AppearanceView : Gtk.Box { pink.set_active (false); }); - tau_appearance_settings.notify["changed::accent-color"].connect (() => { - accent_setup.begin (); - }); - // Contrast Block var contrast_label = new Gtk.Label (_("Contrast Settings")) { halign = Gtk.Align.START, @@ -451,6 +448,8 @@ public class AppearanceView : Gtk.Box { He.Ensor.accent_from_pixels_async.begin (pixbuf.get_pixels_with_length (), pixbuf.get_has_alpha (), (obj, res) => { GLib.Array result = He.Ensor.accent_from_pixels_async.end (res); + int[] argb_ints = new int[3]; // We're only interested in 4 colors. + for (int i = 0; i == color_carousel.get_n_pages(); i++) { color_carousel.remove (color_carousel.get_nth_page(i)); } @@ -458,43 +457,19 @@ public class AppearanceView : Gtk.Box { for (int i = 0; i < result.length; i++) { var value = result.index(i); if (value != null) { - var defavlt = new Gtk.FlowBoxChild (); - defavlt.child = new EnsorModeButton (value, "default"); - defavlt.tooltip_text = _("Default Scheme"); - var muted = new Gtk.FlowBoxChild (); - muted.child = new EnsorModeButton (value, "muted"); - muted.tooltip_text = _("Muted Scheme"); - var vibrant = new Gtk.FlowBoxChild (); - vibrant.child = new EnsorModeButton (value, "vibrant"); - vibrant.tooltip_text = _("Vibrant Scheme"); - var salad = new Gtk.FlowBoxChild (); - salad.child = new EnsorModeButton (value, "salad"); - salad.tooltip_text = _("Fruit Salad Scheme"); - - var ensor_flowbox = new Gtk.FlowBox () { - hexpand = true, - halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER, - column_spacing = 12, - homogeneous = true, - min_children_per_line = 4, - max_children_per_line = 4 - }; - ensor_flowbox.add_css_class ("ensor-box"); - ensor_flowbox.append (defavlt); - ensor_flowbox.append (muted); - ensor_flowbox.append (vibrant); - ensor_flowbox.append (salad); - ensor_flowbox.child_activated.connect ((c) => { - var ensor = ((EnsorModeButton)c.get_first_child ()).mode; - tau_appearance_settings.set_string ("ensor-scheme", ensor); - tau_appearance_settings.set_string ("accent-color", He.hexcode_argb (value)); - }); - - color_carousel.append (ensor_flowbox); + argb_ints[i] = value; } } + var ensor_flowbox1 = new EnsorFlowBox (argb_ints[0]); + var ensor_flowbox2 = new EnsorFlowBox (argb_ints[1]); + var ensor_flowbox3 = new EnsorFlowBox (argb_ints[2]); + var ensor_flowbox4 = new EnsorFlowBox (argb_ints[3]); + color_carousel.append (ensor_flowbox1); + color_carousel.append (ensor_flowbox2); + color_carousel.append (ensor_flowbox3); + color_carousel.append (ensor_flowbox4); + loop.quit (); }); loop.run (); diff --git a/fuses/appearance/Widgets/EnsorFlowBox.vala b/fuses/appearance/Widgets/EnsorFlowBox.vala new file mode 100644 index 0000000..a6b1040 --- /dev/null +++ b/fuses/appearance/Widgets/EnsorFlowBox.vala @@ -0,0 +1,52 @@ +public class EnsorFlowBox : He.Bin { + private int color; + + private static GLib.Settings tau_appearance_settings; + + public EnsorFlowBox (int color) { + this.color = color; + } + + static construct { + tau_appearance_settings = new GLib.Settings ("com.fyralabs.desktop.appearance"); + } + + construct { + var defavlt = new Gtk.FlowBoxChild (); + defavlt.child = new EnsorModeButton (color, "default"); + defavlt.tooltip_text = _("Default Scheme"); + var muted = new Gtk.FlowBoxChild (); + muted.child = new EnsorModeButton (color, "muted"); + muted.tooltip_text = _("Muted Scheme"); + var vibrant = new Gtk.FlowBoxChild (); + vibrant.child = new EnsorModeButton (color, "vibrant"); + vibrant.tooltip_text = _("Vibrant Scheme"); + var salad = new Gtk.FlowBoxChild (); + salad.child = new EnsorModeButton (color, "salad"); + salad.tooltip_text = _("Fruit Salad Scheme"); + + var flowbox = new Gtk.FlowBox () { + hexpand = true, + halign = Gtk.Align.CENTER, + valign = Gtk.Align.CENTER, + column_spacing = 12, + homogeneous = true, + min_children_per_line = 1, + max_children_per_line = 4, + margin_start = 6, + margin_end = 6 + }; + flowbox.add_css_class ("ensor-box"); + flowbox.append (defavlt); + flowbox.append (muted); + flowbox.append (vibrant); + flowbox.append (salad); + flowbox.child_activated.connect ((flowboxchild) => { + var ensor = ((EnsorModeButton)flowboxchild.get_first_child ()).mode; + tau_appearance_settings.set_string ("ensor-scheme", ensor); + tau_appearance_settings.set_string ("accent-color", He.hexcode_argb (color)); + }); + + this.child = flowbox; + } +} \ No newline at end of file diff --git a/fuses/appearance/Utils/EnsorModeButton.vala b/fuses/appearance/Widgets/EnsorModeButton.vala similarity index 100% rename from fuses/appearance/Utils/EnsorModeButton.vala rename to fuses/appearance/Widgets/EnsorModeButton.vala diff --git a/fuses/appearance/meson.build b/fuses/appearance/meson.build index 157dd9d..0e91c04 100644 --- a/fuses/appearance/meson.build +++ b/fuses/appearance/meson.build @@ -6,7 +6,8 @@ fuse_files = files( 'TextView.vala', 'WindowView.vala', 'Utils/ColorGenerator.vala', - 'Utils/EnsorModeButton.vala', + 'Widgets/EnsorModeButton.vala', + 'Widgets/EnsorFlowBox.vala', # 'DockView.vala', )