[Xfce4-commits] [xfce/xfce4-power-manager] 10/14: Sleep mode: Do not use translated strings in xfconf

noreply at xfce.org noreply at xfce.org
Sun Jul 27 13:04:12 CEST 2014


This is an automated email from the git hooks/post-receive script.

hjudt pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 0e33dac3fec24723f4c98e2c73a651e2898a469e
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Jul 25 17:34:36 2014 +0200

    Sleep mode: Do not use translated strings in xfconf
---
 settings/xfpm-settings.c |   76 +++++++++++++++++++++++-----------------------
 src/xfpm-manager.c       |   14 ++-------
 src/xfpm-xfconf.c        |   20 +++++++-----
 3 files changed, 53 insertions(+), 57 deletions(-)

diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index 6f97bab..1eaa06f 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -331,7 +331,7 @@ on_ac_sleep_mode_changed_cb (GtkWidget *w, XfconfChannel *channel)
 {
     GtkTreeModel     *model;
     GtkTreeIter       selected_row;
-    gchar *value = "";
+    guint value = 0;
 
     if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
     return;
@@ -340,13 +340,13 @@ on_ac_sleep_mode_changed_cb (GtkWidget *w, XfconfChannel *channel)
 
     gtk_tree_model_get(model,
                        &selected_row,
-                       0,
+                       1,
                        &value,
                        -1);
 
-    if (!xfconf_channel_set_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_AC, value) )
+    if (!xfconf_channel_set_uint (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_AC, value) )
     {
-    g_critical ("Cannot set value for property %s\n", INACTIVITY_SLEEP_MODE_ON_AC);
+	g_critical ("Cannot set value for property %s\n", INACTIVITY_SLEEP_MODE_ON_AC);
     }
 }
 
@@ -355,7 +355,7 @@ on_battery_sleep_mode_changed_cb (GtkWidget *w, XfconfChannel *channel)
 {
     GtkTreeModel     *model;
     GtkTreeIter       selected_row;
-    gchar *value = "";
+    guint value = 0;
 
     if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &selected_row))
     return;
@@ -364,13 +364,13 @@ on_battery_sleep_mode_changed_cb (GtkWidget *w, XfconfChannel *channel)
 
     gtk_tree_model_get(model,
                        &selected_row,
-                       0,
+                       1,
                        &value,
                        -1);
 
-    if (!xfconf_channel_set_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_BATTERY, value) )
+    if (!xfconf_channel_set_uint (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_BATTERY, value) )
     {
-    g_critical ("Cannot set value for property %s\n", INACTIVITY_SLEEP_MODE_ON_BATTERY);
+	g_critical ("Cannot set value for property %s\n", INACTIVITY_SLEEP_MODE_ON_BATTERY);
     }
 }
 
@@ -732,8 +732,6 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_suspend,
     gboolean valid;
     gint list_value;
     gint val;
-    gchar *str;
-    gchar *list_str;
     GtkListStore *list_store;
     GtkTreeIter iter;
     GtkWidget *inact_timeout, *inact_action;
@@ -753,7 +751,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_suspend,
     if ( can_suspend )
     {
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), -1);
+    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
     }
     else if ( !auth_suspend )
     {
@@ -767,7 +765,7 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_suspend,
     if ( can_hibernate )
     {
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), -1);
+    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
     }
     else if ( !auth_hibernate )
     {
@@ -780,20 +778,22 @@ xfpm_settings_on_battery (XfconfChannel *channel, gboolean auth_suspend,
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (inact_action), 0);
 
-    str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_BATTERY, "Hibernate");
+    val = xfconf_channel_get_uint (channel,
+                                   PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_BATTERY,
+                                   XFPM_DO_HIBERNATE);
+
     for ( valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter);
-      valid;
-      valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter) )
-    {
-    gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
-                0, &list_str, -1);
-    if ( g_strcmp0 (str, list_str) )
+	  valid;
+	  valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter) )
     {
-        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (inact_action), &iter);
-        break;
-    }
+	gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
+			    1, &list_value, -1);
+	if ( val == list_value )
+	{
+	    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (inact_action), &iter);
+	    break;
+	}
     }
-    g_free (str);
 
     /*
      * Inactivity timeout on battery
@@ -962,8 +962,6 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend,
     GtkWidget *frame;
     GtkWidget *brg;
     GtkWidget *brg_level;
-    gchar *str;
-    gchar *list_str;
     GtkListStore *list_store;
     GtkTreeIter iter;
     guint val;
@@ -980,7 +978,7 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend,
     if ( can_suspend )
     {
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), -1);
+    gtk_list_store_set (list_store, &iter, 0, _("Suspend"), 1, XFPM_DO_SUSPEND, -1);
     }
     else if ( !auth_suspend )
     {
@@ -994,7 +992,7 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend,
     if ( can_hibernate )
     {
     gtk_list_store_append (list_store, &iter);
-    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), -1);
+    gtk_list_store_set (list_store, &iter, 0, _("Hibernate"), 1, XFPM_DO_HIBERNATE, -1);
     }
     else if ( !auth_hibernate )
     {
@@ -1007,20 +1005,22 @@ xfpm_settings_on_ac (XfconfChannel *channel, gboolean auth_suspend,
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (inact_action), 0);
 
-    str = xfconf_channel_get_string (channel, PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_AC, "Suspend");
+    val = xfconf_channel_get_uint (channel,
+                                   PROPERTIES_PREFIX INACTIVITY_SLEEP_MODE_ON_AC,
+                                   XFPM_DO_SUSPEND);
+
     for ( valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter);
-      valid;
-      valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter) )
-    {
-    gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
-                0, &list_str, -1);
-    if ( g_strcmp0 (str, list_str) )
+	  valid;
+	  valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter) )
     {
-        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (inact_action), &iter);
-        break;
-    }
+	gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
+			    1, &list_value, -1);
+	if ( val == list_value )
+	{
+	    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (inact_action), &iter);
+	    break;
+	}
     }
-    g_free (str);
 
     /*
      * Inactivity timeout on AC
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index a1d47af..fed0553 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -410,8 +410,7 @@ xfpm_manager_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmManager *manager
 
     if ( id == TIMEOUT_INACTIVITY_ON_AC || id == TIMEOUT_INACTIVITY_ON_BATTERY )
     {
-	XfpmShutdownRequest req = XFPM_DO_NOTHING;
-	gchar *sleep_mode;
+	XfpmShutdownRequest sleep_mode = XFPM_DO_NOTHING;
 	gboolean on_battery;
 
 	if ( manager->priv->inhibited )
@@ -433,17 +432,10 @@ xfpm_manager_alarm_timeout_cb (EggIdletime *idle, guint id, XfpmManager *manager
 		      "on-battery", &on_battery,
 		      NULL);
 
-	if ( !g_strcmp0 (sleep_mode, "Suspend") )
-	    req = XFPM_DO_SUSPEND;
-	else
-	    req = XFPM_DO_HIBERNATE;
-
-	g_free (sleep_mode);
-
 	if ( id == TIMEOUT_INACTIVITY_ON_AC && on_battery == FALSE )
-	    xfpm_manager_sleep_request (manager, req, FALSE);
+	    xfpm_manager_sleep_request (manager, sleep_mode, FALSE);
 	else if ( id ==  TIMEOUT_INACTIVITY_ON_BATTERY && on_battery  )
-	    xfpm_manager_sleep_request (manager, req, FALSE);
+	    xfpm_manager_sleep_request (manager, sleep_mode, FALSE);
     }
 }
 
diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c
index 4321ce8..acafc35 100644
--- a/src/xfpm-xfconf.c
+++ b/src/xfpm-xfconf.c
@@ -498,20 +498,24 @@ xfpm_xfconf_class_init (XfpmXfconfClass *klass)
      **/
     g_object_class_install_property (object_class,
                                      PROP_IDLE_SLEEP_MODE_ON_BATTERY,
-                                     g_param_spec_string (INACTIVITY_SLEEP_MODE_ON_BATTERY,
-                                                          NULL, NULL,
-                                                          "Hibernate",
-                                                          G_PARAM_READWRITE));
+                                     g_param_spec_uint (INACTIVITY_SLEEP_MODE_ON_BATTERY,
+                                                        NULL, NULL,
+                                                        XFPM_DO_SUSPEND,
+                                                        XFPM_DO_HIBERNATE,
+                                                        XFPM_DO_HIBERNATE,
+                                                        G_PARAM_READWRITE));
 
     /**
      * XfpmXfconf::inactivity-sleep-mode-on-ac
      **/
     g_object_class_install_property (object_class,
                                      PROP_IDLE_SLEEP_MODE_ON_AC,
-                                     g_param_spec_string (INACTIVITY_SLEEP_MODE_ON_AC,
-                                                          NULL, NULL,
-                                                          "Suspend",
-                                                          G_PARAM_READWRITE));
+                                     g_param_spec_uint (INACTIVITY_SLEEP_MODE_ON_AC,
+                                                        NULL, NULL,
+                                                        XFPM_DO_SUSPEND,
+                                                        XFPM_DO_HIBERNATE,
+                                                        XFPM_DO_SUSPEND,
+                                                        G_PARAM_READWRITE));
 
     /**
      * XfpmXfconf::brightness-on-ac

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list