summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battstat/Makefile.am22
-rw-r--r--battstat/battstat.h6
-rw-r--r--battstat/battstat.schemas.in104
-rw-r--r--battstat/battstat_applet.c32
-rw-r--r--battstat/docs/C/mate-battstat.xml2
-rw-r--r--battstat/org.mate.panel.applet.battstat.gschema.xml.in.in54
-rw-r--r--battstat/properties.c75
7 files changed, 107 insertions, 188 deletions
diff --git a/battstat/Makefile.am b/battstat/Makefile.am
index 10f40af0..cd01741f 100644
--- a/battstat/Makefile.am
+++ b/battstat/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = docs sounds $(APMDIR)
DIST_SUBDIRS = docs sounds apmlib
INCLUDES = \
- $(MATE_APPLETS3_CFLAGS) \
+ $(MATE_APPLETS4_CFLAGS) \
$(LIBMATENOTIFY_CFLAGS) \
$(HAL_CFLAGS) \
$(UPOWER_CFLAGS) \
@@ -54,23 +54,19 @@ battstat_applet_2_SOURCES = \
battstat_applet_2_LDADD = \
- $(MATE_APPLETS3_LIBS) \
+ $(MATE_APPLETS4_LIBS) \
$(LIBMATENOTIFY_LIBS) \
$(HAL_LIBS) \
$(APMLIB) \
$(UPOWER_LIBS) \
-lm
-schemasdir = @MATECONF_SCHEMA_FILE_DIR@
-schemas_in_files = battstat.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+@INTLTOOL_XML_NOMERGE_RULE@
+gsettings_SCHEMAS = org.mate.panel.applet.battstat.gschema.xml
+@GSETTINGS_RULES@
-@INTLTOOL_SCHEMAS_RULE@
-
-if MATECONF_SCHEMAS_INSTALL
-install-data-local:
- MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) ;
-endif
+%.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.BattstatApplet.mate-panel-applet.in
@@ -93,7 +89,7 @@ org.mate.panel.applet.BattstatAppletFactory.service: $(service_in_files)
-e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
$< > $@
-CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS) *.gschema.valid
uidir = $(datadir)/mate-2.0/ui
ui_DATA = battstat-applet-menu.xml
@@ -103,7 +99,7 @@ EXTRA_DIST = \
$(ui_DATA) \
org.mate.applets.BattstatApplet.mate-panel-applet.in.in \
$(service_in_files) \
- $(schemas_in_files)
+ $(gsettings_SCHEMAS_in_in)
-include $(top_srcdir)/git.mk
diff --git a/battstat/battstat.h b/battstat/battstat.h
index 1c591bce..a48dd121 100644
--- a/battstat/battstat.h
+++ b/battstat/battstat.h
@@ -24,9 +24,10 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
#include <mate-panel-applet.h>
-#include <mate-panel-applet-mateconf.h>
+#include <mate-panel-applet-gsettings.h>
#define DEBUG 0
@@ -96,7 +97,8 @@ typedef struct _ProgressData {
GtkWidget *full_toggle;
GtkWidget *hbox_ptr;
- /* flags set from mateconf or the properties dialog */
+ /* flags set from gsettings or the properties dialog */
+ GSettings *settings;
guint red_val;
guint orange_val;
guint yellow_val;
diff --git a/battstat/battstat.schemas.in b/battstat/battstat.schemas.in
deleted file mode 100644
index b356c11a..00000000
--- a/battstat/battstat.schemas.in
+++ /dev/null
@@ -1,104 +0,0 @@
-<mateconfschemafile>
- <schemalist>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/red_value</key>
- <owner>battstat-applet</owner>
- <type>int</type>
- <default>15</default>
- <locale name="C">
- <short>Red value level</short>
- <long>The battery level below which the battery is displayed as red. Also the value at which the low battery warning is displayed.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/red_value_is_time</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <locale name="C">
- <short>Warn on low time rather than low percentage</short>
- <long>Use the value defined in red_value as a time remaining to show the warning dialog rather than a percentage.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/low_battery_notification</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>true</default>
- <locale name="C">
- <short>Low Battery Notification</short>
- <long>Notify user when the battery is low.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/full_battery_notification</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>false</default>
- <locale name="C">
- <short>Full Battery Notification</short>
- <long>Notify user when the battery is full.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/beep</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>false</default>
- <locale name="C">
- <short>Beep for warnings</short>
- <long>Beep when displaying a warning.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/drain_from_top</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>false</default>
- <locale name="C">
- <short>Drain from top</short>
- <long>Show the battery meter draining from the top of the battery. Only implemented for traditional battery view.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/show_status</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>true</default>
- <locale name="C">
- <short>Upright (small) battery</short>
- <long>Show the upright, smaller battery on the panel.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/show_battery</key>
- <owner>battstat-applet</owner>
- <type>bool</type>
- <default>false</default>
- <locale name="C">
- <short>Show the horizontal battery</short>
- <long>Show the traditional, horizontal battery on the panel.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/battstat-applet/prefs/show_text</key>
- <owner>battstat-applet</owner>
- <type>int</type>
- <default>0</default>
- <locale name="C">
- <short>Show the time/percent label</short>
- <long>0 for no label, 1 for percentage and 2 for time remaining.</long>
- </locale>
- </schema>
-
- </schemalist>
-
-</mateconfschemafile>
diff --git a/battstat/battstat_applet.c b/battstat/battstat_applet.c
index 53c9e034..3fd76401 100644
--- a/battstat/battstat_applet.c
+++ b/battstat/battstat_applet.c
@@ -38,7 +38,7 @@
#include <gtk/gtk.h>
#include <mate-panel-applet.h>
-#include <mate-panel-applet-mateconf.h>
+#include <mate-panel-applet-gsettings.h>
#ifdef HAVE_LIBMATENOTIFY
#include <libmatenotify/notify.h>
@@ -51,7 +51,7 @@
#define gettext_noop(String) (String)
#endif
-#define MATECONF_PATH ""
+#define BATTSTAT_SCHEMA "org.mate.panel.applet.battstat"
static gboolean check_for_updates (gpointer data);
static void about_cb( GtkAction *, ProgressData * );
@@ -1329,20 +1329,19 @@ size_allocate( MatePanelApplet *applet, GtkAllocation *allocation,
reconfigure_layout( battstat );
}
-/* Get our settings out of mateconf.
+/* Get our settings out of gsettings.
*/
static void
load_preferences(ProgressData *battstat)
{
MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
+ GSettings *settings = battstat->settings;
if (DEBUG) g_print("load_preferences()\n");
- battstat->red_val = mate_panel_applet_mateconf_get_int (applet, MATECONF_PATH "red_value", NULL);
+ battstat->red_val = g_settings_get_int (settings, "red-value");
battstat->red_val = CLAMP (battstat->red_val, 0, 100);
- battstat->red_value_is_time = mate_panel_applet_mateconf_get_bool (applet,
- MATECONF_PATH "red_value_is_time",
- NULL);
+ battstat->red_value_is_time = g_settings_get_boolean (settings, "red-value-is-time");
/* automatically calculate orangle and yellow values from the red value */
battstat->orange_val = battstat->red_val * ORANGE_MULTIPLIER;
@@ -1351,19 +1350,19 @@ load_preferences(ProgressData *battstat)
battstat->yellow_val = battstat->red_val * YELLOW_MULTIPLIER;
battstat->yellow_val = CLAMP (battstat->yellow_val, 0, 100);
- battstat->lowbattnotification = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "low_battery_notification", NULL);
- battstat->fullbattnot = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "full_battery_notification", NULL);
- battstat->beep = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "beep", NULL);
- battstat->draintop = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "drain_from_top", NULL);
+ battstat->lowbattnotification = g_settings_get_boolean (settings, "low-battery-notification");
+ battstat->fullbattnot = g_settings_get_boolean (settings, "full-battery-notification");
+ battstat->beep = g_settings_get_boolean (settings, "beep");
+ battstat->draintop = g_settings_get_boolean (settings, "drain-from-top");
- battstat->showstatus = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "show_status", NULL);
- battstat->showbattery = mate_panel_applet_mateconf_get_bool (applet, MATECONF_PATH "show_battery", NULL);
+ battstat->showstatus = g_settings_get_boolean (settings, "show-status");
+ battstat->showbattery = g_settings_get_boolean (settings, "show-battery");
/* for miagration from older versions */
if (battstat->showstatus && battstat->showbattery)
battstat->showbattery = FALSE;
- battstat->showtext = mate_panel_applet_mateconf_get_int (applet, MATECONF_PATH "show_text", NULL);
+ battstat->showtext = g_settings_get_int (settings, "show-text");
}
/* Convenience function to attach a child widget to a GtkTable in the
@@ -1630,11 +1629,10 @@ battstat_applet_fill (MatePanelApplet *applet)
gtk_window_set_default_icon_name ("battery");
- mate_panel_applet_add_preferences (applet, "/schemas/apps/battstat-applet/prefs",
- NULL);
mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
battstat = g_new0 (ProgressData, 1);
+ battstat->settings = mate_panel_applet_settings_new (applet, BATTSTAT_SCHEMA);
/* Some starting values... */
battstat->applet = GTK_WIDGET (applet);
@@ -1684,7 +1682,7 @@ battstat_applet_fill (MatePanelApplet *applet)
atk_object_set_description(atk_widget, _("Monitor a laptop's remaining power"));
}
- no_hal = mate_panel_applet_mateconf_get_bool( applet, "no_hal", NULL );
+ no_hal = g_settings_get_boolean (battstat->settings, "no-hal");
if ((err = static_global_initialisation (no_hal, battstat)))
battstat_error_dialog (GTK_WIDGET (applet), err);
diff --git a/battstat/docs/C/mate-battstat.xml b/battstat/docs/C/mate-battstat.xml
index 2ba2273a..281be3ad 100644
--- a/battstat/docs/C/mate-battstat.xml
+++ b/battstat/docs/C/mate-battstat.xml
@@ -487,7 +487,7 @@ present voltage: 11400 mV
You can check that your battery is detected by HAL using the command
<command>hal-device-manager</command>. If your battery is not detected
by HAL or the wrong information is being reported, you can attempt to
- disable the HAL backend by setting a MateConf key.
+ disable the HAL backend by setting a GSettings key.
</para>
<para>
Select <guimenuitem>Configuration Editor</guimenuitem> from the
diff --git a/battstat/org.mate.panel.applet.battstat.gschema.xml.in.in b/battstat/org.mate.panel.applet.battstat.gschema.xml.in.in
new file mode 100644
index 00000000..f35103a1
--- /dev/null
+++ b/battstat/org.mate.panel.applet.battstat.gschema.xml.in.in
@@ -0,0 +1,54 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+ <schema id="org.mate.panel.applet.battstat">
+ <key name="red-value" type="i">
+ <default>15</default>
+ <_summary>Red value level</_summary>
+ <_description>The battery level below which the battery is displayed as red. Also the value at which the low battery warning is displayed.</_description>
+ </key>
+ <key name="red-value-is-time" type="b">
+ <default>false</default>
+ <_summary>Warn on low time rather than low percentage</_summary>
+ <_description>Use the value defined in red_value as a time remaining to show the warning dialog rather than a percentage.</_description>
+ </key>
+ <key name="low-battery-notification" type="b">
+ <default>true</default>
+ <_summary>Low Battery Notification</_summary>
+ <_description>Notify user when the battery is low.</_description>
+ </key>
+ <key name="full-battery-notification" type="b">
+ <default>false</default>
+ <_summary>Full Battery Notification</_summary>
+ <_description>Notify user when the battery is full.</_description>
+ </key>
+ <key name="beep" type="b">
+ <default>false</default>
+ <_summary>Beep for warnings</_summary>
+ <_description>Beep when displaying a warning.</_description>
+ </key>
+ <key name="drain-from-top" type="b">
+ <default>false</default>
+ <_summary>Drain from top</_summary>
+ <_description>Show the battery meter draining from the top of the battery. Only implemented for traditional battery view.</_description>
+ </key>
+ <key name="show-status" type="b">
+ <default>true</default>
+ <_summary>Upright (small) battery</_summary>
+ <_description>Show the upright, smaller battery on the panel.</_description>
+ </key>
+ <key name="show-battery" type="b">
+ <default>false</default>
+ <_summary>Show the horizontal battery</_summary>
+ <_description>Show the traditional, horizontal battery on the panel.</_description>
+ </key>
+ <key name="show-text" type="i">
+ <default>0</default>
+ <_summary>Show the time/percent label</_summary>
+ <_description>0 for no label, 1 for percentage and 2 for time remaining.</_description>
+ </key>
+ <key name="no-hal" type="b">
+ <default>false</default>
+ <_summary>Disable HAL</_summary>
+ <_description>Disable HAL if true</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/battstat/properties.c b/battstat/properties.c
index bcca19a2..8242ccee 100644
--- a/battstat/properties.c
+++ b/battstat/properties.c
@@ -42,10 +42,10 @@
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <mate-panel-applet.h>
-#include <mate-panel-applet-mateconf.h>
+#include <mate-panel-applet-gsettings.h>
#include "battstat.h"
@@ -87,10 +87,9 @@ combo_ptr_cb (GtkWidget *combo_ptr, gpointer data)
else
battstat->red_value_is_time = FALSE;
- mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (battstat->applet),
- "red_value_is_time",
- battstat->red_value_is_time,
- NULL);
+ g_settings_set_boolean (battstat->settings,
+ "red-value-is-time",
+ battstat->red_value_is_time);
}
static void
@@ -109,28 +108,9 @@ spin_ptr_cb (GtkWidget *spin_ptr, gpointer data)
battstat->yellow_val = battstat->red_val * YELLOW_MULTIPLIER;
battstat->yellow_val = CLAMP (battstat->yellow_val, 0, 100);
- mate_panel_applet_mateconf_set_int (MATE_PANEL_APPLET (battstat->applet),
- "red_value",
- battstat->red_val,
- NULL);
-}
-
-static gboolean
-key_writable (MatePanelApplet *applet, const char *key)
-{
- gboolean writable;
- char *fullkey;
- static MateConfClient *client = NULL;
- if (client == NULL)
- client = mateconf_client_get_default ();
-
- fullkey = mate_panel_applet_mateconf_get_full_key (applet, key);
-
- writable = mateconf_client_key_is_writable (client, fullkey, NULL);
-
- g_free (fullkey);
-
- return writable;
+ g_settings_set_int (battstat->settings,
+ "red-value",
+ battstat->red_val);
}
static void
@@ -150,8 +130,8 @@ radio_traditional_toggled (GtkToggleButton *button, gpointer data)
battstat->showbattery = toggled;
reconfigure_layout( battstat );
- mate_panel_applet_mateconf_set_bool (applet, "show_battery",
- battstat->showbattery, NULL);
+ g_settings_set_boolean (battstat->settings, "show-battery",
+ battstat->showbattery);
}
@@ -172,8 +152,8 @@ radio_ubuntu_toggled (GtkToggleButton *button, gpointer data)
battstat->showstatus = toggled;
reconfigure_layout( battstat );
- mate_panel_applet_mateconf_set_bool (applet, "show_status",
- battstat->showstatus, NULL);
+ g_settings_set_boolean (battstat->settings, "show-status",
+ battstat->showstatus);
}
@@ -203,8 +183,7 @@ show_text_toggled (GtkToggleButton *button, gpointer data)
gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
battstat->showtext);
- mate_panel_applet_mateconf_set_int (applet, "show_text",
- battstat->showtext, NULL);
+ g_settings_set_int (battstat->settings, "show-text", battstat->showtext);
}
static void
@@ -214,8 +193,8 @@ lowbatt_toggled (GtkToggleButton *button, gpointer data)
MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
battstat->lowbattnotification = gtk_toggle_button_get_active (button);
- mate_panel_applet_mateconf_set_bool (applet,"low_battery_notification",
- battstat->lowbattnotification, NULL);
+ g_settings_set_boolean (battstat->settings, "low-battery-notification",
+ battstat->lowbattnotification);
hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);
}
@@ -227,8 +206,8 @@ full_toggled (GtkToggleButton *button, gpointer data)
MatePanelApplet *applet = MATE_PANEL_APPLET (battstat->applet);
battstat->fullbattnot = gtk_toggle_button_get_active (button);
- mate_panel_applet_mateconf_set_bool (applet,"full_battery_notification",
- battstat->fullbattnot, NULL);
+ g_settings_set_boolean (battstat->settings, "full-battery-notification",
+ battstat->fullbattnot);
}
static void
@@ -248,15 +227,9 @@ prop_cb (GtkAction *action,
{
GtkBuilder *builder;
GtkWidget *combo_ptr, *spin_ptr;
- MateConfClient *client;
GtkListStore *liststore;
GtkCellRenderer *renderer;
GtkTreeIter iter;
- /* Shouldn't this be used for something later on? */
- gboolean inhibit_command_line;
-
- client = mateconf_client_get_default ();
- inhibit_command_line = mateconf_client_get_bool (client, "/desktop/mate/lockdown/inhibit_command_line", NULL);
if (DEBUG) g_print("prop_cb()\n");
@@ -282,8 +255,8 @@ prop_cb (GtkAction *action,
g_signal_connect (G_OBJECT (battstat->lowbatt_toggle), "toggled",
G_CALLBACK (lowbatt_toggled), battstat);
- if (!key_writable (MATE_PANEL_APPLET (battstat->applet),
- "low_battery_notification"))
+ if (!g_settings_is_writable (battstat->settings,
+ "low-battery-notification"))
{
hard_set_sensitive (battstat->lowbatt_toggle, FALSE);
}
@@ -334,8 +307,8 @@ prop_cb (GtkAction *action,
g_signal_connect (G_OBJECT (battstat->full_toggle), "toggled",
G_CALLBACK (full_toggled), battstat);
- if (!key_writable (MATE_PANEL_APPLET (battstat->applet),
- "full_battery_notification"))
+ if (!g_settings_is_writable (battstat->settings,
+ "full-battery-notification"))
{
hard_set_sensitive (battstat->full_toggle, FALSE);
}
@@ -355,7 +328,7 @@ prop_cb (GtkAction *action,
g_signal_connect (G_OBJECT (battstat->radio_traditional_battery), "toggled",
G_CALLBACK (radio_traditional_toggled), battstat);
- if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_battery"))
+ if (!g_settings_is_writable (battstat->settings, "show-battery"))
hard_set_sensitive (battstat->radio_traditional_battery, FALSE);
if (battstat->showbattery)
@@ -370,7 +343,7 @@ prop_cb (GtkAction *action,
g_signal_connect (G_OBJECT (battstat->radio_ubuntu_battery), "toggled",
G_CALLBACK (radio_ubuntu_toggled), battstat);
- if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_status"))
+ if (!g_settings_is_writable (battstat->settings, "show-status"))
hard_set_sensitive (battstat->radio_ubuntu_battery, FALSE);
if (battstat->showstatus)
@@ -394,7 +367,7 @@ prop_cb (GtkAction *action,
g_signal_connect (G_OBJECT (battstat->check_text), "toggled",
G_CALLBACK (show_text_toggled), battstat);
- if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_text"))
+ if (!g_settings_is_writable (battstat->settings, "show-text"))
{
hard_set_sensitive (battstat->check_text, FALSE);
hard_set_sensitive (battstat->radio_text_1, FALSE);