[ekiga/ds-gsettings3] Ported the GmConf::PersonalDetails component to GSettings.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings3] Ported the GmConf::PersonalDetails component to GSettings.
- Date: Sun, 6 Oct 2013 17:54:47 +0000 (UTC)
commit 790142bff24d6515b287a8f3998c5dcee0a9876b
Author: Damien Sandras <dsandras beip be>
Date: Sun Oct 6 19:54:17 2013 +0200
Ported the GmConf::PersonalDetails component to GSettings.
.../gmconf-personal-details.cpp | 143 +++++---------------
.../gmconf-personal-details.h | 13 +--
2 files changed, 37 insertions(+), 119 deletions(-)
---
diff --git a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
index cc234c9..79dd2e0 100644
--- a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
+++ b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.cpp
@@ -36,93 +36,44 @@
#include "gmconf-personal-details.h"
-#include <glib.h>
-
-#include "gmconf.h"
-
-static void
-display_name_changed_nt (G_GNUC_UNUSED gpointer id,
- GmConfEntry* entry,
- gpointer data)
-{
- Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- gchar* val = gm_conf_entry_get_string (entry);
-
- if (val != NULL)
- details->display_name_changed (val);
- g_free (val);
-}
-
-static void
-presence_changed_nt (G_GNUC_UNUSED gpointer id,
- GmConfEntry* entry,
- gpointer data)
-{
- Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- gchar* val = gm_conf_entry_get_string (entry);
-
- if (val != NULL)
- details->presence_changed (val);
- g_free (val);
-}
-
-static void
-status_changed_nt (G_GNUC_UNUSED gpointer id,
- GmConfEntry* entry,
- gpointer data)
+Gmconf::PersonalDetails::PersonalDetails ()
{
- Gmconf::PersonalDetails *details = (Gmconf::PersonalDetails *) data;
- gchar* val = gm_conf_entry_get_string (entry);
+ personal_details = new Ekiga::Settings (PERSONAL_DATA_SCHEMA);
+ personal_details->changed.connect (boost::bind (&PersonalDetails::setup, this, _1));
- if (val != NULL)
- details->status_changed (val);
- g_free (val);
+ setup ();
}
-Gmconf::PersonalDetails::PersonalDetails ()
+Gmconf::PersonalDetails::~PersonalDetails ()
{
- gchar* str = NULL;
-
- display_name_notifier
- = gm_conf_notifier_add (PERSONAL_DATA_KEY "full_name",
- display_name_changed_nt, this);
- presence_notifier
- = gm_conf_notifier_add (PERSONAL_DATA_KEY "short_status",
- presence_changed_nt, this);
- status_notifier
- = gm_conf_notifier_add (PERSONAL_DATA_KEY "long_status",
- status_changed_nt, this);
-
- str = gm_conf_get_string (PERSONAL_DATA_KEY "full_name");
- if (str != NULL) {
-
- display_name = str;
- g_free (str);
- } else
- display_name = "";
-
- str = gm_conf_get_string (PERSONAL_DATA_KEY "short_status");
- if (str != NULL) {
-
- presence = str;
- g_free (str);
- } else
- presence = "";
-
- str = gm_conf_get_string (PERSONAL_DATA_KEY "long_status");
- if (str != NULL) {
-
- status = str;
- g_free (str);
- } else
- status = "";
+ delete personal_details;
}
-Gmconf::PersonalDetails::~PersonalDetails ()
+void
+Gmconf::PersonalDetails::setup (std::string setting)
{
- gm_conf_notifier_remove (display_name_notifier);
- gm_conf_notifier_remove (presence_notifier);
- gm_conf_notifier_remove (status_notifier);
+ std::string value;
+ if (setting.empty () || setting == "full-name") {
+ value = personal_details->get_string ("full-name");
+ if (value != display_name) {
+ display_name = value;
+ updated ();
+ }
+ }
+ if (setting.empty () || setting == "short-status") {
+ value = personal_details->get_string ("short-status");
+ if (value != presence) {
+ presence = value;
+ updated ();
+ }
+ }
+ if (setting.empty () || setting == "full-name") {
+ value = personal_details->get_string ("long-status");
+ if (value != status) {
+ status = value;
+ updated ();
+ }
+ }
}
const std::string
@@ -146,22 +97,19 @@ Gmconf::PersonalDetails::get_status () const
void
Gmconf::PersonalDetails::set_display_name (const std::string display_name_)
{
- gm_conf_set_string (PERSONAL_DATA_KEY "full_name",
- display_name_.c_str ());
+ personal_details->set_string ("full-name", display_name_);
}
void
Gmconf::PersonalDetails::set_presence (const std::string presence_)
{
- gm_conf_set_string (PERSONAL_DATA_KEY "short_status",
- presence_.c_str ());
+ personal_details->set_string ("short-status", presence_);
}
void
Gmconf::PersonalDetails::set_status (const std::string status_)
{
- gm_conf_set_string (PERSONAL_DATA_KEY "long_status",
- status_.c_str ());
+ personal_details->set_string ("long-status", status_);
}
void
@@ -176,28 +124,3 @@ Gmconf::PersonalDetails::set_presence_info (const std::string _presence,
updated ();
}
-
-void
-Gmconf::PersonalDetails::display_name_changed (std::string val)
-{
- display_name = val;
- updated ();
-}
-
-void
-Gmconf::PersonalDetails::presence_changed (std::string val)
-{
- if (presence != val) {
- presence = val;
- updated ();
- }
-}
-
-void
-Gmconf::PersonalDetails::status_changed (std::string val)
-{
- if (status != val) {
- status = val;
- updated ();
- }
-}
diff --git a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
index 11018a2..1e3373e 100644
--- a/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
+++ b/lib/engine/components/gmconf-personal-details/gmconf-personal-details.h
@@ -38,6 +38,7 @@
#define __GMCONF_PERSONAL_DETAILS_H__
#include "personal-details.h"
+#include "ekiga-settings.h"
namespace Gmconf
{
@@ -76,19 +77,13 @@ namespace Gmconf
void set_presence_info (const std::string presence,
const std::string status);
- /*** public but only to be called by C callbacks ***/
- public:
- void display_name_changed (std::string val);
- void presence_changed (std::string val);
- void status_changed (std::string val);
-
private:
- void* display_name_notifier;
- void* presence_notifier;
- void* status_notifier;
+ void setup (std::string what = "");
+
std::string display_name;
std::string presence;
std::string status;
+ Ekiga::Settings *personal_details;
};
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]