diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-06-12 15:12:22 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-06-12 15:12:22 +0200 |
commit | 63394a6ddc29eac797bfdd7bbb2c429d4b5ffd9f (patch) | |
tree | a4dd13c0fe4c35ac4623fbddd3bf560edaae2274 | |
parent | 99d2c2687cf3d08cdf80dc1bd5a4e9603fbd9f71 (diff) | |
download | arctica-greeter-63394a6ddc29eac797bfdd7bbb2c429d4b5ffd9f.tar.gz arctica-greeter-63394a6ddc29eac797bfdd7bbb2c429d4b5ffd9f.tar.bz2 arctica-greeter-63394a6ddc29eac797bfdd7bbb2c429d4b5ffd9f.zip |
override_font() deprecation warning: replace by GtkCssProvider blocks. Additionally, don't hard-code Cabin font anymore, use font_name gsettings property instead.
-rw-r--r-- | src/dash-button.vala | 10 | ||||
-rw-r--r-- | src/dash-entry.vala | 24 | ||||
-rw-r--r-- | src/prompt-box.vala | 70 | ||||
-rw-r--r-- | src/shutdown-dialog.vala | 26 | ||||
-rw-r--r-- | src/toggle-box.vala | 6 |
5 files changed, 118 insertions, 18 deletions
diff --git a/src/dash-button.vala b/src/dash-button.vala index 4554dc2..d48ef70 100644 --- a/src/dash-button.vala +++ b/src/dash-button.vala @@ -22,6 +22,10 @@ public class DashButton : FlatButton, Fadable protected FadeTracker fade_tracker { get; protected set; } private Gtk.Label text_label; + 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]); + private string _text = ""; public string text { @@ -29,16 +33,18 @@ public class DashButton : FlatButton, Fadable set { _text = value; - text_label.set_markup ("<span font=\"Cabin 13\">%s</span>".printf (value)); + text_label.set_markup ("<span font=\"%s %d\">%s</span>".printf (font_family, font_size+2, value)); } } - public DashButton (string text) { fade_tracker = new FadeTracker (this); var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + if (font_size < 6) + font_size = 6; + /* Add text */ text_label = new Gtk.Label (""); text_label.use_markup = true; diff --git a/src/dash-entry.vala b/src/dash-entry.vala index cc51767..d209602 100644 --- a/src/dash-entry.vala +++ b/src/dash-entry.vala @@ -23,7 +23,10 @@ extern bool gtk_style_context_lookup_color (Gtk.StyleContext ctx, string color_n public class DashEntry : Gtk.Entry, Fadable { - public static string font = "Cabin 14"; + 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 signal void respond (); public string constant_placeholder_text { get; set; } @@ -71,8 +74,6 @@ public class DashEntry : Gtk.Entry, Fadable } } - override_font (Pango.FontDescription.from_string (font)); - var style_ctx = get_style_context (); try @@ -87,6 +88,21 @@ public class DashEntry : Gtk.Entry, Fadable { debug ("Internal error loading padding style: %s", e.message); } + + if (font_size < 6) + font_size = 6; + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: %s; font-size: %dpt;}".printf (font_family, font_size+3); + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size+3, e.message); + } } public override bool draw (Cairo.Context c) @@ -162,7 +178,7 @@ public class DashEntry : Gtk.Entry, Fadable /* Draw text */ var layout = create_pango_layout (constant_placeholder_text); - layout.set_font_description (Pango.FontDescription.from_string ("Cabin 13")); + layout.set_font_description (Pango.FontDescription.from_string ("%s %d".printf(font_family, font_size+2))); Pango.cairo_show_layout (c, layout); c.restore (); diff --git a/src/prompt-box.vala b/src/prompt-box.vala index db5e405..49c2403 100644 --- a/src/prompt-box.vala +++ b/src/prompt-box.vala @@ -25,6 +25,10 @@ public class PromptBox : FadableBox public signal void show_options (); public signal void name_clicked (); + 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 bool has_errors { get; set; default = false; } public string id { get; construct; } @@ -111,6 +115,9 @@ public class PromptBox : FadableBox Entry......... */ + if (font_size < 6) + font_size = 6; + active_indicator = new ActiveIndicator (); active_indicator.valign = Gtk.Align.START; active_indicator.margin_top = (grid_size - ActiveIndicator.HEIGHT) / 2; @@ -172,7 +179,21 @@ public class PromptBox : FadableBox name_grid.hexpand = true; name_label = new FadingLabel (""); - name_label.override_font (Pango.FontDescription.from_string ("Cabin 13")); + + var style_ctx = name_label.get_style_context(); + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: %s; font-size: %dpt;}".printf (font_family, font_size+2); + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size+2, e.message); + } + name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f }); name_label.valign = Gtk.Align.START; name_label.vexpand = true; @@ -228,7 +249,22 @@ public class PromptBox : FadableBox small_name_grid.column_spacing = 4; small_name_label = new FadingLabel (""); - small_name_label.override_font (Pango.FontDescription.from_string ("Cabin 13")); + + var style_ctx = small_name_label.get_style_context(); + + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: %s; font-size: %dpt;}".printf (font_family, font_size); + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size, e.message); + } + small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f }); small_name_label.yalign = 0.5f; small_name_label.xalign = 0.0f; @@ -431,7 +467,20 @@ public class PromptBox : FadableBox { var label = new FadingLabel (text); - label.override_font (Pango.FontDescription.from_string ("Cabin 10")); + var style_ctx = label.get_style_context(); + + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: %s; font-size: %dpt;}".printf (font_family, font_size-1); + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size-1, e.message); + } Gdk.RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f }; if (is_error) @@ -509,7 +558,20 @@ public class PromptBox : FadableBox combo.get_style_context ().add_class ("lightdm-combo"); combo.get_child ().get_style_context ().add_class ("lightdm-combo"); - combo.get_child ().override_font (Pango.FontDescription.from_string (DashEntry.font)); + + var style_ctx = combo.get_child ().get_style_context(); + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: %s; font-size: %dpt;}".printf (DashEntry.font_family, DashEntry.font_size); + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (%s, %dpt): %s", font_family, font_size+2, e.message); + } attach_item (combo, false); diff --git a/src/shutdown-dialog.vala b/src/shutdown-dialog.vala index cbe4d7e..6cc88e9 100644 --- a/src/shutdown-dialog.vala +++ b/src/shutdown-dialog.vala @@ -102,10 +102,9 @@ public class ShutdownDialog : Gtk.Fixed } else { - var title_label = new Gtk.Label (_("Shut Down")); + var title_label = new Gtk.Label (null); title_label.visible = true; - title_label.override_font (Pango.FontDescription.from_string ("Cantarell 15")); - title_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f }); + title_label.set_markup ("<span font=\"Cantarell 15\" fgcolor=\"%s\">%s</span>".printf (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), _("Shut Down"))); title_label.set_alignment (0.0f, 0.5f); vbox.pack_start (title_label, false, false, 0); @@ -136,10 +135,9 @@ public class ShutdownDialog : Gtk.Fixed if (have_open_sessions) text = "%s\n\n%s".printf (_("Other users are currently logged in to this computer, shutting down now will also close these other sessions."), text); - var label = new Gtk.Label (text); + var label = new Gtk.Label (null); label.set_line_wrap (true); - label.override_font (Pango.FontDescription.from_string ("Cantarell 12")); - label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f }); + label.set_markup ("<span font=\"Cantarell 12\" fgcolor=\"%s\">%s</span>".printf (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), text)); label.set_alignment (0.0f, 0.5f); label.visible = true; vbox.pack_start (label, false, false, 0); @@ -560,7 +558,21 @@ private class DialogButton : Gtk.Button if (l != null) { l.visible = true; - l.override_font (Pango.FontDescription.from_string ("Cantarell 12")); + + var style_ctx = l.get_style_context(); + try + { + var font_provider = new Gtk.CssProvider (); + var css = "* {font-family: Cantarell; font-size: 12pt;}"; + font_provider.load_from_data (css, -1); + style_ctx.add_provider (font_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + catch (Error e) + { + debug ("Internal error loading font style (Cantarell 12pt): %s", e.message); + } + l.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 0.0f }); l.override_color (Gtk.StateFlags.FOCUSED, { 1.0f, 1.0f, 1.0f, 1.0f }); l.override_color (Gtk.StateFlags.ACTIVE, { 1.0f, 1.0f, 1.0f, 1.0f }); diff --git a/src/toggle-box.vala b/src/toggle-box.vala index 91a3e57..d953b2f 100644 --- a/src/toggle-box.vala +++ b/src/toggle-box.vala @@ -23,6 +23,10 @@ public class ToggleBox : Gtk.Box public string starting_key {get; construct;} 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 ToggleBox (string? default_key, string? starting_key) { Object (default_key: default_key, starting_key: starting_key, @@ -124,7 +128,7 @@ public class ToggleBox : Gtk.Box } var label = new Gtk.Label (null); - label.set_markup ("<span font=\"Cabin 13\" fgcolor=\"%s\">%s</span>".printf (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), name)); + label.set_markup ("<span font=\"%s %d\" fgcolor=\"%s\">%s</span>".printf (font_family, font_size+2, AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), name)); label.halign = Gtk.Align.START; hbox.pack_start (label, true, true, 0); |