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/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/Application.vala b/src/Application.vala
index 0117ec71..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";
@@ -103,16 +100,8 @@ 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"});
+ 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
@@ -198,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) {
@@ -242,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 ()));
@@ -265,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/Services/Constants.vala b/src/Constants.vala
similarity index 88%
rename from src/Services/Constants.vala
rename to src/Constants.vala
index 89d75c71..4e66c5ed 100644
--- a/src/Services/Constants.vala
+++ b/src/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
@@ -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 = 490;
+ const int DEFAULT_PREF_HEIGHT = 270;
// Used by random_emote () for the emote selection menu
const string[] EMOTES = {
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/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/Services/NoteManager.vala b/src/Services/NoteManager.vala
index 32acbd04..da9e7893 100644
--- a/src/Services/NoteManager.vala
+++ b/src/Services/NoteManager.vala
@@ -87,34 +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.show ();
- note.present ();
- note.textview.paste ();
- }
-
/*************************************************/
/**
* Delete a note by remove it from the active list and closing its window
@@ -183,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 f9156fcd..faeacb3a 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 ();
@@ -104,22 +104,4 @@ public class Jorts.Storage : Object {
return array;
}
-
- /*************************************************/
- /**
- * Like it says on the tin
- */
- public void dump () {
- debug("[STORAGE] 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/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/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/Views/PreferencesView.vala b/src/Views/PreferencesView.vala
index eb4e440a..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,
@@ -44,13 +44,13 @@
halign = Gtk.Align.END,
hexpand = false,
valign = Gtk.Align.CENTER,
- max_length = 5,
- max_width_chars = 5
+ max_length = 6,
+ 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
};
@@ -73,8 +73,8 @@
debug ("Built UI. Lets do connects and binds");
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)"),
+ _("Scribble mode"),
+ _("Make notes unreadable when unfocused (Ctrl+H)"),
"scribbly-mode-active");
settingsbox.append (scribbly_box);
@@ -85,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);
@@ -102,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 ();
});
@@ -119,7 +118,6 @@
};
remove_autostart.clicked.connect (() => {
- debug ("Removing autostart");
Jorts.Utils.autostart_remove ();
toast.send_notification ();
});
@@ -129,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 automatically")) {
mnemonic_widget = both_buttons,
- secondary_text = _("You can request the system to start this application automatically"),
- hexpand = true
+ hexpand = true,
+ secondary_text = _("open the app when you log in")
};
autostart_box.append (autostart_label);
@@ -165,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/Popover.vala b/src/Widgets/Popover.vala
index c5ac9797..16cf08e9 100644
--- a/src/Widgets/Popover.vala
+++ b/src/Widgets/Popover.vala
@@ -9,16 +9,15 @@
* 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_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 {
@@ -26,7 +25,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);
@@ -45,24 +44,11 @@ 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);
- }
+ }
/****************/
- public PopoverView (Jorts.StickyNoteWindow window) {
+ public Popover (Jorts.StickyNoteWindow window) {
position = Gtk.PositionType.TOP;
halign = Gtk.Align.END;
parent_window = window;
@@ -72,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 28b84900..3e070eb9 100644
--- a/src/Widgets/PopoverWidgets/ColorBox.vala
+++ b/src/Widgets/PopoverWidgets/ColorBox.vala
@@ -11,128 +11,63 @@
*/
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;
- 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);
+ spacing = 1;
+ margin_start = 10;
+ margin_end = 10;
+
+
+ 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);
+ // 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);
+ 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..8892e4d5 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/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 70ba8882..93e75994 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;
@@ -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 cb93f80d..c96a9d5a 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;
@@ -27,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);
@@ -42,28 +53,23 @@ public class Jorts.TextView : Granite.HyperTextView {
// on_cursor_changed ();
// move_cursor.connect_after (on_cursor_changed);
- }
- public void paste () {
- var clipboard = Gdk.Display.get_default ().get_clipboard ();
- clipboard.read_text_async.begin ((null), (obj, res) => {
+ // var menuitem = new GLib.MenuItem (_("Toggle list"), TextView.ACTION_PREFIX + TextView.ACTION_TOGGLE_LIST);
+ // var extra = new GLib.Menu ();
+ // var section = new GLib.Menu ();
- try {
- var pasted_text = clipboard.read_text_async.end (res);
- this.buffer.text = pasted_text;
+ // section.append_item (menuitem);
+ // extra.append_section (null, section);
- } catch (Error e) {
- print ("Cannot access clipboard: " + e.message);
- }
- });
+ // this.extra_menu = extra;
}
public void toggle_list () {
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);
@@ -77,12 +83,16 @@ public class Jorts.TextView : Granite.HyperTextView {
this.set_list (first_line, last_line);
}
buffer.end_user_action ();
+
+ grab_focus ();
}
/**
* 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;
buffer.get_iter_at_line_offset (out start, line_number, 0);
@@ -97,9 +107,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)) {
@@ -113,9 +123,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)) {
@@ -128,8 +138,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);
}
}
@@ -137,9 +147,9 @@ 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.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);
@@ -151,7 +161,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) {
@@ -160,7 +170,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)) {
@@ -175,14 +185,13 @@ 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
} 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)) {
@@ -202,13 +211,13 @@ 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 ();
+ var line_number = start.get_line ();
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/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
diff --git a/src/Windows/StickyNoteWindow.vala b/src/Windows/StickyNoteWindow.vala
index e6d3e031..df39b099 100644
--- a/src/Windows/StickyNoteWindow.vala
+++ b/src/Windows/StickyNoteWindow.vala
@@ -16,11 +16,12 @@
public class Jorts.StickyNoteWindow : Gtk.Window {
public Jorts.NoteView view;
- public PopoverView popover;
+ public Popover 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 ();}
@@ -43,17 +44,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 = {
@@ -63,19 +53,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) {
@@ -87,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) {
@@ -113,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);
@@ -130,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);
@@ -213,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
};
@@ -232,33 +213,21 @@ 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 ();}
- 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 (); set_focus (view.textview);}
-
- 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];}
+ 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 ();}
+ private void action_zoom_in () {zoom_controller.zoom_in ();}
}
diff --git a/src/meson.build b/src/meson.build
index 0631155d..faa95d87 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -6,11 +6,11 @@ sources = files (
'Utils' / 'Random.vala',
- 'Services' / 'Constants.vala',
'Services' / 'Storage.vala',
'Services' / 'NoteManager.vala',
'Services' / 'ZoomController.vala',
'Services' / 'ScribblyController.vala',
+ 'Services' / 'ColorController.vala',
'Widgets' / 'EditableLabel.vala',
'Widgets' / 'TextView.vala',
@@ -29,6 +29,7 @@ sources = files (
'Windows' / 'PreferenceWindow.vala',
'Windows' / 'StickyNoteWindow.vala',
+ 'Constants.vala',
'Application.vala',
)