From 404b023492210d709661027f2f92d5eb3dd32ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 15 Oct 2014 01:26:03 -0400 Subject: StaticCairoText: use glib::Signal (bzr r3871.4.2) --- unity-shared/StaticCairoText.cpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/StaticCairoText.cpp b/unity-shared/StaticCairoText.cpp index 804ad1006..ebb634f6e 100644 --- a/unity-shared/StaticCairoText.cpp +++ b/unity-shared/StaticCairoText.cpp @@ -34,6 +34,7 @@ #include #include +#include #include "CairoTexture.h" #include "UnitySettings.h" @@ -45,7 +46,6 @@ namespace unity struct StaticCairoText::Impl : sigc::trackable { Impl(StaticCairoText* parent, std::string const& text); - ~Impl(); PangoEllipsizeMode GetPangoEllipsizeMode() const; PangoAlignment GetPangoAlignment() const; @@ -77,8 +77,6 @@ struct StaticCairoText::Impl : sigc::trackable void UpdateTexture(); void OnFontChanged(); - static void FontChanged(GObject* gobject, GParamSpec* pspec, gpointer data); - StaticCairoText* parent_; bool accept_key_nav_focus_; mutable bool need_new_extent_cache_; @@ -106,6 +104,8 @@ struct StaticCairoText::Impl : sigc::trackable int actual_lines_; float line_spacing_; double scale_; + + glib::Signal font_changed_; }; StaticCairoText::Impl::Impl(StaticCairoText* parent, std::string const& text) @@ -126,21 +126,10 @@ StaticCairoText::Impl::Impl(StaticCairoText* parent, std::string const& text) , line_spacing_(0.5) , scale_(1.0f) { - GtkSettings* settings = gtk_settings_get_default(); // not ref'ed - g_signal_connect(settings, "notify::gtk-font-name", - (GCallback)FontChanged, this); - + font_changed_.Connect(gtk_settings_get_default(), "notify::gtk-font-name", sigc::hide(sigc::hide(sigc::mem_fun(this, &Impl::OnFontChanged)))); Settings::Instance().font_scaling.changed.connect(sigc::hide(sigc::mem_fun(this, &Impl::OnFontChanged))); } -StaticCairoText::Impl::~Impl() -{ - GtkSettings* settings = gtk_settings_get_default(); // not ref'ed - g_signal_handlers_disconnect_by_func(settings, - (void*)FontChanged, - this); -} - PangoEllipsizeMode StaticCairoText::Impl::GetPangoEllipsizeMode() const { switch (ellipsize_) @@ -780,14 +769,6 @@ void StaticCairoText::Impl::UpdateTexture() } } -void StaticCairoText::Impl::FontChanged(GObject* gobject, - GParamSpec* pspec, - gpointer data) -{ - StaticCairoText::Impl* self = static_cast(data); - self->OnFontChanged(); -} - void StaticCairoText::Impl::OnFontChanged() { need_new_extent_cache_ = true; -- cgit v1.2.3