From 9e67dfb80bf976812fc218197b927596f66a1b15 Mon Sep 17 00:00:00 2001 From: teamcons Date: Sun, 26 Jan 2025 20:59:41 +0100 Subject: [PATCH] some solid cleanup --- data/Application.css | 113 +++++++++++--- meson.build | 5 +- po/POTFILES | 1 + src/Application.vala | 7 +- src/MainWindow.vala | 234 ++++------------------------ src/Services/Themer.vala | 14 +- src/Services/Utils.vala | 59 ++++++++ src/Widgets/ColorPill.vala | 34 +++++ src/Widgets/ColorPillButton.vala | 11 -- src/Widgets/SettingsPopover.vala | 251 +++++++++++++++++++++++++++++++ 10 files changed, 477 insertions(+), 252 deletions(-) create mode 100644 src/Services/Utils.vala create mode 100644 src/Widgets/ColorPill.vala delete mode 100644 src/Widgets/ColorPillButton.vala create mode 100644 src/Widgets/SettingsPopover.vala diff --git a/data/Application.css b/data/Application.css index 1a07d97..12d8319 100644 --- a/data/Application.css +++ b/data/Application.css @@ -3,13 +3,12 @@ * SPDX-FileCopyrightText: 2025 Stella, whose hairs are shiny and soft. (https://teamcons.carrd.co) */ - @define-color textColorPrimary #323232; +@define-color MainColor @BLUEBERRY_100; +@define-color SecondaryColor @BLUEBERRY_900; /* TODO : These only exist to colour the "pills" to select theme. This needs a fixing */ - - .color-strawberry { background-color: @STRAWBERRY_100; } @@ -48,14 +47,96 @@ -/* Idk wth this is */ + + +/* These are the colored pills to select theme */ +.color-button { + border-radius: 50%; + background-image: none; + border: 1px solid alpha(#333, 0.25); + box-shadow: + inset 0 1px 0 0 alpha (@inset_dark_color, 0.7), + inset 0 0 0 1px alpha (@inset_dark_color, 0.3), + 0 1px 0 0 alpha (@bg_highlight_color, 0.3); +} + +.color-button:hover, +.color_button:focus { + border: 1px solid @inset_dark_color; +} + + +.window { + background-color: @MainColor; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); +} + +.window undershoot.top { + background: + linear-gradient( + @MainColor 0%, + alpha(@MainColor, 0) 50% + ); +} + +.window undershoot.bottom { + background: + linear-gradient( + alpha(@MainColor, 0) 50%, + @MainColor 100% + ); +} + +.jorts-view text selection { + color: shade(@MainColor, 1.88); + background-color: @SecondaryColor; + transition: color 800ms cubic-bezier(0.4, 0, 0.2, 1); + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); +} + entry.flat { background: transparent; } +.window .jorts-title image, +.window .jorts-label { + color: @SecondaryColor; + box-shadow: none; +} + +.window .jorts-bar { + color: @SecondaryColor; + background-color: @MainColor; + border-top-color: @SecondaryColor; + box-shadow: none; + background-image: none; + padding: 3px; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); + transition: color 800ms cubic-bezier(0.4, 0, 0.2, 1); +} + +.window .jorts-bar image { + color: @SecondaryColor; + padding: 3px; + box-shadow: none; + background-image: none; +} + +.window .jorts-view, +.window .jorts-view text, +.window .jorts-title { + background-color: @MainColor; + background-image: none; + border-bottom-color: @SecondaryColor; + font-weight: 500; + font-size: 1.2em; + color: shade(@SecondaryColor, 0.77); + box-shadow: none; +} + + -/* These are the various buttons in the interface */ .image-button, .titlebutton { background-color: transparent; @@ -75,6 +156,7 @@ entry.flat { box-shadow: none; } + /* This is the EditableLabel */ .jorts-label { font-weight: 700; @@ -82,27 +164,10 @@ entry.flat { } .jorts-label:backdrop { - color: mix (@textColorPrimary, @colorPrimary, 0.3); + color: mix (@textColorPrimary, @SecondaryColor, 0.3); + transition: color 800ms cubic-bezier(0.4, 0, 0.2, 1); } .jorts-bar box { border: none; } - - - -/* These are the colored pills to select theme */ -.color-button { - border-radius: 50%; - background-image: none; - border: 1px solid alpha(#333, 0.25); - box-shadow: - inset 0 1px 0 0 alpha (@inset_dark_color, 0.7), - inset 0 0 0 1px alpha (@inset_dark_color, 0.3), - 0 1px 0 0 alpha (@bg_highlight_color, 0.3); -} - -.color-button:hover, -.color_button:focus { - border: 1px solid @inset_dark_color; -} diff --git a/meson.build b/meson.build index fe5e88c..ebd4e08 100644 --- a/meson.build +++ b/meson.build @@ -56,12 +56,13 @@ cc = meson.get_compiler('c') executable( meson.project_name(), gresource, - 'src/Application.vala', - 'src/MainWindow.vala', 'src/Widgets/EditableLabel.vala', 'src/Services/NoteManager.vala', 'src/Services/Storage.vala', 'src/Services/Themer.vala', + 'src/Services/Utils.vala', + 'src/Application.vala', + 'src/MainWindow.vala', c_args: c_args, dependencies: [ dependency('granite'), diff --git a/po/POTFILES b/po/POTFILES index a1b97b3..dcbcb85 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -4,3 +4,4 @@ src/Services/NoteManager.vala src/Services/Storage.vala src/Widgets/ColorButton.vala src/Widgets/EditableLabel.vala +src/Services/Utils.vala diff --git a/src/Application.vala b/src/Application.vala index 157231c..5d072f9 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -60,9 +60,6 @@ namespace jorts { } protected override void activate () { - var provider = new Gtk.CssProvider (); - provider.load_from_resource ("/io/github/ellie_commons/jorts/Application.css"); - if (get_windows ().length () > 0) { foreach (var window in open_notes) { if (window.visible) { @@ -85,7 +82,7 @@ namespace jorts { public void create_note(Storage? storage) { debug ("Creating a noteā€¦\n"); - var note = new MainWindow(this,storage); + var note = new MainWindow(this, storage); open_notes.add(note); update_storage(); } @@ -146,4 +143,4 @@ namespace jorts { return app.run(args); } } -} +} \ No newline at end of file diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 87e5183..56bd344 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -57,6 +57,8 @@ namespace jorts { public MainWindow (Gtk.Application app, Storage? storage) { Object (application: app); + print(this.uid.to_string()); + var actions = new SimpleActionGroup (); actions.add_action_entries (action_entries, this); insert_action_group ("win", actions); @@ -65,27 +67,17 @@ namespace jorts { // Else do a new with theme at random if (storage != null) { init_from_storage(storage); + + } else { - string[] alltitles = { - _("All my very best friends"), - _("My super good secret recipe"), - _("My todo list"), - _("Super secret to not tell anyone"), - _("My grocery list"), - _("Random shower thoughts"), - _("My fav fanfics"), - _("My fav dinosaurs"), - _("My evil mastermind plan")}; - - this.title_name = alltitles[Random.int_range (0,9)]; + this.title_name = jorts.Utils.random_title(); set_title (this.title_name); // First sticky is always blue - signature look! // After that, it is random //if (uid_counter == 0) { - string[] allthemes = {"STRAWBERRY", "ORANGE", "BANANA", "LIME", "BLUEBERRY", "BUBBLEGUM", "GRAPE", "COCOA", "SILVER", "SLATE"}; - this.theme = allthemes[Random.int_range (0,9)]; + this.theme = jorts.Utils.random_theme(); //} else { // this.theme = "BLUEBERRY"; //} @@ -95,6 +87,7 @@ namespace jorts { } // add required base classes + //this.get_style_context().add_class(this.uid.to_string ()); this.get_style_context().add_class("rounded"); this.get_style_context().add_class("default-decoration"); this.get_style_context().add_class("jorts-window"); @@ -201,29 +194,6 @@ namespace jorts { ((Application)this.application).update_storage(); } - // TODO: A theming service or something. Something cleaner than this in all cases - // Basically the menu button defines two public variables - // And then this reconstructs a whole ass theme out of these two - // Either it can be a service, or just all defined in CSS and add/remove css - private void update_theme(string theme) { - var css_provider = new Gtk.CssProvider(); - this.get_style_context().add_class("mainwindow-%d".printf(uid)); - this.get_style_context().add_class("window-%d".printf(uid)); - - string style = generate_css(uid, theme); - - try { - css_provider.load_from_data(style, -1); - } catch (GLib.Error e) { - warning ("Failed to parse css style : %s", e.message); - } - - Gtk.StyleContext.add_provider_for_screen ( - Gdk.Screen.get_default (), - css_provider, - Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION - ); - } @@ -548,187 +518,39 @@ namespace jorts { jorts.Application.gsettings.set_int("window-y", y); return false; } - } - /* Get a name, spit an array with colours from standard granite stylesheet */ - /* EX: STRAWBERRY --> { "@STRAWBERRY_100" "@STRAWBERRY_900" }*/ - public static string[] generate_palette (string theme) { - var string_palette = new string[2]; - string_palette = { - "@" + theme + "_100", - "@" + theme + "_900" - }; - return string_palette; - } - - /* Get a name, spit a whole CSS */ - /* We kinda need better tbh but it is better than before */ - public static string generate_css (int uid, string theme) { - var palette = generate_palette(theme); - string style = ""; - - style = (N_(""" - @define-color textColorPrimary #323232; + // TODO: A theming service or something. Something cleaner than this in all cases + // Basically the menu button defines two public variables + // And then this reconstructs a whole ass theme out of these two + // Either it can be a service, or just all defined in CSS and add/remove css + private void update_theme(string theme) { + this.get_style_context().add_class("mainwindow-%d".printf(uid)); + this.get_style_context().add_class("window-%d".printf(uid)); - .mainwindow-%d { - background-color: %s; - transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); - } + // Palette color + var css_provider = new Gtk.CssProvider(); + var style = jorts.Themer.generate_css(uid,theme); - .mainwindow-%d undershoot.top { - background: - linear-gradient( - %s 0%, - alpha(%s, 0) 50% - ); - } + try { + css_provider.load_from_data(style, -1); - .mainwindow-%d undershoot.bottom { - background: - linear-gradient( - alpha(%s, 0) 50%, - %s 100% - ); - } - - .jorts-view text selection { - color: shade(%s, 1.88); - transition: color 800ms cubic-bezier(0.4, 0, 0.2, 1); - background-color: %s; - transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); - } - - entry.flat { - background: transparent; - } - - .window-%d .jorts-title image, - .window-%d .jorts-label { - color: %s; - box-shadow: none; - } - - .window-%d .jorts-bar { - color: %s; - background-color: %s; - border-top-color: %s; - box-shadow: none; - background-image: none; - padding: 3px; - transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); - } - - .window-%d .jorts-bar image { - color: %s; - padding: 3px; - box-shadow: none; - background-image: none; - } - - .window-%d .jorts-view, - .window-%d .jorts-view text, - .window-%d .jorts-title { - background-color: %s; - transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); - background-image: none; - border-bottom-color: %s; - font-weight: 500; - font-size: 1.2em; - color: shade(%s, 0.77); - box-shadow: none; - } - - .window-%d .rotated > widget > box > image { - -gtk-icon-transform: rotate(90deg); - } - - .color-button { - border-radius: 50%; - background-image: none; - border: 1px solid alpha(#333, 0.25); - box-shadow: - inset 0 1px 0 0 alpha (@inset_dark_color, 0.7), - inset 0 0 0 1px alpha (@inset_dark_color, 0.3), - 0 1px 0 0 alpha (@bg_highlight_color, 0.3); - } - - .color-button:hover, - .color_button:focus { - border: 1px solid @inset_dark_color; - } - - .color-slate { - background-color: @SLATE_100; - } - - .color-silver { - background-color: @SILVER_100; - } - - .color-strawberry { - background-color: @STRAWBERRY_100; - } - - .color-orange { - background-color: @ORANGE_100; - } - - .color-banana { - background-color: @BANANA_100; - } - - .color-lime { - background-color: @LIME_100; - } - - .color-blueberry { - background-color: @BLUEBERRY_100; - } - - .color-grape { - background-color: @GRAPE_100; - } - - .color-cocoa { - background-color: @COCOA_100; - } - - .jorts-bar box { - border: none; - } - - .image-button, - .titlebutton { - background-color: transparent; - background-image: none; - border: 1px solid transparent; - padding: 3px; - box-shadow: none; - } - - .image-button:hover, - .image-button:focus, - .titlebutton:hover, - .titlebutton:focus { - background-color: alpha(@fg_color, 0.3); - background-image: none; - border: 1px solid transparent; - box-shadow: none; - } - """)).printf(uid, palette[0], uid, palette[0], palette[0], uid, palette[0], palette[0], palette[0], palette[1], uid, uid, palette[1], uid, palette[1], palette[0], palette[0], uid, palette[1], uid, uid, uid, palette[0], palette[0], palette[1], uid); + } catch (GLib.Error e) { + warning ("Failed to parse css style : %s", e.message); + } - return style; + Gtk.StyleContext.add_provider_for_screen ( + Gdk.Screen.get_default (), + css_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ); + } } - - - - } diff --git a/src/Services/Themer.vala b/src/Services/Themer.vala index 6cc6be8..ee1bb68 100644 --- a/src/Services/Themer.vala +++ b/src/Services/Themer.vala @@ -22,14 +22,12 @@ namespace jorts.Themer { /* Get a name, spit an array with colours from standard granite stylesheet */ /* EX: STRAWBERRY --> { "@STRAWBERRY_100" "@STRAWBERRY_900" }*/ - public static string[] generate_palette (string theme) { + public string[] generate_palette (string theme) { var string_palette = new string[2]; - string_palette = { "@" + theme + "_100", "@" + theme + "_900" }; - return string_palette; } @@ -45,6 +43,7 @@ namespace jorts.Themer { .mainwindow-%d { background-color: %s; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); } .mainwindow-%d undershoot.top { @@ -65,7 +64,9 @@ namespace jorts.Themer { .jorts-view text selection { color: shade(%s, 1.88); + transition: color 800ms cubic-bezier(0.4, 0, 0.2, 1); background-color: %s; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); } entry.flat { @@ -85,6 +86,7 @@ namespace jorts.Themer { box-shadow: none; background-image: none; padding: 3px; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); } .window-%d .jorts-bar image { @@ -98,6 +100,7 @@ namespace jorts.Themer { .window-%d .jorts-view text, .window-%d .jorts-title { background-color: %s; + transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1); background-image: none; border-bottom-color: %s; font-weight: 500; @@ -186,6 +189,9 @@ namespace jorts.Themer { """)).printf(uid, palette[0], uid, palette[0], palette[0], uid, palette[0], palette[0], palette[0], palette[1], uid, uid, palette[1], uid, palette[1], palette[0], palette[0], uid, palette[1], uid, uid, uid, palette[0], palette[0], palette[1], uid); return style; - } +} + + + } diff --git a/src/Services/Utils.vala b/src/Services/Utils.vala new file mode 100644 index 0000000..e1e1cae --- /dev/null +++ b/src/Services/Utils.vala @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2025 Stella +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +namespace jorts.Utils { + + /* Get a name, spit an array with colours from standard granite stylesheet */ + /* EX: STRAWBERRY --> { "@STRAWBERRY_100" "@STRAWBERRY_900" }*/ + public string random_title () { + string[] alltitles = { + _("All my very best friends"), + _("My super good secret recipe"), + _("My todo list"), + _("Super secret to not tell anyone"), + _("My grocery list"), + _("Random shower thoughts"), + _("My fav fanfics"), + _("My fav dinosaurs"), + _("My evil mastermind plan"), + _("What made me smile today"), + _("Hello world!"), + _("New sticky, new me")}; + + return alltitles[Random.int_range (0,(alltitles.length - 1))]; + } + + + public string random_theme () { + string[] allthemes = { + "STRAWBERRY", + "ORANGE", + "BANANA", + "LIME", + "BLUEBERRY", + "BUBBLEGUM", + "GRAPE", + "COCOA", + "SILVER", + "SLATE"}; + return allthemes[Random.int_range (0,(allthemes.length - 1))]; + } + +} \ No newline at end of file diff --git a/src/Widgets/ColorPill.vala b/src/Widgets/ColorPill.vala new file mode 100644 index 0000000..6f919ca --- /dev/null +++ b/src/Widgets/ColorPill.vala @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2025 Stella - teamcons.carrd.co +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +public class jorts.ColorPill : Gtk.Button { + + public bool has_focus = false; + public Gtk.Align halign = Gtk.Align.CENTER; + public int height_request = 24; + public int width_request = 24; + + + public ColorPill () { + Object(); + } + + +} diff --git a/src/Widgets/ColorPillButton.vala b/src/Widgets/ColorPillButton.vala deleted file mode 100644 index a7c8bec..0000000 --- a/src/Widgets/ColorPillButton.vala +++ /dev/null @@ -1,11 +0,0 @@ - - -public class jorts.ColorPillButton : Gtk.Button { - - Public has_focus = false; - Public halign = Gtk.Align.CENTER; - Public height_request = 24; - Public width_request = 24; - - -} diff --git a/src/Widgets/SettingsPopover.vala b/src/Widgets/SettingsPopover.vala new file mode 100644 index 0000000..a54f9a5 --- /dev/null +++ b/src/Widgets/SettingsPopover.vala @@ -0,0 +1,251 @@ +/* +* Copyright (c) 2025 Stella - teamcons.carrd.co +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + + + +public class jorts.SettingsPopover : Gtk.Popover { + + Public string selected + + + + + public SettingsPopover () { + Object (); + } + + construct { + var color_button_strawberry = new Gtk.Button (); + color_button_strawberry.has_focus = false; + color_button_strawberry.halign = Gtk.Align.CENTER; + color_button_strawberry.height_request = 24; + color_button_strawberry.width_request = 24; + color_button_strawberry.tooltip_text = _("Strawberry"); + color_button_strawberry.get_style_context ().add_class ("color-button"); + color_button_strawberry.get_style_context ().add_class ("color-strawberry"); + + var color_button_orange = new Gtk.Button (); + color_button_orange.has_focus = false; + color_button_orange.halign = Gtk.Align.CENTER; + color_button_orange.height_request = 24; + color_button_orange.width_request = 24; + color_button_orange.tooltip_text = _("Orange"); + + var color_button_orange_context = color_button_orange.get_style_context (); + color_button_orange_context.add_class ("color-button"); + color_button_orange_context.add_class ("color-orange"); + + var color_button_banana = new Gtk.Button (); + color_button_banana.has_focus = false; + color_button_banana.halign = Gtk.Align.CENTER; + color_button_banana.height_request = 24; + color_button_banana.width_request = 24; + color_button_banana.tooltip_text = _("Banana"); + + var color_button_banana_context = color_button_banana.get_style_context (); + color_button_banana_context.add_class ("color-button"); + color_button_banana_context.add_class ("color-banana"); + + var color_button_lime = new Gtk.Button (); + color_button_lime.has_focus = false; + color_button_lime.halign = Gtk.Align.CENTER; + color_button_lime.height_request = 24; + color_button_lime.width_request = 24; + color_button_lime.tooltip_text = _("Lime"); + + var color_button_lime_context = color_button_lime.get_style_context (); + color_button_lime_context.add_class ("color-button"); + color_button_lime_context.add_class ("color-lime"); + + var color_button_blueberry = new Gtk.Button (); + color_button_blueberry.has_focus = false; + color_button_blueberry.halign = Gtk.Align.CENTER; + color_button_blueberry.height_request = 24; + color_button_blueberry.width_request = 24; + color_button_blueberry.tooltip_text = _("Blueberry"); + + var color_button_blueberry_context = color_button_blueberry.get_style_context (); + color_button_blueberry_context.add_class ("color-button"); + color_button_blueberry_context.add_class ("color-blueberry"); + + + var color_button_bubblegum = new Gtk.Button (); + color_button_bubblegum.has_focus = false; + color_button_bubblegum.halign = Gtk.Align.CENTER; + color_button_bubblegum.height_request = 24; + color_button_bubblegum.width_request = 24; + color_button_bubblegum.tooltip_text = _("Bubblegum"); + + var color_button_bubblegum_context = color_button_blueberry.get_style_context (); + color_button_bubblegum_context.add_class ("color-button"); + color_button_bubblegum_context.add_class ("color-bubblegum"); + + + var color_button_grape = new Gtk.Button (); + color_button_grape.has_focus = false; + color_button_grape.halign = Gtk.Align.CENTER; + color_button_grape.height_request = 24; + color_button_grape.width_request = 24; + color_button_grape.tooltip_text = _("Grape"); + + var color_button_grape_context = color_button_grape.get_style_context (); + color_button_grape_context.add_class ("color-button"); + color_button_grape_context.add_class ("color-grape"); + + var color_button_cocoa = new Gtk.Button (); + color_button_cocoa.has_focus = false; + color_button_cocoa.halign = Gtk.Align.CENTER; + color_button_cocoa.height_request = 24; + color_button_cocoa.width_request = 24; + color_button_cocoa.tooltip_text = _("Cocoa"); + + var color_button_cocoa_context = color_button_cocoa.get_style_context (); + color_button_cocoa_context.add_class ("color-button"); + color_button_cocoa_context.add_class ("color-cocoa"); + + var color_button_silver = new Gtk.Button (); + color_button_silver.has_focus = false; + color_button_silver.halign = Gtk.Align.CENTER; + color_button_silver.height_request = 24; + color_button_silver.width_request = 24; + color_button_silver.tooltip_text = _("Silver"); + + var color_button_silver_context = color_button_silver.get_style_context (); + color_button_silver_context.add_class ("color-button"); + color_button_silver_context.add_class ("color-silver"); + + + var color_button_slate = new Gtk.Button (); + color_button_slate.has_focus = false; + color_button_slate.halign = Gtk.Align.CENTER; + color_button_slate.height_request = 24; + color_button_slate.width_request = 24; + color_button_slate.tooltip_text = _("Slate"); + + var color_button_slate_context = color_button_slate.get_style_context (); + color_button_slate_context.add_class ("color-button"); + color_button_slate_context.add_class ("color-slate"); + + var color_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + // GTK4: append + // THE HECK IS THESE + color_button_box.pack_start (color_button_strawberry, false, true, 0); + color_button_box.pack_start (color_button_orange, false, true, 0); + color_button_box.pack_start (color_button_banana, false, true, 0); + color_button_box.pack_start (color_button_lime, false, true, 0); + color_button_box.pack_start (color_button_blueberry, false, true, 0); + color_button_box.pack_start (color_button_grape, false, true, 0); + color_button_box.pack_start (color_button_cocoa, false, true, 0); + color_button_box.pack_start (color_button_silver, false, true, 0); + color_button_box.pack_start (color_button_slate, false, true, 0); + + var color_button_label = new Granite.HeaderLabel (_("Note Color")); + + var setting_grid = new Gtk.Grid (); + setting_grid.margin = 12; + setting_grid.column_spacing = 6; + setting_grid.row_spacing = 6; + setting_grid.orientation = Gtk.Orientation.VERTICAL; + setting_grid.attach (color_button_label, 0, 0, 1, 1); + setting_grid.attach (color_button_box, 0, 1, 1, 1); + setting_grid.show_all (); + + var popover = new Gtk.Popover (null); + popover.add (setting_grid); + + var app_button = new Gtk.MenuButton(); + app_button.has_tooltip = true; + app_button.tooltip_text = (_("Settings")); + app_button.image = new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.SMALL_TOOLBAR); + app_button.popover = popover; + + + // All the "change theme when theme button changed" + // TODO: cleaner theme management + color_button_strawberry.clicked.connect (() => { + this.theme = "STRAWBERRY"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_orange.clicked.connect (() => { + this.theme = "ORANGE"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_banana.clicked.connect (() => { + this.theme = "BANANA"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_lime.clicked.connect (() => { + this.theme = "LIME"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_blueberry.clicked.connect (() => { + this.theme = "BLUEBERRY"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_bubblegum.clicked.connect (() => { + this.theme = "BUBBLEGUM"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_grape.clicked.connect (() => { + this.theme = "GRAPE"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_cocoa.clicked.connect (() => { + this.theme = "COCOA"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_silver.clicked.connect (() => { + this.theme = "SILVER"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + color_button_slate.clicked.connect (() => { + this.theme = "SLATE"; + update_theme(this.theme); + ((Application)this.application).update_storage(); + }); + + // GTK4: Append + //actionbar.pack_end (app_button); + } + + + + + + +} \ No newline at end of file