summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/org.mate.power-manager.gschema.xml73
-rw-r--r--src/gpm-backlight.c11
-rw-r--r--src/gpm-common.c84
-rw-r--r--src/gpm-common.h4
-rw-r--r--src/gpm-dpms.c47
-rw-r--r--src/gpm-dpms.h2
-rw-r--r--src/gpm-engine.c10
-rw-r--r--src/gpm-manager.c31
-rw-r--r--src/gpm-prefs-core.c21
9 files changed, 64 insertions, 219 deletions
diff --git a/data/org.mate.power-manager.gschema.xml b/data/org.mate.power-manager.gschema.xml
index 0d930e5..daa78f3 100644
--- a/data/org.mate.power-manager.gschema.xml
+++ b/data/org.mate.power-manager.gschema.xml
@@ -1,34 +1,55 @@
<schemalist>
+ <enum id="org.mate.power-manager.ActionType">
+ <value nick="blank" value="0"/>
+ <value nick="suspend" value="1"/>
+ <value nick="shutdown" value="2"/>
+ <value nick="hibernate" value="3"/>
+ <value nick="interactive" value="4"/>
+ <value nick="nothing" value="5"/>
+ </enum>
+ <enum id="org.mate.power-manager.IconPolicy">
+ <value nick="always" value="0"/>
+ <value nick="present" value="1"/>
+ <value nick="charge" value="2"/>
+ <value nick="low" value="3"/>
+ <value nick="critical" value="4"/>
+ <value nick="never" value="5"/>
+ </enum>
+ <enum id="org.mate.power-manager.DpmsMethod">
+ <value nick="standby" value="1"/>
+ <value nick="suspend" value="2"/>
+ <value nick="off" value="3"/>
+ </enum>
<schema id="org.mate.power-manager" path="/org/mate/power-manager/">
- <key name="action-sleep-type-battery" type="s">
+ <key name="action-sleep-type-battery" enum="org.mate.power-manager.ActionType">
<default>'hibernate'</default>
<summary>Whether to hibernate, suspend or do nothing when inactive</summary>
- <description>The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing".</description>
+ <description>The type of sleeping that should be performed when the computer is inactive.</description>
</key>
- <key name="action-critical-battery" type="s">
+ <key name="action-critical-battery" enum="org.mate.power-manager.ActionType">
<default>'hibernate'</default>
<summary>Battery critical low action</summary>
- <description>The action to take when the battery is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing".</description>
+ <description>The action to take when the battery is critically low.</description>
</key>
<key name="event-when-closed-battery" type="b">
<default>true</default>
<summary>If the battery event should occur when the lid is shut and the power disconnected</summary>
<description>If the battery lid close event should occur (for example 'Suspend when lid closed on battery') when the lid is previously shut and the AC power disconnected at a later time.</description>
</key>
- <key name="action-sleep-type-ac" type="s">
+ <key name="action-sleep-type-ac" enum="org.mate.power-manager.ActionType">
<default>'suspend'</default>
<summary>Whether to hibernate, suspend or do nothing when inactive</summary>
- <description>The type of sleeping that should be performed when the computer is inactive. Possible values are "hibernate", "suspend" and "nothing".</description>
+ <description>The type of sleeping that should be performed when the computer is inactive.</description>
</key>
- <key name="action-critical-ups" type="s">
+ <key name="action-critical-ups" enum="org.mate.power-manager.ActionType">
<default>'shutdown'</default>
<summary>UPS critical low action</summary>
- <description>The action to take when the UPS is critically low. Possible values are "hibernate", "suspend", "shutdown" and "nothing".</description>
+ <description>The action to take when the UPS is critically low.</description>
</key>
- <key name="action-low-ups" type="s">
+ <key name="action-low-ups" enum="org.mate.power-manager.ActionType">
<default>'hibernate'</default>
<summary>UPS low power action</summary>
- <description>The action to take when the UPS is low. Possible values are "hibernate", "suspend", "shutdown" and "nothing".</description>
+ <description>The action to take when the UPS is low.</description>
</key>
<key name="backlight-enable" type="b">
<default>true</default>
@@ -65,45 +86,45 @@
<summary>Dim the screen after a period of inactivity when on AC power</summary>
<description>If the screen should be dimmed to save power when the computer is idle when on AC power.</description>
</key>
- <key name="dpms-method-ac" type="s">
+ <key name="dpms-method-ac" enum="org.mate.power-manager.DpmsMethod">
<default>'off'</default>
<summary>Method used to blank screen on AC</summary>
- <description>The DPMS method used to blank the screen when on AC power. Possible values are "standby", "suspend" and "off".</description>
+ <description>The DPMS method used to blank the screen when on AC power.</description>
</key>
- <key name="dpms-method-battery" type="s">
+ <key name="dpms-method-battery" enum="org.mate.power-manager.DpmsMethod">
<default>'off'</default>
<summary>Method used to blank screen on battery</summary>
- <description>The DPMS method used to blank the screen when on battery power. Possible values are "standby", "suspend" and "off".</description>
+ <description>The DPMS method used to blank the screen when on battery power.</description>
</key>
<key name="brightness-ac" type="d">
<default>100.0</default>
<summary>LCD brightness when on AC</summary>
<description>The brightness of the display when on AC power. Possible values are between 0.0 and 100.0.</description>
</key>
- <key name="button-suspend" type="s">
+ <key name="button-suspend" enum="org.mate.power-manager.ActionType">
<default>'suspend'</default>
<summary>Suspend button action</summary>
- <description>The action to take when the system suspend button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing".</description>
+ <description>The action to take when the system suspend button is pressed.</description>
</key>
- <key name="button-hibernate" type="s">
+ <key name="button-hibernate" enum="org.mate.power-manager.ActionType">
<default>'hibernate'</default>
<summary>Hibernate button action</summary>
- <description>The action to take when the system hibernate button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing".</description>
+ <description>The action to take when the system hibernate button is pressed.</description>
</key>
- <key name="button-power" type="s">
+ <key name="button-power" enum="org.mate.power-manager.ActionType">
<default>'interactive'</default>
<summary>Power button action</summary>
- <description>The action to take when the system power button is pressed. Possible values are "suspend", "hibernate", "interactive", "shutdown" and "nothing".</description>
+ <description>The action to take when the system power button is pressed.</description>
</key>
- <key name="button-lid-battery" type="s">
+ <key name="button-lid-battery" enum="org.mate.power-manager.ActionType">
<default>'suspend'</default>
<summary>Laptop lid close action on battery</summary>
- <description>The action to take when the laptop lid is closed and the laptop is on battery power. Possible values are "suspend", "hibernate", "blank", and "nothing".</description>
+ <description>The action to take when the laptop lid is closed and the laptop is on battery power.</description>
</key>
- <key name="button-lid-ac" type="s">
+ <key name="button-lid-ac" enum="org.mate.power-manager.ActionType">
<default>'suspend'</default>
<summary>Laptop lid close action when on AC</summary>
- <description>The action to take when the laptop lid is closed and the laptop is on AC power. Possible values are "suspend", "hibernate", "blank" and "nothing".</description>
+ <description>The action to take when the laptop lid is closed and the laptop is on AC power.</description>
</key>
<key name="schema-version" type="i">
<default>3</default>
@@ -329,10 +350,10 @@
<default>true</default>
<summary>If preferences and statistics items should be shown in the context menu</summary>
</key>
- <key name="icon-policy" type="s">
+ <key name="icon-policy" enum="org.mate.power-manager.IconPolicy">
<default>'present'</default>
<summary>When to show the notification icon</summary>
- <description>Display options for the notification icon. Valid options are "never", "low", "critical", "charge", and "present".</description>
+ <description>Display options for the notification icon.</description>
</key>
</schema>
</schemalist>
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 9f6b148..573778a 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -545,7 +545,6 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
gboolean ret;
GError *error = NULL;
gboolean on_battery;
- gchar *dpms_method;
GpmDpmsMode dpms_mode;
/* don't dim or undim the screen when the lid is closed */
@@ -594,16 +593,13 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
"on-battery", &on_battery,
NULL);
if (!on_battery)
- dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC);
+ dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_AC);
else
- dpms_method = g_settings_get_string (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT);
-
- /* convert the string types to standard types */
- dpms_mode = gpm_dpms_mode_from_string (dpms_method);
+ dpms_mode = g_settings_get_enum (backlight->priv->settings, GPM_SETTINGS_DPMS_METHOD_BATT);
/* check if method is valid */
if (dpms_mode == GPM_DPMS_MODE_UNKNOWN || dpms_mode == GPM_DPMS_MODE_ON) {
- egg_warning ("BACKLIGHT method %s unknown. Using OFF.", dpms_method);
+ egg_warning ("BACKLIGHT method %i unknown. Using OFF.", dpms_mode);
dpms_mode = GPM_DPMS_MODE_OFF;
}
@@ -614,7 +610,6 @@ idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, GpmBacklight *backlight)
g_error_free (error);
}
- g_free (dpms_method);
}
}
diff --git a/src/gpm-common.c b/src/gpm-common.c
index 0d0e536..861837a 100644
--- a/src/gpm-common.c
+++ b/src/gpm-common.c
@@ -79,90 +79,6 @@ gpm_get_timestring (guint time_secs)
}
/**
- * gpm_icon_policy_from_string:
- **/
-GpmIconPolicy
-gpm_icon_policy_from_string (const gchar *policy)
-{
- if (policy == NULL)
- return GPM_ICON_POLICY_NEVER;
- if (g_strcmp0 (policy, "always") == 0)
- return GPM_ICON_POLICY_ALWAYS;
- if (g_strcmp0 (policy, "present") == 0)
- return GPM_ICON_POLICY_PRESENT;
- if (g_strcmp0 (policy, "charge") == 0)
- return GPM_ICON_POLICY_CHARGE;
- if (g_strcmp0 (policy, "low") == 0)
- return GPM_ICON_POLICY_LOW;
- if (g_strcmp0 (policy, "critical") == 0)
- return GPM_ICON_POLICY_CRITICAL;
- if (g_strcmp0 (policy, "never") == 0)
- return GPM_ICON_POLICY_NEVER;
- return GPM_ICON_POLICY_NEVER;
-}
-
-/**
- * gpm_icon_policy_to_string:
- **/
-const gchar *
-gpm_icon_policy_to_string (GpmIconPolicy policy)
-{
- if (policy == GPM_ICON_POLICY_ALWAYS)
- return "always";
- if (policy == GPM_ICON_POLICY_PRESENT)
- return "present";
- if (policy == GPM_ICON_POLICY_CHARGE)
- return "charge";
- if (policy == GPM_ICON_POLICY_LOW)
- return "low";
- if (policy == GPM_ICON_POLICY_CRITICAL)
- return "critical";
- if (policy == GPM_ICON_POLICY_NEVER)
- return "never";
- return "never";
-}
-
-/**
- * gpm_action_policy_from_string:
- **/
-GpmActionPolicy
-gpm_action_policy_from_string (const gchar *policy)
-{
- if (policy == NULL)
- return GPM_ACTION_POLICY_NOTHING;
- if (g_strcmp0 (policy, "blank") == 0)
- return GPM_ACTION_POLICY_BLANK;
- if (g_strcmp0 (policy, "shutdown") == 0)
- return GPM_ACTION_POLICY_SHUTDOWN;
- if (g_strcmp0 (policy, "suspend") == 0)
- return GPM_ACTION_POLICY_SUSPEND;
- if (g_strcmp0 (policy, "hibernate") == 0)
- return GPM_ACTION_POLICY_HIBERNATE;
- if (g_strcmp0 (policy, "interactive") == 0)
- return GPM_ACTION_POLICY_INTERACTIVE;
- return GPM_ACTION_POLICY_NOTHING;
-}
-
-/**
- * gpm_action_policy_to_string:
- **/
-const gchar *
-gpm_action_policy_to_string (GpmActionPolicy policy)
-{
- if (policy == GPM_ACTION_POLICY_BLANK)
- return "blank";
- if (policy == GPM_ACTION_POLICY_SHUTDOWN)
- return "shutdown";
- if (policy == GPM_ACTION_POLICY_SUSPEND)
- return "suspend";
- if (policy == GPM_ACTION_POLICY_HIBERNATE)
- return "hibernate";
- if (policy == GPM_ACTION_POLICY_INTERACTIVE)
- return "interactive";
- return "nothing";
-}
-
-/**
* gpm_help_display:
* @link_id: Subsection of mate-power-manager help section
**/
diff --git a/src/gpm-common.h b/src/gpm-common.h
index 96a06a4..ee05036 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -157,10 +157,6 @@ typedef enum {
} GpmActionPolicy;
gchar *gpm_get_timestring (guint time);
-GpmIconPolicy gpm_icon_policy_from_string (const gchar *policy);
-const gchar *gpm_icon_policy_to_string (GpmIconPolicy policy);
-GpmActionPolicy gpm_action_policy_from_string (const gchar *policy);
-const gchar *gpm_action_policy_to_string (GpmActionPolicy policy);
void gpm_help_display (const gchar *link_id);
#ifdef EGG_TEST
void gpm_common_test (gpointer data);
diff --git a/src/gpm-dpms.c b/src/gpm-dpms.c
index 13928f9..8eaf704 100644
--- a/src/gpm-dpms.c
+++ b/src/gpm-dpms.c
@@ -190,53 +190,6 @@ gpm_dpms_x11_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error)
}
/**
- * gpm_dpms_mode_from_string:
- **/
-GpmDpmsMode
-gpm_dpms_mode_from_string (const gchar *str)
-{
- if (str == NULL)
- return GPM_DPMS_MODE_UNKNOWN;
- if (strcmp (str, "on") == 0)
- return GPM_DPMS_MODE_ON;
- if (strcmp (str, "standby") == 0)
- return GPM_DPMS_MODE_STANDBY;
- if (strcmp (str, "suspend") == 0)
- return GPM_DPMS_MODE_SUSPEND;
- if (strcmp (str, "off") == 0)
- return GPM_DPMS_MODE_OFF;
- return GPM_DPMS_MODE_UNKNOWN;
-}
-
-/**
- * gpm_dpms_mode_to_string:
- **/
-const gchar *
-gpm_dpms_mode_to_string (GpmDpmsMode mode)
-{
- const gchar *str = NULL;
-
- switch (mode) {
- case GPM_DPMS_MODE_ON:
- str = "on";
- break;
- case GPM_DPMS_MODE_STANDBY:
- str = "standby";
- break;
- case GPM_DPMS_MODE_SUSPEND:
- str = "suspend";
- break;
- case GPM_DPMS_MODE_OFF:
- str = "off";
- break;
- default:
- str = NULL;
- break;
- }
- return str;
-}
-
-/**
* gpm_dpms_set_mode:
**/
gboolean
diff --git a/src/gpm-dpms.h b/src/gpm-dpms.h
index 95cd226..b6218fc 100644
--- a/src/gpm-dpms.h
+++ b/src/gpm-dpms.h
@@ -71,8 +71,6 @@ gboolean gpm_dpms_get_mode (GpmDpms *dpms,
gboolean gpm_dpms_set_mode (GpmDpms *dpms,
GpmDpmsMode mode,
GError **error);
-const gchar *gpm_dpms_mode_to_string (GpmDpmsMode mode);
-GpmDpmsMode gpm_dpms_mode_from_string (const gchar *mode);
void gpm_dpms_test (gpointer data);
G_END_DECLS
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index b006c32..0f9d0c1 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -513,7 +513,6 @@ gpm_engine_recalculate_state (GpmEngine *engine)
static void
gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEngine *engine)
{
- gchar *icon_policy;
if (g_strcmp0 (key, GPM_SETTINGS_USE_TIME_POLICY) == 0) {
engine->priv->use_time_primary = g_settings_get_boolean (settings, key);
@@ -521,9 +520,7 @@ gpm_engine_settings_key_changed_cb (GSettings *settings, const gchar *key, GpmEn
} else if (g_strcmp0 (key, GPM_SETTINGS_ICON_POLICY) == 0) {
/* do we want to display the icon in the tray */
- icon_policy = g_settings_get_string (settings, key);
- engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy);
- g_free (icon_policy);
+ engine->priv->icon_policy = g_settings_get_enum (settings, key);
/* perhaps change icon */
gpm_engine_recalculate_state_icon (engine);
@@ -1045,7 +1042,6 @@ phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
static void
gpm_engine_init (GpmEngine *engine)
{
- gchar *icon_policy;
engine->priv = GPM_ENGINE_GET_PRIVATE (engine);
@@ -1084,9 +1080,7 @@ gpm_engine_init (GpmEngine *engine)
engine->priv->previous_summary = NULL;
/* do we want to display the icon in the tray */
- icon_policy = g_settings_get_string (engine->priv->settings, GPM_SETTINGS_ICON_POLICY);
- engine->priv->icon_policy = gpm_icon_policy_from_string (icon_policy);
- g_free (icon_policy);
+ engine->priv->icon_policy = g_settings_get_enum (engine->priv->settings, GPM_SETTINGS_ICON_POLICY);
/* get percentage policy */
engine->priv->low_percentage = g_settings_get_int (engine->priv->settings, GPM_SETTINGS_PERCENTAGE_LOW);
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 6014f84..b351b6f 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -667,16 +667,14 @@ gpm_manager_action_hibernate (GpmManager *manager, const gchar *reason)
static gboolean
gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const gchar *reason)
{
- gchar *action = NULL;
GpmActionPolicy policy;
/* are we inhibited? */
if (gpm_manager_is_inhibit_valid (manager, FALSE, "policy action") == FALSE)
return FALSE;
- action = g_settings_get_string (manager->priv->settings, policy_key);
- egg_debug ("action: %s set to %s (%s)", policy_key, action, reason);
- policy = gpm_action_policy_from_string (action);
+ policy = g_settings_get_enum (manager->priv->settings, policy_key);
+ egg_debug ("action: %s set to %i (%s)", policy_key, policy, reason);
if (policy == GPM_ACTION_POLICY_NOTHING) {
egg_debug ("doing nothing, reason: %s", reason);
@@ -700,10 +698,9 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const
gpm_session_logout (session);
g_object_unref (session);
} else {
- egg_warning ("unknown action %s", action);
+ egg_warning ("unknown action %i", policy);
}
- g_free (action);
return TRUE;
}
@@ -717,16 +714,14 @@ gpm_manager_perform_policy (GpmManager *manager, const gchar *policy_key, const
static void
gpm_manager_idle_do_sleep (GpmManager *manager)
{
- gchar *action = NULL;
gboolean ret;
GError *error = NULL;
GpmActionPolicy policy;
if (!manager->priv->on_battery)
- action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC);
+ policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_AC);
else
- action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT);
- policy = gpm_action_policy_from_string (action);
+ policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_SLEEP_TYPE_BATT);
if (policy == GPM_ACTION_POLICY_NOTHING) {
egg_debug ("doing nothing as system idle action");
@@ -759,7 +754,6 @@ gpm_manager_idle_do_sleep (GpmManager *manager)
}
}
}
- g_free (action);
}
/**
@@ -1553,7 +1547,6 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM
{
const gchar *title = NULL;
gchar *message = NULL;
- gchar *action;
gchar *icon = NULL;
UpDeviceKind kind;
gdouble percentage;
@@ -1589,8 +1582,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM
}
/* we have to do different warnings depending on the policy */
- action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
- policy = gpm_action_policy_from_string (action);
+ policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
/* use different text for different actions */
if (policy == GPM_ACTION_POLICY_NOTHING) {
@@ -1610,7 +1602,6 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmM
message = g_strdup_printf (_("Computer will shutdown very soon unless it is plugged in."));
}
- g_free (action);
} else if (kind == UP_DEVICE_KIND_UPS) {
gchar *remaining_text;
@@ -1720,7 +1711,6 @@ static void
gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
- gchar *action;
gchar *message = NULL;
gchar *icon = NULL;
UpDeviceKind kind;
@@ -1745,8 +1735,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
title = _("Laptop battery critically low");
/* we have to do different warnings depending on the policy */
- action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
- policy = gpm_action_policy_from_string (action);
+ policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_BATT);
/* use different text for different actions */
if (policy == GPM_ACTION_POLICY_NOTHING) {
@@ -1773,8 +1762,6 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
"this computer is about to shutdown."));
}
- g_free (action);
-
/* wait 20 seconds for user-panic */
g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
@@ -1783,8 +1770,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
title = _("UPS critically low");
/* we have to do different warnings depending on the policy */
- action = g_settings_get_string (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS);
- policy = gpm_action_policy_from_string (action);
+ policy = g_settings_get_enum (manager->priv->settings, GPM_SETTINGS_ACTION_CRITICAL_UPS);
/* use different text for different actions */
if (policy == GPM_ACTION_POLICY_NOTHING) {
@@ -1807,7 +1793,6 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmMan
/* wait 20 seconds for user-panic */
g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
- g_free (action);
}
/* not all types have actions */
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 3f23c87..790427b 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -135,13 +135,10 @@ gpm_prefs_help_cb (GtkWidget *widget, GpmPrefs *prefs)
static void
gpm_prefs_icon_radio_cb (GtkWidget *widget, GpmPrefs *prefs)
{
- const gchar *str;
gint policy;
policy = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "policy"));
- str = gpm_icon_policy_to_string (policy);
- egg_debug ("Changing %s to %s", GPM_SETTINGS_ICON_POLICY, str);
- g_settings_set_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, str);
+ g_settings_set_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY, policy);
}
/**
@@ -164,7 +161,6 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
GpmActionPolicy policy;
const GpmActionPolicy *actions;
const gchar *gpm_pref_key;
- const gchar *action;
guint active;
actions = (const GpmActionPolicy *) g_object_get_data (G_OBJECT (widget), "actions");
@@ -172,9 +168,7 @@ gpm_prefs_action_combo_changed_cb (GtkWidget *widget, GpmPrefs *prefs)
active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
policy = actions[active];
- action = gpm_action_policy_to_string (policy);
- egg_debug ("Changing %s to %s", gpm_pref_key, action);
- g_settings_set_string (prefs->priv->settings, gpm_pref_key, action);
+ g_settings_set_enum (prefs->priv->settings, gpm_pref_key, policy);
}
/**
@@ -242,7 +236,6 @@ static void
gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
const gchar *gpm_pref_key, const GpmActionPolicy *actions)
{
- gchar *value_txt;
gint i;
gboolean is_writable;
GtkWidget *widget;
@@ -254,9 +247,8 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
widget = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder, widget_name));
gpm_prefs_set_combo_simple_text (widget);
- value_txt = g_settings_get_string (prefs->priv->settings, gpm_pref_key);
+ value = g_settings_get_enum (prefs->priv->settings, gpm_pref_key);
is_writable = g_settings_is_writable (prefs->priv->settings, gpm_pref_key);
- value = gpm_action_policy_from_string (value_txt);
gtk_widget_set_sensitive (widget, is_writable);
@@ -340,13 +332,11 @@ gpm_prefs_setup_action_combo (GpmPrefs *prefs, const gchar *widget_name,
/* set what we have in the settings */
for (i=0; actions_added[i] != -1; i++) {
policy = actions_added[i];
- egg_debug ("added: %s", gpm_action_policy_to_string (policy));
if (value == policy)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
}
g_ptr_array_unref (array);
- g_free (value_txt);
}
/**
@@ -435,7 +425,6 @@ gpm_prefs_delete_event_cb (GtkWidget *widget, GdkEvent *event, GpmPrefs *prefs)
static void
prefs_setup_notification (GpmPrefs *prefs)
{
- gchar *icon_policy_str;
gint icon_policy;
GtkWidget *radiobutton_icon_always;
GtkWidget *radiobutton_icon_present;
@@ -444,9 +433,7 @@ prefs_setup_notification (GpmPrefs *prefs)
GtkWidget *radiobutton_icon_never;
gboolean is_writable;
- icon_policy_str = g_settings_get_string (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY);
- icon_policy = gpm_icon_policy_from_string (icon_policy_str);
- g_free (icon_policy_str);
+ icon_policy = g_settings_get_enum (prefs->priv->settings, GPM_SETTINGS_ICON_POLICY);
radiobutton_icon_always = GTK_WIDGET (gtk_builder_get_object (prefs->priv->builder,
"radiobutton_notification_always"));