Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions data/Application.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion data/jorts.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<description>Whether to hide the actionbar and its buttons</description>
</key>
<key name="list-item-start" type="s">
<default>" - "</default>
<default>" "</default>
<summary>Hide actionbar</summary>
<description>Whether to hide the actionbar and its buttons</description>
</key>
Expand Down
31 changes: 3 additions & 28 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -103,16 +100,8 @@ public class Jorts.Application : Gtk.Application {
set_accels_for_action ("win.action_toggle_list", {"<Shift>F12"});
set_accels_for_action ("win.action_show_menu", {"<Control>G", "<Control>O"});

set_accels_for_action ("win.action_theme_1", {"<Alt>1"});
set_accels_for_action ("win.action_theme_2", {"<Alt>2"});
set_accels_for_action ("win.action_theme_3", {"<Alt>3"});
set_accels_for_action ("win.action_theme_4", {"<Alt>4"});
set_accels_for_action ("win.action_theme_5", {"<Alt>5"});
set_accels_for_action ("win.action_theme_6", {"<Alt>6"});
set_accels_for_action ("win.action_theme_7", {"<Alt>7"});
set_accels_for_action ("win.action_theme_8", {"<Alt>8"});
set_accels_for_action ("win.action_theme_9", {"<Alt>9"});
set_accels_for_action ("win.action_theme_0", {"<Alt>0", "<Alt>KP_0"});
set_accels_for_action ("textview.action_toggle_list", {"<Shift>F12"});



// Force the eOS icon theme, and set the blueberry as fallback, if for some reason it fails for individual notes
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 ()));
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/Services/Constants.vala → src/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ 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
const int DEFAULT_WIDTH = 290;
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 = {
Expand Down
6 changes: 3 additions & 3 deletions src/Objects/NoteData.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;}
Expand Down
6 changes: 3 additions & 3 deletions src/Objects/Zoom.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
48 changes: 48 additions & 0 deletions src/Services/ColorController.vala
Original file line number Diff line number Diff line change
@@ -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 ();
}
}
31 changes: 0 additions & 31 deletions src/Services/NoteManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -183,7 +155,4 @@ public class Jorts.NoteManager : Object {
}
}
}

/*************************************************/
public void dump () {storage.dump ();}
}
24 changes: 3 additions & 21 deletions src/Services/Storage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 ();
Expand All @@ -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));
}
}
8 changes: 4 additions & 4 deletions src/Services/ZoomController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);}
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/Views/NoteView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();}
}
Loading