summaryrefslogtreecommitdiff
path: root/src/smooth_refresh.cpp
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-06 14:22:49 -0800
committerStefano Karapetsas <[email protected]>2012-11-06 14:22:49 -0800
commit684e6bb4c072f707a92ce72d85954b5790aaab53 (patch)
treee8a449764975fe5066a67c9275ea73c56a88309b /src/smooth_refresh.cpp
parent7caef9a314fc9f1fea996d79601d4242286825b1 (diff)
parentf27253b155db8d3c06bf13801c63bdc282da4157 (diff)
downloadmate-system-monitor-684e6bb4c072f707a92ce72d85954b5790aaab53.tar.bz2
mate-system-monitor-684e6bb4c072f707a92ce72d85954b5790aaab53.tar.xz
Merge pull request #10 from NiceandGently/master
port to gsettings
Diffstat (limited to 'src/smooth_refresh.cpp')
-rw-r--r--src/smooth_refresh.cpp47
1 files changed, 16 insertions, 31 deletions
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 <unistd.h>
#include <glib.h>
-#include <mateconf/mateconf-client.h>
#include <glibtop.h>
#include <glibtop/proctime.h>
#include <glibtop/cpu.h>
@@ -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<SmoothRefresh*>(user_data)->load_mateconf_value(mateconf_entry_get_value(entry));
+ static_cast<SmoothRefresh*>(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);
}