aboutsummaryrefslogtreecommitdiff
path: root/src/dash-entry.vala
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-12 15:12:22 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-12 15:12:22 +0200
commit63394a6ddc29eac797bfdd7bbb2c429d4b5ffd9f (patch)
treea4dd13c0fe4c35ac4623fbddd3bf560edaae2274 /src/dash-entry.vala
parent99d2c2687cf3d08cdf80dc1bd5a4e9603fbd9f71 (diff)
downloadarctica-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.
Diffstat (limited to 'src/dash-entry.vala')
-rw-r--r--src/dash-entry.vala24
1 files changed, 20 insertions, 4 deletions
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 ();