* Move marshallers to external files generated by glib-genmarshal.
authorFlorian Boor <florian@kernelconcepts.de>
Tue, 13 Jun 2006 13:46:12 +0000 (13:46 +0000)
committerFlorian Boor <florian@kernelconcepts.de>
Tue, 13 Jun 2006 13:46:12 +0000 (13:46 +0000)
* Add input file for glib-ganmarshal.
* Introduce ModestAccountMgr signals.
* Some minor cleanups.

pmo-trunk-r253

src/Makefile.am
src/marshall.list [new file with mode: 0644]
src/modest-account-mgr.c
src/modest-conf-gconf.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h

index 7c47629..033ca0b 100644 (file)
@@ -11,6 +11,15 @@ INCLUDES=\
        -DPREFIX=\"@prefix@\" \
        -Wall
 
+BUILT_SOURCES = modest-marshal.c modest-marshal.h
+
+modest-marshal.c:
+       glib-genmarshal --body --prefix=modest_marshal < marshall.list > modest-marshal.c
+       
+modest-marshal.h:
+       glib-genmarshal --header --prefix=modest_marshal < marshall.list > modest-marshal.h
+
+
 bin_PROGRAMS=\
        modest
 
@@ -54,7 +63,9 @@ modest_SOURCES=\
        modest-editor-window.h\
        modest-viewer-window.c\
        modest-viewer-window.h\
-       modest-ui.h
+       modest-ui.h \
+       modest-marshal.c \
+       modest-marshal.h
 
 modest_LDADD = \
        $(MODEST_GSTUFF_LIBS) \
diff --git a/src/marshall.list b/src/marshall.list
new file mode 100644 (file)
index 0000000..cd48853
--- /dev/null
@@ -0,0 +1 @@
+VOID:POINTER,POINTER
index 9196af6..4a079cc 100644 (file)
@@ -3,6 +3,8 @@
 /* insert (c)/licensing information) */
 
 #include <string.h>
+#include "modest-marshal.h"
+#include "modest-account-keys.h"
 #include "modest-account-mgr.h"
 
 /* 'private'/'protected' functions */
@@ -16,8 +18,9 @@ static gchar *get_server_account_keyname (const gchar * accname,
 
 /* list my signals */
 enum {
-       /* MY_SIGNAL_1, */
-       /* MY_SIGNAL_2, */
+       ACCOUNT_CHANGE_SIGNAL,
+       ACCOUNT_REMOVE_SIGNAL,
+       ACCOUNT_ADD_SIGNAL,
        LAST_SIGNAL
 };
 
@@ -32,15 +35,20 @@ struct _ModestAccountMgrPrivate {
 /* globals */
 static GObjectClass *parent_class = NULL;
 
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
+static guint signals[LAST_SIGNAL] = {0};
 
+
+/* map configuration changes to account changes */
 static void
 modest_account_mgr_check_change (ModestConf *conf, const gchar *key, 
                                  const gchar *new_value, gpointer user_data)
 {
        ModestAccountMgr *amgr = user_data;
        
+       
+       
+       g_signal_emit (amgr, signals[ACCOUNT_CHANGE_SIGNAL], 0, key, new_value);
+               
        g_message ("value changed: %s %s\n", key, new_value);
 }
 
@@ -74,6 +82,7 @@ static void
 modest_account_mgr_class_init (ModestAccountMgrClass * klass)
 {
        GObjectClass *gobject_class;
+       GType paramtypes[2] = {G_TYPE_POINTER, G_TYPE_POINTER};
 
        gobject_class = (GObjectClass *) klass;
 
@@ -83,12 +92,26 @@ modest_account_mgr_class_init (ModestAccountMgrClass * klass)
        g_type_class_add_private (gobject_class,
                                  sizeof (ModestAccountMgrPrivate));
 
-       /* signal definitions go here, e.g.: */
-/*     signals[MY_SIGNAL_1] = */
-/*             g_signal_new ("my_signal_1",....); */
-/*     signals[MY_SIGNAL_2] = */
-/*             g_signal_new ("my_signal_2",....); */
-/*     etc. */
+       /* signal definitions */
+       signals[ACCOUNT_ADD_SIGNAL] = 
+               g_signal_newv ("account-add", 
+                              G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+                              NULL, NULL, NULL,
+                              g_cclosure_marshal_VOID__POINTER,
+                              G_TYPE_NONE, 1, paramtypes);
+       
+       signals[ACCOUNT_REMOVE_SIGNAL] = 
+               g_signal_newv ("account-remove", 
+                              G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+                              NULL, NULL, NULL,
+                              g_cclosure_marshal_VOID__POINTER,
+                              G_TYPE_NONE, 1, paramtypes);
+       signals[ACCOUNT_CHANGE_SIGNAL] = 
+               g_signal_newv ("account-change", 
+                              G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+                              NULL, NULL, NULL,
+                              modest_marshal_VOID__POINTER_POINTER,
+                              G_TYPE_NONE, 2, paramtypes);
 }
 
 
index c6668a6..1202a89 100644 (file)
@@ -4,6 +4,7 @@
 /* insert (c)/licensing information) */
 
 #include "modest-conf.h"
+#include "modest-marshal.h"
 #include <gconf/gconf-client.h>
 
 
@@ -32,42 +33,10 @@ static GObjectClass *parent_class = NULL;
 
 static guint signals[LAST_SIGNAL] = {0};
 
-typedef void (*MarshalFunc_VOID__POINTER_POINTER) (gpointer data1, 
-       gpointer arg_1, gpointer arg_2, gpointer data2);
-                                                   
-  
-static void
-modest_marshal_VOID__POINTER_POINTER (GClosure     *closure,
-                                      GValue       *return_value,
-                                      guint         n_param_values,
-                                      const GValue *param_values,
-                                      gpointer      invocation_hint,
-                                      gpointer      marshal_data)
-{
-       MarshalFunc_VOID__POINTER_POINTER callback;
-       GCClosure *cc = (GCClosure*) closure;
-       gpointer data1, data2;
-
-       g_return_if_fail (n_param_values == 3);
-
-       if (G_CCLOSURE_SWAP_DATA (closure)) {
-               data1 = closure->data;
-               data2 = g_value_peek_pointer (param_values + 0);
-       } else {
-               data1 = g_value_peek_pointer (param_values + 0);
-               data2 = closure->data;
-       }
-       
-       callback = (MarshalFunc_VOID__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
-
-       callback (data1, g_value_get_pointer (param_values + 1),
-                 g_value_get_pointer (param_values + 2), data2);
-}
-
 void 
 modest_conf_key_changed (ModestConf* self, const gchar *key, const gchar *new_value)
 {
-
+       g_signal_emit (self, signals[KEY_CHANGED_SIGNAL], 0, key, new_value);
 }
 
 
@@ -99,6 +68,7 @@ modest_conf_class_init (ModestConfClass *klass)
 {
        GObjectClass *gobject_class;
        gobject_class = (GObjectClass*) klass;
+       GType paramtypes[2] = {G_TYPE_POINTER, G_TYPE_POINTER};
 
        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = modest_conf_finalize;
@@ -107,13 +77,12 @@ modest_conf_class_init (ModestConfClass *klass)
        
        klass->key_changed = modest_conf_key_changed;
 
-       signals[KEY_CHANGED_SIGNAL] = 
-               g_signal_new ("key-changed", 
-                             G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET(ModestConfClass, key_changed),
-                             NULL, NULL,
-                             modest_marshal_VOID__POINTER_POINTER,
-                             G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+       signals[KEY_CHANGED_SIGNAL] = 
+               g_signal_newv ("key-changed", 
+                              G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST,
+                              NULL, NULL, NULL,
+                              modest_marshal_VOID__POINTER_POINTER,
+                              G_TYPE_NONE, 2, paramtypes);
 }
 
 static void
index 86f7190..7d7b97a 100644 (file)
@@ -192,8 +192,10 @@ modest_tny_account_store_new (ModestAccountMgr *modest_acc_mgr)
        obj  = G_OBJECT(g_object_new(MODEST_TYPE_TNY_ACCOUNT_STORE, NULL));
 
        priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(obj);
-       g_object_ref(G_OBJECT(priv->modest_acc_mgr = modest_acc_mgr));
-
+       
+       g_object_ref(G_OBJECT(modest_acc_mgr));
+       priv->modest_acc_mgr = modest_acc_mgr;
+       
        priv->device = (TnyDeviceIface*)tny_device_new();
        if (!priv->device) {
                g_warning ("Cannot create Device instance");
@@ -258,7 +260,7 @@ add_account  (TnyAccountStoreIface *self, TnyAccountIface *account)
        ModestTnyAccountStore *account_store;
        ModestTnyAccountStorePrivate *priv;
 
-       const gchar* account_name;
+       const gchar *account_name;
        const gchar *hostname, *username, *proto;
 
        g_return_val_if_fail (self, FALSE);
index 842e9cf..5d723ac 100644 (file)
@@ -24,12 +24,10 @@ typedef struct _ModestTnyAccountStore      ModestTnyAccountStore;
 typedef struct _ModestTnyAccountStoreClass ModestTnyAccountStoreClass;
 
 struct _ModestTnyAccountStore {
-       //TnyAccountStore parent;
        GObject parent;
 };
 
 struct _ModestTnyAccountStoreClass {
-       //TnyAccountStoreClass parent_class;
        GObjectClass parent_class;
 
        void (*password_requested) (ModestTnyAccountStore *self,