summaryrefslogtreecommitdiff
path: root/cpufreq
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-24 18:18:51 +0100
committerStefano Karapetsas <[email protected]>2012-11-24 18:18:51 +0100
commit8c30f31702202aed1b7e8c21b204a44ac2dc37cc (patch)
tree57d8a94324b6f320e9d4848b3fc7012217487ba4 /cpufreq
parentd2d15da67e19e821d051d1b2382885854acd140c (diff)
downloadmate-applets-8c30f31702202aed1b7e8c21b204a44ac2dc37cc.tar.bz2
mate-applets-8c30f31702202aed1b7e8c21b204a44ac2dc37cc.tar.xz
cpufreq: migrate to gsettings
Diffstat (limited to 'cpufreq')
-rw-r--r--cpufreq/Makefile.am20
-rw-r--r--cpufreq/README3
-rw-r--r--cpufreq/cpufreq-applet.schemas.in36
-rw-r--r--cpufreq/org.mate.panel.applet.cpufreq.gschema.xml.in.in20
-rw-r--r--cpufreq/src/Makefile.am4
-rw-r--r--cpufreq/src/cpufreq-applet.c12
-rw-r--r--cpufreq/src/cpufreq-prefs.c150
-rw-r--r--cpufreq/src/cpufreq-prefs.h3
8 files changed, 71 insertions, 177 deletions
diff --git a/cpufreq/Makefile.am b/cpufreq/Makefile.am
index f2b4f80e..e6a63607 100644
--- a/cpufreq/Makefile.am
+++ b/cpufreq/Makefile.am
@@ -1,10 +1,11 @@
SUBDIRS = help pixmaps src
-schemasdir = @MATECONF_SCHEMA_FILE_DIR@
-schemas_in_files = cpufreq-applet.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+@INTLTOOL_XML_NOMERGE_RULE@
+gsettings_SCHEMAS = org.mate.panel.applet.cpufreq.gschema.xml
+@GSETTINGS_RULES@
-@INTLTOOL_SCHEMAS_RULE@
+%.gschema.xml.in: %.gschema.xml.in.in Makefile
+ $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@
appletdir = $(datadir)/mate-panel/applets
applet_in_files = org.mate.applets.CPUFreqApplet.mate-panel-applet.in
@@ -32,23 +33,20 @@ builder_DATA = cpufreq-preferences.ui
uidir = $(datadir)/mate-2.0/ui
ui_DATA = cpufreq-applet-menu.xml
-if MATECONF_SCHEMAS_INSTALL
-install-data-local:
- -MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(top_builddir)/cpufreq/$(schemas_DATA) ;
-endif
-
CLEANFILES = \
$(applet_DATA) \
$(applet_DATA).in \
$(service_DATA) \
- cpufreq-applet.schemas \
+ $(gsettings_SCHEMAS_in) \
+ $(gsettings_SCHEMAS) \
+ *.gschema.valid \
*.bak \
*.gladep
EXTRA_DIST = \
org.mate.applets.CPUFreqApplet.mate-panel-applet.in.in \
$(service_in_files) \
- $(schemas_in_files) \
+ $(gsettings_SCHEMAS_in_in) \
$(builder_DATA) \
$(ui_DATA)
diff --git a/cpufreq/README b/cpufreq/README
index 45b6e2f2..a4d516af 100644
--- a/cpufreq/README
+++ b/cpufreq/README
@@ -13,10 +13,7 @@ FEATURES
PREREQUISITES
-------------
- - MATE 2 libraries
- MATE Panel libraries
- - MATE-VFS libraries
- - MateConf
FREQUENCY SELECTOR
diff --git a/cpufreq/cpufreq-applet.schemas.in b/cpufreq/cpufreq-applet.schemas.in
deleted file mode 100644
index 88ed4684..00000000
--- a/cpufreq/cpufreq-applet.schemas.in
+++ /dev/null
@@ -1,36 +0,0 @@
-<mateconfschemafile>
-<schemalist>
-
-<schema>
- <key>/schemas/apps/cpufreq-applet/prefs/cpu</key>
- <owner>cpufreq-applet</owner>
- <type>int</type>
- <default>0</default>
- <locale name="C">
- <short>CPU to Monitor</short>
- <long>Set the CPU to monitor. In a single processor system you don't have to change it.</long>
- </locale>
-</schema>
-<schema>
- <key>/schemas/apps/cpufreq-applet/prefs/show_mode</key>
- <owner>cpufreq-applet</owner>
- <type>int</type>
- <default>2</default>
- <locale name="C">
- <short>Mode to show cpu usage</short>
- <long>A 0 value means to show the applet in graphic mode (pixmap only), 1 to show the applet in text mode (not to show the pixmap) and 2 to show the applet in graphic and text mode.</long>
- </locale>
-</schema>
-<schema>
- <key>/schemas/apps/cpufreq-applet/prefs/show_text_mode</key>
- <owner>cpufreq-applet</owner>
- <type>int</type>
- <default>1</default>
- <locale name="C">
- <short>The type of text to display (if the text is enabled).</short>
- <long>A 0 value means to show cpu frequency, 1 to show frequency and units, and 2 to show percentage instead of frequency.</long>
- </locale>
-</schema>
-
-</schemalist>
-</mateconfschemafile>
diff --git a/cpufreq/org.mate.panel.applet.cpufreq.gschema.xml.in.in b/cpufreq/org.mate.panel.applet.cpufreq.gschema.xml.in.in
new file mode 100644
index 00000000..7f306a7e
--- /dev/null
+++ b/cpufreq/org.mate.panel.applet.cpufreq.gschema.xml.in.in
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+ <schema id="org.mate.panel.applet.cpufreq">
+ <key name="cpu" type="i">
+ <default>0</default>
+ <summary>CPU to Monitor</summary>
+ <description>Set the CPU to monitor. In a single processor system you don't have to change it.</description>
+ </key>
+ <key name="show-mode" type="i">
+ <default>2</default>
+ <summary>Mode to show cpu usage</summary>
+ <description>A 0 value means to show the applet in graphic mode (pixmap only), 1 to show the applet in text mode (not to show the pixmap) and 2 to show the applet in graphic and text mode.</description>
+ </key>
+ <key name="show-text-mode" type="i">
+ <default>1</default>
+ <summary>The type of text to display (if the text is enabled).</summary>
+ <description>A 0 value means to show cpu frequency, 1 to show frequency and units, and 2 to show percentage instead of frequency.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/cpufreq/src/Makefile.am b/cpufreq/src/Makefile.am
index db5679d0..d51e1529 100644
--- a/cpufreq/src/Makefile.am
+++ b/cpufreq/src/Makefile.am
@@ -6,7 +6,7 @@ SUBDIRS = $(selector_SUBDIR)
INCLUDES = \
-DCPUFREQ_MENU_UI_DIR=\""$(datadir)/mate-2.0/ui"\" \
- $(MATE_APPLETS3_CFLAGS) \
+ $(MATE_APPLETS4_CFLAGS) \
$(LIBGLADE_CFLAGS) \
$(DBUS_CFLAGS)
@@ -30,7 +30,7 @@ cpufreq_applet_SOURCES = \
cpufreq-monitor-cpuinfo.c cpufreq-monitor-cpuinfo.h
cpufreq_applet_LDADD = \
- $(MATE_APPLETS3_LIBS) \
+ $(MATE_APPLETS4_LIBS) \
$(LIBGLADE_LIBS) \
$(LIBCPUFREQ_LIBS) \
$(DBUS_LIBS)
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index 6937fd04..acc24ddb 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -25,8 +25,9 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include <gio/gio.h>
#include <mate-panel-applet.h>
-#include <mate-panel-applet-mateconf.h>
+#include <mate-panel-applet-gsettings.h>
#include <glib/gi18n.h>
#include <stdlib.h>
#include <string.h>
@@ -942,21 +943,18 @@ cpufreq_applet_setup (CPUFreqApplet *applet)
gchar *ui_path;
AtkObject *atk_obj;
gchar *prefs_key;
+ GSettings *settings;
g_set_application_name (_("CPU Frequency Scaling Monitor"));
gtk_window_set_default_icon_name ("mate-cpu-frequency-applet");
- mate_panel_applet_add_preferences (MATE_PANEL_APPLET (applet),
- "/schemas/apps/cpufreq-applet/prefs", NULL);
-
/* Preferences */
if (applet->prefs)
g_object_unref (applet->prefs);
- prefs_key = mate_panel_applet_get_preferences_key (MATE_PANEL_APPLET (applet));
- applet->prefs = cpufreq_prefs_new (prefs_key);
- g_free (prefs_key);
+ settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (applet), "org.mate.panel.applet.cpufreq");
+ applet->prefs = cpufreq_prefs_new (settings);
g_signal_connect (G_OBJECT (applet->prefs),
"notify::cpu",
diff --git a/cpufreq/src/cpufreq-prefs.c b/cpufreq/src/cpufreq-prefs.c
index cf057829..38c0ca07 100644
--- a/cpufreq/src/cpufreq-prefs.c
+++ b/cpufreq/src/cpufreq-prefs.c
@@ -25,22 +25,21 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include "cpufreq-prefs.h"
#include "cpufreq-utils.h"
enum {
PROP_0,
- PROP_MATECONF_KEY,
+ PROP_GSETTINGS,
PROP_CPU,
PROP_SHOW_MODE,
PROP_SHOW_TEXT_MODE,
};
struct _CPUFreqPrefsPrivate {
- MateConfClient *mateconf_client;
- gchar *mateconf_key;
+ GSettings *settings;
guint cpu;
CPUFreqShowMode show_mode;
@@ -82,8 +81,7 @@ cpufreq_prefs_init (CPUFreqPrefs *prefs)
{
prefs->priv = CPUFREQ_PREFS_GET_PRIVATE (prefs);
- prefs->priv->mateconf_client = mateconf_client_get_default ();
- prefs->priv->mateconf_key = NULL;
+ prefs->priv->settings = NULL;
prefs->priv->cpu = 0;
}
@@ -100,10 +98,10 @@ cpufreq_prefs_class_init (CPUFreqPrefsClass *klass)
/* Properties */
g_object_class_install_property (g_object_class,
- PROP_MATECONF_KEY,
- g_param_spec_string ("mateconf-key",
- "MateConfKey",
- "The applet mateconf key",
+ PROP_GSETTINGS,
+ g_param_spec_string ("gsettings",
+ "GSettings",
+ "The applet gsettings object",
NULL,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
@@ -141,14 +139,9 @@ cpufreq_prefs_finalize (GObject *object)
{
CPUFreqPrefs *prefs = CPUFREQ_PREFS (object);
- if (prefs->priv->mateconf_client) {
- g_object_unref (prefs->priv->mateconf_client);
- prefs->priv->mateconf_client = NULL;
- }
-
- if (prefs->priv->mateconf_key) {
- g_free (prefs->priv->mateconf_key);
- prefs->priv->mateconf_key = NULL;
+ if (prefs->priv->settings) {
+ g_object_unref (prefs->priv->settings);
+ prefs->priv->settings = NULL;
}
if (prefs->priv->dialog) {
@@ -169,25 +162,17 @@ cpufreq_prefs_set_property (GObject *object,
gboolean update_sensitivity = FALSE;
switch (prop_id) {
- case PROP_MATECONF_KEY:
- prefs->priv->mateconf_key = g_value_dup_string (value);
+ case PROP_GSETTINGS:
+ prefs->priv->settings = g_value_get_object (value);
break;
case PROP_CPU: {
guint cpu;
cpu = g_value_get_uint (value);
if (prefs->priv->cpu != cpu) {
- gchar *key;
-
prefs->priv->cpu = cpu;
- key = g_strjoin ("/",
- prefs->priv->mateconf_key,
- "cpu",
- NULL);
- mateconf_client_set_int (prefs->priv->mateconf_client,
- key, prefs->priv->cpu,
- NULL);
- g_free (key);
+ g_settings_set_int (prefs->priv->settings,
+ "cpu", prefs->priv->cpu);
}
}
break;
@@ -196,18 +181,10 @@ cpufreq_prefs_set_property (GObject *object,
mode = g_value_get_enum (value);
if (prefs->priv->show_mode != mode) {
- gchar *key;
-
update_sensitivity = TRUE;
prefs->priv->show_mode = mode;
- key = g_strjoin ("/",
- prefs->priv->mateconf_key,
- "show_mode",
- NULL);
- mateconf_client_set_int (prefs->priv->mateconf_client,
- key, prefs->priv->show_mode,
- NULL);
- g_free (key);
+ g_settings_set_int (prefs->priv->settings,
+ "show-mode", prefs->priv->show_mode);
}
}
break;
@@ -216,18 +193,10 @@ cpufreq_prefs_set_property (GObject *object,
mode = g_value_get_enum (value);
if (prefs->priv->show_text_mode != mode) {
- gchar *key;
-
update_sensitivity = TRUE;
prefs->priv->show_text_mode = mode;
- key = g_strjoin ("/",
- prefs->priv->mateconf_key,
- "show_text_mode",
- NULL);
- mateconf_client_set_int (prefs->priv->mateconf_client,
- key, prefs->priv->show_text_mode,
- NULL);
- g_free (key);
+ g_settings_set_int (prefs->priv->settings,
+ "show-text-mode", prefs->priv->show_text_mode);
}
}
break;
@@ -248,7 +217,7 @@ cpufreq_prefs_get_property (GObject *object,
CPUFreqPrefs *prefs = CPUFREQ_PREFS (object);
switch (prop_id) {
- case PROP_MATECONF_KEY:
+ case PROP_GSETTINGS:
/* Is not readable */
break;
case PROP_CPU:
@@ -268,72 +237,23 @@ cpufreq_prefs_get_property (GObject *object,
static void
cpufreq_prefs_setup (CPUFreqPrefs *prefs)
{
- guint cpu;
- CPUFreqShowMode show_mode;
- CPUFreqShowTextMode show_text_mode;
- gchar *key;
- GError *error = NULL;
-
- g_assert (MATECONF_IS_CLIENT (prefs->priv->mateconf_client));
- g_assert (prefs->priv->mateconf_key != NULL);
-
- key = g_strjoin ("/", prefs->priv->mateconf_key, "cpu", NULL);
- cpu = mateconf_client_get_int (prefs->priv->mateconf_client,
- key, &error);
- g_free (key);
- /* In case anything went wrong with mateconf, get back to the default */
- if (error) {
- g_warning ("%s", error->message);
- cpu = 0;
- g_error_free (error);
- error = NULL;
- }
- prefs->priv->cpu = cpu;
-
- key = g_strjoin ("/", prefs->priv->mateconf_key, "show_mode", NULL);
- show_mode = mateconf_client_get_int (prefs->priv->mateconf_client,
- key, &error);
- g_free (key);
- /* In case anything went wrong with mateconf, get back to the default */
- if (error ||
- show_mode < CPUFREQ_MODE_GRAPHIC ||
- show_mode > CPUFREQ_MODE_BOTH) {
- show_mode = CPUFREQ_MODE_BOTH;
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
- }
- prefs->priv->show_mode = show_mode;
-
- key = g_strjoin ("/", prefs->priv->mateconf_key, "show_text_mode", NULL);
- show_text_mode = mateconf_client_get_int (prefs->priv->mateconf_client,
- key, &error);
- g_free (key);
- /* In case anything went wrong with mateconf, get back to the default */
- if (error ||
- show_text_mode < CPUFREQ_MODE_TEXT_FREQUENCY ||
- show_text_mode > CPUFREQ_MODE_TEXT_PERCENTAGE) {
- show_text_mode = CPUFREQ_MODE_TEXT_FREQUENCY_UNIT;
- if (error) {
- g_warning ("%s", error->message);
- g_error_free (error);
- error = NULL;
- }
- }
- prefs->priv->show_text_mode = show_text_mode;
+ g_assert (G_IS_SETTINGS (prefs->priv->settings));
+ g_assert (prefs->priv->settings != NULL);
+
+ prefs->priv->cpu = g_settings_get_int (prefs->priv->settings, "cpu");
+ prefs->priv->show_mode = g_settings_get_int (prefs->priv->settings, "show-mode");
+ prefs->priv->show_text_mode = g_settings_get_int (prefs->priv->settings, "show-text-mode");
}
CPUFreqPrefs *
-cpufreq_prefs_new (const gchar *mateconf_key)
+cpufreq_prefs_new (GSettings *settings)
{
CPUFreqPrefs *prefs;
- g_return_val_if_fail (mateconf_key != NULL, NULL);
+ g_return_val_if_fail (settings != NULL, NULL);
prefs = CPUFREQ_PREFS (g_object_new (CPUFREQ_TYPE_PREFS,
- "mateconf-key", mateconf_key,
+ "gsettings", settings,
NULL));
cpufreq_prefs_setup (prefs);
@@ -373,14 +293,10 @@ static gboolean
cpufreq_prefs_key_is_writable (CPUFreqPrefs *prefs, const gchar *key)
{
gboolean writable;
- gchar *fullkey;
- g_assert (prefs->priv->mateconf_client != NULL);
+ g_assert (prefs->priv->settings != NULL);
- fullkey = g_strjoin ("/", prefs->priv->mateconf_key, key, NULL);
- writable = mateconf_client_key_is_writable (prefs->priv->mateconf_client,
- fullkey, NULL);
- g_free (fullkey);
+ writable = g_settings_is_writable (prefs->priv->settings, key);
return writable;
}
@@ -498,12 +414,12 @@ static void
cpufreq_prefs_dialog_update_sensitivity (CPUFreqPrefs *prefs)
{
gtk_widget_set_sensitive (prefs->priv->show_mode_combo,
- cpufreq_prefs_key_is_writable (prefs, "show_mode"));
+ cpufreq_prefs_key_is_writable (prefs, "show-mode"));
if (prefs->priv->show_mode != CPUFREQ_MODE_GRAPHIC) {
gboolean key_writable;
- key_writable = cpufreq_prefs_key_is_writable (prefs, "show_text_mode");
+ key_writable = cpufreq_prefs_key_is_writable (prefs, "show-text-mode");
gtk_widget_set_sensitive (prefs->priv->show_freq,
(TRUE && key_writable));
diff --git a/cpufreq/src/cpufreq-prefs.h b/cpufreq/src/cpufreq-prefs.h
index 6a695cb6..760d9621 100644
--- a/cpufreq/src/cpufreq-prefs.h
+++ b/cpufreq/src/cpufreq-prefs.h
@@ -24,6 +24,7 @@
#include <gdk/gdk.h>
#include <glib-object.h>
+#include <gio/gio.h>
#include "cpufreq-applet.h"
G_BEGIN_DECLS
@@ -51,7 +52,7 @@ struct _CPUFreqPrefsClass {
GType cpufreq_prefs_get_type (void) G_GNUC_CONST;
-CPUFreqPrefs *cpufreq_prefs_new (const gchar *mateconf_key);
+CPUFreqPrefs *cpufreq_prefs_new (GSettings *settings);
guint cpufreq_prefs_get_cpu (CPUFreqPrefs *prefs);
CPUFreqShowMode cpufreq_prefs_get_show_mode (CPUFreqPrefs *prefs);