* Fixes NB#85740, save separator position as float in order to enhace placement...
authorSergio Villar Senin <svillar@igalia.com>
Fri, 23 May 2008 09:24:18 +0000 (09:24 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Fri, 23 May 2008 09:24:18 +0000 (09:24 +0000)
pmo-trunk-r4561

src/modest-conf.c
src/modest-conf.h
src/modest-widget-memory.c

index e8fc818..4696520 100644 (file)
@@ -207,6 +207,18 @@ modest_conf_get_int (ModestConf* self, const gchar* key, GError **err)
        return gconf_client_get_int (priv->gconf_client, key, err);
 }
 
        return gconf_client_get_int (priv->gconf_client, key, err);
 }
 
+gdouble
+modest_conf_get_float (ModestConf* self, const gchar* key, GError **err)
+{
+       ModestConfPrivate *priv;
+
+       g_return_val_if_fail (self, -1);
+       g_return_val_if_fail (key, -1);
+
+       priv = MODEST_CONF_GET_PRIVATE(self);
+       
+       return gconf_client_get_float (priv->gconf_client, key, err);
+}
 
 gboolean
 modest_conf_get_bool (ModestConf* self, const gchar* key, GError **err)
 
 gboolean
 modest_conf_get_bool (ModestConf* self, const gchar* key, GError **err)
@@ -281,6 +293,27 @@ modest_conf_set_int  (ModestConf* self, const gchar* key, gint val,
        return gconf_client_set_int (priv->gconf_client, key, val, err);
 }
 
        return gconf_client_set_int (priv->gconf_client, key, val, err);
 }
 
+gboolean
+modest_conf_set_float (ModestConf* self, 
+                      const gchar* key, 
+                      gdouble val,
+                      GError **err)
+{
+       ModestConfPrivate *priv;
+               
+       g_return_val_if_fail (self,FALSE);
+       g_return_val_if_fail (key, FALSE);
+       
+       priv = MODEST_CONF_GET_PRIVATE(self);
+
+       if (!gconf_client_key_is_writable(priv->gconf_client,key,err)) {
+               g_printerr ("modest: '%s' is not writable\n", key);
+               return FALSE;
+       }
+                       
+       return gconf_client_set_float (priv->gconf_client, key, val, err);
+}
+
 
 gboolean
 modest_conf_set_bool (ModestConf* self, const gchar* key, gboolean val,
 
 gboolean
 modest_conf_set_bool (ModestConf* self, const gchar* key, gboolean val,
index c681549..4cdfb57 100644 (file)
@@ -121,6 +121,19 @@ gchar*       modest_conf_get_string  (ModestConf* self, const gchar* key, GError
  */
 gint         modest_conf_get_int     (ModestConf* self, const gchar* key, GError **err);
 
  */
 gint         modest_conf_get_int     (ModestConf* self, const gchar* key, GError **err);
 
+/** 
+ * modest_conf_get_float:
+ * @self: a ModestConf instance
+ * @key: the key of the value to retrieve
+ * @err: a GError ptr, or NULL to ignore.
+ * 
+ * get an integer from the configuration system
+ *  
+ * Returns: an double with the value for the key, or -1 in case of
+ * error (of course, -1 can also be returned in non-error cases).
+ * @err gives details in case of error
+ */
+gdouble      modest_conf_get_float   (ModestConf* self, const gchar* key, GError **err);
 
 /** 
  * modest_conf_get_bool:
 
 /** 
  * modest_conf_get_bool:
@@ -183,6 +196,23 @@ gboolean     modest_conf_set_int    (ModestConf* self, const gchar* key, int val
                                     GError **err);
 
 /**
                                     GError **err);
 
 /**
+ * modest_conf_set_float:
+ * @self: a ModestConf instance
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @err: a GError ptr, or NULL if not interested.
+ *
+ * store an integer value in the configuration system
+ * 
+ * Returns: TRUE if succeeded or FALSE in case of error.
+ * @err gives details in case of error
+ */
+gboolean     modest_conf_set_float  (ModestConf* self, 
+                                    const gchar* key, 
+                                    gdouble val,
+                                    GError **err);
+
+/**
  * modest_conf_set_bool:
  * @self: a ModestConf instance
  * @key: the key of the value to set
  * modest_conf_set_bool:
  * @self: a ModestConf instance
  * @key: the key of the value to set
index f98238c..56ab18a 100644 (file)
@@ -219,16 +219,17 @@ static gboolean
 save_settings_paned (ModestConf *conf, GtkPaned *paned, const gchar *name)
 {
        gchar *key;
 save_settings_paned (ModestConf *conf, GtkPaned *paned, const gchar *name)
 {
        gchar *key;
-       int pos, percent;
+       gint pos;
+       gdouble percent;
 
        /* Don't save the paned position if it's not visible, 
         * because it could not be correct: */
        if (GTK_WIDGET_REALIZED (GTK_WIDGET (paned))) {
                pos = gtk_paned_get_position (paned);
 
        /* Don't save the paned position if it's not visible, 
         * because it could not be correct: */
        if (GTK_WIDGET_REALIZED (GTK_WIDGET (paned))) {
                pos = gtk_paned_get_position (paned);
-               percent = pos * 100 / GTK_WIDGET (paned)->allocation.width;
+               percent = (gdouble) (pos * 100) / (gdouble) GTK_WIDGET (paned)->allocation.width;
 
                key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS);
 
                key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS);
-               modest_conf_set_int (conf, key, percent, NULL);
+               modest_conf_set_float (conf, key, percent, NULL);
                g_free (key);
        }
        
                g_free (key);
        }
        
@@ -240,10 +241,11 @@ static gboolean
 restore_settings_paned (ModestConf *conf, GtkPaned *paned, const gchar *name)
 {
        gchar *key;
 restore_settings_paned (ModestConf *conf, GtkPaned *paned, const gchar *name)
 {
        gchar *key;
-       int percent, pos;
+       gdouble percent;
+       gint pos;
        
        key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS); 
        
        key = _modest_widget_memory_get_keyname (name, MODEST_WIDGET_MEMORY_PARAM_POS); 
-       percent = modest_conf_get_int (conf, key, NULL);
+       percent = modest_conf_get_float (conf, key, NULL);
        
        if (GTK_WIDGET_VISIBLE (GTK_WIDGET (paned)) && GTK_WIDGET_REALIZED (GTK_WIDGET (paned))) {
                pos = GTK_WIDGET (paned)->allocation.width * percent /100;
        
        if (GTK_WIDGET_VISIBLE (GTK_WIDGET (paned)) && GTK_WIDGET_REALIZED (GTK_WIDGET (paned))) {
                pos = GTK_WIDGET (paned)->allocation.width * percent /100;