-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5653a91
commit 3218bac
Showing
5 changed files
with
65 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
public class QuickSettings.TextScale : Gtk.Box { | ||
private Gtk.Button zoom_in_button; | ||
private Gtk.Button zoom_out_button; | ||
private Settings interface_settings; | ||
|
||
class construct { | ||
set_css_name ("scalebox"); | ||
} | ||
|
||
construct { | ||
zoom_out_button = new Gtk.Button.from_icon_name ("format-text-smaller-symbolic") { | ||
tooltip_text = _("Decrease text size") | ||
}; | ||
zoom_out_button.get_style_context ().add_class ("circular"); | ||
|
||
var zoom_adjustment = new Gtk.Adjustment (-1, 0.75, 1.75, 0.05, 0, 0); | ||
|
||
var zoom_scale = new Gtk.Scale (HORIZONTAL, zoom_adjustment) { | ||
draw_value = false, | ||
hexpand = true | ||
}; | ||
zoom_scale.add_mark (1, BOTTOM, null); | ||
zoom_scale.add_mark (1.5, BOTTOM, null); | ||
|
||
zoom_in_button = new Gtk.Button.from_icon_name ("format-text-larger-symbolic") { | ||
tooltip_text = _("Increase text size") | ||
}; | ||
zoom_in_button.get_style_context ().add_class ("circular"); | ||
|
||
get_style_context ().add_class ("font-size"); | ||
add (zoom_out_button); | ||
add (zoom_scale); | ||
add (zoom_in_button); | ||
|
||
interface_settings = new Settings ("org.gnome.desktop.interface"); | ||
interface_settings.bind ("text-scaling-factor", zoom_adjustment, "value", DEFAULT); | ||
interface_settings.changed["text-scaling-factor"].connect (update_zoom_buttons); | ||
update_zoom_buttons (); | ||
|
||
zoom_in_button.clicked.connect (() => { | ||
zoom_adjustment.value += 0.05; | ||
}); | ||
|
||
zoom_out_button.clicked.connect (() => { | ||
zoom_adjustment.value += -0.05; | ||
}); | ||
} | ||
|
||
private void update_zoom_buttons () { | ||
var scaling_factor = interface_settings.get_double ("text-scaling-factor"); | ||
zoom_in_button.sensitive = scaling_factor < 1.75; | ||
zoom_out_button.sensitive = scaling_factor > 0.75; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters