Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for antialias and related subpixel order settings #291

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/Plug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class PantheonShell.Plug : Switchboard.Plug {
settings.set ("desktop/appearance", "appearance");
settings.set ("desktop/dock", "dock");
settings.set ("desktop/multitasking", "multitasking");
settings.set ("desktop/text", "text");

// DEPRECATED
settings.set ("desktop/wallpaper", "wallpaper");
Expand All @@ -60,6 +61,9 @@ public class PantheonShell.Plug : Switchboard.Plug {

var appearance = new Appearance ();
stack.add_titled (appearance, "appearance", _("Appearance"));

var text = new Text ();
stack.add_titled (text, "text", _("Text"));

if (GLib.Environment.find_program_in_path ("plank") != null) {
var dock = new Dock ();
Expand Down
121 changes: 0 additions & 121 deletions src/Views/Appearance.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ public class PantheonShell.Appearance : Gtk.Grid {
private const string INTERFACE_SCHEMA = "org.gnome.desktop.interface";
private const string STYLESHEET_KEY = "gtk-theme";
private const string STYLESHEET_PREFIX = "io.elementary.stylesheet.";
private const string TEXT_SIZE_KEY = "text-scaling-factor";

private const string DYSLEXIA_KEY = "dyslexia-friendly-support";
private const string FONT_KEY = "font-name";
private const string DOCUMENT_FONT_KEY = "document-font-name";
private const string MONOSPACE_FONT_KEY = "monospace-font-name";

private const string OD_REG_FONT = "OpenDyslexic Regular 9";
private const string OD_DOC_FONT = "OpenDyslexic Regular 10";
private const string OD_MON_FONT = "OpenDyslexicMono Regular 10";

private const double[] TEXT_SCALE = {0.75, 1, 1.25, 1.5};

private Granite.Widgets.ModeButton text_size_modebutton;

private enum AccentColor {
NO_PREFERENCE,
Expand Down Expand Up @@ -178,48 +164,6 @@ public class PantheonShell.Appearance : Gtk.Grid {
schedule_grid.add (to_label);
schedule_grid.add (to_time);

var text_size_label = new Gtk.Label (_("Text size:")) {
halign = Gtk.Align.END,
margin_top = 24
};

text_size_modebutton = new Granite.Widgets.ModeButton () {
margin_top = 24
};
text_size_modebutton.append_text (_("Small"));
text_size_modebutton.append_text (_("Default"));
text_size_modebutton.append_text (_("Large"));
text_size_modebutton.append_text (_("Larger"));

var dyslexia_font_label = new Gtk.Label (_("Dyslexia-friendly text:")) {
halign = Gtk.Align.END
};

var dyslexia_font_switch = new Gtk.Switch () {
halign = Gtk.Align.START
};

var dyslexia_font_description_label = new Gtk.Label (
_("Bottom-heavy shapes and increased character spacing can help improve legibility and reading speed.")
) {
max_width_chars = 60,
wrap = true,
xalign = 0
};
dyslexia_font_description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

/* Rows 0 to 3 are for the dark style UI that gets attached only if we
* can connect to the DBus API
*
* Row 4 and 5 are for accent color UI that gets constructed only if the
* current stylesheet is supported (begins with the STYLESHEET_PREFIX)
*/
attach (text_size_label, 0, 8);
attach (text_size_modebutton, 1, 8, 2);
attach (dyslexia_font_label, 0, 9);
attach (dyslexia_font_switch, 1, 9);
attach (dyslexia_font_description_label, 1, 10, 2);

Pantheon.AccountsService? pantheon_act = null;

string? user_path = null;
Expand Down Expand Up @@ -412,22 +356,6 @@ public class PantheonShell.Appearance : Gtk.Grid {
attach (accent_grid, 1, 4, 2);
attach (accent_info, 1, 5, 2);
}

update_text_size_modebutton (interface_settings);

interface_settings.changed.connect (() => {
update_text_size_modebutton (interface_settings);
});

text_size_modebutton.mode_changed.connect (() => {
set_text_scale (interface_settings, text_size_modebutton.selected);
});

dyslexia_font_switch.set_active (update_dyslexia_font_switch (interface_settings));

dyslexia_font_switch.state_set.connect (() => {
toggle_dyslexia_support (interface_settings, dyslexia_font_switch.get_active () );
});
}

private class PrefersAccentColorButton : Gtk.RadioButton {
Expand Down Expand Up @@ -474,55 +402,6 @@ public class PantheonShell.Appearance : Gtk.Grid {
}
}

private void toggle_dyslexia_support (GLib.Settings interface_settings, bool state) {
if (state == true) {
interface_settings.set_string (FONT_KEY, OD_REG_FONT);
interface_settings.set_string (DOCUMENT_FONT_KEY, OD_DOC_FONT);
interface_settings.set_string (MONOSPACE_FONT_KEY, OD_MON_FONT);
}
else {
interface_settings.reset (FONT_KEY);
interface_settings.reset (DOCUMENT_FONT_KEY);
interface_settings.reset (MONOSPACE_FONT_KEY);
}
}

private bool update_dyslexia_font_switch (GLib.Settings interface_settings) {
var interface_font = interface_settings.get_string (FONT_KEY);
var document_font = interface_settings.get_string (DOCUMENT_FONT_KEY);
var monospace_font = interface_settings.get_string (MONOSPACE_FONT_KEY);

if (interface_font == OD_REG_FONT || document_font == OD_DOC_FONT || monospace_font == OD_MON_FONT ) {
return true;
}

else {
return false;
}
}

private int get_text_scale (GLib.Settings interface_settings) {
double text_scaling_factor = interface_settings.get_double (TEXT_SIZE_KEY);

if (text_scaling_factor <= TEXT_SCALE[0]) {
return 0;
} else if (text_scaling_factor <= TEXT_SCALE[1]) {
return 1;
} else if (text_scaling_factor <= TEXT_SCALE[2]) {
return 2;
} else {
return 3;
}
}

private void set_text_scale (GLib.Settings interface_settings, int option) {
interface_settings.set_double (TEXT_SIZE_KEY, TEXT_SCALE[option]);
}

private void update_text_size_modebutton (GLib.Settings interface_settings) {
text_size_modebutton.set_active (get_text_scale (interface_settings));
}

private static DateTime double_date_time (double dbl) {
var hours = (int) dbl;
var minutes = (int) Math.round ((dbl - hours) * 60);
Expand Down
Loading