Skip to content

Commit 91b3862

Browse files
committed
try
1 parent b9ab434 commit 91b3862

File tree

5 files changed

+93
-35
lines changed

5 files changed

+93
-35
lines changed

data/io.github.ellie_commons.jorts.metainfo.xml.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<releases>
6767
<release version="2.1.0" date="2025-02-25">
6868
<description>
69-
<p>2.0.1 Appcenter release</p>
69+
<p>2.1.0 Fresh out of the laundry!<br></p>
7070
<ul>
7171
<li>Includes a per-note zoom! So you can get bigger or smaller text</li>
7272
<li>Latest set zoom, aka what is most comfortable to you, stays as default for new notes</li>
@@ -78,12 +78,12 @@
7878
</release>
7979
<release version="2.0.1" date="2025-02-25">
8080
<description>
81-
<p>2.0.1 Appcenter release</p>
81+
<p>2.0.1 Appcenter release<br></p>
8282
</description>
8383
</release>
8484
<release version="2.0.0" date="2025-02-25">
8585
<description>
86-
<p>2.0.0 Release: Slate And Bubblegum</p>
86+
<p>2.0.0 Release: Slate And Bubblegum<br></p>
8787
<ul>
8888
<li>Revival of an ancient but well loved version of Notejot</li>
8989
<li>The app is now named Jorts. You however cannot wear it</li>

src/MainWindow.vala

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,23 @@ namespace jorts {
6464
public const string ACTION_NEW = "action_new";
6565
public const string ACTION_DELETE = "action_delete";
6666

67+
public const string ACTION_ZOOM_DEFAULT = "action_zoom_default";
68+
public const string ACTION_ZOOM_IN = "zoom_in";
69+
public const string ACTION_ZOOM_OUT = "zoom_out";
70+
71+
public const string[] ACCELS_ZOOM_DEFAULT = { "<control>0", "<Control>KP_0", null };
72+
public const string[] ACCELS_ZOOM_IN = { "<Control>plus", "<Control>equal", "<Control>KP_Add", null };
73+
public const string[] ACCELS_ZOOM_OUT = { "<Control>minus", "<Control>KP_Subtract", null };
74+
75+
6776
public static Gee.MultiMap<string, string> action_accelerators = new Gee.HashMultiMap<string, string> ();
6877

6978
private const GLib.ActionEntry[] action_entries = {
70-
{ ACTION_NEW, action_new },
71-
{ ACTION_DELETE, action_delete }
79+
{ ACTION_NEW, action_new },
80+
{ ACTION_DELETE, action_delete },
81+
{ ACTION_ZOOM_DEFAULT, action_zoom_default }
82+
{ ACTION_ZOOM_IN, zoom_in }
83+
{ ACTION_ZOOM_OUT, zoom_out }
7284
};
7385

7486
// Init or something
@@ -81,6 +93,14 @@ namespace jorts {
8193
actions.add_action_entries (action_entries, this);
8294
insert_action_group ("win", actions);
8395

96+
97+
set_accels_for_action (ACTION_ZOOM_DEFAULT, ACCELS_ZOOM_DEFAULT);
98+
set_accels_for_action (ACTION_ZOOM_IN, ACCELS_ZOOM_IN);
99+
set_accels_for_action (ACTION_ZOOM_OUT, ACCELS_ZOOM_OUT);
100+
}
101+
102+
103+
84104
this.set_hexpand (false);
85105
this.set_vexpand (false);
86106

@@ -142,21 +162,8 @@ namespace jorts {
142162
delete_item.add_css_class("themedbutton");
143163

144164

145-
var popover = new SettingsPopover (this.zoom, this.theme);
146-
147-
popover.theme_changed.connect ((selected) => {
148-
this.update_theme(selected);
149-
});
165+
var popover = new SettingsPopover (this.theme, this.zoom);
150166

151-
popover.zoom_changed.connect ((zoomkind) => {
152-
if (zoomkind == "zoom_in") {
153-
this.zoom_in();
154-
} else if (zoomkind == "zoom_out") {
155-
this.zoom_out();
156-
} else if (zoomkind == "reset") {
157-
this.set_zoom(100);
158-
}
159-
});
160167

161168
var app_button = new Gtk.MenuButton();
162169
app_button.has_tooltip = true;
@@ -203,6 +210,23 @@ namespace jorts {
203210
popover.set_zoomlevel(this.zoom);
204211
});
205212

213+
214+
popover.theme_changed.connect ((selected) => {
215+
this.update_theme(selected);
216+
});
217+
218+
popover.zoom_changed.connect ((zoomkind) => {
219+
if (zoomkind == "zoom_in") {
220+
this.zoom_in();
221+
} else if (zoomkind == "zoom_out") {
222+
this.zoom_out();
223+
} else if (zoomkind == "reset") {
224+
this.set_zoom(100);
225+
}
226+
});
227+
228+
229+
206230
}
207231

208232
// TITLE IS TITLE
@@ -242,6 +266,10 @@ namespace jorts {
242266
this.close ();
243267
}
244268

269+
private void action_zoom_default () {
270+
this.set_zoom(100);
271+
}
272+
245273
// Strip old stylesheet, apply the new
246274
private void update_theme(string theme) {
247275
// in GTK4 we can replace this with setting css_classes
@@ -254,7 +282,6 @@ namespace jorts {
254282

255283
public string zoom_to_class(int64 zoom) {
256284
switch (zoom) {
257-
258285
case 40: return "muchsmaller";
259286
case 60: return "smaller";
260287
case 80: return "small";
@@ -269,13 +296,13 @@ namespace jorts {
269296
}
270297

271298
public void zoom_in() {
272-
if ((this.zoom + 20) <= max_zoom) {
299+
if ((this.zoom + 20) <= jorts.Utils.max_zoom) {
273300
this.set_zoom((this.zoom + 20));
274301
}
275302
}
276303

277304
public void zoom_out() {
278-
if ((this.zoom - 20) >= min_zoom) {
305+
if ((this.zoom - 20) >= jorts.Utils.min_zoom) {
279306
this.set_zoom((this.zoom - 20));
280307
}
281308
}
@@ -286,6 +313,8 @@ namespace jorts {
286313
this.add_css_class (zoom_to_class( this.zoom));
287314
((Application)this.application).latest_zoom = zoom;
288315

316+
var label = "%.0f%%".printf(zoom.to_string);
317+
popovover.zoom_default_button.set_label(this.zoom);
289318

290319

291320
}

src/Services/Themer.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace jorts.Themer {
156156
public static void init_all_themes() {
157157

158158
debug("Init all themes");
159-
foreach (unowned var theme in jorts.Themer.themearray) {
159+
foreach (unowned var theme in jorts.Utils.themearray) {
160160
// Palette color
161161
var theme_provider = new Gtk.CssProvider ();
162162
var style = jorts.Themer.generate_css (theme);

src/Services/Utils.vala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,29 @@ TODO: will need to know the theme to skip
3232

3333
namespace jorts.Utils {
3434

35+
const int max_zoom = 200;
36+
const int min_zoom = 60;
37+
38+
// As seen on TV!
39+
const string[] themearray = {
40+
"BLUEBERRY",
41+
"MINT",
42+
"LIME",
43+
"BANANA",
44+
"ORANGE",
45+
"STRAWBERRY",
46+
"BUBBLEGUM",
47+
"GRAPE",
48+
"COCOA",
49+
"SLATE"
50+
};
51+
3552
// Spits out a random theme for a new note
3653
// If there is the name of a string to skip, just skip it.
3754
// Having an gee.arraylist defined from the start only causes issues
3855
public string random_theme (string? skip_theme) {
3956
Gee.ArrayList<string> themes = new Gee.ArrayList<string> ();
40-
themes.add_all_array (jorts.Themer.themearray);
57+
themes.add_all_array (jorts.Utils.themearray);
4158

4259
if (skip_theme != null) {
4360
themes.remove(skip_theme);

src/Widgets/SettingsPopover.vala

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ public class jorts.SettingsPopover : Gtk.Popover {
3535
public signal void theme_changed (string selected);
3636
public signal void zoom_changed (string zoomkind);
3737

38+
public int64 zoom;
39+
3840
public Gtk.Button zoom_out_button;
3941
public Gtk.Button zoom_in_button;
4042
public Gtk.Button zoom_default_button;
4143

42-
public SettingsPopover (int64 zoom, string theme) {
44+
public SettingsPopover (string theme, int64 zoom) {
45+
46+
this.zoom = zoom;
4347
this.set_position (Gtk.PositionType.TOP);
4448
this.set_halign (Gtk.Align.END);
4549

@@ -61,24 +65,35 @@ public class jorts.SettingsPopover : Gtk.Popover {
6165
_("Zoom out")
6266
) */
6367
};
64-
zoom_out_button.clicked.connect (() => {this.zoom_changed("zoom_out");});
68+
6569

6670
var zoom_default_button = new Gtk.Button () {
6771
/* tooltip_markup = Granite.markup_accel_tooltip (
6872
TerminalWidget.ACCELS_ZOOM_DEFAULT,
6973
_("Default zoom level")
7074
) */
7175
};
72-
zoom_default_button.clicked.connect (() => {this.zoom_changed("reset");});
73-
zoom_default_button.set_label ("");
76+
77+
zoom_default_button.set_label (this.zoom.to_string);
7478

7579
var zoom_in_button = new Gtk.Button.from_icon_name ("zoom-in-symbolic") {
7680
/* tooltip_markup = Granite.markup_accel_tooltip (
7781
TerminalWidget.ACCELS_ZOOM_IN,
7882
_("Zoom in")
7983
) */
8084
};
81-
zoom_in_button.clicked.connect (() => {this.zoom_changed("zoom_in");});
85+
86+
87+
88+
zoom_out_button.clicked.connect (() => {
89+
this.zoom_changed("zoom_out");
90+
});
91+
zoom_default_button.clicked.connect (() => {
92+
this.zoom_changed("reset");
93+
});
94+
zoom_in_button.clicked.connect (() => {
95+
this.zoom_changed("zoom_in");
96+
});
8297

8398
var font_size_box = new Gtk.Box (HORIZONTAL, 0) {
8499
homogeneous = true,
@@ -212,14 +227,11 @@ public class jorts.SettingsPopover : Gtk.Popover {
212227
});
213228
}
214229

230+
231+
215232
public void set_zoomlevel (int64 zoom) {
216-
zoom_default_button.set_label(zoom.to_string());
233+
this.zoom_default_button.set_label(this.zoom);
217234
}
218235

219236

220-
/* private static bool font_scale_to_zoom (Binding binding, Value font_scale, ref Value label) {
221-
label.set_string ("%.0f%%".printf (font_scale.get_double () * 100));
222-
return true;
223-
} */
224-
225237
}

0 commit comments

Comments
 (0)