* Stored the reference to the security widget in the private structure of ModestStore...
authorSergio Villar Senin <svillar@igalia.com>
Wed, 20 Dec 2006 12:40:52 +0000 (12:40 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 20 Dec 2006 12:40:52 +0000 (12:40 +0000)
* Added the new method modest_conf_set_list
* Added the new method modest_account_mgr_set_list

pmo-trunk-r570

src/gtk/modest-store-widget.c
src/modest-account-mgr.c
src/modest-account-mgr.h
src/modest-conf.c
src/modest-conf.h

index 33989db..9054bf9 100644 (file)
@@ -220,13 +220,13 @@ imap_pop_configuration (ModestStoreWidget *self)
        gtk_label_set_markup (GTK_LABEL(label),_("<b>Security</b>"));
        gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0);
 
+       priv->security = modest_widget_factory_get_combo_box (priv->factory, 
+                                                             MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS);
        hbox = gtk_hbox_new (FALSE, 6);
        label = gtk_label_new(NULL);
        gtk_label_set_text (GTK_LABEL(label),_("Connection type:"));
        gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
-       gtk_box_pack_start (GTK_BOX(hbox),  modest_widget_factory_get_combo_box
-                           (priv->factory, MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS),
-                           FALSE, FALSE,0);
+       gtk_box_pack_start (GTK_BOX(hbox),  priv->security, FALSE, FALSE,0);
        gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0);
        
        hbox = gtk_hbox_new (FALSE, 6);
@@ -347,9 +347,8 @@ modest_store_widget_get_proto (ModestStoreWidget *self)
 {
        ModestStoreWidgetPrivate *priv;
 
-       g_return_val_if_fail (self, FALSE);
+       g_return_val_if_fail (self, NULL);
        priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
 
        return priv->proto;
 }
-
index 88da136..7a18d51 100644 (file)
@@ -782,6 +782,29 @@ modest_account_mgr_set_bool (ModestAccountMgr * self, const gchar * name,
        return retval;
 }
 
+void 
+modest_account_mgr_set_list (ModestAccountMgr *self,
+                            const gchar *name,
+                            const gchar *key,
+                            GSList *val,
+                            ModestConfValueType list_type,
+                            gboolean server_account,
+                            GError **err)
+{
+       ModestAccountMgrPrivate *priv;
+       gchar *keyname;
+       
+       g_return_if_fail (self);
+       g_return_if_fail (name);
+       g_return_if_fail (key);
+       g_return_if_fail (val);
+
+       keyname = get_account_keyname (name, key, server_account);
+       
+       priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+       modest_conf_set_list (priv->modest_conf, keyname, val, list_type, err);
+       g_free (keyname);
+}
 
 gboolean
 modest_account_mgr_account_exists (ModestAccountMgr * self, const gchar * name,
index 4930893..2e0e418 100644 (file)
@@ -327,6 +327,27 @@ gboolean   modest_account_mgr_get_bool       (ModestAccountMgr *self,
                                                   GError **err);
 
 /**
+ * modest_account_mgr_get_list:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to get
+ * @list_type: the type of the members of the list
+ * @server_account: if TRUE, this is a server account
+ * @err: a GError ptr, or NULL to ignore.
+ * 
+ * get a config list of values of type @list_type of an account
+ *
+ * Returns: a newly allocated list of elements
+ * @err gives details in case of error
+ */
+GSList*                modest_account_mgr_get_list       (ModestAccountMgr *self,
+                                                  const gchar *name,
+                                                  const gchar *key,
+                                                  ModestConfValueType list_type,
+                                                  gboolean server_account,
+                                                  GError **err);
+
+/**
  * modest_account_mgr_set_account_string:
  * @self: a ModestAccountMgr instance
  * @name: the name of the account
@@ -387,24 +408,23 @@ gboolean  modest_account_mgr_set_bool       (ModestAccountMgr *self,
                                                   gboolean server_account,
                                                   GError **err);
 
-
 /**
- * modest_account_mgr_get_list:
+ * modest_account_mgr_set_list:
  * @self: a ModestAccountMgr instance
  * @name: the name of the account
- * @key: the key of the value to get
+ * @key: the key of the value to set
+ * @key: the list with the values to set
  * @list_type: the type of the members of the list
  * @server_account: if TRUE, this is a server account
  * @err: a GError ptr, or NULL to ignore.
  * 
- * get a config list of values of type @list_type of an account
- *
- * Returns: a newly allocated list of elements
+ * set a config list of values of type @list_type of an account
  * @err gives details in case of error
  */
-GSList*                modest_account_mgr_get_list       (ModestAccountMgr *self,
+void           modest_account_mgr_set_list       (ModestAccountMgr *self,
                                                   const gchar *name,
                                                   const gchar *key,
+                                                  GSList *val,
                                                   ModestConfValueType list_type,
                                                   gboolean server_account,
                                                   GError **err);
index 3fc3509..42f0759 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <gconf/gconf-client.h>
 #include <string.h>
+#include <glib/gi18n.h>
 #include "modest-conf.h"
 #include "modest-marshal.h"
 
@@ -37,6 +38,8 @@ static void   modest_conf_init           (ModestConf *obj);
 static void   modest_conf_finalize       (GObject *obj);
 static void   modest_conf_on_change     (GConfClient *client, guint conn_id,
                                          GConfEntry *entry, gpointer data);
+static GConfValueType modest_conf_type_to_gconf_type (ModestConfValueType value_type, 
+                                                     GError **err);
 /* list my signals */
 enum {
        KEY_CHANGED_SIGNAL,
@@ -225,31 +228,19 @@ modest_conf_get_list (ModestConf* self, const gchar* key, ModestConfValueType li
 {
        ModestConfPrivate *priv;
        GConfValueType gconf_type;
+       GSList *retval = NULL;
        
        g_return_val_if_fail (self, NULL);
        g_return_val_if_fail (key,  NULL);
 
        priv = MODEST_CONF_GET_PRIVATE(self);
 
-       switch (list_type) {
-       case MODEST_CONF_VALUE_INT:
-               gconf_type = GCONF_VALUE_INT;
-               break;
-       case MODEST_CONF_VALUE_BOOL:
-               gconf_type = GCONF_VALUE_BOOL;
-               break;
-       case MODEST_CONF_VALUE_FLOAT:
-               gconf_type = GCONF_VALUE_FLOAT;
-               break;
-       case MODEST_CONF_VALUE_STRING:
-               gconf_type = GCONF_VALUE_STRING;
-               break;
-       default:
-               g_printerr ("modest: invalid list type %d requested\n", list_type);
-              /* FIXME: fill GError */
-              return NULL;
-       }
-       return gconf_client_get_list (priv->gconf_client, key, gconf_type, err);
+       gconf_type = modest_conf_type_to_gconf_type (list_type, err);
+
+       if (!err)
+              retval = gconf_client_get_list (priv->gconf_client, key, gconf_type, err);
+
+       return retval;
 }
 
 
@@ -315,6 +306,24 @@ modest_conf_set_bool (ModestConf* self, const gchar* key, gboolean val,
 }
 
 
+void 
+modest_conf_set_list (ModestConf* self, const gchar* key, 
+                     GSList *val, ModestConfValueType list_type, 
+                     GError **err)
+{
+       ModestConfPrivate *priv;
+       GConfValueType gconf_type;
+       
+       g_return_if_fail (self);
+       g_return_if_fail (key);
+
+       priv = MODEST_CONF_GET_PRIVATE(self);
+
+       gconf_type = modest_conf_type_to_gconf_type (list_type, err);
+
+       if (!err)
+              gconf_client_set_list (priv->gconf_client, key, gconf_type, val, err);
+}
 
 
 GSList*
@@ -415,3 +424,27 @@ modest_conf_on_change (GConfClient *client, guint conn_id, GConfEntry *entry,
                       key, event);
 }
 
+static GConfValueType
+modest_conf_type_to_gconf_type (ModestConfValueType value_type, GError **err)
+{
+       GConfValueType gconf_type;
+
+       switch (value_type) {
+       case MODEST_CONF_VALUE_INT:
+               gconf_type = GCONF_VALUE_INT;
+               break;
+       case MODEST_CONF_VALUE_BOOL:
+               gconf_type = GCONF_VALUE_BOOL;
+               break;
+       case MODEST_CONF_VALUE_FLOAT:
+               gconf_type = GCONF_VALUE_FLOAT;
+               break;
+       case MODEST_CONF_VALUE_STRING:
+               gconf_type = GCONF_VALUE_STRING;
+               break;
+       default:
+               /* FIXME: use MODEST_ERROR, and error code */
+               *err = g_error_new_literal (0, 0, _("Invalid list value type"));
+       }
+       return gconf_type;
+}
index 80e34b4..a2c483c 100644 (file)
@@ -196,19 +196,19 @@ gboolean     modest_conf_set_bool    (ModestConf* self, const gchar* key, gboole
 
 
 /** 
- * modest_conf_get_list:
+ * modest_conf_set_list:
  * @self: a ModestConf instance
  * @key: the key of the value to retrieve
+ * @val: the list with the values to set
  * @list_type: the type of the elements of the list
  * @err: a GError ptr, or NULL to ignore.
  * 
- * get a list of values from the configuration system
- *  
- * Returns: a list with the values for the key, or NULL in case of error or
- * if the list is empty; @err gives details in case of error
+ * set a list of values in the configuration system
+ * @err gives details in case of error
  */
-GSList *     modest_conf_get_list    (ModestConf* self, const gchar* key, 
-                                     ModestConfValueType list_type, GError **err);
+void         modest_conf_set_list    (ModestConf* self, const gchar* key, 
+                                     GSList *val, ModestConfValueType list_type, 
+                                     GError **err);
 
 
 /**