diff options
| author | Brandon Schaefer <brandontschaefer@gmail.com> | 2014-01-30 14:42:26 -0800 |
|---|---|---|
| committer | Brandon Schaefer <brandontschaefer@gmail.com> | 2014-01-30 14:42:26 -0800 |
| commit | 8f38944552cfba22005f7f2a06418439f189eb6d (patch) | |
| tree | a73b5558efb3ddd60d3d1b4203f94714f49f9136 /unity-shared | |
| parent | 06a285516dcab3a76a01a5dd86058b03608724da (diff) | |
* Move the EMConverter over to the unitysettings, this way only it will be doing
the DPI/FontSize updating. (bzr r3635.2.1)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/UnitySettings.cpp | 49 | ||||
| -rw-r--r-- | unity-shared/UnitySettings.h | 6 |
2 files changed, 54 insertions, 1 deletions
diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp index 9d7c578b3..00d2ec987 100644 --- a/unity-shared/UnitySettings.cpp +++ b/unity-shared/UnitySettings.cpp @@ -19,10 +19,12 @@ */ #include <gdk/gdk.h> +#include <gtk/gtk.h> #include <gio/gio.h> #include <NuxCore/Logger.h> +#include "DecorationStyle.h" #include "UnitySettings.h" #include "UScreen.h" @@ -62,6 +64,8 @@ public: CacheDoubleClickActivate(); parent_->double_click_activate.changed.emit(cached_double_click_activate_); }); + + UpdateEMConverter(); } void CacheFormFactor() @@ -103,6 +107,44 @@ public: return cached_double_click_activate_; } + int GetFontSize() const + { + gint font_size; + PangoFontDescription* desc; + + desc = pango_font_description_from_string(decoration::Style::Get()->font().c_str()); + font_size = pango_font_description_get_size(desc); + pango_font_description_free(desc); + + return font_size; + } + + int GetDPI() const + { + int dpi = 0; + g_object_get(gtk_settings_get_default(), "gtk-xft-dpi", &dpi, nullptr); + + return dpi; + } + + void UpdateFontSize() + { + int font_size = GetFontSize() / 1024; + em_.SetFontSize(font_size); + } + + void UpdateDPI() + { + int dpi = GetDPI() / 1024; + em_.SetDPI(dpi); + } + + void UpdateEMConverter() + { + UpdateFontSize(); + UpdateDPI(); + } + Settings* parent_; glib::Object<GSettings> gsettings_; FormFactor cached_form_factor_; @@ -111,6 +153,8 @@ public: glib::Signal<void, GSettings*, gchar* > form_factor_changed_; glib::Signal<void, GSettings*, gchar* > double_click_activate_changed_; + + EMConverter em_; }; // @@ -163,4 +207,9 @@ void Settings::SetLowGfxMode(const bool low_gfx) pimpl->lowGfx_ = low_gfx; } +EMConverter const& Settings::em() const +{ + return pimpl->em_; +} + } // namespace unity diff --git a/unity-shared/UnitySettings.h b/unity-shared/UnitySettings.h index cc44fb5c4..1aec701d0 100644 --- a/unity-shared/UnitySettings.h +++ b/unity-shared/UnitySettings.h @@ -23,7 +23,9 @@ #include <memory> #include <sigc++/signal.h> -#include <Nux/Nux.h> +#include <NuxCore/Property.h> + +#include "EMConverter.h" namespace unity { @@ -49,6 +51,8 @@ public: nux::Property<bool> is_standalone; nux::ROProperty<bool> double_click_activate; + EMConverter const& em() const; + private: class Impl; std::unique_ptr<Impl> pimpl; |
