From aa63cfa07949266ae61c307784e75bd0476c4dfd Mon Sep 17 00:00:00 2001 From: teamcons Date: Tue, 18 Nov 2025 20:36:01 +0100 Subject: [PATCH 01/15] Simplify and improve code --- data/Application.css | 37 ------ src/Application.vala | 11 -- src/Widgets/Popover.vala | 15 +-- src/Widgets/PopoverWidgets/ColorBox.vala | 151 ++++++---------------- src/Widgets/PopoverWidgets/ColorPill.vala | 36 +++--- src/Widgets/TextView.vala | 6 +- src/Windows/StickyNoteWindow.vala | 24 +--- 7 files changed, 66 insertions(+), 214 deletions(-) diff --git a/data/Application.css b/data/Application.css index 1e0bbf50..adb547f8 100644 --- a/data/Application.css +++ b/data/Application.css @@ -138,43 +138,6 @@ window.s300 editablelabel {font-size: 305%;} window.s300 editablelabel.editing {font-size: 300%;} -/* ALL the colorpills */ - -colorpill.blueberry {background-color: @BLUEBERRY_300;} -colorpill.blueberry:hover {border: 1px solid @BLUEBERRY_900;} - -colorpill.mint {background-color: @MINT_300;} -colorpill.mint:hover {border: 1px solid @MINT_900;} - -colorpill.lime {background-color: @LIME_300;} -colorpill.lime:hover {border: 1px solid @LIME_900;} - -colorpill.banana {background-color: @BANANA_300;} -colorpill.banana:hover {border: 1px solid @BANANA_900;} - -colorpill.strawberry {background-color: @STRAWBERRY_300;} -colorpill.strawberry:hover {border: 1px solid @STRAWBERRY_900;} - -colorpill.orange {background-color: @ORANGE_300;} -colorpill.orange:hover {border: 1px solid @ORANGE_900;} - -colorpill.bubblegum {background-color: @BUBBLEGUM_300;} -colorpill.bubblegum:hover {border: 1px solid @BUBBLEGUM_900;} - -colorpill.grape {background-color: @GRAPE_300;} -colorpill.grape:hover {border: 1px solid @GRAPE_900;} - -colorpill.latte {background-color: @LATTE_300;} -colorpill.latte:hover {border: 1px solid @LATTE_900;} - -colorpill.cocoa {background-color: @COCOA_300;} -colorpill.cocoa:hover {border: 1px solid @COCOA_900;} - -colorpill.slate {background-color: @SLATE_300;} -colorpill.slate:hover {border: 1px solid @SLATE_900;} - - - /* ANIMATION */ window.animated, window.animated overshoot, diff --git a/src/Application.vala b/src/Application.vala index 0117ec71..8e334b0b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,17 +103,6 @@ public class Jorts.Application : Gtk.Application { set_accels_for_action ("win.action_toggle_list", {"F12"}); set_accels_for_action ("win.action_show_menu", {"G", "O"}); - set_accels_for_action ("win.action_theme_1", {"1"}); - set_accels_for_action ("win.action_theme_2", {"2"}); - set_accels_for_action ("win.action_theme_3", {"3"}); - set_accels_for_action ("win.action_theme_4", {"4"}); - set_accels_for_action ("win.action_theme_5", {"5"}); - set_accels_for_action ("win.action_theme_6", {"6"}); - set_accels_for_action ("win.action_theme_7", {"7"}); - set_accels_for_action ("win.action_theme_8", {"8"}); - set_accels_for_action ("win.action_theme_9", {"9"}); - set_accels_for_action ("win.action_theme_0", {"0", "KP_0"}); - // Force the eOS icon theme, and set the blueberry as fallback, if for some reason it fails for individual notes var granite_settings = Granite.Settings.get_default (); diff --git a/src/Widgets/Popover.vala b/src/Widgets/Popover.vala index c5ac9797..6df37e0a 100644 --- a/src/Widgets/Popover.vala +++ b/src/Widgets/Popover.vala @@ -45,20 +45,7 @@ public class Jorts.PopoverView : Gtk.Popover { add_binding_action(Gdk.Key.g, Gdk.ModifierType.CONTROL_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_SHOW_MENU, null); add_binding_action(Gdk.Key.o, Gdk.ModifierType.CONTROL_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_SHOW_MENU, null); add_binding_action(Gdk.Key.l, Gdk.ModifierType.CONTROL_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_FOCUS_TITLE, null); - - // Compiler whines about Gdk.Key.1 because name is a number so it doesnt see it. - // So we use magic numbers - add_binding_action(49, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_1, null); - add_binding_action(50, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_2, null); - add_binding_action(51, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_3, null); - add_binding_action(52, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_4, null); - add_binding_action(53, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_5, null); - add_binding_action(54, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_6, null); - add_binding_action(55, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_7, null); - add_binding_action(56, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_8, null); - add_binding_action(57, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_9, null); - add_binding_action(48, Gdk.ModifierType.ALT_MASK, StickyNoteWindow.ACTION_PREFIX + StickyNoteWindow.ACTION_THEME_0, null); - } + } /****************/ diff --git a/src/Widgets/PopoverWidgets/ColorBox.vala b/src/Widgets/PopoverWidgets/ColorBox.vala index 28b84900..0d7899b5 100644 --- a/src/Widgets/PopoverWidgets/ColorBox.vala +++ b/src/Widgets/PopoverWidgets/ColorBox.vala @@ -11,128 +11,61 @@ */ public class Jorts.ColorBox : Gtk.Box { - private Themes _color = Constants.DEFAULT_THEME; + public SimpleAction accent_color_action; + public Jorts.Themes color { - get {return _color;} - set {set_all_toggles (value);} + get {return (Jorts.Themes)accent_color_action.get_state ();} + set {accent_color_action.set_state (value);} } - public signal void theme_changed (Themes selected); + public signal void theme_changed (Themes selected); - private Jorts.ColorPill color_button_blueberry; - private Jorts.ColorPill color_button_lime; - private Jorts.ColorPill color_button_mint; - private Jorts.ColorPill color_button_banana; - private Jorts.ColorPill color_button_strawberry; - private Jorts.ColorPill color_button_orange; - private Jorts.ColorPill color_button_bubblegum; - private Jorts.ColorPill color_button_grape; - private Jorts.ColorPill color_button_cocoa; - private Jorts.ColorPill color_button_slate; - // TODO: We could loop instead of by-hand definition public ColorBox () { orientation = Gtk.Orientation.HORIZONTAL; - accessible_role = Gtk.AccessibleRole.LIST; - spacing = 0; + + spacing = 1; margin_start = 12; margin_end = 12; - //TRANSLATORS: Shown as a tooltip when people hover a color theme - color_button_blueberry = new ColorPill (Jorts.Themes.BLUEBERRY); - color_button_mint = new ColorPill (Jorts.Themes.MINT); - color_button_lime = new ColorPill (Jorts.Themes.LIME); - color_button_banana = new ColorPill (Jorts.Themes.BANANA); - color_button_orange = new ColorPill (Jorts.Themes.ORANGE); - color_button_strawberry = new ColorPill (Jorts.Themes.STRAWBERRY); - color_button_bubblegum = new ColorPill (Jorts.Themes.BUBBLEGUM); - color_button_grape = new ColorPill (Jorts.Themes.GRAPE); - color_button_cocoa = new ColorPill (Jorts.Themes.COCOA); - color_button_slate = new ColorPill (Jorts.Themes.SLATE); - - color_button_blueberry.tooltip_markup = Granite.markup_accel_tooltip ( - {"1"}, Jorts.Themes.BLUEBERRY.to_nicename ()); - - color_button_mint.tooltip_markup = Granite.markup_accel_tooltip ( - {"2"}, Jorts.Themes.MINT.to_nicename ()); - - color_button_lime.tooltip_markup = Granite.markup_accel_tooltip ( - {"3"}, Jorts.Themes.LIME.to_nicename ()); - - color_button_banana.tooltip_markup = Granite.markup_accel_tooltip ( - {"4"}, Jorts.Themes.BANANA.to_nicename ()); - - color_button_orange.tooltip_markup = Granite.markup_accel_tooltip ( - {"5"}, Jorts.Themes.ORANGE.to_nicename ()); - - color_button_strawberry.tooltip_markup = Granite.markup_accel_tooltip ( - {"6"}, Jorts.Themes.STRAWBERRY.to_nicename ()); - color_button_bubblegum.tooltip_markup = Granite.markup_accel_tooltip ( - {"7"}, Jorts.Themes.BUBBLEGUM.to_nicename ()); - - color_button_grape.tooltip_markup = Granite.markup_accel_tooltip ( - {"8"}, Jorts.Themes.GRAPE.to_nicename ()); - - color_button_cocoa.tooltip_markup = Granite.markup_accel_tooltip ( - {"9"}, Jorts.Themes.COCOA.to_nicename ()); - - color_button_slate.tooltip_markup = Granite.markup_accel_tooltip ( - {"0"}, Jorts.Themes.SLATE.to_nicename ()); - - - color_button_lime.set_group (color_button_blueberry); - color_button_mint.set_group (color_button_blueberry); - color_button_banana.set_group (color_button_blueberry); - color_button_strawberry.set_group (color_button_blueberry); - color_button_orange.set_group (color_button_blueberry); - color_button_bubblegum.set_group (color_button_blueberry); - color_button_grape.set_group (color_button_blueberry); - color_button_cocoa.set_group (color_button_blueberry); - color_button_slate.set_group (color_button_blueberry); - - // Emit a signal when a button is toggled - color_button_blueberry.selected.connect (on_selected); - color_button_orange.selected.connect (on_selected); - color_button_mint.selected.connect (on_selected); - color_button_banana.selected.connect (on_selected); - color_button_lime.selected.connect (on_selected); - color_button_strawberry.selected.connect (on_selected); - color_button_bubblegum.selected.connect (on_selected); - color_button_grape.selected.connect (on_selected); - color_button_cocoa.selected.connect (on_selected); - color_button_slate.selected.connect (on_selected); - - append (color_button_blueberry); - append (color_button_mint); - append (color_button_lime); - append (color_button_banana); - append (color_button_orange); - append (color_button_strawberry); - append (color_button_bubblegum); - append (color_button_grape); - append (color_button_cocoa); - append (color_button_slate); + var blueberry_button = new ColorPill (Themes.BLUEBERRY); + var mint_button = new ColorPill (Themes.MINT, blueberry_button); + var lime_button = new ColorPill (Themes.LIME, blueberry_button); + var banana_button = new ColorPill (Themes.BANANA, blueberry_button); + var orange_button = new ColorPill (Themes.ORANGE, blueberry_button); + var strawberry_button = new ColorPill (Themes.STRAWBERRY, blueberry_button); + var bubblegum_button = new ColorPill (Themes.BUBBLEGUM, blueberry_button); + var grape_button = new ColorPill (Themes.GRAPE, blueberry_button); + var cocoa_button = new ColorPill (Themes.COCOA, blueberry_button); + var slate_button = new ColorPill (Themes.SLATE, blueberry_button); + var auto_button = new ColorPill (Themes.IDK, blueberry_button); + + append (blueberry_button); + append (mint_button); + append (lime_button); + append (banana_button); + append (orange_button); + append (strawberry_button); + append (bubblegum_button); + append (grape_button); + append (cocoa_button); + append (slate_button); + append (auto_button); + + accent_color_action = new SimpleAction.stateful ("prefers-accent-color", GLib.VariantType.INT32, new Variant.int32 (Themes.IDK)); + var action_group = new SimpleActionGroup (); + action_group.add_action (accent_color_action); + insert_action_group ("popover", action_group); + + accent_color_action.activate.connect (set_broadcast); } - private void on_selected (Jorts.Themes color) { - _color = color; - theme_changed (color); + private void set_broadcast (GLib.Variant? value) { + if (!accent_color_action.get_state ().equal (value)) { + accent_color_action.set_state (value); + theme_changed ((Jorts.Themes)color); + } } - - private void set_all_toggles (Jorts.Themes color) { - _color = color; - color_button_blueberry.set_active ((color == color_button_blueberry.color)); - color_button_lime.set_active ((color == color_button_lime.color)); - color_button_mint.set_active ((color == color_button_mint.color)); - color_button_banana.set_active ((color == color_button_banana.color)); - color_button_strawberry.set_active ((color == color_button_strawberry.color)); - color_button_orange.set_active ((color == color_button_orange.color)); - color_button_bubblegum.set_active ((color == color_button_bubblegum.color)); - color_button_grape.set_active ((color == color_button_grape.color)); - color_button_cocoa.set_active ((color == color_button_cocoa.color)); - color_button_slate.set_active ((color == color_button_slate.color)); - } - } diff --git a/src/Widgets/PopoverWidgets/ColorPill.vala b/src/Widgets/PopoverWidgets/ColorPill.vala index 2982088d..3c17fefe 100644 --- a/src/Widgets/PopoverWidgets/ColorPill.vala +++ b/src/Widgets/PopoverWidgets/ColorPill.vala @@ -11,27 +11,29 @@ * I just dont wanna rewrite the same button over and over */ public class Jorts.ColorPill : Gtk.CheckButton { - public Jorts.Themes color; - public signal void selected (Jorts.Themes color); - public ColorPill (Jorts.Themes? theme = (null)) { - this.color = theme; + public Jorts.Themes color { get; construct; } - add_css_class ("colorpill"); - add_css_class (theme.to_css_class ()); - set_size_request (24, 24); - set_tooltip_text (theme.to_nicename ()); - add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + public ColorPill (Themes color, Gtk.CheckButton? group_member = null) { + Object ( + color: color, + group: group_member + ); + } - margin_top = 0; - margin_bottom = 0; - margin_start = 0; - margin_end = 0; + construct { + add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - this.toggled.connect (on_connect); - } + if (color == Themes.IDK) { + add_css_class ("auto"); + + } else { + add_css_class (color.to_css_class ()); + } + + tooltip_text = color.to_nicename (); - public void on_connect () { - selected (color); + action_name = "popover.prefers-accent-color"; + action_target = new Variant.int32 (color); } } diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index cb93f80d..b911161c 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -151,7 +151,7 @@ public class Jorts.TextView : Granite.HyperTextView { * Handler whenever a key is pressed, to see if user needs something and get ahead * Some local stuff is deduplicated in the Ifs, because i do not like the idea of getting computation done not needed 98% of the time */ - private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { + private bool on_key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) { // If backspace on a prefix: Delete the prefix. if (keyval == Gdk.Key.BackSpace) { @@ -202,7 +202,7 @@ public class Jorts.TextView : Granite.HyperTextView { list_item_start = Application.gsettings.get_string ("list-item-start"); } - private void on_cursor_changed () { +/* private void on_cursor_changed () { Gtk.TextIter start, end; buffer.get_selection_bounds (out start, out end); var line_number = (uint8)start.get_line (); @@ -210,5 +210,5 @@ public class Jorts.TextView : Granite.HyperTextView { on_list_item = this.has_prefix (line_number); print ("THIS IS LIST. HAS " + on_list_item.to_string () + "ON LINE " + line_number.to_string ()); - } + } */ } diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index e6d3e031..d6f4dea8 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -63,19 +63,9 @@ public class Jorts.StickyNoteWindow : Gtk.Window { { ACTION_FOCUS_TITLE, action_focus_title}, { ACTION_ZOOM_OUT, action_zoom_out}, { ACTION_ZOOM_DEFAULT, action_zoom_default}, + { ACTION_ZOOM_IN, action_zoom_in}, { ACTION_TOGGLE_MONO, action_toggle_mono}, { ACTION_TOGGLE_LIST, action_toggle_list}, - { ACTION_ZOOM_IN, action_zoom_in}, - { ACTION_THEME_1, action_theme_1}, - { ACTION_THEME_2, action_theme_2}, - { ACTION_THEME_3, action_theme_3}, - { ACTION_THEME_4, action_theme_4}, - { ACTION_THEME_5, action_theme_5}, - { ACTION_THEME_6, action_theme_6}, - { ACTION_THEME_7, action_theme_7}, - { ACTION_THEME_8, action_theme_8}, - { ACTION_THEME_9, action_theme_9}, - { ACTION_THEME_0, action_theme_0}, }; public StickyNoteWindow (Jorts.Application app, NoteData data) { @@ -249,16 +239,4 @@ public class Jorts.StickyNoteWindow : Gtk.Window { private void action_zoom_out () {zoomcontroller.zoom_out ();} private void action_zoom_default () {zoomcontroller.zoom_default ();} private void action_zoom_in () {zoomcontroller.zoom_in ();} - - // Careful! The keyboard counts from 1 to 10 (0), but the themes are from 0 to 9 - private void action_theme_1 () {popover.color = (Jorts.Themes.all ())[0];} - private void action_theme_2 () {popover.color = (Jorts.Themes.all ())[1];} - private void action_theme_3 () {popover.color = (Jorts.Themes.all ())[2];} - private void action_theme_4 () {popover.color = (Jorts.Themes.all ())[3];} - private void action_theme_5 () {popover.color = (Jorts.Themes.all ())[4];} - private void action_theme_6 () {popover.color = (Jorts.Themes.all ())[5];} - private void action_theme_7 () {popover.color = (Jorts.Themes.all ())[6];} - private void action_theme_8 () {popover.color = (Jorts.Themes.all ())[7];} - private void action_theme_9 () {popover.color = (Jorts.Themes.all ())[8];} - private void action_theme_0 () {popover.color = (Jorts.Themes.all ())[9];} } From c7305d17bb46c35473184b4943b329780cd87051 Mon Sep 17 00:00:00 2001 From: teamcons Date: Thu, 20 Nov 2025 17:25:00 +0100 Subject: [PATCH 02/15] avoid undeletable line when prefix null --- src/Widgets/TextView.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index b911161c..b36dd234 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -83,6 +83,8 @@ public class Jorts.TextView : Granite.HyperTextView { * Add the list prefix only to lines who hasnt it already */ private bool has_prefix (uint8 line_number) { + if (list_item_start == null) {return false;} + Gtk.TextIter start, end; buffer.get_iter_at_line_offset (out start, line_number, 0); From 57bbc830c9947f5590254e3ae418edeae306525d Mon Sep 17 00:00:00 2001 From: teamcons Date: Thu, 20 Nov 2025 17:25:25 +0100 Subject: [PATCH 03/15] use "" for empty instead --- src/Widgets/TextView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index b36dd234..37ccd3bc 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -83,7 +83,7 @@ public class Jorts.TextView : Granite.HyperTextView { * Add the list prefix only to lines who hasnt it already */ private bool has_prefix (uint8 line_number) { - if (list_item_start == null) {return false;} + if (list_item_start == "") {return false;} Gtk.TextIter start, end; buffer.get_iter_at_line_offset (out start, line_number, 0); From 453bf1e6e856e7ea1d5df77a79f604ef7cbcbe23 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 11:23:23 +0100 Subject: [PATCH 04/15] avoid chomping on UTF-8 characters --- src/Widgets/TextView.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index 37ccd3bc..01e1b90a 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -141,7 +141,7 @@ public class Jorts.TextView : Granite.HyperTextView { */ private void remove_prefix (uint8 line_number) { Gtk.TextIter line_start, prefix_end; - var remove_range = list_item_start.length; + var remove_range = list_item_start.char_count (); debug ("doing line " + line_number.to_string ()); buffer.get_iter_at_line_offset (out line_start, line_number, 0); From 4626d204f4ff7ebf4e586c4dd60b9cf67adba2ca Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 11:41:36 +0100 Subject: [PATCH 05/15] slightly change defaults --- data/jorts.gschema.xml | 2 +- src/Views/PreferencesView.vala | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/jorts.gschema.xml b/data/jorts.gschema.xml index 635aab15..b3850c7c 100644 --- a/data/jorts.gschema.xml +++ b/data/jorts.gschema.xml @@ -12,7 +12,7 @@ Whether to hide the actionbar and its buttons - " - " + " • " Hide actionbar Whether to hide the actionbar and its buttons diff --git a/src/Views/PreferencesView.vala b/src/Views/PreferencesView.vala index eb4e440a..ba6ebefb 100644 --- a/src/Views/PreferencesView.vala +++ b/src/Views/PreferencesView.vala @@ -44,8 +44,9 @@ halign = Gtk.Align.END, hexpand = false, valign = Gtk.Align.CENTER, - max_length = 5, - max_width_chars = 5 + max_length = 6, + max_width_chars = 6, + xalign = 0.5f }; var list_label = new Granite.HeaderLabel (_("List item symbol")) { From db098680454f6ee950d2c28faf10e13309359597 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 12:23:48 +0100 Subject: [PATCH 06/15] remove unneeded uint16/uint8ing since gobject aligns to int anway --- src/Objects/NoteData.vala | 6 +++--- src/Objects/Zoom.vala | 6 +++--- src/Services/Constants.vala | 6 +++--- src/Services/ZoomController.vala | 8 ++++---- src/Widgets/Popover.vala | 2 +- src/Widgets/PopoverWidgets/ZoomBox.vala | 4 ++-- src/Widgets/TextView.vala | 26 ++++++++++++------------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Objects/NoteData.vala b/src/Objects/NoteData.vala index 660cdd75..bad5f1ca 100644 --- a/src/Objects/NoteData.vala +++ b/src/Objects/NoteData.vala @@ -14,14 +14,14 @@ public class Jorts.NoteData : Object { // Will determine properties (or lack thereof) for any new note public static Jorts.Themes latest_theme = Jorts.Constants.DEFAULT_THEME; - public static uint16 latest_zoom = Jorts.Constants.DEFAULT_ZOOM; + public static int latest_zoom = Jorts.Constants.DEFAULT_ZOOM; public static bool latest_mono = Jorts.Constants.DEFAULT_MONO; public string? title; public Jorts.Themes? theme; public string? content; public bool? monospace; - public uint16? zoom; + public int? zoom; public int? width; public int? height; @@ -49,7 +49,7 @@ public class Jorts.NoteData : Object { theme = (Jorts.Themes)node.get_int_member_with_default ("color", Jorts.Themes.random_theme ()); content = node.get_string_member_with_default ("content",""); monospace = node.get_boolean_member_with_default ("monospace", Jorts.Constants.DEFAULT_MONO); - zoom = (uint16)node.get_int_member_with_default ("zoom", Jorts.Constants.DEFAULT_ZOOM); + zoom = (int)node.get_int_member_with_default ("zoom", Jorts.Constants.DEFAULT_ZOOM); // Make sure the values are nothing crazy if (zoom < Jorts.Constants.ZOOM_MIN) { zoom = Jorts.Constants.ZOOM_MIN;} diff --git a/src/Objects/Zoom.vala b/src/Objects/Zoom.vala index 80f15f28..85e42cf2 100644 --- a/src/Objects/Zoom.vala +++ b/src/Objects/Zoom.vala @@ -30,7 +30,7 @@ public enum Jorts.Zoom { /** * Returns an Int representation we can use to display and store the value */ - public uint16 to_int () { + public int to_int () { switch (this) { case ANTSIZED: return 20; case MUCHSMALLER: return 40; @@ -63,7 +63,7 @@ public enum Jorts.Zoom { /** * We cannot save Enums in JSON, so this recovers the enum from stored int */ - public static Zoom from_int (uint16 wtf_is_this) { + public static Zoom from_int (int wtf_is_this) { switch (wtf_is_this) { case 20: return ANTSIZED; case 40: return MUCHSMALLER; @@ -88,7 +88,7 @@ public enum Jorts.Zoom { /** * We have to scale some UI elements according to zoom */ - public uint16 to_ui_size () { + public int to_ui_size () { switch (this) { case ANTSIZED: return 24; case MUCHSMALLER: return 26; diff --git a/src/Services/Constants.vala b/src/Services/Constants.vala index 89d75c71..0c9829a4 100644 --- a/src/Services/Constants.vala +++ b/src/Services/Constants.vala @@ -27,9 +27,9 @@ namespace Jorts.Constants { const int DEBOUNCE = 750; // We need to say stop at some point - const uint16 ZOOM_MAX = 300; - const uint16 DEFAULT_ZOOM = 100; - const uint16 ZOOM_MIN = 20; + const int ZOOM_MAX = 300; + const int DEFAULT_ZOOM = 100; + const int ZOOM_MIN = 20; const bool DEFAULT_MONO = false; // For new stickies diff --git a/src/Services/ZoomController.vala b/src/Services/ZoomController.vala index 73891d43..4de588fa 100644 --- a/src/Services/ZoomController.vala +++ b/src/Services/ZoomController.vala @@ -8,7 +8,7 @@ /*************************************************/ /** * Responsible to apply zoom appropriately to a window. -* Mainly, this abstracts zoom into an uint16 and swap CSS classes +* Mainly, this abstracts zoom into an int and swap CSS classes * As a treat it includes also the plumbing for ctrl+scroll zooming */ public class Jorts.ZoomController : Object { @@ -17,8 +17,8 @@ public class Jorts.ZoomController : Object { private Jorts.StickyNoteWindow window; // Avoid setting this unless it is to restore a specific value, do_set_zoom does not check input - private uint16 _old_zoom; - public uint16 zoom { + private int _old_zoom; + public int zoom { get {return _old_zoom;} set {do_set_zoom (value);} } @@ -73,7 +73,7 @@ public class Jorts.ZoomController : Object { /** * Switch zoom classes, then reflect in the UI and tell the application */ - private void do_set_zoom (uint16 new_zoom) { + private void do_set_zoom (int new_zoom) { debug ("Setting zoom: " + zoom.to_string ()); // Switches the classes that control font size diff --git a/src/Widgets/Popover.vala b/src/Widgets/Popover.vala index 6df37e0a..dae5e196 100644 --- a/src/Widgets/Popover.vala +++ b/src/Widgets/Popover.vala @@ -26,7 +26,7 @@ public class Jorts.PopoverView : Gtk.Popover { set {on_monospace_changed (value);} } - public uint16 zoom { set {font_size_box.zoom = value;}} + public int zoom { set {font_size_box.zoom = value;}} public signal void theme_changed (Jorts.Themes selected); public signal void zoom_changed (Jorts.Zoomkind zoomkind); diff --git a/src/Widgets/PopoverWidgets/ZoomBox.vala b/src/Widgets/PopoverWidgets/ZoomBox.vala index 70ba8882..3e6e6ba3 100644 --- a/src/Widgets/PopoverWidgets/ZoomBox.vala +++ b/src/Widgets/PopoverWidgets/ZoomBox.vala @@ -13,9 +13,9 @@ public class Jorts.ZoomBox : Gtk.Box { private Gtk.Button zoom_default_button; - private uint16 _zoom = 100; + private int _zoom = 100; - public uint16 zoom { + public int zoom { get { return _zoom;} set { _zoom = value; diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index 01e1b90a..dd9762fe 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -62,8 +62,8 @@ public class Jorts.TextView : Granite.HyperTextView { Gtk.TextIter start, end; buffer.get_selection_bounds (out start, out end); - var first_line = (uint8)start.get_line (); - var last_line = (uint8)end.get_line (); + var first_line = start.get_line (); + var last_line = end.get_line (); debug ("got " + first_line.to_string () + " to " + last_line.to_string ()); var selected_is_list = this.is_list (first_line, last_line, list_item_start); @@ -82,7 +82,7 @@ public class Jorts.TextView : Granite.HyperTextView { /** * Add the list prefix only to lines who hasnt it already */ - private bool has_prefix (uint8 line_number) { + private bool has_prefix (int line_number) { if (list_item_start == "") {return false;} Gtk.TextIter start, end; @@ -99,9 +99,9 @@ public class Jorts.TextView : Granite.HyperTextView { /** * Checks whether Line x to Line y are all bulleted. */ - private bool is_list (uint8 first_line, uint8 last_line, string list_item_start) { + private bool is_list (int first_line, int last_line, string list_item_start) { - for (uint8 line_number = first_line; line_number <= last_line; line_number++) { + for (int line_number = first_line; line_number <= last_line; line_number++) { debug ("doing line " + line_number.to_string ()); if (!this.has_prefix (line_number)) { @@ -115,9 +115,9 @@ public class Jorts.TextView : Granite.HyperTextView { /** * Add the list prefix only to lines who hasnt it already */ - private void set_list (uint8 first_line, uint8 last_line) { + private void set_list (int first_line, int last_line) { Gtk.TextIter line_start; - for (uint8 line_number = first_line; line_number <= last_line; line_number++) { + for (int line_number = first_line; line_number <= last_line; line_number++) { debug ("doing line " + line_number.to_string ()); if (!this.has_prefix (line_number)) { @@ -130,8 +130,8 @@ public class Jorts.TextView : Granite.HyperTextView { /** * Remove list prefix from line x to line y. Presuppose it is there */ - private void remove_list (uint8 first_line, uint8 last_line) { - for (uint8 line_number = first_line; line_number <= last_line; line_number++) { + private void remove_list (int first_line, int last_line) { + for (int line_number = first_line; line_number <= last_line; line_number++) { remove_prefix (line_number); } } @@ -139,7 +139,7 @@ public class Jorts.TextView : Granite.HyperTextView { /** * Remove list prefix from line x to line y. Presuppose it is there */ - private void remove_prefix (uint8 line_number) { + private void remove_prefix (int line_number) { Gtk.TextIter line_start, prefix_end; var remove_range = list_item_start.char_count (); @@ -162,7 +162,7 @@ public class Jorts.TextView : Granite.HyperTextView { Gtk.TextIter start, end; buffer.get_selection_bounds (out start, out end); - var line_number = (uint8)start.get_line (); + var line_number = start.get_line (); if (has_prefix (line_number)) { @@ -184,7 +184,7 @@ public class Jorts.TextView : Granite.HyperTextView { } else if (keyval == Gdk.Key.Return) { Gtk.TextIter start, end; buffer.get_selection_bounds (out start, out end); - var line_number = (uint8)start.get_line (); + var line_number = start.get_line (); if (this.has_prefix (line_number)) { @@ -207,7 +207,7 @@ public class Jorts.TextView : Granite.HyperTextView { /* private void on_cursor_changed () { Gtk.TextIter start, end; buffer.get_selection_bounds (out start, out end); - var line_number = (uint8)start.get_line (); + var line_number = start.get_line (); on_list_item = this.has_prefix (line_number); From 8e974b337937af9edfba2cd838cc8dd7b59cf00d Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 17:21:45 +0100 Subject: [PATCH 07/15] Polish preferences, remove old code and add menu section --- src/Application.vala | 3 ++ src/Services/Constants.vala | 4 +-- src/Views/PreferencesView.vala | 48 +++++++------------------------ src/Widgets/TextView.vala | 23 ++++++++++++++- src/Windows/StickyNoteWindow.vala | 11 ------- 5 files changed, 38 insertions(+), 51 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 8e334b0b..7cb3f0a4 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,6 +103,9 @@ public class Jorts.Application : Gtk.Application { set_accels_for_action ("win.action_toggle_list", {"F12"}); set_accels_for_action ("win.action_show_menu", {"G", "O"}); + set_accels_for_action ("textview.action_toggle_list", {"F12"}); + + // Force the eOS icon theme, and set the blueberry as fallback, if for some reason it fails for individual notes var granite_settings = Granite.Settings.get_default (); diff --git a/src/Services/Constants.vala b/src/Services/Constants.vala index 0c9829a4..65a366d9 100644 --- a/src/Services/Constants.vala +++ b/src/Services/Constants.vala @@ -37,8 +37,8 @@ namespace Jorts.Constants { const int DEFAULT_HEIGHT = 320; // New preference window - const int DEFAULT_PREF_WIDTH = 570; - const int DEFAULT_PREF_HEIGHT = 340; + const int DEFAULT_PREF_WIDTH = 510; + const int DEFAULT_PREF_HEIGHT = 290; // Used by random_emote () for the emote selection menu const string[] EMOTES = { diff --git a/src/Views/PreferencesView.vala b/src/Views/PreferencesView.vala index ba6ebefb..db1cf30e 100644 --- a/src/Views/PreferencesView.vala +++ b/src/Views/PreferencesView.vala @@ -45,13 +45,12 @@ hexpand = false, valign = Gtk.Align.CENTER, max_length = 6, - max_width_chars = 6, - xalign = 0.5f + max_width_chars = 6 }; - var list_label = new Granite.HeaderLabel (_("List item symbol")) { + var list_label = new Granite.HeaderLabel (_("List item prefix")) { mnemonic_widget = list_entry, - secondary_text = _("Prefix by which to begin each item in a list. If there is no prefix, the toggle list button will be hidden"), + secondary_text = _("If empty, the toggle list button will be hidden"), hexpand = true }; @@ -75,7 +74,7 @@ var scribbly_box = new Jorts.SettingsSwitch ( _("Make unfocused notes unreadable"), - _("If enabled, unfocused sticky notes become unreadable to protect their content from peeking eyes (Ctrl+H)"), + _("Protect notes from peeking eyes (Ctrl+H)"), "scribbly-mode-active"); settingsbox.append (scribbly_box); @@ -86,8 +85,8 @@ /*************************************************/ var hidebar_box = new Jorts.SettingsSwitch ( - _("Hide buttons"), - _("If enabled, hides the bottom bar in sticky notes. Keyboard shortcuts will still function (Ctrl+T)"), + _("Hide bottom bar"), + _("Keyboard shortcuts will still function (Ctrl+T)"), "hide-bar"); settingsbox.append (hidebar_box); @@ -103,12 +102,11 @@ ///TRANSLATORS: Button to autostart the application var set_autostart = new Gtk.Button () { - label = _("Autostart"), + label = _("Set autostart"), valign = Gtk.Align.CENTER }; set_autostart.clicked.connect (() => { - debug ("Setting autostart"); Jorts.Utils.autostart_set (); toast.send_notification (); }); @@ -120,7 +118,6 @@ }; remove_autostart.clicked.connect (() => { - debug ("Removing autostart"); Jorts.Utils.autostart_remove (); toast.send_notification (); }); @@ -130,10 +127,10 @@ var autostart_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5); - var autostart_label = new Granite.HeaderLabel (_("Allow to start at login")) { + var autostart_label = new Granite.HeaderLabel (_("Start app at login")) { mnemonic_widget = both_buttons, - secondary_text = _("You can request the system to start this application automatically"), - hexpand = true + hexpand = true, + secondary_text = _("Sends a request to the system") }; autostart_box.append (autostart_label); @@ -166,32 +163,9 @@ ) }; - var reset = new Gtk.Button.from_icon_name ("system-reboot-symbolic") { - tooltip_markup = _("Reset all settings to defaults"), - valign = Gtk.Align.CENTER - }; - reset.clicked.connect (on_reset); - - var end_box = new Gtk.Box (HORIZONTAL, 5); - end_box.append (reset); - end_box.append (close_button); - actionbar.end_widget = end_box; + actionbar.end_widget = close_button; append (settingsbox); append (actionbar); } - - private void on_reset () { - debug ("Resetting settings…"); - - string[] keys = {"scribbly-mode-active", "hide-bar", "list-item-start"}; - foreach (var key in keys) { - Application.gsettings.reset (key); - } - -#if !WINDOWS - Jorts.Utils.autostart_remove (); - toast.send_notification (); -#endif - } } diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index dd9762fe..b344f93b 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -20,6 +20,13 @@ public class Jorts.TextView : Granite.HyperTextView { set {buffer.text = value;} } + public const string ACTION_PREFIX = "textview."; + public const string ACTION_TOGGLE_LIST = "action_toggle_list"; + + private const GLib.ActionEntry[] ACTION_ENTRIES = { + { ACTION_TOGGLE_LIST, toggle_list}, + }; + construct { buffer = new Gtk.TextBuffer (null); bottom_margin = 10; @@ -42,6 +49,21 @@ public class Jorts.TextView : Granite.HyperTextView { // on_cursor_changed (); // move_cursor.connect_after (on_cursor_changed); + var actions = new SimpleActionGroup (); + actions.add_action_entries (ACTION_ENTRIES, this); + insert_action_group ("textview", actions); + + var menuitem = new GLib.MenuItem (_("Toggle list"), TextView.ACTION_PREFIX + TextView.ACTION_TOGGLE_LIST); + + var extra = new GLib.Menu (); + var section = new GLib.Menu (); + section.append_item (menuitem); + + extra.append_section (null, section); + + this.extra_menu = extra; + + } public void paste () { @@ -177,7 +199,6 @@ public class Jorts.TextView : Granite.HyperTextView { buffer.end_user_action (); } } - return false; // If Enter on a list item, add a list prefix on the new line diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index d6f4dea8..15a8ecea 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -43,17 +43,6 @@ public class Jorts.StickyNoteWindow : Gtk.Window { public const string ACTION_DELETE = "action_delete"; public const string ACTION_TOGGLE_LIST = "action_toggle_list"; - public const string ACTION_THEME_1 = "action_theme_1"; - public const string ACTION_THEME_2 = "action_theme_2"; - public const string ACTION_THEME_3 = "action_theme_3"; - public const string ACTION_THEME_4 = "action_theme_4"; - public const string ACTION_THEME_5 = "action_theme_5"; - public const string ACTION_THEME_6 = "action_theme_6"; - public const string ACTION_THEME_7 = "action_theme_7"; - public const string ACTION_THEME_8 = "action_theme_8"; - public const string ACTION_THEME_9 = "action_theme_9"; - public const string ACTION_THEME_0 = "action_theme_0"; - public static Gee.MultiMap action_accelerators; private const GLib.ActionEntry[] ACTION_ENTRIES = { From ff3fb88e5a88b4cdf1922271d425ed78a7ff386e Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 17:33:26 +0100 Subject: [PATCH 08/15] skip auto for now --- src/Widgets/PopoverWidgets/ColorBox.vala | 4 ++-- src/Widgets/PopoverWidgets/ColorPill.vala | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Widgets/PopoverWidgets/ColorBox.vala b/src/Widgets/PopoverWidgets/ColorBox.vala index 0d7899b5..a29e054b 100644 --- a/src/Widgets/PopoverWidgets/ColorBox.vala +++ b/src/Widgets/PopoverWidgets/ColorBox.vala @@ -40,7 +40,7 @@ public class Jorts.ColorBox : Gtk.Box { var grape_button = new ColorPill (Themes.GRAPE, blueberry_button); var cocoa_button = new ColorPill (Themes.COCOA, blueberry_button); var slate_button = new ColorPill (Themes.SLATE, blueberry_button); - var auto_button = new ColorPill (Themes.IDK, blueberry_button); + //var auto_button = new ColorPill (Themes.IDK, blueberry_button); append (blueberry_button); append (mint_button); @@ -52,7 +52,7 @@ public class Jorts.ColorBox : Gtk.Box { append (grape_button); append (cocoa_button); append (slate_button); - append (auto_button); + //append (auto_button); accent_color_action = new SimpleAction.stateful ("prefers-accent-color", GLib.VariantType.INT32, new Variant.int32 (Themes.IDK)); var action_group = new SimpleActionGroup (); diff --git a/src/Widgets/PopoverWidgets/ColorPill.vala b/src/Widgets/PopoverWidgets/ColorPill.vala index 3c17fefe..8892e4d5 100644 --- a/src/Widgets/PopoverWidgets/ColorPill.vala +++ b/src/Widgets/PopoverWidgets/ColorPill.vala @@ -24,12 +24,12 @@ public class Jorts.ColorPill : Gtk.CheckButton { construct { add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - if (color == Themes.IDK) { - add_css_class ("auto"); + //if (color == Themes.IDK) { + // add_css_class ("auto"); - } else { + //} else { add_css_class (color.to_css_class ()); - } + //} tooltip_text = color.to_nicename (); From feae783cb98690e6948c1d3190bf2987e7505c61 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 18:15:21 +0100 Subject: [PATCH 09/15] normalize some sizes --- src/Widgets/PopoverWidgets/ColorBox.vala | 4 +-- src/Widgets/PopoverWidgets/MonospaceBox.vala | 4 +-- src/Widgets/PopoverWidgets/ZoomBox.vala | 4 +-- src/Widgets/TextView.vala | 26 ++++++++++---------- src/Windows/PreferenceWindow.vala | 2 -- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Widgets/PopoverWidgets/ColorBox.vala b/src/Widgets/PopoverWidgets/ColorBox.vala index a29e054b..1ac2ae03 100644 --- a/src/Widgets/PopoverWidgets/ColorBox.vala +++ b/src/Widgets/PopoverWidgets/ColorBox.vala @@ -26,8 +26,8 @@ public class Jorts.ColorBox : Gtk.Box { accessible_role = Gtk.AccessibleRole.LIST; spacing = 1; - margin_start = 12; - margin_end = 12; + margin_start = 10; + margin_end = 10; var blueberry_button = new ColorPill (Themes.BLUEBERRY); diff --git a/src/Widgets/PopoverWidgets/MonospaceBox.vala b/src/Widgets/PopoverWidgets/MonospaceBox.vala index 9d97c7d0..6748fd7c 100644 --- a/src/Widgets/PopoverWidgets/MonospaceBox.vala +++ b/src/Widgets/PopoverWidgets/MonospaceBox.vala @@ -25,8 +25,8 @@ public class Jorts.MonospaceBox : Gtk.Box { orientation = Gtk.Orientation.HORIZONTAL; homogeneous = true; hexpand = true; - margin_start = 12; - margin_end = 12; + margin_start = 10; + margin_end = 10; ///TRANSLATORS: Both Default and Monospace are togglable buttons, synchronized with each other var mono_default_toggle = new Gtk.ToggleButton () { diff --git a/src/Widgets/PopoverWidgets/ZoomBox.vala b/src/Widgets/PopoverWidgets/ZoomBox.vala index 3e6e6ba3..93e75994 100644 --- a/src/Widgets/PopoverWidgets/ZoomBox.vala +++ b/src/Widgets/PopoverWidgets/ZoomBox.vala @@ -32,8 +32,8 @@ public class Jorts.ZoomBox : Gtk.Box { orientation = Gtk.Orientation.HORIZONTAL; homogeneous = true; hexpand = true; - margin_start = 12; - margin_end = 12; + margin_start = 10; + margin_end = 10; ///TRANSLATORS: These are displayed on small linked buttons in a menu. User can click them to change zoom var zoom_out_button = new Gtk.Button.from_icon_name ("zoom-out-symbolic") { diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index b344f93b..55dc0877 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -34,9 +34,13 @@ public class Jorts.TextView : Granite.HyperTextView { right_margin = 10; top_margin = 5; - set_hexpand (true); - set_vexpand (true); - set_wrap_mode (Gtk.WrapMode.WORD_CHAR); + hexpand = true; + vexpand = true; + wrap_mode = Gtk.WrapMode.WORD_CHAR; + + var actions = new SimpleActionGroup (); + actions.add_action_entries (ACTION_ENTRIES, this); + insert_action_group ("textview", actions); list_item_start = Application.gsettings.get_string ("list-item-start"); Application.gsettings.changed["list-item-start"].connect (on_prefix_changed); @@ -49,19 +53,15 @@ public class Jorts.TextView : Granite.HyperTextView { // on_cursor_changed (); // move_cursor.connect_after (on_cursor_changed); - var actions = new SimpleActionGroup (); - actions.add_action_entries (ACTION_ENTRIES, this); - insert_action_group ("textview", actions); - - var menuitem = new GLib.MenuItem (_("Toggle list"), TextView.ACTION_PREFIX + TextView.ACTION_TOGGLE_LIST); - var extra = new GLib.Menu (); - var section = new GLib.Menu (); - section.append_item (menuitem); + // var menuitem = new GLib.MenuItem (_("Toggle list"), TextView.ACTION_PREFIX + TextView.ACTION_TOGGLE_LIST); + // var extra = new GLib.Menu (); + // var section = new GLib.Menu (); - extra.append_section (null, section); + // section.append_item (menuitem); + // extra.append_section (null, section); - this.extra_menu = extra; + // this.extra_menu = extra; } diff --git a/src/Windows/PreferenceWindow.vala b/src/Windows/PreferenceWindow.vala index b2a53f26..a838f3f7 100644 --- a/src/Windows/PreferenceWindow.vala +++ b/src/Windows/PreferenceWindow.vala @@ -45,8 +45,6 @@ public class Jorts.PreferenceWindow : Gtk.Window { set_default_size (Jorts.Constants.DEFAULT_PREF_WIDTH, Jorts.Constants.DEFAULT_PREF_HEIGHT); resizable = false; - add_css_class (Granite.STYLE_CLASS_MESSAGE_DIALOG); - var prefview = new Jorts.PreferencesView (); // Make the whole window grabbable From c4aec7946bec2087bd7a2e540cb786867a63fc2f Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 18:47:31 +0100 Subject: [PATCH 10/15] make textview responsible for refocus --- src/Widgets/TextView.vala | 2 ++ src/Windows/StickyNoteWindow.vala | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index 55dc0877..80de1d11 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -99,6 +99,8 @@ public class Jorts.TextView : Granite.HyperTextView { this.set_list (first_line, last_line); } buffer.end_user_action (); + + grab_focus (); } /** diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index 15a8ecea..e1264560 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -223,7 +223,7 @@ public class Jorts.StickyNoteWindow : Gtk.Window { private void action_show_menu () {view.menu_button.activate ();} private void action_delete () {((Jorts.Application)this.application).manager.delete_note (this);} private void action_toggle_mono () {popover.monospace = !popover.monospace;} - private void action_toggle_list () {view.textview.toggle_list (); set_focus (view.textview);} + private void action_toggle_list () {view.textview.toggle_list ();} private void action_zoom_out () {zoomcontroller.zoom_out ();} private void action_zoom_default () {zoomcontroller.zoom_default ();} From 9ef2d302a0ce4717d0c1fac201178ca8a0a43dd0 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 22:21:41 +0100 Subject: [PATCH 11/15] introduce a color controller to handle theming --- src/Services/ColorController.vala | 48 ++++++++++++++++++++++++ src/Widgets/Popover.vala | 43 ++++----------------- src/Widgets/PopoverWidgets/ColorBox.vala | 2 + src/Windows/StickyNoteWindow.vala | 32 ++++++++-------- src/meson.build | 1 + 5 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 src/Services/ColorController.vala diff --git a/src/Services/ColorController.vala b/src/Services/ColorController.vala new file mode 100644 index 00000000..a09cf464 --- /dev/null +++ b/src/Services/ColorController.vala @@ -0,0 +1,48 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2017-2024 Lains + * 2025 Stella & Charlie (teamcons.carrd.co) + * 2025 Contributions from the ellie_Commons community (github.com/ellie-commons/) + */ + +/*************************************************/ +/** +* Responsible to apply RedactedScript font +* Give it a window and it will simply follow settings +*/ +public class Jorts.ColorController : Object { + + private Jorts.StickyNoteWindow window; + + private Jorts.Themes _theme; + public Jorts.Themes theme { + get { return _theme;} + set { on_color_changed (value);} + } + + public ColorController (Jorts.StickyNoteWindow window) { + this.window = window; + } + + /** + * Switches stylesheet + * First use appropriate stylesheet, Then switch the theme classes + */ + public void on_color_changed (Jorts.Themes new_theme) { + debug ("Updating theme to %s".printf (new_theme.to_string ())); + + // Add remove class + if (_theme.to_string () in window.css_classes) { + window.remove_css_class (_theme.to_string ()); + } + window.add_css_class (new_theme.to_string ()); + + // Propagate values + _theme = new_theme; + window.popover.color = new_theme; + NoteData.latest_theme = new_theme; + + // Cleanup; + window.changed (); + } +} diff --git a/src/Widgets/Popover.vala b/src/Widgets/Popover.vala index dae5e196..e51ae000 100644 --- a/src/Widgets/Popover.vala +++ b/src/Widgets/Popover.vala @@ -11,14 +11,13 @@ */ public class Jorts.PopoverView : Gtk.Popover { private Jorts.StickyNoteWindow parent_window; - private Jorts.ColorBox color_button_box; + private Jorts.ColorBox color_box; private Jorts.MonospaceBox monospace_box; private Jorts.ZoomBox font_size_box; - private Themes _old_color = Jorts.Constants.DEFAULT_THEME; public Themes color { - get {return _old_color;} - set {on_color_changed (value);} + get {return color_box.color;} + set {color_box.color = value;} } public bool monospace { @@ -59,47 +58,19 @@ public class Jorts.PopoverView : Gtk.Popover { margin_bottom = 12 }; - color_button_box = new Jorts.ColorBox (); + color_box = new Jorts.ColorBox (); monospace_box = new Jorts.MonospaceBox (); font_size_box = new Jorts.ZoomBox (); - view.append (color_button_box); + view.append (color_box); view.append (monospace_box); view.append (font_size_box); child = view; - color_button_box.theme_changed.connect (on_color_changed); + color_box.theme_changed.connect ((theme) => {theme_changed (theme);}); monospace_box.monospace_changed.connect (on_monospace_changed); - font_size_box.zoom_changed.connect ((zoomkind) => {this.zoom_changed (zoomkind);}); - } - - - - /** - * Switches stylesheet - * First use appropriate stylesheet, Then switch the theme classes - */ - private void on_color_changed (Jorts.Themes new_theme) { - debug ("Updating theme to %s".printf (new_theme.to_string ())); - - // Avoid deathloop where the handler calls itself - color_button_box.theme_changed.disconnect (on_color_changed); - - // Add remove class - if (_old_color.to_string () in parent_window.css_classes) { - parent_window.remove_css_class (_old_color.to_string ()); - } - parent_window.add_css_class (new_theme.to_string ()); - - // Propagate values - _old_color = new_theme; - color_button_box.color = new_theme; - NoteData.latest_theme = new_theme; - - // Cleanup; - parent_window.changed (); - color_button_box.theme_changed.connect (on_color_changed); + font_size_box.zoom_changed.connect ((zoomkind) => {zoom_changed (zoomkind);}); } /** diff --git a/src/Widgets/PopoverWidgets/ColorBox.vala b/src/Widgets/PopoverWidgets/ColorBox.vala index 1ac2ae03..3e070eb9 100644 --- a/src/Widgets/PopoverWidgets/ColorBox.vala +++ b/src/Widgets/PopoverWidgets/ColorBox.vala @@ -62,6 +62,8 @@ public class Jorts.ColorBox : Gtk.Box { accent_color_action.activate.connect (set_broadcast); } + // Ignore if user switches from same value to same value + // Only send signal if it is a user action, to avoid a deathloop if theme is changed elsewhere private void set_broadcast (GLib.Variant? value) { if (!accent_color_action.get_state ().equal (value)) { accent_color_action.set_state (value); diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index e1264560..cae17e49 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -19,8 +19,9 @@ public class Jorts.StickyNoteWindow : Gtk.Window { public PopoverView popover; public TextView textview; - private Jorts.ZoomController zoomcontroller; - private Jorts.ScribblyController scribblycontroller; + private Jorts.ColorController color_controller; + private Jorts.ZoomController zoom_controller; + private Jorts.ScribblyController scribbly_controller; public NoteData data { owned get { return packaged ();} @@ -66,9 +67,9 @@ public class Jorts.StickyNoteWindow : Gtk.Window { actions.add_action_entries (ACTION_ENTRIES, this); insert_action_group ("win", actions); - - zoomcontroller = new Jorts.ZoomController (this); - scribblycontroller = new Jorts.ScribblyController (this); + color_controller = new Jorts.ColorController (this); + zoom_controller = new Jorts.ZoomController (this); + scribbly_controller = new Jorts.ScribblyController (this); keypress_controller = new Gtk.EventControllerKey (); scroll_controller = new Gtk.EventControllerScroll (VERTICAL) { @@ -109,16 +110,17 @@ public class Jorts.StickyNoteWindow : Gtk.Window { /***************************************************/ // We need this for Ctr + Scroll. We delegate everything to zoomcontroller - keypress_controller.key_pressed.connect (zoomcontroller.on_key_press_event); - keypress_controller.key_released.connect (zoomcontroller.on_key_release_event); - scroll_controller.scroll.connect (zoomcontroller.on_scroll); + keypress_controller.key_pressed.connect (zoom_controller.on_key_press_event); + keypress_controller.key_released.connect (zoom_controller.on_key_release_event); + scroll_controller.scroll.connect (zoom_controller.on_scroll); debug ("Built UI. Lets do connects and binds"); // Save when title or text have changed view.editablelabel.changed.connect (on_editable_changed); view.textview.buffer.changed.connect (has_changed); - popover.zoom_changed.connect (zoomcontroller.zoom_changed); + popover.zoom_changed.connect (zoom_controller.zoom_changed); + popover.theme_changed.connect (color_controller.on_color_changed); // Use the color theme of this sticky note when focused this.notify["is-active"].connect (on_focus_changed); @@ -192,7 +194,7 @@ public class Jorts.StickyNoteWindow : Gtk.Window { theme = popover.color, content = view.content, monospace = popover.monospace, - zoom = zoomcontroller.zoom, + zoom = zoom_controller.zoom, width = this_width, height = this_height }; @@ -211,9 +213,9 @@ public class Jorts.StickyNoteWindow : Gtk.Window { title = view.editablelabel.text + _(" - Jorts"); view.textview.buffer.text = data.content; - zoomcontroller.zoom = data.zoom; + color_controller.theme = data.theme; + zoom_controller.zoom = data.zoom; popover.monospace = data.monospace; - popover.color = data.theme; } private void has_changed () {changed ();} @@ -225,7 +227,7 @@ public class Jorts.StickyNoteWindow : Gtk.Window { private void action_toggle_mono () {popover.monospace = !popover.monospace;} private void action_toggle_list () {view.textview.toggle_list ();} - private void action_zoom_out () {zoomcontroller.zoom_out ();} - private void action_zoom_default () {zoomcontroller.zoom_default ();} - private void action_zoom_in () {zoomcontroller.zoom_in ();} + private void action_zoom_out () {zoom_controller.zoom_out ();} + private void action_zoom_default () {zoom_controller.zoom_default ();} + private void action_zoom_in () {zoom_controller.zoom_in ();} } diff --git a/src/meson.build b/src/meson.build index 0631155d..1a83a0b4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,6 +11,7 @@ sources = files ( 'Services' / 'NoteManager.vala', 'Services' / 'ZoomController.vala', 'Services' / 'ScribblyController.vala', + 'Services' / 'ColorController.vala', 'Widgets' / 'EditableLabel.vala', 'Widgets' / 'TextView.vala', From ef97c9ab60998ca2d61aac37170152e0928c1045 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 22:34:52 +0100 Subject: [PATCH 12/15] move constants to src --- src/{Services => }/Constants.vala | 0 src/meson.build | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{Services => }/Constants.vala (100%) diff --git a/src/Services/Constants.vala b/src/Constants.vala similarity index 100% rename from src/Services/Constants.vala rename to src/Constants.vala diff --git a/src/meson.build b/src/meson.build index 1a83a0b4..faa95d87 100644 --- a/src/meson.build +++ b/src/meson.build @@ -6,7 +6,6 @@ sources = files ( 'Utils' / 'Random.vala', - 'Services' / 'Constants.vala', 'Services' / 'Storage.vala', 'Services' / 'NoteManager.vala', 'Services' / 'ZoomController.vala', @@ -30,6 +29,7 @@ sources = files ( 'Windows' / 'PreferenceWindow.vala', 'Windows' / 'StickyNoteWindow.vala', + 'Constants.vala', 'Application.vala', ) From e04fcb4f2635be2ca0c4642f6c0a196efb175ba1 Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 22:36:15 +0100 Subject: [PATCH 13/15] move some supporting functions to the view --- src/Views/NoteView.vala | 5 +++++ src/Windows/StickyNoteWindow.vala | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Views/NoteView.vala b/src/Views/NoteView.vala index c5e20c91..d17d1154 100644 --- a/src/Views/NoteView.vala +++ b/src/Views/NoteView.vala @@ -87,4 +87,9 @@ editablelabel.monospace = if_mono; textview.monospace = if_mono; } + + public void action_focus_title () {editablelabel.editing = true;} + public void action_show_emoji () {emoji_button.activate ();} + public void action_show_menu () {menu_button.activate ();} + public void action_toggle_list () {textview.toggle_list ();} } diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index cae17e49..eb1cda80 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -220,12 +220,12 @@ public class Jorts.StickyNoteWindow : Gtk.Window { private void has_changed () {changed ();} - private void action_focus_title () {set_focus (view.editablelabel); view.editablelabel.editing = true;} - private void action_show_emoji () {view.emoji_button.activate ();} - private void action_show_menu () {view.menu_button.activate ();} + private void action_focus_title () {view.action_focus_title ();} + private void action_show_emoji () {view.action_show_emoji ();} + private void action_show_menu () {view.action_show_menu ();} private void action_delete () {((Jorts.Application)this.application).manager.delete_note (this);} private void action_toggle_mono () {popover.monospace = !popover.monospace;} - private void action_toggle_list () {view.textview.toggle_list ();} + private void action_toggle_list () {view.action_toggle_list ();} private void action_zoom_out () {zoom_controller.zoom_out ();} private void action_zoom_default () {zoom_controller.zoom_default ();} From e85bbce2d42335b3721015e8d6cab86b07931e4c Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 22:51:37 +0100 Subject: [PATCH 14/15] Rename Popoverview to popover --- src/Services/NoteManager.vala | 1 + src/Services/Storage.vala | 8 ++++---- src/Widgets/Popover.vala | 4 ++-- src/Windows/StickyNoteWindow.vala | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Services/NoteManager.vala b/src/Services/NoteManager.vala index 32acbd04..c15408ca 100644 --- a/src/Services/NoteManager.vala +++ b/src/Services/NoteManager.vala @@ -110,6 +110,7 @@ public class Jorts.NoteManager : Object { print ("new"); } + note.changed.connect (save_all); note.show (); note.present (); note.textview.paste (); diff --git a/src/Services/Storage.vala b/src/Services/Storage.vala index f9156fcd..5cf13c06 100644 --- a/src/Services/Storage.vala +++ b/src/Services/Storage.vala @@ -47,7 +47,7 @@ public class Jorts.Storage : Object { * Persistently check for the data directory and create if there is none */ private void check_if_stash () { - debug ("[STORAGE] do we have a data directory?"); + debug ("do we have a data directory?"); var dir = File.new_for_path (data_directory); try { @@ -65,7 +65,7 @@ public class Jorts.Storage : Object { * Converts a Json.Node into a string and take care of saving it */ public void save (Json.Array json_data) { - debug("[STORAGE] Writing..."); + debug("Writing..."); check_if_stash (); try { @@ -87,7 +87,7 @@ public class Jorts.Storage : Object { * Grab from storage, into a Json.Node we can parse. Insist if necessary */ public Json.Array? load () { - debug("[STORAGE] Loading from storage letsgo"); + debug("Loading from storage letsgo"); check_if_stash (); var parser = new Json.Parser (); var array = new Json.Array (); @@ -110,7 +110,7 @@ public class Jorts.Storage : Object { * Like it says on the tin */ public void dump () { - debug("[STORAGE] DROP TABLE Students;--"); + debug("DROP TABLE Students;--"); var everything = load (); var generator = new Json.Generator () { diff --git a/src/Widgets/Popover.vala b/src/Widgets/Popover.vala index e51ae000..16cf08e9 100644 --- a/src/Widgets/Popover.vala +++ b/src/Widgets/Popover.vala @@ -9,7 +9,7 @@ * The popover menu to tweak individual notes * Contains a setting for color, one for monospace font, one for zoom */ -public class Jorts.PopoverView : Gtk.Popover { +public class Jorts.Popover : Gtk.Popover { private Jorts.StickyNoteWindow parent_window; private Jorts.ColorBox color_box; private Jorts.MonospaceBox monospace_box; @@ -48,7 +48,7 @@ public class Jorts.PopoverView : Gtk.Popover { /****************/ - public PopoverView (Jorts.StickyNoteWindow window) { + public Popover (Jorts.StickyNoteWindow window) { position = Gtk.PositionType.TOP; halign = Gtk.Align.END; parent_window = window; diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala index eb1cda80..df39b099 100644 --- a/src/Windows/StickyNoteWindow.vala +++ b/src/Windows/StickyNoteWindow.vala @@ -16,7 +16,7 @@ public class Jorts.StickyNoteWindow : Gtk.Window { public Jorts.NoteView view; - public PopoverView popover; + public Popover popover; public TextView textview; private Jorts.ColorController color_controller; @@ -93,7 +93,7 @@ public class Jorts.StickyNoteWindow : Gtk.Window { view = new NoteView (); textview = view.textview; - popover = new Jorts.PopoverView (this); + popover = new Jorts.Popover (this); view.menu_button.popover = popover; set_child (view); From 33fe63026d8ca9bd5a3f5522b9a652c972d972db Mon Sep 17 00:00:00 2001 From: teamcons Date: Fri, 21 Nov 2025 23:25:16 +0100 Subject: [PATCH 15/15] remove unused features --- src/Application.vala | 19 +------------------ src/Constants.vala | 4 ++-- src/Services/NoteManager.vala | 32 -------------------------------- src/Services/Storage.vala | 18 ------------------ src/Views/PreferencesView.vala | 10 +++++----- src/Widgets/TextView.vala | 16 ---------------- 6 files changed, 8 insertions(+), 91 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 7cb3f0a4..87029adc 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -49,10 +49,7 @@ public class Jorts.Application : Gtk.Application { // Used for commandline option handling public static bool new_note = false; - public static bool new_from_clipboard = false; public static bool show_pref = false; - public static bool reset_settings = false; - public static bool dump_storage = false; public const string ACTION_PREFIX = "app."; public const string ACTION_QUIT = "action_quit"; @@ -190,10 +187,7 @@ Please wait while the app remembers all the things... } if (new_note) {manager.create_note (); new_note = false;} - if (new_from_clipboard) {manager.from_clipboard (); new_from_clipboard = false;} if (show_pref) {action_show_preferences (); show_pref = false;} - if (reset_settings) {action_reset_settings (); reset_settings = false;} - if (dump_storage) {manager.dump (); dump_storage = false;} } public static int main (string[] args) { @@ -234,14 +228,6 @@ Please wait while the app remembers all the things... manager.save_all (); } - private void action_reset_settings () { - debug ("[ACTION] Resetting settings…"); - string[] keys = {"scribbly-mode-active", "hide-bar"}; - foreach (var key in keys) { - gsettings.reset (key); - } - } - // checked upon window closing to make sure we do not linger in the background public void check_if_quit () { debug ("Windows open: %s".printf (get_windows ().length ().to_string ())); @@ -257,10 +243,7 @@ Please wait while the app remembers all the things... OptionEntry[] CMD_OPTION_ENTRIES = { {"new-note", 'n', OptionFlags.NONE, OptionArg.NONE, ref new_note, "Create a new note", null}, - {"new-from-clipboard", 'c', OptionFlags.NONE, OptionArg.NONE, ref new_from_clipboard, "Create a note then paste from clipboard", null}, - {"preferences", 'p', OptionFlags.NONE, OptionArg.NONE, ref show_pref, "Show preferences", null}, - {"reset-settings", 'r', OptionFlags.NONE, OptionArg.NONE, ref reset_settings, "Reset all settings", null}, - {"dump", 'd', OptionFlags.NONE, OptionArg.NONE, ref dump_storage, "Dump the content of the storage as a pretty JSON", null} + {"preferences", 'p', OptionFlags.NONE, OptionArg.NONE, ref show_pref, "Show preferences", null} }; // We have to make an extra copy of the array, since .parse assumes diff --git a/src/Constants.vala b/src/Constants.vala index 65a366d9..4e66c5ed 100644 --- a/src/Constants.vala +++ b/src/Constants.vala @@ -37,8 +37,8 @@ namespace Jorts.Constants { const int DEFAULT_HEIGHT = 320; // New preference window - const int DEFAULT_PREF_WIDTH = 510; - const int DEFAULT_PREF_HEIGHT = 290; + const int DEFAULT_PREF_WIDTH = 490; + const int DEFAULT_PREF_HEIGHT = 270; // Used by random_emote () for the emote selection menu const string[] EMOTES = { diff --git a/src/Services/NoteManager.vala b/src/Services/NoteManager.vala index c15408ca..da9e7893 100644 --- a/src/Services/NoteManager.vala +++ b/src/Services/NoteManager.vala @@ -87,35 +87,6 @@ public class Jorts.NoteManager : Object { note.present (); } - /*************************************************/ - /** - * When user asked for a new note and for it to be pasted in - */ - public void from_clipboard () { - debug ("Creating and loading from clipboard…"); - print ("clipboard!"); - Jorts.StickyNoteWindow note; - - // If the app has only one empty note (or no note but just created one), - // Then paste in it. - if ((open_notes.size == 1) && open_notes[0].textview.buffer.text == "") { - note = open_notes[0]; - print ("first one"); - - } else { - // Skip theme from previous window, but use same text zoom - var random_data = new NoteData (); - note = new StickyNoteWindow (application, random_data); - open_notes.add (note); - print ("new"); - } - - note.changed.connect (save_all); - note.show (); - note.present (); - note.textview.paste (); - } - /*************************************************/ /** * Delete a note by remove it from the active list and closing its window @@ -184,7 +155,4 @@ public class Jorts.NoteManager : Object { } } } - - /*************************************************/ - public void dump () {storage.dump ();} } diff --git a/src/Services/Storage.vala b/src/Services/Storage.vala index 5cf13c06..faeacb3a 100644 --- a/src/Services/Storage.vala +++ b/src/Services/Storage.vala @@ -104,22 +104,4 @@ public class Jorts.Storage : Object { return array; } - - /*************************************************/ - /** - * Like it says on the tin - */ - public void dump () { - debug("DROP TABLE Students;--"); - - var everything = load (); - var generator = new Json.Generator () { - pretty = true - }; - - var node = new Json.Node (Json.NodeType.ARRAY); - node.set_array (everything); - generator.set_root (node); - print (generator.to_data (null)); - } } diff --git a/src/Views/PreferencesView.vala b/src/Views/PreferencesView.vala index db1cf30e..f87b6324 100644 --- a/src/Views/PreferencesView.vala +++ b/src/Views/PreferencesView.vala @@ -24,7 +24,7 @@ overlay.add_overlay (toast); // the box with all the settings - var settingsbox = new Gtk.Box (VERTICAL, 20) { + var settingsbox = new Gtk.Box (VERTICAL, 15) { margin_top = 5, margin_start = 5, margin_end = 5, @@ -73,8 +73,8 @@ debug ("Built UI. Lets do connects and binds"); var scribbly_box = new Jorts.SettingsSwitch ( - _("Make unfocused notes unreadable"), - _("Protect notes from peeking eyes (Ctrl+H)"), + _("Scribble mode"), + _("Make notes unreadable when unfocused (Ctrl+H)"), "scribbly-mode-active"); settingsbox.append (scribbly_box); @@ -127,10 +127,10 @@ var autostart_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5); - var autostart_label = new Granite.HeaderLabel (_("Start app at login")) { + var autostart_label = new Granite.HeaderLabel (_("Start automatically")) { mnemonic_widget = both_buttons, hexpand = true, - secondary_text = _("Sends a request to the system") + secondary_text = _("open the app when you log in") }; autostart_box.append (autostart_label); diff --git a/src/Widgets/TextView.vala b/src/Widgets/TextView.vala index 80de1d11..c96a9d5a 100644 --- a/src/Widgets/TextView.vala +++ b/src/Widgets/TextView.vala @@ -62,22 +62,6 @@ public class Jorts.TextView : Granite.HyperTextView { // extra.append_section (null, section); // this.extra_menu = extra; - - - } - - public void paste () { - var clipboard = Gdk.Display.get_default ().get_clipboard (); - clipboard.read_text_async.begin ((null), (obj, res) => { - - try { - var pasted_text = clipboard.read_text_async.end (res); - this.buffer.text = pasted_text; - - } catch (Error e) { - print ("Cannot access clipboard: " + e.message); - } - }); } public void toggle_list () {