Skip to content

Commit

Permalink
Refactored saving zoom on change via control+scroll to Glib.SimpleAction
Browse files Browse the repository at this point in the history
  • Loading branch information
ldrahnik committed Oct 30, 2023
1 parent 21c27f5 commit e67ddeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,6 @@ namespace Terminal {

terminal_widget.window_title_changed.connect (check_for_tabs_with_same_name);
terminal_widget.cwd_changed.connect (cwd_changed);
terminal_widget.zoom_changed.connect (zoom_changed);

terminal_widget.set_font (term_font);

Expand Down Expand Up @@ -1201,18 +1200,22 @@ namespace Terminal {

private void action_reload_tab () {
current_terminal.reload ();
save_opened_terminal_zoom (current_terminal);
}

private void action_zoom_in_font () {
current_terminal.increment_size ();
save_opened_terminal_zoom (current_terminal);
}

private void action_zoom_out_font () {
current_terminal.decrement_size ();
save_opened_terminal_zoom (current_terminal);
}

private void action_zoom_default_font () {
current_terminal.set_default_font_size ();
save_opened_terminal_zoom()
}

private void action_next_tab () {
Expand Down Expand Up @@ -1344,10 +1347,6 @@ namespace Terminal {
return;
}

private void zoom_changed (TerminalWidget terminal_widget) {
save_opened_terminal_zoom (terminal_widget);
}

private void cwd_changed () {
check_for_tabs_with_same_name ();
save_opened_terminals ();
Expand Down
9 changes: 2 additions & 7 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ namespace Terminal {

public signal void cwd_changed ();

public signal void zoom_changed (TerminalWidget terminal_widget);

public TerminalWidget (MainWindow parent_window) {
pointer_autohide = true;

Expand Down Expand Up @@ -203,11 +201,11 @@ namespace Terminal {
if ((event.state & Gdk.ModifierType.CONTROL_MASK) > 0) {
switch (event.direction) {
case Gdk.ScrollDirection.UP:
increment_size ();
window.get_simple_action (MainWindow.ACTION_ZOOM_IN_FONT).activate (null);
return Gdk.EVENT_STOP;

case Gdk.ScrollDirection.DOWN:
decrement_size ();
window.get_simple_action (MainWindow.ACTION_ZOOM_OUT_FONT).activate (null);
return Gdk.EVENT_STOP;

case Gdk.ScrollDirection.SMOOTH:
Expand Down Expand Up @@ -452,17 +450,14 @@ namespace Terminal {

public void increment_size () {
font_scale = (font_scale + 0.1).clamp (MIN_SCALE, MAX_SCALE);
zoom_changed (this);
}

public void decrement_size () {
font_scale = (font_scale - 0.1).clamp (MIN_SCALE, MAX_SCALE);
zoom_changed (this);
}

public void set_default_font_size () {
font_scale = 1.0;
zoom_changed (this);
}

public bool is_init_complete () {
Expand Down

0 comments on commit e67ddeb

Please sign in to comment.