diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-01-16 00:21:28 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-01-16 00:21:28 +0100 |
| commit | c42718af3fee65ead2b8a94a58e26b581806fb73 (patch) | |
| tree | 34dcf761237e6dd73109a8c19b5ee52df1afc7eb /unity-shared | |
| parent | a10cc1ec1c4460a8c83e60e5dff11b01f7fcb4f6 (diff) | |
DecorationStyle: add support for titlebar-uses-system-font gnome wm setting
(bzr r3566.5.214)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/DecorationStyle.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/unity-shared/DecorationStyle.cpp b/unity-shared/DecorationStyle.cpp index 7505fad33..5547a27f7 100644 --- a/unity-shared/DecorationStyle.cpp +++ b/unity-shared/DecorationStyle.cpp @@ -43,6 +43,7 @@ const std::array<std::string, size_t(WidgetState::Size)> WBUTTON_STATES = {"", " const std::string SETTINGS_NAME = "org.gnome.desktop.wm.preferences"; const std::string FONT_KEY = "titlebar-font"; +const std::string USE_SYSTEM_FONT_KEY = "titlebar-uses-system-font"; const std::string HIGH_CONTRAST_THEME_PREFIX = "HighContrast"; struct UnityDecoration @@ -102,7 +103,7 @@ struct Style::Impl parent_->theme = glib::String(GetSettingValue<gchar*>("gtk-theme-name")).Str(); parent_->font = glib::String(GetSettingValue<gchar*>("gtk-font-name")).Str(); - parent_->title_font = glib::String(g_settings_get_string(settings_, FONT_KEY.c_str())).Str(); + SetTitleFont(); UpdatePangoContext(parent_->title_font); UpdateThemedValues(); @@ -117,6 +118,13 @@ struct Style::Impl signals_.Add<void, GtkSettings*, GParamSpec*>(settings, "notify::gtk-font-name", [this] (GtkSettings*, GParamSpec*) { parent_->font = glib::String(GetSettingValue<gchar*>("gtk-font-name")).Str(); + + if (g_settings_get_boolean(settings_, USE_SYSTEM_FONT_KEY.c_str())) + { + UpdatePangoContext(parent_->font()); + parent_->title_font = parent_->font(); + } + LOG_INFO(logger) << "gtk-font-name changed to " << parent_->font(); }); @@ -129,11 +137,21 @@ struct Style::Impl }); signals_.Add<void, GSettings*, gchar*>(settings_, "changed::" + FONT_KEY, [this] (GSettings*, gchar*) { + if (g_settings_get_boolean(settings_, USE_SYSTEM_FONT_KEY.c_str())) + return; + auto const& font = glib::String(g_settings_get_string(settings_, FONT_KEY.c_str())).Str(); UpdatePangoContext(font); parent_->title_font = font; LOG_INFO(logger) << FONT_KEY << " changed to " << font; }); + + signals_.Add<void, GSettings*, gchar*>(settings_, "changed::" + USE_SYSTEM_FONT_KEY, [this] (GSettings*, gchar*) { + SetTitleFont(); + UpdatePangoContext(parent_->font()); + parent_->title_font = parent_->font(); + LOG_INFO(logger) << USE_SYSTEM_FONT_KEY << " changed to " << g_settings_get_boolean(settings_, USE_SYSTEM_FONT_KEY.c_str()); + }); } void UpdateThemedValues() @@ -154,6 +172,14 @@ struct Style::Impl title_fade_ = std::max<unsigned>(0, GetProperty<guint>("title-fade")); } + void SetTitleFont() + { + if (g_settings_get_boolean(settings_, USE_SYSTEM_FONT_KEY.c_str())) + parent_->title_font = parent_->font(); + else + parent_->title_font = glib::String(g_settings_get_string(settings_, FONT_KEY.c_str())).Str(); + } + void UpdatePangoContext(std::string const& font) { std::shared_ptr<PangoFontDescription> desc(pango_font_description_from_string(font.c_str()), pango_font_description_free); |
