~ubuntu-branches/ubuntu/oneiric/gnome-system-monitor/oneiric-proposed

« back to all changes in this revision

Viewing changes to src/smooth_refresh.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2011-06-21 16:49:23 UTC
  • mto: (2.1.7 sid) (1.1.59 upstream)
  • mto: This revision was merged to the branch mainline in revision 78.
  • Revision ID: james.westby@ubuntu.com-20110621164923-o6titd2srek1uh84
Tags: upstream-3.0.1
ImportĀ upstreamĀ versionĀ 3.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include <unistd.h>
5
5
 
6
6
#include <glib.h>
7
 
#include <gconf/gconf-client.h>
8
7
#include <glibtop.h>
9
8
#include <glibtop/proctime.h>
10
9
#include <glibtop/cpu.h>
16
15
#include "util.h"
17
16
 
18
17
 
19
 
const string SmoothRefresh::KEY("/apps/procman/smooth_refresh");
20
 
const bool SmoothRefresh::KEY_DEFAULT_VALUE(true);
 
18
const string SmoothRefresh::KEY("smooth-refresh");
21
19
 
22
20
 
23
21
 
46
44
 
47
45
 
48
46
 
49
 
void SmoothRefresh::status_changed(GConfClient *client,
50
 
                                   guint cnxn_id,
51
 
                                   GConfEntry *entry,
52
 
                                   gpointer user_data)
 
47
void SmoothRefresh::status_changed(GSettings *settings,
 
48
                                   const gchar *key,
 
49
                                   gpointer user_data)
53
50
{
54
 
  static_cast<SmoothRefresh*>(user_data)->load_gconf_value(gconf_entry_get_value(entry));
 
51
  static_cast<SmoothRefresh*>(user_data)->load_settings_value(key);
55
52
}
56
53
 
57
 
void SmoothRefresh::load_gconf_value(GConfValue* value)
 
54
void SmoothRefresh::load_settings_value(const gchar *key)
58
55
{
59
 
  bool own_value = false;
60
 
 
61
 
  if (not value) {
62
 
    value = gconf_client_get(gconf_client_get_default(), KEY.c_str(), NULL);
63
 
  }
64
 
 
65
 
  this->active = value ? gconf_value_get_bool(value) : KEY_DEFAULT_VALUE;
 
56
  this->active = g_settings_get_boolean(settings, key);
66
57
 
67
58
  if (this->active)
68
59
    procman_debug("smooth_refresh is enabled");
69
 
 
70
 
  if (own_value and value)
71
 
    gconf_value_free(value);
72
60
}
73
61
 
74
62
 
75
 
SmoothRefresh::SmoothRefresh()
 
63
SmoothRefresh::SmoothRefresh(GSettings *a_settings)
 
64
:
 
65
    settings(a_settings)
76
66
{
77
 
  this->connection = gconf_client_notify_add(gconf_client_get_default(),
78
 
                                             KEY.c_str(),
79
 
                                             status_changed,
80
 
                                             this,
81
 
                                             NULL,
82
 
                                             NULL);
 
67
  this->connection = g_signal_connect(G_OBJECT(settings),
 
68
                                      "changed::smooth-refresh",
 
69
                                      G_CALLBACK(status_changed),
 
70
                                      this);
83
71
 
84
72
  this->reset();
85
 
  this->load_gconf_value();
 
73
  this->load_settings_value(KEY.c_str());
86
74
}
87
75
 
88
76
 
106
94
SmoothRefresh::~SmoothRefresh()
107
95
{
108
96
  if (this->connection)
109
 
    gconf_client_notify_remove(gconf_client_get_default(),
110
 
                               this->connection);
 
97
    g_signal_handler_disconnect(G_OBJECT(settings), this->connection);
111
98
}
112
99
 
113
100