* Fixes NB#85740, merged from trunk r4561 & r5983 + some extra changes
authorSergio Villar Senin <svillar@igalia.com>
Mon, 27 Oct 2008 10:50:03 +0000 (10:50 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 27 Oct 2008 10:50:03 +0000 (10:50 +0000)
pmo-diablo-r6162

src/modest-conf.c
src/modest-conf.h
src/modest-init.c
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);
 }
 
+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)
@@ -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);
 }
 
+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,
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);
 
+/** 
+ * 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:
@@ -183,6 +196,23 @@ gboolean     modest_conf_set_int    (ModestConf* self, const gchar* key, int val
                                     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
index e3f54de..8607192 100644 (file)
@@ -80,6 +80,7 @@ typedef struct {
 
 
 static const guint MODEST_MAIN_PANED_POS_PERCENTAGE = 30;
+static const guint MODEST_MSG_PANED_POS_PERCENTAGE = 50;
 
 static const FolderCols INBOX_COLUMNS_DETAILS[] = {
        {MODEST_HEADER_VIEW_COLUMN_MSGTYPE, 40, 0},
@@ -428,7 +429,16 @@ init_header_columns (ModestConf *conf, gboolean overwrite)
        /* if we're not in overwrite mode, only write stuff it
         * there was nothing before */
        if (overwrite || !modest_conf_key_exists(conf, key, NULL)) 
-               modest_conf_set_int (conf, key, MODEST_MAIN_PANED_POS_PERCENTAGE, NULL);
+               modest_conf_set_float (conf, key, MODEST_MAIN_PANED_POS_PERCENTAGE, NULL);
+       
+       g_free (key);
+
+       key = _modest_widget_memory_get_keyname (MODEST_CONF_MSG_PANED_KEY, 
+                                                MODEST_WIDGET_MEMORY_PARAM_POS);
+       /* if we're not in overwrite mode, only write stuff it
+        * there was nothing before */
+       if (overwrite || !modest_conf_key_exists(conf, key, NULL)) 
+               modest_conf_set_float (conf, key, MODEST_MSG_PANED_POS_PERCENTAGE, NULL);
        
        g_free (key);
        return TRUE;
index f98238c..56ab18a 100644 (file)
@@ -219,16 +219,17 @@ static gboolean
 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);
-               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);
-               modest_conf_set_int (conf, key, percent, NULL);
+               modest_conf_set_float (conf, key, percent, NULL);
                g_free (key);
        }
        
@@ -240,10 +241,11 @@ static gboolean
 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); 
-       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;