[ekiga] Settings: Added the callback to the ctor.



commit 85e0ee938dc9d3b352b5d1c9b182d77c5bcf7bd2
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Mar 8 13:17:37 2015 +0100

    Settings: Added the callback to the ctor.
    
    This simplifies signal connection.

 lib/settings/ekiga-settings.h |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/lib/settings/ekiga-settings.h b/lib/settings/ekiga-settings.h
index b54d556..c622664 100644
--- a/lib/settings/ekiga-settings.h
+++ b/lib/settings/ekiga-settings.h
@@ -95,8 +95,14 @@ public:
 
     Settings (const std::string & schema)
     {
-      gsettings = g_settings_new (schema.c_str ());
-      handler = g_signal_connect (gsettings, "changed", G_CALLBACK (&f_callback), this);
+      init (schema);
+    }
+
+    Settings (const std::string & schema,
+              boost::function1<void, const std::string &> & f)
+    {
+      init (schema);
+      changed.connect (f);
     }
 
     ~Settings ()
@@ -208,9 +214,17 @@ public:
     boost::signals2::signal<void(std::string)> changed;
 
 private:
+    void init (const std::string & schema)
+    {
+      gsettings = g_settings_new (schema.c_str ());
+      handler = g_signal_connect (gsettings, "changed", G_CALLBACK (&f_callback), this);
+    }
+
     gulong handler;
     GSettings *gsettings;
   };
+
+  typedef boost::shared_ptr<Settings> SettingsPtr;
 }
 
 #endif /* EKIGA_SETTINGS_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]