diff --git a/data/meson.build b/data/meson.build
index 15c8648..d40ecf6 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -53,3 +53,25 @@ install_data(
)
subdir('icons')
+
+# Blueprint
+subproject('blueprint-compiler')
+blueprints = custom_target(
+ 'blueprints',
+ input: files(
+ 'ui/menu.blp',
+ 'ui/window.blp',
+ ),
+ output: '.',
+ command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
+)
+#
+
+asresources = gnome.compile_resources(
+ 'as-resources',
+ 'io.github.lainsce.Colorway.gresource.xml',
+ source_dir: meson.current_build_dir(),
+ dependencies: blueprints,
+ c_name: 'as',
+ install_dir: get_option('datadir') / meson.project_name(),
+)
\ No newline at end of file
diff --git a/data/ui/menu.blp b/data/ui/menu.blp
new file mode 100644
index 0000000..eb2a7cb
--- /dev/null
+++ b/data/ui/menu.blp
@@ -0,0 +1,27 @@
+using Gtk 4.0;
+
+menu menu {
+ section {
+ item {
+ label: _("Copy Colors to Clipboard");
+ action: "win.action_export_txt";
+ }
+
+ item {
+ label: _("Copy Colors Image to Clipboard");
+ action: "win.action_export_png";
+ }
+ }
+
+ section {
+ item {
+ label: _("Keyboard Shortcuts");
+ action: "win.action_keys";
+ }
+
+ item {
+ label: _("About Colorway");
+ action: "win.action_about";
+ }
+ }
+}
diff --git a/data/ui/menu.ui b/data/ui/menu.ui
deleted file mode 100644
index 1e54b2f..0000000
--- a/data/ui/menu.ui
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
diff --git a/data/ui/window.blp b/data/ui/window.blp
new file mode 100644
index 0000000..5727f55
--- /dev/null
+++ b/data/ui/window.blp
@@ -0,0 +1,80 @@
+using Gtk 4.0;
+using He 1;
+
+template $ColorwayMainWindow : He.ApplicationWindow {
+ resizable: false;
+ title: "Colorway";
+
+ Box main_box {
+ orientation: vertical;
+
+ styles [
+ "main-box",
+ ]
+
+ Overlay {
+ [overlay]
+ He.AppBar headerbar {
+ show-back: false;
+ valign: start;
+ viewtitle-widget:
+ He.TextField color_label {
+ tooltip-text: _("Change color (hexcode)");
+ halign: start;
+
+ styles [
+ "numeric",
+ ]
+ };
+
+ MenuButton menu_button {
+ icon-name: "open-menu-symbolic";
+ }
+ }
+
+ WindowHandle {
+ vexpand: true;
+ hexpand: true;
+
+ Box {
+ orientation: horizontal;
+
+ Box {
+ orientation: vertical;
+ vexpand: true;
+
+ He.OverlayButton color_picker_button {
+ icon: "color-select-symbolic";
+ primary-tooltip: _("Pick Color");
+ typeb: primary;
+ size: small;
+
+ styles [
+ "clr-preview",
+ ]
+
+ Box {
+ orientation: vertical;
+
+ Box props_box {
+ orientation: vertical;
+ spacing: 6;
+ margin-start: 18;
+ margin-end: 18;
+ margin-top: 118;
+
+ Box color_box {
+ }
+ }
+
+ styles [
+ "clr-props",
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/data/ui/window.ui b/data/ui/window.ui
deleted file mode 100644
index 07fd374..0000000
--- a/data/ui/window.ui
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
- 0
- Colorway
-
-
-
-
-
diff --git a/meson.build b/meson.build
index 08631c6..dc95947 100644
--- a/meson.build
+++ b/meson.build
@@ -35,11 +35,12 @@ add_project_arguments(
'-DGETTEXT_PACKAGE="@0@"'.format(app_id),
language: 'c'
)
-
-asresources = gnome.compile_resources(
- 'as-resources', 'data/io.github.lainsce.Colorway.gresource.xml',
- source_dir: 'data',
- c_name: 'as'
+add_project_arguments(
+ [
+ '--target-glib=2.68',
+ '--gresourcesdir', meson.current_build_dir() / 'data',
+ ],
+ language: 'vala',
)
sources = [
@@ -64,18 +65,18 @@ dependencies = [
meson.get_compiler('c').find_library('m', required: true)
]
+subdir('data')
+subdir('po')
+
executable(
meson.project_name(),
- sources,
asresources,
+ sources,
dependencies: dependencies,
vala_args: [meson.project_source_root() + '/src/config.vapi'],
install : true
)
-subdir('data')
-subdir('po')
-
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
diff --git a/src/chooser.vala b/src/chooser.vala
index 468a21b..c17d0c4 100644
--- a/src/chooser.vala
+++ b/src/chooser.vala
@@ -46,7 +46,7 @@ public class Colorway.Chooser : Gtk.DrawingArea {
g = active_color.green;
b = active_color.blue;
this.active_color = active_color;
- this.get_style_context ().add_class ("clr-da");
+ this.add_css_class ("clr-da");
Gtk.rgb_to_hsv ((float)r, (float)g, (float)b, out h, out s, out v);
this.h = h;
diff --git a/src/hue_slider.vala b/src/hue_slider.vala
index e6302bb..a92f4ad 100644
--- a/src/hue_slider.vala
+++ b/src/hue_slider.vala
@@ -35,7 +35,7 @@ public class Colorway.HueSlider : Gtk.Scale {
this.digits = 0;
this.has_origin = false;
- this.get_style_context ().add_class ("clr-hue");
+ this.add_css_class ("clr-hue");
this.value_changed.connect (() => {
double hue = this.adjustment.get_value () / 360;
diff --git a/src/window.vala b/src/window.vala
index a7d885e..9f8b5c7 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -32,7 +32,7 @@ namespace Colorway {
public Chooser da;
public HueSlider hue_slider;
- public Gtk.ComboBoxText color_rule_dropdown;
+ public Gtk.DropDown color_rule_dropdown;
public PaletteButton box;
public PaletteButton tbox;
public PaletteButton sbox;
@@ -95,14 +95,13 @@ namespace Colorway {
color = "#72dec2";
contrast = "#000";
+
+ var model = new Gtk.StringList ({_("Analogous"), _("Complementary"), _("Triadic"), _("Tetradic"), _("Monochromatic")});
+ var expression = new Gtk.PropertyExpression(typeof(string), null, "value");
- color_rule_dropdown = new Gtk.ComboBoxText ();
- color_rule_dropdown.append_text(_("Analogous"));
- color_rule_dropdown.append_text(_("Complementary"));
- color_rule_dropdown.append_text(_("Triadic"));
- color_rule_dropdown.append_text(_("Tetradic"));
- color_rule_dropdown.append_text(_("Monochromatic"));
- color_rule_dropdown.set_active(3);
+ color_rule_dropdown = new Gtk.DropDown (model, expression);
+ color_rule_dropdown.model = model;
+ color_rule_dropdown.set_selected (3);
color_rule_dropdown.set_halign (Gtk.Align.START);
color_rule_dropdown.margin_bottom = 18;
color_rule_dropdown.width_request = 160;
@@ -210,7 +209,7 @@ namespace Colorway {
da.pos_to_sv (out s, out v);
setup_color_rules.begin (color, contrast, hue, s, v, color_rule_dropdown, sbox, tbox);
- color_rule_dropdown.changed.connect(() => {
+ color_rule_dropdown.notify["selected"].connect(() => {
Gdk.RGBA clrd = {};
clrd.parse(color_label.get_entry ().get_text());
@@ -262,42 +261,13 @@ namespace Colorway {
setup_color_rules.begin (color, contrast, chl, csl, cvl, color_rule_dropdown, sbox, tbox);
});
- color_label.get_entry ().icon_press.connect(() => {
- Gdk.RGBA clrc = {};
- clr.parse(color_label.get_entry ().get_text());
-
- float chc,csc,cvc,hc,rc,gc,bc;
- Gtk.rgb_to_hsv(clrc.red, clrc.green, clrc.blue, out chc, out csc, out cvc);
- Gtk.hsv_to_rgb(chc, csc, cvc, out rc, out gc, out bc);
- var pcc = Utils.make_hex((float)Utils.make_srgb(rc),
- (float)Utils.make_srgb(gc),
- (float)Utils.make_srgb(bc));
-
- active_color = {(float)clrc.red, (float)clrc.green, (float)clrc.blue};
- da.update_surface_color (clrc.red, clrc.green, clrc.blue);
- da.sv_to_pos (csc, cvc);
- da.queue_draw();
-
- hue_slider.set_value(chc*360);
-
- color = pcc.up();
- color_label.get_entry ().set_text (pcc.up());
-
- if (Utils.contrast_ratio(active_color, {0,0,0,1}) > Utils.contrast_ratio(active_color, {1,1,1,1}) + 3) {
- contrast = "#000";
- } else {
- contrast = "#fff";
- }
-
- setup_color_rules.begin (color, contrast, chc, csc, cvc, color_rule_dropdown, sbox, tbox);
- });
this.set_size_request (295, 400);
this.show ();
}
- public async void setup_color_rules (string color, string contrast, double hue, double s, double v, Gtk.ComboBoxText? crd, PaletteButton? sbox, PaletteButton? tbox) {
- switch (crd.get_active ()) {
+ public async void setup_color_rules (string color, string contrast, double hue, double s, double v, Gtk.DropDown? crd, PaletteButton? sbox, PaletteButton? tbox) {
+ switch (crd.get_selected ()) {
case 0:
da.pos_to_sv (out s, out v);
if (hue <= 0.5) {
@@ -551,12 +521,11 @@ namespace Colorway {
export_txt += box.hex + "\n";
- switch (color_rule_dropdown.get_active ()) {
+ switch (color_rule_dropdown.get_selected ()) {
case 2:
export_txt += sbox.hex + "\n";
break;
- case 3:
- case 4:
+ default:
export_txt += tbox.hex + "\n";
break;
}
diff --git a/subprojects/blueprint-compiler.wrap b/subprojects/blueprint-compiler.wrap
new file mode 100644
index 0000000..6e6ee32
--- /dev/null
+++ b/subprojects/blueprint-compiler.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory = blueprint-compiler
+url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
+revision = main
+depth = 1
+
+[provide]
+program_names = blueprint-compiler
\ No newline at end of file