From f6ae525c79d3665c68a050b4037ea8105b490f05 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Fri, 12 Jan 2007 14:13:31 +0000 Subject: [PATCH] * Cleaned some header files, deleting unused includes * Migrated the edit msg window to GtkUIManager * Added modest-ui-actions.h with the signatures of the ui actions * Added modest-main-window-ui.h and modest-edit-msg-window-ui.h with the ui action entries of the windows * Removed the action entries and actions from modest-ui-priv.h * Moved the GtkUIManager creation to the windows * Added some getter methods to the windows pmo-trunk-r608 --- src/Makefile.am | 9 +- src/gtk/Makefile.am | 11 +- src/gtk/modest-account-assistant.h | 1 - src/gtk/modest-account-view-window.h | 1 - src/gtk/modest-edit-msg-window.c | 348 ++++++----------- src/gtk/modest-main-window.c | 77 +++- src/gtk/modest-store-widget.h | 1 - src/gtk/modest-transport-widget.h | 1 - src/maemo/Makefile.am | 13 +- src/maemo/modest-edit-msg-window.c | 313 ++++++++------- src/modest-formatter.c | 2 - src/modest-icon-factory.h | 2 +- src/modest-main.c | 6 +- src/modest-tny-msg-actions.c | 1 - src/modest-ui-actions.h | 102 +++++ src/modest-ui-priv.h | 49 +++ src/modest-ui.c | 629 +++++++++++++++---------------- src/modest-ui.h | 20 +- src/modest-widget-memory.h | 1 - src/ui/modest-edit-msg-window-ui.xml | 73 ---- src/ui/modest-ui.xml | 89 ----- src/widgets/modest-account-view.c | 4 +- src/widgets/modest-account-view.h | 4 +- src/widgets/modest-edit-msg-window-ui.h | 59 +++ src/widgets/modest-edit-msg-window.h | 24 +- src/widgets/modest-header-view.h | 4 +- src/widgets/modest-main-window-ui.h | 90 +++++ src/widgets/modest-main-window.h | 13 +- src/widgets/modest-msg-view.h | 1 - 29 files changed, 1050 insertions(+), 898 deletions(-) create mode 100644 src/modest-ui-actions.h create mode 100644 src/modest-ui-priv.h delete mode 100644 src/ui/modest-edit-msg-window-ui.xml delete mode 100644 src/ui/modest-ui.xml create mode 100644 src/widgets/modest-edit-msg-window-ui.h create mode 100644 src/widgets/modest-main-window-ui.h diff --git a/src/Makefile.am b/src/Makefile.am index 1e76d84..b0bfb8c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -80,11 +80,4 @@ modest_LDADD = \ $(MODEST_PLATFORM)/libmodest-ui.la \ widgets/libmodest-widgets.la -EXTRA_DIST=modest-marshal.list ui/* - -UI_FILES=\ - ui/modest-ui.xml \ - ui/modest-edit-msg-window-ui.xml - -uidir = $(datadir)/modest/ui -ui_DATA = $(UI_FILES) +EXTRA_DIST=modest-marshal.list diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am index 7603a06..0cb1cfc 100644 --- a/src/gtk/Makefile.am +++ b/src/gtk/Makefile.am @@ -42,7 +42,16 @@ LDADD = \ $(MODEST_GSTUFF_LIBS) \ $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_LIBS) -EXTRA_DIST=pixmaps/* +EXTRA_DIST=\ + pixmaps/* \ + ui/* pixmapdir = $(datadir)/pixmaps/modest pixmap_DATA = $(PIXMAP_FILES) + +UI_FILES=\ + ui/modest-ui.xml \ + ui/modest-edit-msg-window-ui.xml + +uidir = $(datadir)/modest/ui +ui_DATA = $(UI_FILES) diff --git a/src/gtk/modest-account-assistant.h b/src/gtk/modest-account-assistant.h index bc29ce3..72cb232 100644 --- a/src/gtk/modest-account-assistant.h +++ b/src/gtk/modest-account-assistant.h @@ -30,7 +30,6 @@ #ifndef __MODEST_ACCOUNT_ASSISTANT_H__ #define __MODEST_ACCOUNT_ASSISTANT_H__ -#include #include #include diff --git a/src/gtk/modest-account-view-window.h b/src/gtk/modest-account-view-window.h index 1545c6f..bbe3344 100644 --- a/src/gtk/modest-account-view-window.h +++ b/src/gtk/modest-account-view-window.h @@ -4,7 +4,6 @@ #ifndef __MODEST_ACCOUNT_VIEW_WINDOW_H__ #define __MODEST_ACCOUNT_VIEW_WINDOW_H__ -#include #include G_BEGIN_DECLS diff --git a/src/gtk/modest-edit-msg-window.c b/src/gtk/modest-edit-msg-window.c index 3b3d53b..c8caffe 100644 --- a/src/gtk/modest-edit-msg-window.c +++ b/src/gtk/modest-edit-msg-window.c @@ -28,13 +28,16 @@ */ #include #include -#include "modest-toolbar.h" #include "modest-edit-msg-window.h" +#include "modest-edit-msg-window-ui.h" +#include "modest-icon-names.h" +#include "modest-icon-factory.h" #include "modest-widget-memory.h" #include "modest-mail-operation.h" #include "modest-tny-platform-factory.h" #include "modest-tny-msg-actions.h" #include +#include "modest-ui-actions.h" static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass); static void modest_edit_msg_window_init (ModestEditMsgWindow *obj); @@ -50,14 +53,17 @@ enum { typedef struct _ModestEditMsgWindowPrivate ModestEditMsgWindowPrivate; struct _ModestEditMsgWindowPrivate { - ModestWidgetFactory *factory; + ModestWidgetFactory *widget_factory; TnyPlatformFactory *fact; + TnyAccountStore *account_store; + GtkUIManager *ui_manager; GtkWidget *toolbar, *menubar; GtkWidget *msg_body; GtkWidget *from_field, *to_field, *cc_field, *bcc_field, *subject_field; }; + #define MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_EDIT_MSG_WINDOW, \ ModestEditMsgWindowPrivate)) @@ -117,7 +123,7 @@ modest_edit_msg_window_init (ModestEditMsgWindow *obj) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); priv->fact = modest_tny_platform_factory_get_instance (); - priv->factory = NULL; + priv->widget_factory = NULL; priv->toolbar = NULL; priv->menubar = NULL; } @@ -149,220 +155,6 @@ restore_settings (ModestEditMsgWindow *self) modest_widget_memory_restore (conf, G_OBJECT(self), "modest-edit-msg-window"); } - - -static void -on_menu_quit (ModestEditMsgWindow *self, guint action, GtkWidget *widget) -{ - save_settings (self); - gtk_widget_destroy (GTK_WIDGET(self)); -} - - - - - -/* Our menu, an array of GtkItemFactoryEntry structures that defines each menu item */ -static GtkItemFactoryEntry menu_items[] = { - { "/_File", NULL, NULL, 0, "" ,NULL}, - { "/File/_New", "N", NULL, 0, "", GTK_STOCK_NEW }, - { "/File/_Open", "O", NULL, 0, "", GTK_STOCK_OPEN }, - { "/File/_Save", "S", NULL, 0, "", GTK_STOCK_SAVE }, - { "/File/Save _As", NULL, NULL, 0, "", NULL} , - { "/File/Save Draft", "S", NULL, 0, "",NULL }, - - - { "/File/sep1", NULL, NULL, 0, "" ,NULL }, - { "/File/_Quit", "Q", on_menu_quit, 0, "", GTK_STOCK_QUIT }, - - { "/_Edit", NULL, NULL, 0, "" ,NULL }, - { "/Edit/_Undo", "Z", NULL, 0, "", GTK_STOCK_UNDO }, - { "/Edit/_Redo", "Z", NULL, 0, "", GTK_STOCK_REDO }, - { "/File/sep1", NULL, NULL, 0, "",NULL }, - { "/Edit/Cut", "X", NULL, 0, "", GTK_STOCK_CUT }, - { "/Edit/Copy", "C", NULL, 0, "", GTK_STOCK_COPY }, - { "/Edit/Paste", NULL, NULL, 0, "", GTK_STOCK_PASTE}, - { "/Edit/sep1", NULL, NULL, 0, "",NULL }, - { "/Edit/Delete", "Q", NULL, 0, "" ,NULL }, - { "/Edit/Select all", "A", NULL, 0, "" ,NULL }, - { "/Edit/Deselect all", "A", NULL, 0, "",NULL }, - - { "/_View", NULL, NULL, 0, "",NULL }, - { "/View/To-field", NULL, NULL, 0, "",NULL }, - - { "/View/Cc-field:", NULL, NULL, 0, "",NULL }, - { "/View/Bcc-field:", NULL, NULL, 0, "",NULL }, - - - { "/_Insert", NULL, NULL, 0, "",NULL }, -/* { "/Actions/_Reply", NULL, NULL, 0, "" }, */ -/* { "/Actions/_Forward", NULL, NULL, 0, "" }, */ -/* { "/Actions/_Bounce", NULL, NULL, 0, "" }, */ - - { "/_Format", NULL, NULL, 0, "",NULL } -/* { "/Options/_Accounts", NULL, on_menu_accounts,0, "" }, */ -/* { "/Options/_Contacts", NULL, NULL, 0, "" }, */ - - -/* { "/_Help", NULL, NULL, 0, "" }, */ -/* { "/_Help/About", NULL, on_menu_about, 0, "", GTK_STOCK_ABOUT}, */ -}; - -static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); - - -static GtkWidget * -menubar_new (ModestEditMsgWindow *self) -{ - GtkItemFactory *item_factory; - GtkAccelGroup *accel_group; - - /* Make an accelerator group (shortcut keys) */ - accel_group = gtk_accel_group_new (); - - /* Make an ItemFactory (that makes a menubar) */ - item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "
", - accel_group); - - /* This function generates the menu items. Pass the item factory, - the number of items in the array, the array itself, and any - callback data for the the menu items. */ - gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, self); - - ///* Attach the new accelerator group to the window. */ - gtk_window_add_accel_group (GTK_WINDOW (self), accel_group); - - /* Finally, return the actual menu bar created by the item factory. */ - return gtk_item_factory_get_widget (item_factory, "
"); -} - - -static void -send_mail (ModestEditMsgWindow *self) -{ - const gchar *to, *cc, *bcc, *subject; - gchar *body, *from; - ModestEditMsgWindowPrivate *priv; - TnyTransportAccount *transport_account; - ModestMailOperation *mail_operation; - ModestAccountData *data; - - GtkTextBuffer *buf; - GtkTextIter b, e; - - priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); - data = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); - - /* don't free these (except from) */ - from = g_strdup_printf ("%s <%s>", data->full_name, data->email) ; - to = gtk_entry_get_text (GTK_ENTRY(priv->to_field)); - cc = gtk_entry_get_text (GTK_ENTRY(priv->cc_field)); - bcc = gtk_entry_get_text (GTK_ENTRY(priv->bcc_field)); - subject = gtk_entry_get_text (GTK_ENTRY(priv->subject_field)); - - /* don't unref */ - buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body)); - - gtk_text_buffer_get_bounds (buf, &b, &e); - body = gtk_text_buffer_get_text (buf, &b, &e, - FALSE); /* free this one */ - - /* FIXME: Code added just for testing. The final version will - use the send queue provided by tinymail and some - classifier */ - { - TnyList *accounts; - TnyIterator *iter; - TnyAccountStore *account_store; - - accounts = TNY_LIST(tny_simple_list_new ()); - account_store = tny_platform_factory_new_account_store (priv->fact); - tny_account_store_get_accounts (account_store, accounts, - TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); - - iter = tny_list_create_iterator(accounts); - tny_iterator_first (iter); - if (tny_iterator_is_done (iter)) { - /* FIXME: Add error handling through mail operation */ - g_printerr("modest: no transport accounts defined\n"); - g_free (body); - return; - } - transport_account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current(iter)); - g_object_ref (transport_account); - - tny_list_foreach (accounts, (GFunc) g_object_unref, NULL); - g_object_unref (G_OBJECT (accounts)); - g_object_unref (G_OBJECT (iter)); - } - - mail_operation = modest_mail_operation_new (); - - modest_mail_operation_send_new_mail (mail_operation, - transport_account, - from, to, cc, bcc, - subject, body, NULL); - /* Clean up */ - g_object_unref (G_OBJECT (mail_operation)); - g_object_unref (G_OBJECT (transport_account)); - g_free (from); - g_free (body); -} - - -static void -on_toolbar_button_clicked (ModestToolbar *toolbar, ModestToolbarButton button_id, - ModestEditMsgWindow *self) -{ - switch (button_id) { - case MODEST_TOOLBAR_BUTTON_MAIL_SEND: - send_mail (self); - save_settings (self); - gtk_widget_destroy (GTK_WIDGET(self)); - break; - - case MODEST_TOOLBAR_BUTTON_REPLY: - case MODEST_TOOLBAR_BUTTON_REPLY_ALL: - case MODEST_TOOLBAR_BUTTON_FORWARD: - case MODEST_TOOLBAR_BUTTON_SEND_RECEIVE: - case MODEST_TOOLBAR_BUTTON_NEXT: - case MODEST_TOOLBAR_BUTTON_PREV: - case MODEST_TOOLBAR_BUTTON_DELETE: - - default: - g_printerr ("modest: key %d pressed\n", button_id); - } -} - - - - -static ModestToolbar* -toolbar_new (ModestEditMsgWindow *self) -{ - int i; - ModestToolbar *toolbar; - GSList *buttons = NULL; - ModestEditMsgWindowPrivate *priv; - - ModestToolbarButton button_ids[] = { - MODEST_TOOLBAR_BUTTON_MAIL_SEND - }; - - priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); - - for (i = 0 ; i != sizeof(button_ids) / sizeof(ModestToolbarButton); ++i) - buttons = g_slist_append (buttons, GINT_TO_POINTER(button_ids[i])); - - toolbar = modest_toolbar_new (buttons); - g_slist_free (buttons); - - g_signal_connect (G_OBJECT(toolbar), "button_clicked", - G_CALLBACK(on_toolbar_button_clicked), self); - - return toolbar; -} - static void init_window (ModestEditMsgWindow *obj) @@ -378,7 +170,7 @@ init_window (ModestEditMsgWindow *obj) cc_button = gtk_button_new_with_label (_("Cc...")); bcc_button = gtk_button_new_with_label (_("Bcc...")); - priv->from_field = modest_widget_factory_get_combo_box (priv->factory, + priv->from_field = modest_widget_factory_get_combo_box (priv->widget_factory, MODEST_COMBO_BOX_TYPE_TRANSPORTS); priv->to_field = gtk_entry_new_with_max_length (80); priv->cc_field = gtk_entry_new_with_max_length (80); @@ -405,9 +197,6 @@ init_window (ModestEditMsgWindow *obj) main_vbox = gtk_vbox_new (FALSE, 6); - priv->menubar = menubar_new (obj); - priv->toolbar = GTK_WIDGET(toolbar_new (obj)); - gtk_box_pack_start (GTK_BOX(main_vbox), priv->menubar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(main_vbox), priv->toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(main_vbox), header_table, FALSE, FALSE, 6); @@ -426,8 +215,8 @@ modest_edit_msg_window_finalize (GObject *obj) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); - g_object_unref (G_OBJECT(priv->factory)); - priv->factory = NULL; + g_object_unref (G_OBJECT(priv->widget_factory)); + priv->widget_factory = NULL; G_OBJECT_CLASS(parent_class)->finalize (obj); @@ -443,23 +232,62 @@ on_delete_event (GtkWidget *widget, GdkEvent *event, ModestEditMsgWindow *self) } -GtkWidget* +ModestWindow * modest_edit_msg_window_new (ModestWidgetFactory *factory, + TnyAccountStore *account_store, ModestEditType type) { GObject *obj; ModestEditMsgWindowPrivate *priv; + GtkActionGroup *action_group; + GError *error = NULL; g_return_val_if_fail (factory, NULL); g_return_val_if_fail (type < MODEST_EDIT_TYPE_NUM, NULL); -/* g_return_val_if_fail (!(type!=MODEST_EDIT_TYPE_NEW && !msg), NULL); */ obj = g_object_new(MODEST_TYPE_EDIT_MSG_WINDOW, NULL); priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); - g_object_ref (factory); - priv->factory = factory; + priv->widget_factory = g_object_ref (factory); + priv->account_store = g_object_ref (account_store); + + /* ****** */ + priv->ui_manager = gtk_ui_manager_new(); + action_group = gtk_action_group_new ("ModestEditMsgWindowActions"); + + /* Add common actions */ + gtk_action_group_add_actions (action_group, + modest_edit_msg_action_entries, + G_N_ELEMENTS (modest_edit_msg_action_entries), + obj); + gtk_action_group_add_toggle_actions (action_group, + modest_edit_msg_toggle_action_entries, + G_N_ELEMENTS (modest_edit_msg_toggle_action_entries), + obj); + gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, 0); + g_object_unref (action_group); + + /* Load the UI definition */ + gtk_ui_manager_add_ui_from_file (priv->ui_manager, MODEST_UIDIR "modest-edit-msg-window-ui.xml", &error); + if (error != NULL) { + g_warning ("Could not merge modest-edit-msg-window-ui.xml: %s", error->message); + g_error_free (error); + error = NULL; + } + /* ****** */ + + /* Add accelerators */ + gtk_window_add_accel_group (GTK_WINDOW (obj), + gtk_ui_manager_get_accel_group (priv->ui_manager)); + + /* Toolbar / Menubar */ + priv->toolbar = gtk_ui_manager_get_widget (priv->ui_manager, "/EditMsgWindowToolBar"); + priv->menubar = gtk_ui_manager_get_widget (priv->ui_manager, "/EditMsgWindowMenuBar"); + + gtk_toolbar_set_tooltips (GTK_TOOLBAR (priv->toolbar), TRUE); + + /* Init window */ init_window (MODEST_EDIT_MSG_WINDOW(obj)); restore_settings (MODEST_EDIT_MSG_WINDOW(obj)); @@ -471,7 +299,7 @@ modest_edit_msg_window_new (ModestWidgetFactory *factory, g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj); - return GTK_WIDGET (obj); + return (ModestWindow *) (obj); } void @@ -513,3 +341,67 @@ modest_edit_msg_window_set_msg (ModestEditMsgWindow *self, TnyMsg *msg) /* TODO: set attachments */ } + +ModestWidgetFactory * +modest_edit_msg_window_get_widget_factory (ModestEditMsgWindow *edit_window) +{ + ModestEditMsgWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_EDIT_MSG_WINDOW (edit_window), NULL); + + priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE (edit_window); + + return g_object_ref (priv->widget_factory); +} + +TnyAccountStore * +modest_edit_msg_window_get_account_store (ModestEditMsgWindow *edit_window) +{ + ModestEditMsgWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_EDIT_MSG_WINDOW (edit_window), NULL); + + priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE (edit_window); + + return g_object_ref (priv->account_store); +} + +MsgData * +modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *edit_window) +{ + MsgData *data; + ModestAccountData *account_data; + GtkTextBuffer *buf; + GtkTextIter b, e; + ModestEditMsgWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_EDIT_MSG_WINDOW (edit_window), NULL); + + priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE (edit_window); + + account_data = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); + buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)); + gtk_text_buffer_get_bounds (buf, &b, &e); + + /* don't free these (except from) */ + data = g_slice_new0 (MsgData); + data->from = g_strdup_printf ("%s <%s>", account_data->full_name, account_data->email) ; + data->to = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->to_field)); + data->cc = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->cc_field)); + data->bcc = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->bcc_field)); + data->subject = (gchar*) gtk_entry_get_text (GTK_ENTRY(priv->subject_field)); + data->body = gtk_text_buffer_get_text (buf, &b, &e, FALSE); + + return data; +} + +void +modest_edit_msg_window_free_msg_data (ModestEditMsgWindow *edit_window, + MsgData *data) +{ + g_return_if_fail (MODEST_IS_EDIT_MSG_WINDOW (edit_window)); + + g_free (data->from); + g_free (data->body); + g_slice_free (MsgData, data); +} diff --git a/src/gtk/modest-main-window.c b/src/gtk/modest-main-window.c index f993244..c88cee2 100644 --- a/src/gtk/modest-main-window.c +++ b/src/gtk/modest-main-window.c @@ -35,6 +35,7 @@ #include "modest-widget-memory.h" #include "modest-icon-factory.h" #include "modest-ui.h" +#include "modest-main-window-ui.h" #include "modest-account-view-window.h" #include "modest-account-mgr.h" #include "modest-conf.h" @@ -63,7 +64,10 @@ typedef struct _ModestMainWindowPrivate ModestMainWindowPrivate; struct _ModestMainWindowPrivate { GtkUIManager *ui_manager; - + ModestWidgetFactory *widget_factory; + TnyPlatformFactory *factory; + TnyAccountStore *account_store; + GtkWidget *toolbar; GtkWidget *menubar; @@ -71,9 +75,6 @@ struct _ModestMainWindowPrivate { GtkWidget *msg_paned; GtkWidget *main_paned; - ModestWidgetFactory *widget_factory; - TnyPlatformFactory *factory; - ModestHeaderView *header_view; ModestFolderView *folder_view; ModestMsgView *msg_preview; @@ -150,6 +151,9 @@ modest_main_window_init (ModestMainWindow *obj) priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj); priv->factory = modest_tny_platform_factory_get_instance (); + priv->widget_factory = NULL; + priv->ui_manager = NULL; + priv->account_store = NULL; } static void @@ -161,6 +165,14 @@ modest_main_window_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->widget_factory)); priv->widget_factory = NULL; } + if (priv->ui_manager) { + g_object_unref (G_OBJECT(priv->ui_manager)); + priv->ui_manager = NULL; + } + if (priv->account_store) { + g_object_unref (G_OBJECT(priv->account_store)); + priv->account_store = NULL; + } G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -264,15 +276,17 @@ on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMainWindow *self) } -GtkWidget* +ModestWindow * modest_main_window_new (ModestWidgetFactory *widget_factory, - GtkUIManager *ui_manager) + TnyAccountStore *account_store) { GObject *obj; ModestMainWindowPrivate *priv; GtkWidget *main_vbox; GtkWidget *status_hbox; GtkWidget *header_win, *folder_win; + GtkActionGroup *action_group; + GError *error = NULL; g_return_val_if_fail (widget_factory, NULL); @@ -280,7 +294,30 @@ modest_main_window_new (ModestWidgetFactory *widget_factory, priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj); priv->widget_factory = g_object_ref (widget_factory); - priv->ui_manager = g_object_ref (ui_manager); + priv->account_store = g_object_ref (account_store); + + /* ***************** */ + priv->ui_manager = gtk_ui_manager_new(); + action_group = gtk_action_group_new ("ModestMainWindowActions"); + + /* Add common actions */ + gtk_action_group_add_actions (action_group, + modest_action_entries, + G_N_ELEMENTS (modest_action_entries), + obj); + + gtk_ui_manager_insert_action_group (priv->ui_manager, action_group, 0); + g_object_unref (action_group); + + /* Load the UI definition */ + gtk_ui_manager_add_ui_from_file (priv->ui_manager, MODEST_UIDIR "modest-ui.xml", &error); + if (error != NULL) { + g_warning ("Could not merge modest-ui.xml: %s", error->message); + g_error_free (error); + error = NULL; + } + /* *************** */ +/* priv->ui_manager = g_object_ref (ui_manager); */ /* Add accelerators */ gtk_window_add_accel_group (GTK_WINDOW (obj), @@ -350,5 +387,29 @@ modest_main_window_new (ModestWidgetFactory *widget_factory, g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj); - return GTK_WIDGET(obj); + return (ModestWindow *) obj; +} + +ModestWidgetFactory * +modest_main_window_get_widget_factory (ModestMainWindow *main_window) +{ + ModestMainWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (main_window), NULL); + + priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window); + + return g_object_ref (priv->widget_factory); +} + +TnyAccountStore * +modest_main_window_get_account_store (ModestMainWindow *main_window) +{ + ModestMainWindowPrivate *priv; + + g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (main_window), NULL); + + priv = MODEST_MAIN_WINDOW_GET_PRIVATE (main_window); + + return g_object_ref (priv->account_store); } diff --git a/src/gtk/modest-store-widget.h b/src/gtk/modest-store-widget.h index f82c7cd..fc73398 100644 --- a/src/gtk/modest-store-widget.h +++ b/src/gtk/modest-store-widget.h @@ -4,7 +4,6 @@ #ifndef __MODEST_STORE_WIDGET_H__ #define __MODEST_STORE_WIDGET_H__ -#include #include G_BEGIN_DECLS diff --git a/src/gtk/modest-transport-widget.h b/src/gtk/modest-transport-widget.h index b7e5c41..68280a3 100644 --- a/src/gtk/modest-transport-widget.h +++ b/src/gtk/modest-transport-widget.h @@ -4,7 +4,6 @@ #ifndef __MODEST_TRANSPORT_WIDGET_H__ #define __MODEST_TRANSPORT_WIDGET_H__ -#include #include G_BEGIN_DECLS diff --git a/src/maemo/Makefile.am b/src/maemo/Makefile.am index d3ec39e..13458cd 100644 --- a/src/maemo/Makefile.am +++ b/src/maemo/Makefile.am @@ -41,7 +41,16 @@ LDADD = \ $(MODEST_GSTUFF_LIBS) \ $(MODEST_LIBTINYMAIL_GNOME_DESKTOP_LIBS) -EXTRA_DIST=pixmaps/* +EXTRA_DIST=\ + pixmaps/* \ + ui/* -pixmapdir = $(prefix)/share/pixmaps/modest/ +pixmapdir = $(datadir)/pixmaps/modest pixmap_DATA = $(PIXMAP_FILES) + +UI_FILES=\ + ui/modest-ui.xml \ + ui/modest-edit-msg-window-ui.xml + +uidir = $(datadir)/modest/ui +ui_DATA = $(UI_FILES) \ No newline at end of file diff --git a/src/maemo/modest-edit-msg-window.c b/src/maemo/modest-edit-msg-window.c index cefe3fb..39a431ef 100644 --- a/src/maemo/modest-edit-msg-window.c +++ b/src/maemo/modest-edit-msg-window.c @@ -28,16 +28,14 @@ */ #include #include -#include -#include -#include +#include "modest-edit-msg-window.h" +#include "modest-icon-names.h" +#include "modest-icon-factory.h" #include "modest-widget-memory.h" #include "modest-mail-operation.h" #include "modest-tny-platform-factory.h" #include "modest-tny-msg-actions.h" #include -#include - static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass); static void modest_edit_msg_window_init (ModestEditMsgWindow *obj); @@ -53,15 +51,16 @@ enum { typedef struct _ModestEditMsgWindowPrivate ModestEditMsgWindowPrivate; struct _ModestEditMsgWindowPrivate { - ModestWidgetFactory *factory; + ModestWidgetFactory *widget_factory; TnyPlatformFactory *fact; + GtkUIManager *ui_manager; GtkWidget *toolbar, *menubar; GtkWidget *msg_body; GtkWidget *from_field, *to_field, *cc_field, *bcc_field, *subject_field; - GtkUIManager *ui_manager; }; + #define MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_EDIT_MSG_WINDOW, \ ModestEditMsgWindowPrivate)) @@ -121,9 +120,9 @@ modest_edit_msg_window_init (ModestEditMsgWindow *obj) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); priv->fact = modest_tny_platform_factory_get_instance (); - priv->factory = NULL; + priv->widget_factory = NULL; priv->toolbar = NULL; - //priv->menubar = NULL; + priv->menubar = NULL; } @@ -137,8 +136,7 @@ save_settings (ModestEditMsgWindow *self) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); conf = modest_tny_platform_factory_get_modest_conf_instance (priv->fact); - modest_widget_memory_save (conf, G_OBJECT(self), - "modest-edit-msg-window"); + modest_widget_memory_save (conf, G_OBJECT(self), "modest-edit-msg-window"); } @@ -151,133 +149,156 @@ restore_settings (ModestEditMsgWindow *self) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); conf = modest_tny_platform_factory_get_modest_conf_instance (priv->fact); - modest_widget_memory_restore (conf, G_OBJECT(self), - "modest-edit-msg-window"); + modest_widget_memory_restore (conf, G_OBJECT(self), "modest-edit-msg-window"); } - - -static void -send_mail (ModestEditMsgWindow *self) -{ - const gchar *to, *cc, *bcc, *subject; - gchar *body, *from; - ModestEditMsgWindowPrivate *priv; - TnyTransportAccount *transport_account; - ModestMailOperation *mail_operation; - ModestAccountData *data; +/* /\* Our menu, an array of GtkItemFactoryEntry structures that defines each menu item *\/ */ +/* static GtkItemFactoryEntry menu_items[] = { */ +/* { "/_File", NULL, NULL, 0, "" ,NULL}, */ +/* { "/File/_New", "N", NULL, 0, "", GTK_STOCK_NEW }, */ +/* { "/File/_Open", "O", NULL, 0, "", GTK_STOCK_OPEN }, */ +/* { "/File/_Save", "S", NULL, 0, "", GTK_STOCK_SAVE }, */ +/* { "/File/Save _As", NULL, NULL, 0, "", NULL} , */ +/* { "/File/Save Draft", "S", NULL, 0, "",NULL }, */ + + +/* { "/File/sep1", NULL, NULL, 0, "" ,NULL }, */ +/* { "/File/_Quit", "Q", on_menu_quit, 0, "", GTK_STOCK_QUIT }, */ + +/* { "/_Edit", NULL, NULL, 0, "" ,NULL }, */ +/* { "/Edit/_Undo", "Z", NULL, 0, "", GTK_STOCK_UNDO }, */ +/* { "/Edit/_Redo", "Z", NULL, 0, "", GTK_STOCK_REDO }, */ +/* { "/File/sep1", NULL, NULL, 0, "",NULL }, */ +/* { "/Edit/Cut", "X", NULL, 0, "", GTK_STOCK_CUT }, */ +/* { "/Edit/Copy", "C", NULL, 0, "", GTK_STOCK_COPY }, */ +/* { "/Edit/Paste", NULL, NULL, 0, "", GTK_STOCK_PASTE}, */ +/* { "/Edit/sep1", NULL, NULL, 0, "",NULL }, */ +/* { "/Edit/Delete", "Q", NULL, 0, "" ,NULL }, */ +/* { "/Edit/Select all", "A", NULL, 0, "" ,NULL }, */ +/* { "/Edit/Deselect all", "A", NULL, 0, "",NULL }, */ + +/* { "/_View", NULL, NULL, 0, "",NULL }, */ +/* { "/View/To-field", NULL, NULL, 0, "",NULL }, */ - GtkTextBuffer *buf; - GtkTextIter b, e; +/* { "/View/Cc-field:", NULL, NULL, 0, "",NULL }, */ +/* { "/View/Bcc-field:", NULL, NULL, 0, "",NULL }, */ - priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); - data = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); - - /* don't free these (except from) */ - from = g_strdup_printf ("%s <%s>", data->full_name, data->email) ; - to = gtk_entry_get_text (GTK_ENTRY(priv->to_field)); - cc = gtk_entry_get_text (GTK_ENTRY(priv->cc_field)); - bcc = gtk_entry_get_text (GTK_ENTRY(priv->bcc_field)); - subject = gtk_entry_get_text (GTK_ENTRY(priv->subject_field)); - /* don't unref */ - buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body)); +/* { "/_Insert", NULL, NULL, 0, "",NULL }, */ +/* /\* { "/Actions/_Reply", NULL, NULL, 0, "" }, *\/ */ +/* /\* { "/Actions/_Forward", NULL, NULL, 0, "" }, *\/ */ +/* /\* { "/Actions/_Bounce", NULL, NULL, 0, "" }, *\/ */ - gtk_text_buffer_get_bounds (buf, &b, &e); - body = gtk_text_buffer_get_text (buf, &b, &e, - FALSE); /* free this one */ - - /* FIXME: Code added just for testing. The transport_account - should be provided by the account manager, maybe using - _get_current_account () or _get_default_account - (TRANSPORT_ACCOUNT). These methods do not exist currently. */ - { - TnyList *accounts; - TnyIterator *iter; - TnyAccountStore *account_store; - - accounts = TNY_LIST(tny_simple_list_new ()); - account_store = tny_platform_factory_new_account_store (priv->fact); - tny_account_store_get_accounts (account_store, accounts, - TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); - - iter = tny_list_create_iterator(accounts); - tny_iterator_first (iter); - if (tny_iterator_is_done (iter)) { - /* FIXME: Add error handling through mail operation */ - g_printerr("modest: no transport accounts defined\n"); - g_free (body); - return; - } - transport_account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current(iter)); - } +/* { "/_Format", NULL, NULL, 0, "",NULL } */ +/* /\* { "/Options/_Accounts", NULL, on_menu_accounts,0, "" }, *\/ */ +/* /\* { "/Options/_Contacts", NULL, NULL, 0, "" }, *\/ */ - mail_operation = modest_mail_operation_new (); - modest_mail_operation_send_new_mail (mail_operation, - transport_account, - from, to, cc, bcc, - subject, body, NULL); - /* Clean up */ - g_object_unref (mail_operation); - g_free (from); - g_free (body); -} +/* /\* { "/_Help", NULL, NULL, 0, "" }, *\/ */ +/* /\* { "/_Help/About", NULL, on_menu_about, 0, "", GTK_STOCK_ABOUT}, *\/ */ +/* }; */ +/* static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); */ -static void -on_toolbar_button_clicked (ModestToolbar *toolbar, ModestToolbarButton button_id, - ModestEditMsgWindow *self) -{ - switch (button_id) { - case MODEST_TOOLBAR_BUTTON_MAIL_SEND: - send_mail (self); - save_settings (self); - gtk_widget_destroy (GTK_WIDGET(self)); - break; - - case MODEST_TOOLBAR_BUTTON_REPLY: - case MODEST_TOOLBAR_BUTTON_REPLY_ALL: - case MODEST_TOOLBAR_BUTTON_FORWARD: - case MODEST_TOOLBAR_BUTTON_SEND_RECEIVE: - case MODEST_TOOLBAR_BUTTON_NEXT: - case MODEST_TOOLBAR_BUTTON_PREV: - case MODEST_TOOLBAR_BUTTON_DELETE: - - default: - g_printerr ("modest: key %d pressed\n", button_id); - } -} - - - -static ModestToolbar* -toolbar_new (ModestEditMsgWindow *self) -{ - int i; - ModestToolbar *toolbar; - GSList *buttons = NULL; - ModestEditMsgWindowPrivate *priv; - - ModestToolbarButton button_ids[] = { - MODEST_TOOLBAR_BUTTON_MAIL_SEND - }; +/* static void */ +/* send_mail (ModestEditMsgWindow *self) */ +/* { */ +/* const gchar *to, *cc, *bcc, *subject; */ +/* gchar *body, *from; */ +/* ModestEditMsgWindowPrivate *priv; */ +/* TnyTransportAccount *transport_account; */ +/* ModestMailOperation *mail_operation; */ +/* ModestAccountData *data; */ - priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); - - for (i = 0 ; i != sizeof(button_ids) / sizeof(ModestToolbarButton); ++i) - buttons = g_slist_append (buttons, GINT_TO_POINTER(button_ids[i])); +/* GtkTextBuffer *buf; */ +/* GtkTextIter b, e; */ - toolbar = modest_toolbar_new (buttons); - g_slist_free (buttons); - - g_signal_connect (G_OBJECT(toolbar), "button_clicked", - G_CALLBACK(on_toolbar_button_clicked), self); +/* priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(self); */ +/* data = modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field)); */ + +/* /\* don't free these (except from) *\/ */ +/* from = g_strdup_printf ("%s <%s>", data->full_name, data->email) ; */ +/* to = gtk_entry_get_text (GTK_ENTRY(priv->to_field)); */ +/* cc = gtk_entry_get_text (GTK_ENTRY(priv->cc_field)); */ +/* bcc = gtk_entry_get_text (GTK_ENTRY(priv->bcc_field)); */ +/* subject = gtk_entry_get_text (GTK_ENTRY(priv->subject_field)); */ - return toolbar; -} +/* /\* don't unref *\/ */ +/* buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body)); */ + +/* gtk_text_buffer_get_bounds (buf, &b, &e); */ +/* body = gtk_text_buffer_get_text (buf, &b, &e, */ +/* FALSE); /\* free this one *\/ */ + +/* /\* FIXME: Code added just for testing. The final version will */ +/* use the send queue provided by tinymail and some */ +/* classifier *\/ */ +/* { */ +/* TnyList *accounts; */ +/* TnyIterator *iter; */ +/* TnyAccountStore *account_store; */ + +/* accounts = TNY_LIST(tny_simple_list_new ()); */ +/* account_store = tny_platform_factory_new_account_store (priv->fact); */ +/* tny_account_store_get_accounts (account_store, accounts, */ +/* TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); */ + +/* iter = tny_list_create_iterator(accounts); */ +/* tny_iterator_first (iter); */ +/* if (tny_iterator_is_done (iter)) { */ +/* /\* FIXME: Add error handling through mail operation *\/ */ +/* g_printerr("modest: no transport accounts defined\n"); */ +/* g_free (body); */ +/* return; */ +/* } */ +/* transport_account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current(iter)); */ +/* g_object_ref (transport_account); */ + +/* tny_list_foreach (accounts, (GFunc) g_object_unref, NULL); */ +/* g_object_unref (G_OBJECT (accounts)); */ +/* g_object_unref (G_OBJECT (iter)); */ +/* } */ + +/* mail_operation = modest_mail_operation_new (); */ + +/* modest_mail_operation_send_new_mail (mail_operation, */ +/* transport_account, */ +/* from, to, cc, bcc, */ +/* subject, body, NULL); */ +/* /\* Clean up *\/ */ +/* g_object_unref (G_OBJECT (mail_operation)); */ +/* g_object_unref (G_OBJECT (transport_account)); */ +/* g_free (from); */ +/* g_free (body); */ +/* } */ + + +/* static void */ +/* on_toolbar_button_clicked (ModestToolbar *toolbar, ModestToolbarButton button_id, */ +/* ModestEditMsgWindow *self) */ +/* { */ +/* switch (button_id) { */ +/* case MODEST_TOOLBAR_BUTTON_MAIL_SEND: */ +/* send_mail (self); */ +/* save_settings (self); */ +/* gtk_widget_destroy (GTK_WIDGET(self)); */ +/* break; */ + +/* case MODEST_TOOLBAR_BUTTON_REPLY: */ +/* case MODEST_TOOLBAR_BUTTON_REPLY_ALL: */ +/* case MODEST_TOOLBAR_BUTTON_FORWARD: */ +/* case MODEST_TOOLBAR_BUTTON_SEND_RECEIVE: */ +/* case MODEST_TOOLBAR_BUTTON_NEXT: */ +/* case MODEST_TOOLBAR_BUTTON_PREV: */ +/* case MODEST_TOOLBAR_BUTTON_DELETE: */ + +/* default: */ +/* g_printerr ("modest: key %d pressed\n", button_id); */ +/* } */ +/* } */ + static void @@ -294,12 +315,12 @@ init_window (ModestEditMsgWindow *obj) cc_button = gtk_button_new_with_label (_("Cc...")); bcc_button = gtk_button_new_with_label (_("Bcc...")); - priv->from_field = modest_widget_factory_get_combo_box (priv->factory, + priv->from_field = modest_widget_factory_get_combo_box (priv->widget_factory, MODEST_COMBO_BOX_TYPE_TRANSPORTS); - priv->to_field = gtk_entry_new_with_max_length (40); - priv->cc_field = gtk_entry_new_with_max_length (40); - priv->bcc_field = gtk_entry_new_with_max_length (40); - priv->subject_field = gtk_entry_new_with_max_length (40); + priv->to_field = gtk_entry_new_with_max_length (80); + priv->cc_field = gtk_entry_new_with_max_length (80); + priv->bcc_field = gtk_entry_new_with_max_length (80); + priv->subject_field = gtk_entry_new_with_max_length (80); header_table = gtk_table_new (5,2, FALSE); @@ -321,14 +342,11 @@ init_window (ModestEditMsgWindow *obj) main_vbox = gtk_vbox_new (FALSE, 6); - //priv->menubar = menubar_new (obj); - priv->toolbar = GTK_WIDGET(toolbar_new (obj)); - - //gtk_box_pack_start (GTK_BOX(main_vbox), priv->menubar, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(main_vbox), priv->menubar, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(main_vbox), priv->toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(main_vbox), header_table, FALSE, FALSE, 6); gtk_box_pack_start (GTK_BOX(main_vbox), priv->msg_body, TRUE, TRUE, 6); - gtk_box_pack_start (GTK_BOX(main_vbox), priv->toolbar, FALSE, FALSE, 0); - + gtk_widget_show_all (GTK_WIDGET(main_vbox)); gtk_container_add (GTK_CONTAINER(obj), main_vbox); } @@ -342,8 +360,8 @@ modest_edit_msg_window_finalize (GObject *obj) priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); - g_object_unref (G_OBJECT(priv->factory)); - priv->factory = NULL; + g_object_unref (G_OBJECT(priv->widget_factory)); + priv->widget_factory = NULL; G_OBJECT_CLASS(parent_class)->finalize (obj); @@ -360,7 +378,9 @@ on_delete_event (GtkWidget *widget, GdkEvent *event, ModestEditMsgWindow *self) GtkWidget* -modest_edit_msg_window_new (ModestWidgetFactory *factory, ModestEditType type) +modest_edit_msg_window_new (ModestWidgetFactory *factory, + GtkUIManager *ui_manager, + ModestEditType type) { GObject *obj; ModestEditMsgWindowPrivate *priv; @@ -371,9 +391,21 @@ modest_edit_msg_window_new (ModestWidgetFactory *factory, ModestEditType type) obj = g_object_new(MODEST_TYPE_EDIT_MSG_WINDOW, NULL); priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj); - g_object_ref (factory); - priv->factory = factory; + priv->widget_factory = g_object_ref (factory); + priv->ui_manager = g_object_ref (ui_manager); + + /* Add accelerators */ + gtk_window_add_accel_group (GTK_WINDOW (obj), + gtk_ui_manager_get_accel_group (priv->ui_manager)); + + /* Toolbar / Menubar */ + priv->toolbar = gtk_ui_manager_get_widget (priv->ui_manager, "/EditMsgWindowToolBar"); + priv->menubar = gtk_ui_manager_get_widget (priv->ui_manager, "/EditMsgWindowMenuBar"); + + gtk_toolbar_set_tooltips (GTK_TOOLBAR (priv->toolbar), TRUE); + + /* Init window */ init_window (MODEST_EDIT_MSG_WINDOW(obj)); restore_settings (MODEST_EDIT_MSG_WINDOW(obj)); @@ -384,13 +416,10 @@ modest_edit_msg_window_new (ModestWidgetFactory *factory, ModestEditType type) g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj); - return GTK_WIDGET (obj); } - - void modest_edit_msg_window_set_msg (ModestEditMsgWindow *self, TnyMsg *msg) { diff --git a/src/modest-formatter.c b/src/modest-formatter.c index 7a23329..09390a7 100644 --- a/src/modest-formatter.c +++ b/src/modest-formatter.c @@ -27,8 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include #include #include diff --git a/src/modest-icon-factory.h b/src/modest-icon-factory.h index a96f540..5a4437e 100644 --- a/src/modest-icon-factory.h +++ b/src/modest-icon-factory.h @@ -33,7 +33,7 @@ #ifndef __MODEST_ICON_FACTORY_H__ #define __MODEST_ICON_FACTORY_H__ -#include +#include /** * modest_icon_factory_init diff --git a/src/modest-main.c b/src/modest-main.c index 0b2b0c1..378f7bd 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -171,7 +171,7 @@ start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc, gint retval = 0; #ifndef OLD_UI_STUFF - GtkWidget *win; + ModestWindow *win; #endif modest_ui = MODEST_UI(modest_ui_new (account_store)); @@ -204,7 +204,7 @@ start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc, if (win) { TnyDevice *device; - gtk_widget_show (win); + gtk_widget_show (GTK_WIDGET (win)); /* Go online */ device = tny_account_store_get_device (account_store); diff --git a/src/modest-tny-msg-actions.c b/src/modest-tny-msg-actions.c index b7dd0fc..ccce454 100644 --- a/src/modest-tny-msg-actions.c +++ b/src/modest-tny-msg-actions.c @@ -28,7 +28,6 @@ */ #include -#include #include #include #include diff --git a/src/modest-ui-actions.h b/src/modest-ui-actions.h new file mode 100644 index 0000000..0cc3154 --- /dev/null +++ b/src/modest-ui-actions.h @@ -0,0 +1,102 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_UI_ACTIONS_H__ +#define __MODEST_UI_ACTIONS_H__ + +#include "modest-main-window.h" +#include "modest-edit-msg-window.h" + +G_BEGIN_DECLS + +/* Menu & toolbar actions */ +void _modest_ui_actions_on_about (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_delete (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_quit (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_accounts (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_new_msg (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_reply (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_forward (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_reply_all (GtkWidget *widget, ModestMainWindow *main_window); + +void _modest_ui_actions_on_next (GtkWidget *widget, ModestMainWindow *main_window); + +/* Widget actions */ +void _modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, + TnyHeader *header, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, + TnyFolder *folder, + gboolean selected, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_connection_changed (TnyDevice *device, + gboolean online, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, + ModestItemType type, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, + const gchar *msg, + gint num, + gint total, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, + const gchar* link, + ModestMainWindow *main_window); + + +void _modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, + const gchar* link, + ModestMainWindow *main_window); + +void _modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, + int index, + ModestMainWindow *main_window); + + +void _modest_ui_actions_on_send (GtkWidget *widget, + ModestEditMsgWindow *edit_window); + +G_END_DECLS +#endif /* __MODEST_UI_ACTIONS_H__ */ diff --git a/src/modest-ui-priv.h b/src/modest-ui-priv.h new file mode 100644 index 0000000..e890ea0 --- /dev/null +++ b/src/modest-ui-priv.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_UI_PRIV_H__ +#define __MODEST_UI_PRIV_H__ + +#include +#include +#include "modest-widget-factory.h" +#include "modest-window.h" + +G_BEGIN_DECLS + +typedef struct _ModestUIPrivate ModestUIPrivate; +struct _ModestUIPrivate { + ModestWidgetFactory *widget_factory; + TnyAccountStore *account_store; + ModestWindow *main_window; + GtkUIManager *ui_manager; +}; + +G_END_DECLS +#endif /* __MODEST_UI_PRIV_H__ */ diff --git a/src/modest-ui.c b/src/modest-ui.c index 56a98b2..1136a92 100644 --- a/src/modest-ui.c +++ b/src/modest-ui.c @@ -27,44 +27,27 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include - #ifdef HAVE_CONFIG_H #include #endif /*HAVE_CONFIG_H*/ #include -#include -#include -#include +#include "modest-ui-priv.h" #include "modest-ui.h" -#include "modest-tny-account-store.h" -#include "modest-account-mgr.h" -#include "modest-widget-factory.h" +#include "modest-ui-actions.h" +#include "modest-icon-names.h" #include "modest-tny-platform-factory.h" - -#include -#include "modest-edit-msg-window.h" #include "modest-account-view-window.h" -#include "modest-icon-names.h" #include "modest-main-window.h" - -typedef struct _ModestUIPrivate ModestUIPrivate; -struct _ModestUIPrivate { - ModestWidgetFactory *widget_factory; - TnyAccountStore *account_store; - GtkWidget *main_window; -}; +#include +#include #define MODEST_UI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_UI, \ ModestUIPrivate)) typedef struct _GetMsgAsyncHelper { - ModestUIPrivate *priv; + ModestMainWindow *main_window; TnyIterator *iter; GFunc func; gpointer user_data; @@ -92,8 +75,7 @@ static void modest_ui_finalize (GObject *obj); static void register_stock_icons (); static void connect_signals (ModestUI *self); -static void connect_main_window_signals (ModestUI *self); -static GtkUIManager *create_ui_manager (); +/* static GtkUIManager *create_ui_manager (); */ static void reply_forward_func (gpointer data, gpointer user_data); static void read_msg_func (gpointer data, gpointer user_data); @@ -104,122 +86,14 @@ static void get_msg_cb (TnyFolder *folder, static void reply_forward (GtkWidget *widget, ReplyForwardAction action, - ModestUIPrivate *priv); - -/* Menu & toolbar actions */ -static void modest_ui_actions_on_about (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_delete (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_quit (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_accounts (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_new_msg (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_reply (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_forward (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_reply_all (GtkWidget *widget, ModestUIPrivate *priv); - -static void modest_ui_actions_on_next (GtkWidget *widget, ModestUIPrivate *priv); - -/* Widget actions */ -static void modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, - TnyHeader *header, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, - TnyFolder *folder, - gboolean selected, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, - const gchar* account_name, - gchar **password, - gboolean *cancel, - gboolean *remember, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_connection_changed (TnyDevice *device, - gboolean online, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, - ModestItemType type, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, - const gchar *msg, - gint num, - gint total, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, - const gchar* link, - ModestUIPrivate *priv); - - -static void modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, - const gchar* link, - ModestUIPrivate *priv); - -static void modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, - int index, - ModestUIPrivate *priv); + ModestMainWindow *main_window); - -/* Action entries */ -static const GtkActionEntry modest_action_entries [] = { - - /* Toplevel */ - { "File", NULL, N_("_File") }, - { "Edit", NULL, N_("_Edit") }, - { "Actions", NULL, N_("_Actions") }, - { "Options", NULL, N_("_Options") }, - { "Help", NULL, N_("_Help") }, - - /* FILE menu */ - { "FileNew", GTK_STOCK_NEW, N_("_New"), "N", N_("Compose new message"), G_CALLBACK (modest_ui_actions_on_new_msg) }, - { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "O", N_("Open a message"), NULL }, - { "FileSave", GTK_STOCK_SAVE, N_("_Save"), "S", N_("Save a message"), NULL }, - { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("Save _As"), NULL, N_("Save a message as"), NULL }, - { "FileQuit", GTK_STOCK_QUIT, N_("_Quit"), "Q", N_("Exit the application"), G_CALLBACK (modest_ui_actions_on_quit) }, - - /* EDIT menu */ - { "EditUndo", GTK_STOCK_UNDO, N_("_Undo"), "Z", N_("Undo last action"), NULL }, - { "EditRedo", GTK_STOCK_REDO, N_("_Redo"), "Z", N_("Redo previous action"), NULL }, - { "EditCut", GTK_STOCK_CUT, N_("Cut"), "X", N_("_Cut"), NULL }, - { "EditCopy", GTK_STOCK_COPY, N_("Copy"), "C", N_("Copy"), NULL }, - { "EditPaste", GTK_STOCK_PASTE, N_("Paste"), "V", N_("Paste"), NULL }, - { "EditDelete", GTK_STOCK_DELETE, N_("_Delete"), "Q", N_("Delete"), NULL }, - { "EditSelectAll", NULL, N_("Select all"), "A", N_("Select all"), NULL }, - { "EditDeselectAll", NULL, N_("Deselect all"), "A", N_("Deselect all"), NULL }, - - /* ACTIONS menu */ - { "ActionsNew", MODEST_STOCK_MAIL_SEND, N_("_New Message"), NULL, N_("Compose a new message"), G_CALLBACK (modest_ui_actions_on_new_msg) }, - { "ActionsReply", MODEST_STOCK_REPLY, N_("_Reply"), NULL, N_("Reply to a message"), G_CALLBACK (modest_ui_actions_on_reply) }, - { "ActionsReplyAll", MODEST_STOCK_REPLY_ALL, N_("Reply to all"), NULL, N_("Reply to all"), G_CALLBACK (modest_ui_actions_on_reply_all) }, - { "ActionsForward", MODEST_STOCK_FORWARD, N_("_Forward"), NULL, N_("Forward a message"), G_CALLBACK (modest_ui_actions_on_forward) }, - { "ActionsBounce", NULL, N_("_Bounce"), NULL, N_("Bounce a message"), NULL }, - { "ActionsSendReceive", MODEST_STOCK_SEND_RECEIVE, N_("Send/Receive"), NULL, N_("Send and receive messages"), NULL }, - { "ActionsDelete", MODEST_STOCK_DELETE, N_("Delete message"), NULL, N_("Delete messages"), G_CALLBACK (modest_ui_actions_on_delete) }, - - /* GOTO menu */ - { "GotoPrevious", MODEST_STOCK_PREV, N_("Previous"), NULL, N_("Go to previous message"), NULL }, - { "GotoNext", MODEST_STOCK_NEXT, N_("Next"), NULL, N_("Go to next message"), G_CALLBACK (modest_ui_actions_on_next) }, - - /* OPTIONS menu */ - { "OptionsAccounts", NULL, N_("_Accounts"), NULL, N_("Manage accounts"), G_CALLBACK (modest_ui_actions_on_accounts) }, - { "OptionsContacts", NULL, N_("_Contacts"), NULL, N_("Manage contacts"), NULL }, - - /* HELP menu */ - { "HelpAbout", GTK_STOCK_ABOUT, N_("About"), NULL, N_("About Modest"), G_CALLBACK (modest_ui_actions_on_about) }, -}; +static void _modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, + const gchar* account_name, + gchar **password, + gboolean *cancel, + gboolean *remember, + ModestMainWindow *main_window); GType modest_ui_get_type (void) @@ -283,6 +157,11 @@ modest_ui_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->widget_factory)); priv->widget_factory = NULL; } + + if (priv->ui_manager) { + g_object_unref (G_OBJECT(priv->ui_manager)); + priv->ui_manager = NULL; + } G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -317,8 +196,9 @@ modest_ui_new (TnyAccountStore *account_store) return NULL; } - /* Connect signals */ - connect_signals (MODEST_UI (obj)); + /* Register our own icons as stock icons in order to + use them with the UI manager */ + register_stock_icons (); return MODEST_UI(obj); } @@ -332,34 +212,21 @@ on_main_window_destroy (GtkObject *widget, ModestUI *self) } -GtkWidget* +ModestWindow * modest_ui_main_window (ModestUI *self) { ModestUIPrivate *priv; - GtkUIManager *ui_manager; g_return_val_if_fail (self, NULL); priv = MODEST_UI_GET_PRIVATE(self); if (!priv->main_window) { - TnyDevice *device; - - /* Register our own icons as stock icons in order to - use them with the UI manager */ - register_stock_icons (); - - /* Create UI manager */ - ui_manager = create_ui_manager (self); /* Create main window */ - priv->main_window = modest_main_window_new (priv->widget_factory, ui_manager); - g_signal_connect (G_OBJECT(priv->main_window), "destroy", - G_CALLBACK(on_main_window_destroy), self); - - /* Connect Main Window signals */ - connect_main_window_signals (self); + priv->main_window = modest_main_window_new (priv->widget_factory, + priv->account_store); - g_object_unref (G_OBJECT (ui_manager)); + connect_signals (self); } if (!priv->main_window) @@ -368,35 +235,24 @@ modest_ui_main_window (ModestUI *self) return priv->main_window; } -static GtkUIManager * -create_ui_manager (ModestUI *self) +ModestWindow * +modest_ui_edit_window (ModestUI *self, ModestEditType edit_type) { - GtkUIManager *ui_manager; - GtkActionGroup *action_group; - GError *error = NULL; ModestUIPrivate *priv; + ModestWindow *edit_window; + g_return_val_if_fail (self, NULL); priv = MODEST_UI_GET_PRIVATE(self); - /* Create UI manager */ - ui_manager = gtk_ui_manager_new(); - - /* Create action group */ - action_group = gtk_action_group_new ("ModestMainWindowActions"); - gtk_action_group_add_actions (action_group, - modest_action_entries, - G_N_ELEMENTS (modest_action_entries), - priv); - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - g_object_unref (action_group); - - /* Load the UI definition */ - gtk_ui_manager_add_ui_from_file (ui_manager, MODEST_UIDIR "modest-ui.xml", &error); - if (error != NULL) { - g_warning ("Could not merge modest-ui.xml: %s", error->message); - g_error_free (error); - } - return ui_manager; + /* Create window */ + edit_window = modest_edit_msg_window_new (priv->widget_factory, + priv->account_store, + edit_type); + + /* Connect Edit Window signals */ +/* connect_edit_window_signals (self); */ + + return edit_window; } /* @@ -495,75 +351,74 @@ connect_signals (ModestUI *self) /* folder view */ g_signal_connect (G_OBJECT(folder_view), "folder_selection_changed", - G_CALLBACK(modest_ui_actions_on_folder_selection_changed), - priv); + G_CALLBACK(_modest_ui_actions_on_folder_selection_changed), + priv->main_window); /* g_signal_connect (G_OBJECT(folder_view), "key-press-event", */ /* G_CALLBACK(on_folder_key_press_event), priv->widget_factory); */ /* header view */ g_signal_connect (G_OBJECT(header_view), "status_update", - G_CALLBACK(modest_ui_actions_on_header_status_update), - priv); + G_CALLBACK(_modest_ui_actions_on_header_status_update), + priv->main_window); g_signal_connect (G_OBJECT(header_view), "header_selected", - G_CALLBACK(modest_ui_actions_on_header_selected), - priv); + G_CALLBACK(_modest_ui_actions_on_header_selected), + priv->main_window); g_signal_connect (G_OBJECT(header_view), "item_not_found", - G_CALLBACK(modest_ui_actions_on_item_not_found), - priv); + G_CALLBACK(_modest_ui_actions_on_item_not_found), + priv->main_window); /* msg preview */ g_signal_connect (G_OBJECT(msg_view), "link_clicked", - G_CALLBACK(modest_ui_actions_on_msg_link_clicked), - priv); + G_CALLBACK(_modest_ui_actions_on_msg_link_clicked), + priv->main_window); g_signal_connect (G_OBJECT(msg_view), "link_hover", - G_CALLBACK(modest_ui_actions_on_msg_link_hover), - priv); + G_CALLBACK(_modest_ui_actions_on_msg_link_hover), + priv->main_window); g_signal_connect (G_OBJECT(msg_view), "attachment_clicked", - G_CALLBACK(modest_ui_actions_on_msg_attachment_clicked), - priv); + G_CALLBACK(_modest_ui_actions_on_msg_attachment_clicked), + priv->main_window); /* Device */ g_signal_connect (G_OBJECT(device), "connection_changed", - G_CALLBACK(modest_ui_actions_on_connection_changed), - priv); + G_CALLBACK(_modest_ui_actions_on_connection_changed), + priv->main_window); g_signal_connect (G_OBJECT(toggle), "toggled", - G_CALLBACK(modest_ui_actions_on_online_toggle_toggled), - priv); + G_CALLBACK(_modest_ui_actions_on_online_toggle_toggled), + priv->main_window); - /* Init toggle in correct state */ - modest_ui_actions_on_connection_changed (device, - tny_device_is_online (device), - priv); -} - - -static void -connect_main_window_signals (ModestUI *self) -{ - ModestUIPrivate *priv; - - priv = MODEST_UI_GET_PRIVATE(self); - /* account store */ g_signal_connect (G_OBJECT (priv->account_store), "password_requested", - G_CALLBACK(modest_ui_actions_on_password_requested), - priv); + G_CALLBACK(_modest_ui_actions_on_password_requested), + priv->main_window); + + /* Destroy window */ + g_signal_connect (G_OBJECT(priv->main_window), + "destroy", + G_CALLBACK(on_main_window_destroy), + NULL); + + + /* Init toggle in correct state */ + _modest_ui_actions_on_connection_changed (device, + tny_device_is_online (device), + MODEST_MAIN_WINDOW (priv->main_window)); } + /* ***************************************************************** */ /* M O D E S T U I A C T I O N S */ /* ***************************************************************** */ -static void -modest_ui_actions_on_about (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_about (GtkWidget *widget, + ModestMainWindow *main_window) { GtkWidget *about; const gchar *authors[] = { "Dirk-Jan C. Binnema ", NULL - }; + }; about = gtk_about_dialog_new (); gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), PACKAGE_NAME); gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about),PACKAGE_VERSION); @@ -582,9 +437,9 @@ modest_ui_actions_on_about (GtkWidget *widget, gtk_widget_destroy(about); } -static void -modest_ui_actions_on_delete (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_delete (GtkWidget *widget, + ModestMainWindow *main_window) { ModestWidgetFactory *widget_factory; ModestHeaderView *header_view; @@ -592,8 +447,10 @@ modest_ui_actions_on_delete (GtkWidget *widget, TnyIterator *iter; GtkTreeModel *model; - header_view = modest_widget_factory_get_header_view (priv->widget_factory); + widget_factory = modest_main_window_get_widget_factory (main_window); + header_view = modest_widget_factory_get_header_view (widget_factory); header_list = modest_header_view_get_selected_headers (header_view); + g_object_unref (G_OBJECT(widget_factory)); if (header_list) { iter = tny_list_create_iterator (header_list); @@ -633,48 +490,61 @@ modest_ui_actions_on_delete (GtkWidget *widget, } } -static void -modest_ui_actions_on_quit (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_quit (GtkWidget *widget, + ModestMainWindow *main_window) { /* FIXME: save size of main window */ /* save_sizes (main_window); */ - gtk_widget_destroy (GTK_WIDGET (priv->main_window)); + gtk_widget_destroy (GTK_WIDGET (main_window)); } -static void -modest_ui_actions_on_accounts (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_accounts (GtkWidget *widget, + ModestMainWindow *main_window) { GtkWidget *account_win; + ModestWidgetFactory *widget_factory; - account_win = modest_account_view_window_new (priv->widget_factory); + widget_factory = modest_main_window_get_widget_factory (main_window); + account_win = modest_account_view_window_new (widget_factory); + g_object_unref (G_OBJECT(widget_factory)); gtk_window_set_transient_for (GTK_WINDOW (account_win), - GTK_WINDOW (priv->main_window)); + GTK_WINDOW (main_window)); gtk_widget_show (account_win); } -static void -modest_ui_actions_on_new_msg (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_new_msg (GtkWidget *widget, + ModestMainWindow *main_window) { - GtkWidget *msg_win; + ModestWindow *msg_win; + ModestWidgetFactory *widget_factory; + TnyAccountStore *account_store; - msg_win = modest_edit_msg_window_new (priv->widget_factory, + widget_factory = modest_main_window_get_widget_factory (main_window); + account_store = modest_main_window_get_account_store (main_window); + msg_win = modest_edit_msg_window_new (widget_factory, + account_store, MODEST_EDIT_TYPE_NEW); - gtk_widget_show (msg_win); + g_object_unref (G_OBJECT (widget_factory)); + g_object_unref (G_OBJECT (account_store)); + + gtk_widget_show (GTK_WIDGET (msg_win)); } static void reply_forward_func (gpointer data, gpointer user_data) { + ModestWidgetFactory *widget_factory; TnyHeader *new_header; TnyMsg *msg, *new_msg; + TnyAccountStore *account_store; GetMsgAsyncHelper *helper; ReplyForwardHelper *rf_helper; - GtkWidget *msg_win; + GtkWindow *msg_win; ModestEditType edit_type; msg = TNY_MSG (data); @@ -708,14 +578,19 @@ reply_forward_func (gpointer data, gpointer user_data) g_object_unref (G_OBJECT (new_header)); /* Show edit window */ - msg_win = modest_edit_msg_window_new (helper->priv->widget_factory, - edit_type); + widget_factory = modest_main_window_get_widget_factory (helper->main_window); + account_store = modest_main_window_get_account_store (helper->main_window); + msg_win = modest_edit_msg_window_new (widget_factory, + account_store, + MODEST_EDIT_TYPE_NEW); + g_object_unref (G_OBJECT (widget_factory)); + g_object_unref (G_OBJECT (account_store)); modest_edit_msg_window_set_msg (MODEST_EDIT_MSG_WINDOW (msg_win), new_msg); - gtk_widget_show (msg_win); + gtk_widget_show (GTK_WIDGET (msg_win)); /* Clean */ - g_object_unref (new_msg); + g_object_unref (G_OBJECT (new_msg)); g_free (rf_helper->from); g_slice_free (ReplyForwardHelper, rf_helper); } @@ -726,9 +601,10 @@ reply_forward_func (gpointer data, gpointer user_data) static void reply_forward (GtkWidget *widget, ReplyForwardAction action, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { ModestHeaderView *header_view; + ModestWidgetFactory *widget_factory; TnyList *header_list; guint reply_forward_type; ModestConf *conf; @@ -751,8 +627,10 @@ reply_forward (GtkWidget *widget, g_free (key); /* Get the list of headers */ - header_view = modest_widget_factory_get_header_view (priv->widget_factory); + widget_factory = modest_main_window_get_widget_factory (main_window); + header_view = modest_widget_factory_get_header_view (widget_factory); header_list = modest_header_view_get_selected_headers (header_view); + g_object_unref (G_OBJECT(widget_factory)); if (!header_list) return; @@ -772,7 +650,7 @@ reply_forward (GtkWidget *widget, rf_helper->from = from; helper = g_slice_new0 (GetMsgAsyncHelper); - helper->priv = priv; + helper->main_window = main_window; helper->func = reply_forward_func; helper->iter = tny_list_create_iterator (header_list); helper->user_data = rf_helper; @@ -787,37 +665,42 @@ reply_forward (GtkWidget *widget, g_object_unref (G_OBJECT (folder)); } -static void -modest_ui_actions_on_reply (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_reply (GtkWidget *widget, + ModestMainWindow *main_window) { - reply_forward (widget, ACTION_REPLY, priv); + reply_forward (widget, ACTION_REPLY, main_window); } -static void -modest_ui_actions_on_forward (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_forward (GtkWidget *widget, + ModestMainWindow *main_window) { - reply_forward (widget, ACTION_FORWARD, priv); + reply_forward (widget, ACTION_FORWARD, main_window); } -static void -modest_ui_actions_on_reply_all (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_reply_all (GtkWidget *widget, + ModestMainWindow *main_window) { - reply_forward (widget, ACTION_REPLY_TO_ALL, priv); + reply_forward (widget, ACTION_REPLY_TO_ALL, main_window); } -static void -modest_ui_actions_on_next (GtkWidget *widget, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_next (GtkWidget *widget, + ModestMainWindow *main_window) { ModestHeaderView *header_view; + ModestWidgetFactory *widget_factory; + + widget_factory = modest_main_window_get_widget_factory (main_window); + header_view = modest_widget_factory_get_header_view (widget_factory); + g_object_unref (G_OBJECT(widget_factory)); - header_view = modest_widget_factory_get_header_view (priv->widget_factory); modest_header_view_select_next (header_view); } + /* * Marks a message as read and passes it to the msg preview widget */ @@ -825,6 +708,7 @@ static void read_msg_func (gpointer data, gpointer user_data) { ModestMsgView *msg_view; + ModestWidgetFactory *widget_factory; TnyMsg *msg; TnyHeader *header; GetMsgAsyncHelper *helper; @@ -840,7 +724,9 @@ read_msg_func (gpointer data, gpointer user_data) g_object_unref (G_OBJECT (header)); /* Set message on msg view */ - msg_view = modest_widget_factory_get_msg_preview (helper->priv->widget_factory); + widget_factory = modest_main_window_get_widget_factory (helper->main_window); + msg_view = modest_widget_factory_get_msg_preview (widget_factory); + g_object_unref (G_OBJECT(widget_factory)); modest_msg_view_set_message (msg_view, msg); } @@ -862,9 +748,14 @@ get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err, gpointer user_data) if (*err && ((*err)->code == TNY_FOLDER_ERROR_GET_MSG)) { ModestHeaderView *header_view; - - header_view = modest_widget_factory_get_header_view (helper->priv->widget_factory); - modest_ui_actions_on_item_not_found (header_view, MODEST_ITEM_TYPE_MESSAGE, helper->priv); + ModestWidgetFactory *widget_factory; + + widget_factory = modest_main_window_get_widget_factory (helper->main_window); + header_view = modest_widget_factory_get_header_view (widget_factory); + g_object_unref (G_OBJECT (widget_factory)); + _modest_ui_actions_on_item_not_found (header_view, + MODEST_ITEM_TYPE_MESSAGE, + helper->main_window); return; } @@ -889,10 +780,10 @@ get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err, gpointer user_data) get_msg_cb, helper); } -static void -modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, +void +_modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, TnyHeader *header, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { TnyFolder *folder; GetMsgAsyncHelper *helper; @@ -910,7 +801,7 @@ modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, /* Fill helper data */ helper = g_slice_new0 (GetMsgAsyncHelper); - helper->priv = priv; + helper->main_window = main_window; helper->iter = tny_list_create_iterator (list); helper->func = read_msg_func; @@ -923,20 +814,22 @@ modest_ui_actions_on_header_selected (ModestHeaderView *folder_view, g_object_unref (G_OBJECT (folder)); } -static void -modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, +void +_modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, TnyFolder *folder, gboolean selected, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { GtkLabel *folder_info_label; TnyPlatformFactory *factory; gchar *txt; ModestConf *conf; ModestHeaderView *header_view; + ModestWidgetFactory *widget_factory; + widget_factory = modest_main_window_get_widget_factory (main_window); folder_info_label = - GTK_LABEL (modest_widget_factory_get_folder_info_label (priv->widget_factory)); + GTK_LABEL (modest_widget_factory_get_folder_info_label (widget_factory)); if (!folder) { gtk_label_set_label (GTK_LABEL(folder_info_label), ""); @@ -944,8 +837,9 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, } factory = modest_tny_platform_factory_get_instance (); - header_view = modest_widget_factory_get_header_view (priv->widget_factory); + header_view = modest_widget_factory_get_header_view (widget_factory); conf = modest_tny_platform_factory_get_modest_conf_instance (factory); + g_object_unref (G_OBJECT (widget_factory)); if (!selected) { /* the folder was unselected; save it's settings */ modest_widget_memory_save (conf, G_OBJECT (header_view), @@ -966,19 +860,19 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, } } -static void -modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, +void +_modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, const gchar* account_name, gchar **password, gboolean *cancel, gboolean *remember, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { gchar *txt; GtkWidget *dialog, *entry, *remember_pass_check; dialog = gtk_dialog_new_with_buttons (_("Password requested"), - GTK_WINDOW (priv->main_window), + GTK_WINDOW (main_window), GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, @@ -1073,24 +967,27 @@ statusbar_push (ModestWidgetFactory *factory, guint context_id, const gchar *msg } /****************************************************************************/ -static void -modest_ui_actions_on_connection_changed (TnyDevice *device, +void +_modest_ui_actions_on_connection_changed (TnyDevice *device, gboolean online, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { GtkWidget *online_toggle; ModestHeaderView *header_view; - - header_view = modest_widget_factory_get_header_view (priv->widget_factory); - online_toggle = modest_widget_factory_get_online_toggle (priv->widget_factory); + ModestWidgetFactory *widget_factory; + + widget_factory = modest_main_window_get_widget_factory (main_window); + header_view = modest_widget_factory_get_header_view (widget_factory); + online_toggle = modest_widget_factory_get_online_toggle (widget_factory); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(online_toggle), online); gtk_button_set_label (GTK_BUTTON(online_toggle), online ? _("Online") : _("Offline")); - statusbar_push (priv->widget_factory, 0, + statusbar_push (widget_factory, 0, online ? _("Modest went online") : _("Modest went offline")); + g_object_unref (G_OBJECT (widget_factory)); /* If Modest has became online and the header view has a header selected then show it */ @@ -1102,15 +999,22 @@ modest_ui_actions_on_connection_changed (TnyDevice *device, } } -static void -modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, + ModestMainWindow *main_window) { gboolean online; TnyDevice *device; + TnyPlatformFactory *factory; + TnyAccountStore *account_store; + + /* Get device. Do not ask the platform factory for it, because + it returns always a new one */ + factory = modest_tny_platform_factory_get_instance (); + account_store = tny_platform_factory_new_account_store (factory); + device = tny_account_store_get_device (account_store); online = gtk_toggle_button_get_active (toggle); - device = tny_account_store_get_device (priv->account_store); if (online) tny_device_force_online (device); @@ -1118,25 +1022,32 @@ modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle, tny_device_force_offline (device); } -static void -modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, +void +_modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, ModestItemType type, - ModestUIPrivate *priv) + ModestMainWindow *main_window) { GtkWidget *dialog; gchar *txt, *item; gboolean online; TnyDevice *device; + TnyPlatformFactory *factory; + TnyAccountStore *account_store; item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message"; - device = tny_account_store_get_device (priv->account_store); + + /* Get device. Do not ask the platform factory for it, because + it returns always a new one */ + factory = modest_tny_platform_factory_get_instance (); + account_store = tny_platform_factory_new_account_store (factory); + device = tny_account_store_get_device (account_store); gdk_threads_enter (); online = tny_device_is_online (device); if (online) { /* already online -- the item is simply not there... */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->main_window), + dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1146,7 +1057,7 @@ modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, } else { dialog = gtk_dialog_new_with_buttons (_("Connection requested"), - GTK_WINDOW (priv->main_window), + GTK_WINDOW (main_window), GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, @@ -1170,13 +1081,18 @@ modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, gdk_threads_leave (); } -static void -modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, const gchar *msg, - gint num, gint total, ModestUIPrivate *priv) +void +_modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, + const gchar *msg, + gint num, + gint total, + ModestMainWindow *main_window) { GtkWidget *progress_bar; - - progress_bar = modest_widget_factory_get_progress_bar (priv->widget_factory); + ModestWidgetFactory *widget_factory; + + widget_factory = modest_main_window_get_widget_factory (main_window); + progress_bar = modest_widget_factory_get_progress_bar (widget_factory); if (total != 0) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress_bar), @@ -1184,44 +1100,121 @@ modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, const else gtk_progress_bar_pulse (GTK_PROGRESS_BAR(progress_bar)); - statusbar_push (priv->widget_factory, 0, msg); + statusbar_push (widget_factory, 0, msg); + + /* Free */ + g_object_unref (G_OBJECT (widget_factory)); } -static void -modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, const gchar* link, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, + const gchar* link, + ModestMainWindow *main_window) { - - statusbar_push (priv->widget_factory, 0, link); + ModestWidgetFactory *widget_factory; + + widget_factory = modest_main_window_get_widget_factory (main_window); + statusbar_push (widget_factory, 0, link); + g_object_unref (G_OBJECT (widget_factory)); /* TODO: do something */ } -static void -modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, const gchar* link, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, + const gchar* link, + ModestMainWindow *main_window) { gchar *msg; + ModestWidgetFactory *widget_factory; + msg = g_strdup_printf (_("Opening %s..."), link); + widget_factory = modest_main_window_get_widget_factory (main_window); + statusbar_push (widget_factory, 0, msg); + + g_object_unref (G_OBJECT (widget_factory)); - statusbar_push (priv->widget_factory, 0, msg); g_free (msg); /* TODO: do something */ } -static void -modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, int index, - ModestUIPrivate *priv) +void +_modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, + int index, + ModestMainWindow *main_window) { gchar *msg; + ModestWidgetFactory *widget_factory; msg = g_strdup_printf (_("Opening attachment %d..."), index); - statusbar_push (priv->widget_factory, 0, msg); + widget_factory = modest_main_window_get_widget_factory (main_window); + statusbar_push (widget_factory, 0, msg); g_free (msg); - + g_object_unref (G_OBJECT (widget_factory)); /* TODO: do something */ } + +void +_modest_ui_actions_on_send (GtkWidget *widget, + ModestEditMsgWindow *edit_window) +{ + TnyTransportAccount *transport_account; + ModestMailOperation *mail_operation; + MsgData *data; + + data = modest_edit_msg_window_get_msg_data (edit_window); + + /* FIXME: Code added just for testing. The final version will + use the send queue provided by tinymail and some + classifier */ + { + TnyList *accounts; + TnyIterator *iter; + TnyAccountStore *account_store; + + accounts = TNY_LIST(tny_simple_list_new ()); + account_store = modest_edit_msg_window_get_account_store (edit_window); + tny_account_store_get_accounts (account_store, accounts, + TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); + g_object_unref (G_OBJECT (account_store)); + + iter = tny_list_create_iterator(accounts); + tny_iterator_first (iter); + if (tny_iterator_is_done (iter)) { + /* FIXME: Add error handling through mail operation */ + g_printerr("modest: no transport accounts defined\n"); + modest_edit_msg_window_free_msg_data (edit_window, data); + return; + } + transport_account = TNY_TRANSPORT_ACCOUNT (tny_iterator_get_current(iter)); + g_object_ref (transport_account); + + tny_list_foreach (accounts, (GFunc) g_object_unref, NULL); + g_object_unref (G_OBJECT (accounts)); + g_object_unref (G_OBJECT (iter)); + } + + mail_operation = modest_mail_operation_new (); + + modest_mail_operation_send_new_mail (mail_operation, + transport_account, + data->from, + data->to, + data->cc, + data->bcc, + data->subject, + data->body, + NULL); + /* Frees */ + g_object_unref (G_OBJECT (mail_operation)); + g_object_unref (G_OBJECT (transport_account)); + modest_edit_msg_window_free_msg_data (edit_window, data); + + /* Save settings and close the window */ + /* save_settings (edit_window) */ + gtk_widget_destroy (GTK_WIDGET (edit_window)); +} diff --git a/src/modest-ui.h b/src/modest-ui.h index 20a9b40..92f0606 100644 --- a/src/modest-ui.h +++ b/src/modest-ui.h @@ -32,6 +32,9 @@ #include #include +#include +#include "modest-window.h" +#include "modest-edit-msg-window.h" G_BEGIN_DECLS @@ -54,7 +57,6 @@ struct _ModestUI { struct _ModestUIClass { GObjectClass parent_class; /* insert signal callback declarations, eg. */ - /* void (* my_event) (ModestUI* obj); */ }; /** @@ -85,9 +87,23 @@ ModestUI* modest_ui_new (TnyAccountStore *account_store); * * Returns: a #ModestMainWindow, or NULL in case of error */ -GtkWidget* modest_ui_main_window (ModestUI *modest_ui); +ModestWindow* modest_ui_main_window (ModestUI *modest_ui); +/** + * modest_edit_msg_ui_main_window: + * @modest_edit_msg_ui: a ModestEditMsgUI instance + * @edit_type: the type of edit window + * + * Creates an new main window and returns it. If there is already a + * main window then the current one is returned and no new window is + * created + * + * Returns: a #ModestEditMsgWindow, or NULL in case of error + */ +ModestWindow* modest_ui_edit_window (ModestUI *modest_ui, + ModestEditType edit_type); + G_END_DECLS #endif /* __MODEST_UI_H__ */ diff --git a/src/modest-widget-memory.h b/src/modest-widget-memory.h index 13fb2d1..4e3993d 100644 --- a/src/modest-widget-memory.h +++ b/src/modest-widget-memory.h @@ -30,7 +30,6 @@ #ifndef __MODEST_WIDGET_MEMORY_H__ #define __MODEST_WIDGET_MEMORY_H__ -#include #include G_BEGIN_DECLS diff --git a/src/ui/modest-edit-msg-window-ui.xml b/src/ui/modest-edit-msg-window-ui.xml deleted file mode 100644 index 0bf6fb9..0000000 --- a/src/ui/modest-edit-msg-window-ui.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ui/modest-ui.xml b/src/ui/modest-ui.xml deleted file mode 100644 index 04ba930..0000000 --- a/src/ui/modest-ui.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index a9e3bb2..6f8fceb 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -29,7 +29,9 @@ #include #include "modest-account-view.h" -/* include other impl specific header files */ +#include +#include +#include /* 'private'/'protected' functions */ static void modest_account_view_class_init (ModestAccountViewClass *klass); diff --git a/src/widgets/modest-account-view.h b/src/widgets/modest-account-view.h index be71578..c3f476c 100644 --- a/src/widgets/modest-account-view.h +++ b/src/widgets/modest-account-view.h @@ -30,8 +30,8 @@ #ifndef __MODEST_ACCOUNT_VIEW_H__ #define __MODEST_ACCOUNT_VIEW_H__ -#include -#include +#include "modest-account-mgr.h" +#include G_BEGIN_DECLS diff --git a/src/widgets/modest-edit-msg-window-ui.h b/src/widgets/modest-edit-msg-window-ui.h new file mode 100644 index 0000000..419b489 --- /dev/null +++ b/src/widgets/modest-edit-msg-window-ui.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_MAIN_WINDOW_UI_PRIV_H__ +#define __MODEST_MAIN_WINDOW_UI_PRIV_H__ + +#include +#include "modest-icon-names.h" +#include "modest-ui-actions.h" + +G_BEGIN_DECLS + +static const GtkActionEntry modest_edit_msg_action_entries [] = { + + /* Toplevel menus */ + { "View", NULL, N_("_View") }, + { "Insert", NULL, N_("_Insert") }, + { "Format", NULL, N_("For_mat") }, + + /* ACTIONS */ + { "ActionsSend", MODEST_STOCK_MAIL_SEND, N_("Send"), NULL, N_("Send a message"), G_CALLBACK (_modest_ui_actions_on_send) }, +}; + +static const GtkToggleActionEntry modest_edit_msg_toggle_action_entries [] = { + + /* VIEW */ + { "ViewToField", NULL, N_("To: field"), NULL, N_("Shows the To: field"), NULL, TRUE }, + { "ViewCcField", NULL, N_("Cc: field"), NULL, N_("Shows the Cc: field"), NULL, TRUE }, + { "ViewBccField", NULL, N_("Bcc: filed"), NULL, N_("Shows the Bcc: field"), NULL, FALSE }, +}; + +G_END_DECLS +#endif /* __MODEST_MAIN_WINDOW_UI_PRIV_H__ */ diff --git a/src/widgets/modest-edit-msg-window.h b/src/widgets/modest-edit-msg-window.h index 93d9094..8b7439e 100644 --- a/src/widgets/modest-edit-msg-window.h +++ b/src/widgets/modest-edit-msg-window.h @@ -30,10 +30,9 @@ #ifndef __MODEST_EDIT_MSG_WINDOW_H__ #define __MODEST_EDIT_MSG_WINDOW_H__ -#include #include -#include -#include +#include "modest-window.h" +#include "modest-widget-factory.h" G_BEGIN_DECLS @@ -68,14 +67,19 @@ typedef enum _ModestEditType { MODEST_EDIT_TYPE_NUM } ModestEditType; + +typedef struct _MsgData { + gchar *from, *to, *cc, *bcc, *subject, *body; +} MsgData; /* typedef enum _ModestEditType ModestEditType; */ /* member functions */ GType modest_edit_msg_window_get_type (void) G_GNUC_CONST; -GtkWidget* modest_edit_msg_window_new (ModestWidgetFactory *factory, - ModestEditType type); +ModestWindow* modest_edit_msg_window_new (ModestWidgetFactory *factory, + TnyAccountStore *account_store, + ModestEditType type); /** * modest_edit_msg_window_set_msg: @@ -86,6 +90,16 @@ GtkWidget* modest_edit_msg_window_new (ModestWidgetFactory *factory, **/ void modest_edit_msg_window_set_msg (ModestEditMsgWindow *self, TnyMsg *msg); + +ModestWidgetFactory * modest_edit_msg_window_get_widget_factory (ModestEditMsgWindow *edit_window); + +TnyAccountStore * modest_edit_msg_window_get_account_store (ModestEditMsgWindow *edit_window); + +MsgData * modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *edit_window); + +void modest_edit_msg_window_free_msg_data (ModestEditMsgWindow *edit_window, + MsgData *data); + G_END_DECLS #endif /* __MODEST_EDIT_MSG_WINDOW_H__ */ diff --git a/src/widgets/modest-header-view.h b/src/widgets/modest-header-view.h index e6e474a..40203b2 100644 --- a/src/widgets/modest-header-view.h +++ b/src/widgets/modest-header-view.h @@ -30,7 +30,6 @@ #ifndef __MODEST_HEADER_VIEW_H__ #define __MODEST_HEADER_VIEW_H__ -#include #include #include #include @@ -82,7 +81,8 @@ typedef enum _ModestHeaderViewColumn { * to make a small-device specific display */ typedef enum _ModestHeaderViewStyle { - MODEST_HEADER_VIEW_STYLE_SHOW_HEADERS = 0x01 + MODEST_HEADER_VIEW_STYLE_SHOW_HEADERS = 0x01, + MODEST_HEADER_VIEW_STYLE_NORMAL = 0x02, } ModestHeaderViewStyle; typedef enum _ModestItemType { diff --git a/src/widgets/modest-main-window-ui.h b/src/widgets/modest-main-window-ui.h new file mode 100644 index 0000000..1de2a93 --- /dev/null +++ b/src/widgets/modest-main-window-ui.h @@ -0,0 +1,90 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __MODEST_MAIN_WINDOW_UI_PRIV_H__ +#define __MODEST_MAIN_WINDOW_UI_PRIV_H__ + +#include +#include "modest-icon-names.h" +#include "modest-ui-actions.h" + +G_BEGIN_DECLS + + +/* Action entries */ +static const GtkActionEntry modest_action_entries [] = { + + /* Toplevel menus */ + { "File", NULL, N_("_File") }, + { "Edit", NULL, N_("_Edit") }, + { "Actions", NULL, N_("_Actions") }, + { "Options", NULL, N_("_Options") }, + { "Help", NULL, N_("_Help") }, + + /* FILE */ + { "FileNew", GTK_STOCK_NEW, N_("_New"), "N", N_("Compose new message"), G_CALLBACK (_modest_ui_actions_on_new_msg) }, + { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "O", N_("Open a message"), NULL }, + { "FileSave", GTK_STOCK_SAVE, N_("_Save"), "S", N_("Save a message"), NULL }, + { "FileSaveAs", GTK_STOCK_SAVE_AS, N_("Save _As"), NULL, N_("Save a message as"), NULL }, + { "FileQuit", GTK_STOCK_QUIT, N_("_Quit"), "Q", N_("Exit the application"), G_CALLBACK (_modest_ui_actions_on_quit) }, + + /* EDIT */ + { "EditUndo", GTK_STOCK_UNDO, N_("_Undo"), "Z", N_("Undo last action"), NULL }, + { "EditRedo", GTK_STOCK_REDO, N_("_Redo"), "Z", N_("Redo previous action"), NULL }, + { "EditCut", GTK_STOCK_CUT, N_("Cut"), "X", N_("_Cut"), NULL }, + { "EditCopy", GTK_STOCK_COPY, N_("Copy"), "C", N_("Copy"), NULL }, + { "EditPaste", GTK_STOCK_PASTE, N_("Paste"), "V", N_("Paste"), NULL }, + { "EditDelete", GTK_STOCK_DELETE, N_("_Delete"), "Q", N_("Delete"), NULL }, + { "EditSelectAll", NULL, N_("Select all"), "A", N_("Select all"), NULL }, + { "EditDeselectAll", NULL, N_("Deselect all"), "A", N_("Deselect all"), NULL }, + + /* ACTIONS */ + { "ActionsNew", MODEST_STOCK_NEW_MAIL, N_("_New Message"), NULL, N_("Compose a new message"), G_CALLBACK (_modest_ui_actions_on_new_msg) }, + { "ActionsReply", MODEST_STOCK_REPLY, N_("_Reply"), NULL, N_("Reply to a message"), G_CALLBACK (_modest_ui_actions_on_reply) }, + { "ActionsReplyAll", MODEST_STOCK_REPLY_ALL, N_("Reply to all"), NULL, N_("Reply to all"), G_CALLBACK (_modest_ui_actions_on_reply_all) }, + { "ActionsForward", MODEST_STOCK_FORWARD, N_("_Forward"), NULL, N_("Forward a message"), G_CALLBACK (_modest_ui_actions_on_forward) }, + { "ActionsBounce", NULL, N_("_Bounce"), NULL, N_("Bounce a message"), NULL }, + { "ActionsSendReceive", MODEST_STOCK_SEND_RECEIVE, N_("Send/Receive"), NULL, N_("Send and receive messages"), NULL }, + { "ActionsDelete", MODEST_STOCK_DELETE, N_("Delete message"), NULL, N_("Delete messages"), G_CALLBACK (_modest_ui_actions_on_delete) }, + + /* GOTO */ + { "GotoPrevious", MODEST_STOCK_PREV, N_("Previous"), NULL, N_("Go to previous message"), NULL }, + { "GotoNext", MODEST_STOCK_NEXT, N_("Next"), NULL, N_("Go to next message"), G_CALLBACK (_modest_ui_actions_on_next) }, + + /* OPTIONS */ + { "OptionsAccounts", NULL, N_("_Accounts"), NULL, N_("Manage accounts"), G_CALLBACK (_modest_ui_actions_on_accounts) }, + { "OptionsContacts", NULL, N_("_Contacts"), NULL, N_("Manage contacts"), NULL }, + + /* HELP */ + { "HelpAbout", GTK_STOCK_ABOUT, N_("About"), NULL, N_("About Modest"), G_CALLBACK (_modest_ui_actions_on_about) }, +}; + + +G_END_DECLS +#endif /* __MODEST_MAIN_WINDOW_UI_PRIV_H__ */ diff --git a/src/widgets/modest-main-window.h b/src/widgets/modest-main-window.h index 7cbe801..d59ce03 100644 --- a/src/widgets/modest-main-window.h +++ b/src/widgets/modest-main-window.h @@ -35,8 +35,8 @@ #include #endif /*HAVE_CONFIG_H*/ -#include -#include +#include "modest-widget-factory.h" +#include "modest-window.h" G_BEGIN_DECLS @@ -67,8 +67,13 @@ struct _ModestMainWindowClass { GType modest_main_window_get_type (void) G_GNUC_CONST; -GtkWidget* modest_main_window_new (ModestWidgetFactory *factory, - GtkUIManager *ui_manager); +ModestWindow* modest_main_window_new (ModestWidgetFactory *factory, + TnyAccountStore *account_store); + +ModestWidgetFactory * modest_main_window_get_widget_factory (ModestMainWindow *main_window); + +TnyAccountStore * modest_main_window_get_account_store (ModestMainWindow *main_window); + G_END_DECLS diff --git a/src/widgets/modest-msg-view.h b/src/widgets/modest-msg-view.h index 814a638..fd83a5b 100644 --- a/src/widgets/modest-msg-view.h +++ b/src/widgets/modest-msg-view.h @@ -30,7 +30,6 @@ #ifndef __MODEST_MSG_VIEW_H__ #define __MODEST_MSG_VIEW_H__ -#include #include #include #include -- 1.7.9.5