diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-06-27 11:21:50 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2022-06-27 11:21:59 +0200 |
commit | 01dc4632f9729be871772a5ca5d4761fa63b21ac (patch) | |
tree | 8dfd4bbc44ed5dcc20984253805321eb7d65bf28 | |
parent | f87d2df9141b0f3a1d5ec47619c21589c6a24cb0 (diff) | |
download | arctica-greeter-01dc4632f9729be871772a5ca5d4761fa63b21ac.tar.gz arctica-greeter-01dc4632f9729be871772a5ca5d4761fa63b21ac.tar.bz2 arctica-greeter-01dc4632f9729be871772a5ca5d4761fa63b21ac.zip |
src/toggle-box.vala: Port font-family-with-blanks-fix from prompt-box to toggle-box.
Fixes: https://github.com/ArcticaProject/arctica-greeter/issues/34
-rw-r--r-- | src/toggle-box.vala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/toggle-box.vala b/src/toggle-box.vala index cea71f4..5502c1d 100644 --- a/src/toggle-box.vala +++ b/src/toggle-box.vala @@ -26,13 +26,23 @@ public class ToggleBox : Gtk.Box public string selected_key {get; protected set;} public static string font = AGSettings.get_string (AGSettings.KEY_FONT_NAME); - public static string font_family = font.split_set(" ")[0]; - public static int font_size = int.parse(font.split_set(" ")[1]); + public static string font_family = "sans"; + public static int font_size = 11; public ToggleBox (string? default_key, string? starting_key) { Object (default_key: default_key, starting_key: starting_key, selected_key: starting_key); + + /* Split font family and size via regular expression. */ + Regex font_regexp = new Regex ("^([[:blank:]]*)(?<font_family>[ a-zA-Z0-9]+) (?<font_size>[0-9]+)([[:blank:]]*)$"); + MatchInfo font_info; + if (font_regexp.match(font, 0, out font_info)) { + font_family = font_info.fetch_named("font_family"); + font_size = int.parse(font_info.fetch_named("font_size")); + } + debug ("Using font family '%s'.", font_family); + debug ("Using font size base '%d'.", font_size); } public void add_item (string key, string label, Gdk.Pixbuf? icon) |