@@ -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 }
0 commit comments