Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion data/Indicator.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ quicksettings .togglebox {
}

quicksettings scalebox scale {
margin: 0.666rem 0.666rem 0; /* 6px */
margin: 0 0.333rem 0 0.666rem; /* 0 3px 0 6px */
}

quicksettings separator.horizontal {
Expand Down
18 changes: 18 additions & 0 deletions data/icons/text-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions data/icons/text-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions data/quick-settings.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<gresource prefix="org/elementary/wingpanel/icons">
<file alias="scalable/status/dark-mode-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/dark-mode.svg</file>
<file alias="scalable/status/system-suspend-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/system-suspend.svg</file>
<file alias="scalable/status/quick-settings-text-large-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/text-large.svg</file>
<file alias="scalable/status/quick-settings-text-small-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/text-small.svg</file>
<file alias="scalable/status/quick-settings-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/quick-settings.svg</file>
<file alias="scalable/status/quick-settings-rotation-allowed-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/rotation-allowed.svg</file>
<file alias="scalable/status/quick-settings-rotation-locked-symbolic.svg" compressed="true" preprocess="xml-stripblanks">icons/rotation-locked.svg</file>
Expand Down
41 changes: 17 additions & 24 deletions src/Widgets/TextScale.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,49 @@
*/

public class QuickSettings.TextScale : Gtk.Box {
private Gtk.Button zoom_in_button;
private Gtk.Button zoom_out_button;
private Gtk.Button zoom_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");
zoom_button = new Gtk.Button.from_icon_name ("quick-settings-text-small-symbolic");
zoom_button.get_style_context ().add_class ("toggle");

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_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;
zoom_button.clicked.connect (() => {
if (zoom_adjustment.value > 1) {
zoom_adjustment.value = 1;
} else {
zoom_adjustment.value = 1.25;
}
});
}

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;
if (scaling_factor > 1) {
((Gtk.Image) zoom_button.image).icon_name = "quick-settings-text-large-symbolic";
zoom_button.tooltip_text = _("Decrease text size");
} else {
((Gtk.Image) zoom_button.image).icon_name = "quick-settings-text-small-symbolic";
zoom_button.tooltip_text = _("Increase text size");
}
}
}