* Introduce ModestTnyStoreActions, simple update function.
authorFlorian Boor <florian@kernelconcepts.de>
Thu, 8 Jun 2006 13:38:43 +0000 (13:38 +0000)
committerFlorian Boor <florian@kernelconcepts.de>
Thu, 8 Jun 2006 13:38:43 +0000 (13:38 +0000)
* Make Send/Recheive button trigger folder update.

pmo-trunk-r184

src/Makefile.am
src/gtk-glade/modest-ui.c
src/modest-tny-store-actions.c [new file with mode: 0644]
src/modest-tny-store-actions.h [new file with mode: 0644]

index 488d087..e0343af 100644 (file)
@@ -7,7 +7,7 @@ INCLUDES=\
        $(MODEST_GSTUFF_CFLAGS)\
        $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) \
        $(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \
-       -I$(MODEST_UI_DIR)\
+       -I$(MODEST_UI_DIR) -Wall\
        -DPREFIX=\"@prefix@\" \
        -Wall
 
@@ -48,6 +48,8 @@ modest_SOURCES=\
        modest-tny-stream-gtkhtml.c\
        modest-tny-transport-actions.c\
        modest-tny-transport-actions.h\
+       modest-tny-store-actions.c\
+       modest-tny-store-actions.h\
        modest-editor-window.c\
        modest-editor-window.h\
        modest-ui.h
index 74f27da..85d6e6c 100644 (file)
@@ -25,6 +25,7 @@
 #include "../modest-tny-header-tree-view.h"
 #include "../modest-tny-msg-view.h"
 #include "../modest-tny-transport-actions.h"
+#include "../modest-tny-store-actions.h"
 
 #include "../modest-text-utils.h"
 #include "../modest-tny-msg-actions.h"
@@ -70,6 +71,8 @@ static void on_delete_clicked (GtkWidget *widget, ModestUI *modest_ui);
 
 static void on_send_button_clicked (GtkWidget *widget, ModestUI *modest_ui);
 
+static void on_sendreceive_button_clicked (GtkWidget *widget, ModestUI *modest_ui);
+
 static void register_toolbar_callbacks (ModestUI *modest_ui);
 
 
@@ -401,6 +404,13 @@ register_toolbar_callbacks (ModestUI *modest_ui)
                                  G_CALLBACK(on_delete_clicked), modest_ui);
                gtk_widget_set_sensitive(button, FALSE);
        }
+       
+       button = glade_xml_get_widget (priv->glade_xml, "toolb_send_receive");
+       if (button) {
+               g_signal_connect (button, "clicked",
+                                 G_CALLBACK(on_sendreceive_button_clicked), modest_ui);
+               gtk_widget_set_sensitive(button, TRUE);
+       }
 }
 
 
@@ -1071,3 +1081,31 @@ on_delete_clicked (GtkWidget *widget, ModestUI *modest_ui)
                }
        }
 }
+
+static void
+on_sendreceive_button_clicked (GtkWidget *widget, ModestUI *modest_ui)
+{
+       ModestUIPrivate *priv;
+       ModestTnyStoreActions *store_actions;
+       TnyAccountStoreIface *account_store;
+       const GList *store_accounts;
+       const GList *iter;
+       
+       g_return_if_fail (modest_ui);
+
+       store_actions = MODEST_TNY_STORE_ACTIONS (modest_tny_store_actions_new ());
+       priv = MODEST_UI_GET_PRIVATE(modest_ui);
+
+       account_store = priv->account_store;
+       store_accounts =
+               tny_account_store_iface_get_store_accounts (account_store);
+               
+       for (iter = store_accounts; iter; iter = iter->next)
+               modest_tny_store_actions_update_folders (store_actions, 
+                                                                                                TNY_STORE_ACCOUNT_IFACE (iter->data));
+       
+       /* TODO, lock, refresh display */
+       
+       g_object_unref (store_actions);
+
+}
diff --git a/src/modest-tny-store-actions.c b/src/modest-tny-store-actions.c
new file mode 100644 (file)
index 0000000..ad8826a
--- /dev/null
@@ -0,0 +1,139 @@
+/* modest-tny-store-actions.c */
+
+/* insert (c)/licensing information) */
+
+#include <tny-msg.h>
+#include <tny-msg-iface.h>                     
+#include <tny-msg-header.h>
+#include <tny-msg-header-iface.h>
+#include <tny-account-iface.h> 
+#include <tny-account-store-iface.h>
+#include <tny-store-account-iface.h>   
+#include <tny-store-account.h>
+#include <tny-stream-camel.h>
+#include <string.h>
+#include <camel/camel-folder.h>
+#include <camel/camel.h>
+#include <camel/camel-folder-summary.h>
+
+
+#include <glib.h>
+#include "modest-tny-store-actions.h"
+
+
+/* 'private'/'protected' functions */
+static void    modest_tny_store_actions_class_init   (ModestTnyStoreActionsClass *klass);
+static void    modest_tny_store_actions_init         (ModestTnyStoreActions *obj);
+static void    modest_tny_store_actions_finalize     (GObject *obj);
+
+/* list my signals */
+enum {
+       /* MY_SIGNAL_1, */
+       /* MY_SIGNAL_2, */
+       LAST_SIGNAL
+};
+
+typedef struct _ModestTnyStoreActionsPrivate ModestTnyStoreActionsPrivate;
+
+struct _ModestTnyStoreActionsPrivate {
+       gboolean active;
+};
+
+#define MODEST_TNY_STORE_ACTIONS_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                                          MODEST_TYPE_TNY_STORE_ACTIONS, \
+                                                          ModestTnyStoreActionsPrivate))
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+/* uncomment the following if you have defined any signals */
+/* static guint signals[LAST_SIGNAL] = {0}; */
+
+void
+modest_tny_store_actions_update_folders (ModestTnyStoreActions *self,
+                                          TnyStoreAccountIface *storage_account)
+{
+       const TnyListIface* folders;
+       TnyIteratorIface* ifolders;
+       gpointer *cur_folder;
+#if 0  
+       folders = tny_store_account_iface_get_folders (storage_account, 
+                                                                                                 TNY_STORE_ACCOUNT_FOLDER_TYPE_SUBSCRIBED);
+       
+       ifolders = tny_list_iface_create_iterator (folders);
+       
+       for (cur_folder = tny_iterator_iface_first (ifolders); 
+                             tny_iterator_iface_has_next (ifolders); 
+                         tny_iterator_iface_next (ifolders))
+       {
+               cur_folder = tny_iterator_iface_current (ifolders);
+//             tny_msg_folder_iface_refresh (cur_folder);
+       }
+#endif
+}
+
+
+GType
+modest_tny_store_actions_get_type (void)
+{
+       static GType my_type = 0;
+       if (!my_type) {
+               static const GTypeInfo my_info = {
+                       sizeof(ModestTnyStoreActionsClass),
+                       NULL,           /* base init */
+                       NULL,           /* base finalize */
+                       (GClassInitFunc) modest_tny_store_actions_class_init,
+                       NULL,           /* class finalize */
+                       NULL,           /* class data */
+                       sizeof(ModestTnyStoreActions),
+                       1,              /* n_preallocs */
+                       (GInstanceInitFunc) modest_tny_store_actions_init,
+               };
+               my_type = g_type_register_static (G_TYPE_OBJECT,
+                                                 "ModestTnyStoreActions",
+                                                 &my_info, 0);
+       }
+       return my_type;
+}
+
+static void
+modest_tny_store_actions_class_init (ModestTnyStoreActionsClass *klass)
+{
+       GObjectClass *gobject_class;
+       gobject_class = (GObjectClass*) klass;
+
+       parent_class            = g_type_class_peek_parent (klass);
+       gobject_class->finalize = modest_tny_store_actions_finalize;
+
+       g_type_class_add_private (gobject_class, sizeof(ModestTnyStoreActionsPrivate));
+       
+       klass->update_folders = modest_tny_store_actions_update_folders;
+       /* 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. */
+}
+
+static void
+modest_tny_store_actions_init (ModestTnyStoreActions *obj)
+{
+/* uncomment the following if you init any of the private data */
+/*     ModestTnyStoreActionsPrivate *priv = MODEST_TNY_STORE_ACTIONS_GET_PRIVATE(obj); */
+
+/*     initialize this object, eg.: */
+/*     priv->frobnicate_mode = FALSE; */
+}
+
+static void
+modest_tny_store_actions_finalize (GObject *obj)
+{
+/*     free/unref instance resources here */
+}
+
+GObject*
+modest_tny_store_actions_new (void)
+{
+       return G_OBJECT(g_object_new(MODEST_TYPE_TNY_STORE_ACTIONS, NULL));
+}
+
diff --git a/src/modest-tny-store-actions.h b/src/modest-tny-store-actions.h
new file mode 100644 (file)
index 0000000..38b1973
--- /dev/null
@@ -0,0 +1,47 @@
+/* modest-tny-store-actions.h */
+/* insert (c)/licensing information) */
+
+#ifndef __MODEST_TNY_STORE_ACTIONS_H__
+#define __MODEST_TNY_STORE_ACTIONS_H__
+
+#include <glib-object.h>
+#include <tny-store-account-iface.h>
+
+G_BEGIN_DECLS
+
+/* standard convenience macros */
+#define MODEST_TYPE_TNY_STORE_ACTIONS             (modest_tny_store_actions_get_type())
+#define MODEST_TNY_STORE_ACTIONS(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_TNY_STORE_ACTIONS,ModestTnyStoreActions))
+#define MODEST_TNY_STORE_ACTIONS_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_TNY_STORE_ACTIONS,ModestTnyStoreActionsClass))
+#define MODEST_IS_TNY_STORE_ACTIONS(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_TNY_STORE_ACTIONS))
+#define MODEST_IS_TNY_STORE_ACTIONS_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_TNY_STORE_ACTIONS))
+#define MODEST_TNY_STORE_ACTIONS_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_TNY_STORE_ACTIONS,ModestTnyStoreActionsClass))
+
+typedef struct _ModestTnyStoreActions      ModestTnyStoreActions;
+typedef struct _ModestTnyStoreActionsClass ModestTnyStoreActionsClass;
+
+struct _ModestTnyStoreActions {
+        GObject parent;
+       /* insert public members, if any */
+};
+
+struct _ModestTnyStoreActionsClass {
+       GObjectClass parent_class;
+       
+       void (* update_folders) (ModestTnyStoreActions *self,
+                                          TnyStoreAccountIface *storage_account);
+};
+
+/* member functions */
+GType        modest_tny_store_actions_get_type    (void) G_GNUC_CONST;
+
+GObject*    modest_tny_store_actions_new         (void);
+
+void    modest_tny_store_actions_update_folders (ModestTnyStoreActions *self,
+                                          TnyStoreAccountIface *storage_account);
+
+
+G_END_DECLS
+
+#endif /* __MODEST_TNY_STORE_ACTIONS_H__ */
+