From f27253b155db8d3c06bf13801c63bdc282da4157 Mon Sep 17 00:00:00 2001 From: raveit Date: Tue, 6 Nov 2012 18:19:51 +0100 Subject: Port to gesettings --- src/smooth_refresh.cpp | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'src/smooth_refresh.cpp') diff --git a/src/smooth_refresh.cpp b/src/smooth_refresh.cpp index f21c023..484aa67 100644 --- a/src/smooth_refresh.cpp +++ b/src/smooth_refresh.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -16,9 +15,7 @@ #include "util.h" -const string SmoothRefresh::KEY("/apps/procman/smooth_refresh"); -const bool SmoothRefresh::KEY_DEFAULT_VALUE(true); - +const string SmoothRefresh::KEY("smooth-refresh"); unsigned SmoothRefresh::get_own_cpu_usage() @@ -46,43 +43,32 @@ unsigned SmoothRefresh::get_own_cpu_usage() -void SmoothRefresh::status_changed(MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +void SmoothRefresh::status_changed(GSettings *settings, + const gchar *key, + gpointer user_data) { - static_cast(user_data)->load_mateconf_value(mateconf_entry_get_value(entry)); + static_cast(user_data)->load_settings_value(key); } -void SmoothRefresh::load_mateconf_value(MateConfValue* value) +void SmoothRefresh::load_settings_value(const gchar *key) { - bool own_value = false; - - if (not value) { - value = mateconf_client_get(mateconf_client_get_default(), KEY.c_str(), NULL); - } - - this->active = value ? mateconf_value_get_bool(value) : KEY_DEFAULT_VALUE; + this->active = g_settings_get_boolean(settings, key); if (this->active) procman_debug("smooth_refresh is enabled"); - - if (own_value and value) - mateconf_value_free(value); } - -SmoothRefresh::SmoothRefresh() +SmoothRefresh::SmoothRefresh(GSettings *a_settings) +: + settings(a_settings) { - this->connection = mateconf_client_notify_add(mateconf_client_get_default(), - KEY.c_str(), - status_changed, - this, - NULL, - NULL); + this->connection = g_signal_connect(G_OBJECT(settings), + "changed::smooth-refresh", + G_CALLBACK(status_changed), + this); this->reset(); - this->load_mateconf_value(); + this->load_settings_value(KEY.c_str()); } @@ -106,8 +92,7 @@ void SmoothRefresh::reset() SmoothRefresh::~SmoothRefresh() { if (this->connection) - mateconf_client_notify_remove(mateconf_client_get_default(), - this->connection); + g_signal_handler_disconnect(G_OBJECT(settings), this->connection); } -- cgit v1.2.1