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)
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,
*/
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:
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
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},
/* 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;
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);
}
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;