diff options
author | Brent Hull <[email protected]> | 2012-10-30 15:55:35 -0400 |
---|---|---|
committer | Brent Hull <[email protected]> | 2012-10-30 15:55:35 -0400 |
commit | 060a4507145425c02c6aa0ef810138c04d38f5a9 (patch) | |
tree | 696262b89d749abf74ccec08260969679ef70d6e /src/gpm-manager.c | |
parent | e58350ab1a00d55e82f7ae97589562e10a77c485 (diff) | |
download | mate-power-manager-060a4507145425c02c6aa0ef810138c04d38f5a9.tar.bz2 mate-power-manager-060a4507145425c02c6aa0ef810138c04d38f5a9.tar.xz |
Use gsettings enums (partially from GNOME)
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r-- | src/gpm-manager.c | 31 |
1 files changed, 8 insertions, 23 deletions
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 */ |