Skip to content
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
2 changes: 1 addition & 1 deletion src/dash-button.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DashButton : FlatButton, Fadable
set
{
_text = value;
text_label.set_markup ("<span font=\"Ubuntu 13\">%s</span>".printf (value));
text_label.set_markup ("<span font=\"%s\">%s</span>".printf (UGSettings.get_font (13).to_string (), value));
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/dash-entry.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ extern bool gtk_style_context_lookup_color (Gtk.StyleContext ctx, string color_n

public class DashEntry : Gtk.Entry, Fadable
{
public static string font = "Ubuntu 14";
public static Pango.FontDescription get_font ()
{
return UGSettings.get_font (14);
}

public signal void respond ();

public string constant_placeholder_text { get; set; }
Expand Down Expand Up @@ -71,7 +75,7 @@ public class DashEntry : Gtk.Entry, Fadable
}
}

override_font (Pango.FontDescription.from_string (font));
override_font (get_font ());

var style_ctx = get_style_context ();

Expand Down Expand Up @@ -153,7 +157,7 @@ public class DashEntry : Gtk.Entry, Fadable
Gdk.Rectangle rect;

var layout = create_pango_layout (constant_placeholder_text);
layout.set_font_description (Pango.FontDescription.from_string ("Ubuntu 13"));
layout.set_font_description (UGSettings.get_font (13));
layout.get_pixel_size (out layout_width, out layout_height);

get_text_area (out rect);
Expand Down
8 changes: 4 additions & 4 deletions src/prompt-box.vala
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public class PromptBox : FadableBox
name_grid.attach (avatar_image, COL_AVATAR, ROW_NAME, 1, 1);

name_label = new FadingLabel ("");
name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
name_label.override_font (UGSettings.get_font (13));
name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
name_label.halign = Gtk.Align.START;
name_label.valign = Gtk.Align.START;
Expand Down Expand Up @@ -272,7 +272,7 @@ public class PromptBox : FadableBox
small_name_grid.attach (small_avatar_image, 0, 0, 1, 1);

small_name_label = new FadingLabel ("");
small_name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
small_name_label.override_font (UGSettings.get_font (13));
small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
small_name_label.valign = Gtk.Align.CENTER;
small_name_label.yalign = 0.5f;
Expand Down Expand Up @@ -499,7 +499,7 @@ public class PromptBox : FadableBox
{
var label = new FadingLabel (text);

label.override_font (Pango.FontDescription.from_string ("Ubuntu Bold 10"));
label.override_font (UGSettings.get_font (10, Pango.Weight.BOLD));

Gdk.RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f };
if (is_error)
Expand Down Expand Up @@ -617,7 +617,7 @@ 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));
combo.get_child ().override_font (DashEntry.get_font ());

attach_item (combo, false);

Expand Down
26 changes: 26 additions & 0 deletions src/settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ public class UGSettings
return gsettings.get_string (key);
}

/* Size of the default font-name ("Ubuntu 11"). Sizes passed to get_font ()
* are the ones used with that default. */
private const double DEFAULT_FONT_SIZE = 11.0;

/* Returns the family of font-name, scaled so that it keeps the same
* proportion to font-name that 'size' has to the default font. With the
* default font-name this is "Ubuntu <size>", as the greeter always used. */
public static Pango.FontDescription get_font (double size, Pango.Weight weight = Pango.Weight.NORMAL)
{
var base_font = Pango.FontDescription.from_string (get_string (KEY_FONT_NAME));

var family = base_font.get_family ();
if (family == null || family == "")
family = "Ubuntu";

var base_size = DEFAULT_FONT_SIZE;
if (base_font.get_size () > 0 && !base_font.get_size_is_absolute ())
base_size = (double) base_font.get_size () / Pango.SCALE;

var font = new Pango.FontDescription ();
font.set_family (family);
font.set_weight (weight);
font.set_size ((int) Math.round (size * base_size / DEFAULT_FONT_SIZE * Pango.SCALE));
return font;
}

public static bool set_boolean (string key, bool value)
{
var gsettings = new Settings (SCHEMA);
Expand Down
6 changes: 3 additions & 3 deletions src/shutdown-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class ShutdownDialog : Gtk.Fixed
{
var title_label = new Gtk.Label (_("Shut Down"));
title_label.visible = true;
title_label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 15"));
title_label.override_font (UGSettings.get_font (15, Pango.Weight.LIGHT));
title_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
title_label.set_alignment (0.0f, 0.5f);
vbox.pack_start (title_label, false, false, 0);
Expand Down Expand Up @@ -138,7 +138,7 @@ public class ShutdownDialog : Gtk.Fixed

var label = new Gtk.Label (text);
label.set_line_wrap (true);
label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
label.override_font (UGSettings.get_font (12, Pango.Weight.LIGHT));
label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
label.set_alignment (0.0f, 0.5f);
label.visible = true;
Expand Down Expand Up @@ -558,7 +558,7 @@ private class DialogButton : Gtk.Button
if (l != null)
{
l.visible = true;
l.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
l.override_font (UGSettings.get_font (12, Pango.Weight.LIGHT));
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 });
Expand Down
2 changes: 1 addition & 1 deletion src/toggle-box.vala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class ToggleBox : Gtk.Box
}

var label = new Gtk.Label (null);
label.set_markup ("<span font=\"Ubuntu 12.5\">%s</span>".printf (name));
label.set_markup ("<span font=\"%s\">%s</span>".printf (UGSettings.get_font (12.5).to_string (), name));
label.halign = Gtk.Align.START;
hbox.pack_start (label, true, true, 0);

Expand Down