$(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
$(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)
#ifndef __MODEST_ACCOUNT_ASSISTANT_H__
#define __MODEST_ACCOUNT_ASSISTANT_H__
-#include <gtk/gtk.h>
#include <modest-widget-factory.h>
#include <modest-account-mgr.h>
#ifndef __MODEST_ACCOUNT_VIEW_WINDOW_H__
#define __MODEST_ACCOUNT_VIEW_WINDOW_H__
-#include <gtk/gtk.h>
#include <modest-widget-factory.h>
G_BEGIN_DECLS
*/
#include <glib/gi18n.h>
#include <tny-account-store.h>
-#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 <tny-simple-list.h>
+#include "modest-ui-actions.h"
static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass);
static void modest_edit_msg_window_init (ModestEditMsgWindow *obj);
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))
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;
}
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, "<Branch>" ,NULL},
- { "/File/_New", "<control>N", NULL, 0, "<StockItem>", GTK_STOCK_NEW },
- { "/File/_Open", "<control>O", NULL, 0, "<StockItem>", GTK_STOCK_OPEN },
- { "/File/_Save", "<control>S", NULL, 0, "<StockItem>", GTK_STOCK_SAVE },
- { "/File/Save _As", NULL, NULL, 0, "<Item>", NULL} ,
- { "/File/Save Draft", "<control><shift>S", NULL, 0, "<Item>",NULL },
-
-
- { "/File/sep1", NULL, NULL, 0, "<Separator>" ,NULL },
- { "/File/_Quit", "<CTRL>Q", on_menu_quit, 0, "<StockItem>", GTK_STOCK_QUIT },
-
- { "/_Edit", NULL, NULL, 0, "<Branch>" ,NULL },
- { "/Edit/_Undo", "<CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_UNDO },
- { "/Edit/_Redo", "<shift><CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_REDO },
- { "/File/sep1", NULL, NULL, 0, "<Separator>",NULL },
- { "/Edit/Cut", "<control>X", NULL, 0, "<StockItem>", GTK_STOCK_CUT },
- { "/Edit/Copy", "<CTRL>C", NULL, 0, "<StockItem>", GTK_STOCK_COPY },
- { "/Edit/Paste", NULL, NULL, 0, "<StockItem>", GTK_STOCK_PASTE},
- { "/Edit/sep1", NULL, NULL, 0, "<Separator>",NULL },
- { "/Edit/Delete", "<CTRL>Q", NULL, 0, "<Item>" ,NULL },
- { "/Edit/Select all", "<CTRL>A", NULL, 0, "<Item>" ,NULL },
- { "/Edit/Deselect all", "<Shift><CTRL>A", NULL, 0, "<Item>",NULL },
-
- { "/_View", NULL, NULL, 0, "<Branch>",NULL },
- { "/View/To-field", NULL, NULL, 0, "<CheckItem>",NULL },
-
- { "/View/Cc-field:", NULL, NULL, 0, "<CheckItem>",NULL },
- { "/View/Bcc-field:", NULL, NULL, 0, "<CheckItem>",NULL },
-
-
- { "/_Insert", NULL, NULL, 0, "<Branch>",NULL },
-/* { "/Actions/_Reply", NULL, NULL, 0, "<Item>" }, */
-/* { "/Actions/_Forward", NULL, NULL, 0, "<Item>" }, */
-/* { "/Actions/_Bounce", NULL, NULL, 0, "<Item>" }, */
-
- { "/_Format", NULL, NULL, 0, "<Branch>",NULL }
-/* { "/Options/_Accounts", NULL, on_menu_accounts,0, "<Item>" }, */
-/* { "/Options/_Contacts", NULL, NULL, 0, "<Item>" }, */
-
-
-/* { "/_Help", NULL, NULL, 0, "<Branch>" }, */
-/* { "/_Help/About", NULL, on_menu_about, 0, "<StockItem>", 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, "<main>",
- 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, "<main>");
-}
-
-
-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)
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);
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);
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);
}
-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));
g_signal_connect (G_OBJECT(obj), "delete-event",
G_CALLBACK(on_delete_event), obj);
- return GTK_WIDGET (obj);
+ return (ModestWindow *) (obj);
}
void
/* 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);
+}
#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"
struct _ModestMainWindowPrivate {
GtkUIManager *ui_manager;
-
+ ModestWidgetFactory *widget_factory;
+ TnyPlatformFactory *factory;
+ TnyAccountStore *account_store;
+
GtkWidget *toolbar;
GtkWidget *menubar;
GtkWidget *msg_paned;
GtkWidget *main_paned;
- ModestWidgetFactory *widget_factory;
- TnyPlatformFactory *factory;
-
ModestHeaderView *header_view;
ModestFolderView *folder_view;
ModestMsgView *msg_preview;
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
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);
}
}
-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);
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),
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);
}
#ifndef __MODEST_STORE_WIDGET_H__
#define __MODEST_STORE_WIDGET_H__
-#include <gtk/gtk.h>
#include <modest-widget-factory.h>
G_BEGIN_DECLS
#ifndef __MODEST_TRANSPORT_WIDGET_H__
#define __MODEST_TRANSPORT_WIDGET_H__
-#include <gtk/gtk.h>
#include <modest-widget-factory.h>
G_BEGIN_DECLS
$(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
*/
#include <glib/gi18n.h>
#include <tny-account-store.h>
-#include <widgets/modest-edit-msg-window.h>
-#include <hildon-widgets/hildon-window.h>
-#include <widgets/modest-toolbar.h>
+#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 <tny-simple-list.h>
-#include <string.h>
-
static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass);
static void modest_edit_msg_window_init (ModestEditMsgWindow *obj);
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))
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;
}
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");
}
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, "<Branch>" ,NULL}, */
+/* { "/File/_New", "<control>N", NULL, 0, "<StockItem>", GTK_STOCK_NEW }, */
+/* { "/File/_Open", "<control>O", NULL, 0, "<StockItem>", GTK_STOCK_OPEN }, */
+/* { "/File/_Save", "<control>S", NULL, 0, "<StockItem>", GTK_STOCK_SAVE }, */
+/* { "/File/Save _As", NULL, NULL, 0, "<Item>", NULL} , */
+/* { "/File/Save Draft", "<control><shift>S", NULL, 0, "<Item>",NULL }, */
+
+
+/* { "/File/sep1", NULL, NULL, 0, "<Separator>" ,NULL }, */
+/* { "/File/_Quit", "<CTRL>Q", on_menu_quit, 0, "<StockItem>", GTK_STOCK_QUIT }, */
+
+/* { "/_Edit", NULL, NULL, 0, "<Branch>" ,NULL }, */
+/* { "/Edit/_Undo", "<CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_UNDO }, */
+/* { "/Edit/_Redo", "<shift><CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_REDO }, */
+/* { "/File/sep1", NULL, NULL, 0, "<Separator>",NULL }, */
+/* { "/Edit/Cut", "<control>X", NULL, 0, "<StockItem>", GTK_STOCK_CUT }, */
+/* { "/Edit/Copy", "<CTRL>C", NULL, 0, "<StockItem>", GTK_STOCK_COPY }, */
+/* { "/Edit/Paste", NULL, NULL, 0, "<StockItem>", GTK_STOCK_PASTE}, */
+/* { "/Edit/sep1", NULL, NULL, 0, "<Separator>",NULL }, */
+/* { "/Edit/Delete", "<CTRL>Q", NULL, 0, "<Item>" ,NULL }, */
+/* { "/Edit/Select all", "<CTRL>A", NULL, 0, "<Item>" ,NULL }, */
+/* { "/Edit/Deselect all", "<Shift><CTRL>A", NULL, 0, "<Item>",NULL }, */
+
+/* { "/_View", NULL, NULL, 0, "<Branch>",NULL }, */
+/* { "/View/To-field", NULL, NULL, 0, "<CheckItem>",NULL }, */
- GtkTextBuffer *buf;
- GtkTextIter b, e;
+/* { "/View/Cc-field:", NULL, NULL, 0, "<CheckItem>",NULL }, */
+/* { "/View/Bcc-field:", NULL, NULL, 0, "<CheckItem>",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, "<Branch>",NULL }, */
+/* /\* { "/Actions/_Reply", NULL, NULL, 0, "<Item>" }, *\/ */
+/* /\* { "/Actions/_Forward", NULL, NULL, 0, "<Item>" }, *\/ */
+/* /\* { "/Actions/_Bounce", NULL, NULL, 0, "<Item>" }, *\/ */
- 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, "<Branch>",NULL } */
+/* /\* { "/Options/_Accounts", NULL, on_menu_accounts,0, "<Item>" }, *\/ */
+/* /\* { "/Options/_Contacts", NULL, NULL, 0, "<Item>" }, *\/ */
- 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, "<Branch>" }, *\/ */
+/* /\* { "/_Help/About", NULL, on_menu_about, 0, "<StockItem>", 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
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);
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);
}
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);
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;
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));
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)
{
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
#include <string.h>
#include <tny-header.h>
#include <tny-gtk-text-buffer-stream.h>
#ifndef __MODEST_ICON_FACTORY_H__
#define __MODEST_ICON_FACTORY_H__
-#include <gtk/gtk.h>
+#include <gdk/gdkpixbuf.h>
/**
* modest_icon_factory_init
#include <glib.h>
#include <glib/gi18n.h>
-#include <gtk/gtk.h>
+#include <gtk/gtkwidget.h>
#include <tny-list.h>
#include <tny-transport-account.h>
#include <tny-account-store.h>
gint retval = 0;
#ifndef OLD_UI_STUFF
- GtkWidget *win;
+ ModestWindow *win;
#endif
modest_ui = MODEST_UI(modest_ui_new (account_store));
if (win) {
TnyDevice *device;
- gtk_widget_show (win);
+ gtk_widget_show (GTK_WIDGET (win));
/* Go online */
device = tny_account_store_get_device (account_store);
*/
#include <string.h>
-#include <gtk/gtk.h>
#include <gtkhtml/gtkhtml.h>
#include <tny-gtk-text-buffer-stream.h>
#include <tny-simple-list.h>
--- /dev/null
+/* 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__ */
--- /dev/null
+/* 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 <gtk/gtkuimanager.h>
+#include <tny-account-store.h>
+#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__ */
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <glib/gi18n.h>
-#include <string.h>
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <glib/gi18n.h>
-#include <gtk/gtkuimanager.h>
-#include <tny-error.h>
-#include <tny-simple-list.h>
+#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 <modest-widget-memory.h>
-#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 <tny-error.h>
+#include <tny-simple-list.h>
#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;
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);
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"), "<CTRL>N", N_("Compose new message"), G_CALLBACK (modest_ui_actions_on_new_msg) },
- { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "<CTRL>O", N_("Open a message"), NULL },
- { "FileSave", GTK_STOCK_SAVE, N_("_Save"), "<CTRL>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"), "<CTRL>Q", N_("Exit the application"), G_CALLBACK (modest_ui_actions_on_quit) },
-
- /* EDIT menu */
- { "EditUndo", GTK_STOCK_UNDO, N_("_Undo"), "<CTRL>Z", N_("Undo last action"), NULL },
- { "EditRedo", GTK_STOCK_REDO, N_("_Redo"), "<shift><CTRL>Z", N_("Redo previous action"), NULL },
- { "EditCut", GTK_STOCK_CUT, N_("Cut"), "<CTRL>X", N_("_Cut"), NULL },
- { "EditCopy", GTK_STOCK_COPY, N_("Copy"), "<CTRL>C", N_("Copy"), NULL },
- { "EditPaste", GTK_STOCK_PASTE, N_("Paste"), "<CTRL>V", N_("Paste"), NULL },
- { "EditDelete", GTK_STOCK_DELETE, N_("_Delete"), "<CTRL>Q", N_("Delete"), NULL },
- { "EditSelectAll", NULL, N_("Select all"), "<CTRL>A", N_("Select all"), NULL },
- { "EditDeselectAll", NULL, N_("Deselect all"), "<Shift><CTRL>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)
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);
}
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);
}
}
-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)
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;
}
/*
/* 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 <dirk-jan.binnema@nokia.com>",
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);
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;
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);
}
}
-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);
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);
}
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;
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;
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;
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
*/
read_msg_func (gpointer data, gpointer user_data)
{
ModestMsgView *msg_view;
+ ModestWidgetFactory *widget_factory;
TnyMsg *msg;
TnyHeader *header;
GetMsgAsyncHelper *helper;
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);
}
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;
}
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;
/* 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;
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), "");
}
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),
}
}
-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,
}
/****************************************************************************/
-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 */
}
}
-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);
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,
} 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,
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),
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));
+}
#include <glib-object.h>
#include <tny-account-store.h>
+#include <gtk/gtkactiongroup.h>
+#include "modest-window.h"
+#include "modest-edit-msg-window.h"
G_BEGIN_DECLS
struct _ModestUIClass {
GObjectClass parent_class;
/* insert signal callback declarations, eg. */
- /* void (* my_event) (ModestUI* obj); */
};
/**
*
* 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__ */
#ifndef __MODEST_WIDGET_MEMORY_H__
#define __MODEST_WIDGET_MEMORY_H__
-#include <gtk/gtk.h>
#include <modest-conf.h>
G_BEGIN_DECLS
+++ /dev/null
-<!--
- * 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.
--->
-
-<ui>
-
- <menubar name="EditMsgWindowMenuBar">
- <menu name="FileMenu" action="File">
- <menuitem name="FileNewMenu" action="FileNew"/>
- <menuitem name="FileOpenMenu" action="FileOpen"/>
- <separator/>
- <menuitem name="FileSaveMenu" action="FileSave"/>
- <menuitem name="FileSaveAsMenu" action="FileSaveAs"/>
- <separator/>
- <menuitem name="FileQuitMenu" action="FileQuit"/>
- </menu>
-
- <menu name="EditMenu" action="Edit">
- <menuitem name="EditUndoMenu" action="EditUndo"/>
- <menuitem name="EditRedoMenu" action="EditRedo"/>
- <separator/>
- <menuitem name="EditCutMenu" action="EditCut"/>
- <menuitem name="EditCopyMenu" action="EditCopy"/>
- <menuitem name="EditPasteMenu" action="EditPaste"/>
- <menuitem name="EditDeleteMenu" action="EditDelete"/>
- <separator/>
- <menuitem name="EditSelectAllMenu" action="EditSelectAll"/>
- <menuitem name="EditDeselectAllMenu" action="EditDeselectAll"/>
- </menu>
-
- <menu name="ViewMenu" action="View">
- <menuitem name="ViewToFieldMenu" action="ViewToField"/>
- <menuitem name="ViewCcFieldMenu" action="ViewCcField"/>
- <menuitem name="ViewBccFieldMenu" action="ViewBccField"/>
- </menu>
-
- <menu name="ActionsMenu" action="Actions">
- <menuitem name="ActionsSendMenu" action="ActionsSend"/>
- </menu>
-
- </menubar>
-
- <toolbar name="EditMsgWindowToolBar">
- <toolitem action="ActionsSend"/>
- </toolbar>
-
-</ui>
+++ /dev/null
-<!--
- * 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.
--->
-
-<ui>
-
- <menubar name="MenuBar">
- <menu name="FileMenu" action="File">
- <menuitem name="FileNewMenu" action="FileNew"/>
- <menuitem name="FileOpenMenu" action="FileOpen"/>
- <separator/>
- <menuitem name="FileSaveMenu" action="FileSave"/>
- <menuitem name="FileSaveAsMenu" action="FileSaveAs"/>
- <separator/>
- <menuitem name="FileQuitMenu" action="FileQuit"/>
- </menu>
-
- <menu name="EditMenu" action="Edit">
- <menuitem name="EditUndoMenu" action="EditUndo"/>
- <menuitem name="EditRedoMenu" action="EditRedo"/>
- <separator/>
- <menuitem name="EditCutMenu" action="EditCut"/>
- <menuitem name="EditCopyMenu" action="EditCopy"/>
- <menuitem name="EditPasteMenu" action="EditPaste"/>
- <menuitem name="EditDeleteMenu" action="EditDelete"/>
- <separator/>
- <menuitem name="EditSelectAllMenu" action="EditSelectAll"/>
- <menuitem name="EditDeselectAllMenu" action="EditDeselectAll"/>
- </menu>
-
- <menu name="ActionsMenu" action="Actions">
- <menuitem name="ActionsNewMenu" action="ActionsNew"/>
- <menuitem name="ActionsReplyMenu" action="ActionsReply"/>
- <menuitem name="ActionsForwardMenu" action="ActionsForward"/>
- <menuitem name="ActionsBounceMenu" action="ActionsBounce"/>
- </menu>
-
- <menu name="OptionsMenu" action="Options">
- <menuitem name="OptionsAccountsMenu" action="OptionsAccounts"/>
- <menuitem name="OptionsContactsMenu" action="OptionsContacts"/>
- </menu>
-
- <menu name="HelpMenu" action="Help">
- <menuitem name="HelpAboutMenu" action="HelpAbout"/>
- </menu>
- </menubar>
-
- <toolbar name="ToolBar">
- <toolitem action="ActionsNew"/>
- <separator/>
- <toolitem action="ActionsReply"/>
- <toolitem action="ActionsReplyAll"/>
- <toolitem action="ActionsForward"/>
- <separator/>
- <toolitem action="ActionsSendReceive"/>
- <separator/>
- <toolitem action="GotoPrevious"/>
- <toolitem action="GotoNext"/>
- <separator/>
- <toolitem action="ActionsDelete"/>
- </toolbar>
-
-</ui>
#include <glib/gi18n.h>
#include "modest-account-view.h"
-/* include other impl specific header files */
+#include <gtk/gtkcellrenderertoggle.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtktreeselection.h>
/* 'private'/'protected' functions */
static void modest_account_view_class_init (ModestAccountViewClass *klass);
#ifndef __MODEST_ACCOUNT_VIEW_H__
#define __MODEST_ACCOUNT_VIEW_H__
-#include <gtk/gtk.h>
-#include <modest-account-mgr.h>
+#include "modest-account-mgr.h"
+#include <gtk/gtktreeview.h>
G_BEGIN_DECLS
--- /dev/null
+/* 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 <glib/gi18n.h>
+#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__ */
#ifndef __MODEST_EDIT_MSG_WINDOW_H__
#define __MODEST_EDIT_MSG_WINDOW_H__
-#include <gtk/gtk.h>
#include <tny-msg.h>
-#include <widgets/modest-window.h>
-#include <modest-widget-factory.h>
+#include "modest-window.h"
+#include "modest-widget-factory.h"
G_BEGIN_DECLS
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:
**/
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__ */
#ifndef __MODEST_HEADER_VIEW_H__
#define __MODEST_HEADER_VIEW_H__
-#include <gtk/gtk.h>
#include <tny-folder.h>
#include <tny-gtk-account-list-model.h>
#include <tny-msg.h>
* 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 {
--- /dev/null
+/* 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 <glib/gi18n.h>
+#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"), "<CTRL>N", N_("Compose new message"), G_CALLBACK (_modest_ui_actions_on_new_msg) },
+ { "FileOpen", GTK_STOCK_OPEN, N_("_Open"), "<CTRL>O", N_("Open a message"), NULL },
+ { "FileSave", GTK_STOCK_SAVE, N_("_Save"), "<CTRL>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"), "<CTRL>Q", N_("Exit the application"), G_CALLBACK (_modest_ui_actions_on_quit) },
+
+ /* EDIT */
+ { "EditUndo", GTK_STOCK_UNDO, N_("_Undo"), "<CTRL>Z", N_("Undo last action"), NULL },
+ { "EditRedo", GTK_STOCK_REDO, N_("_Redo"), "<shift><CTRL>Z", N_("Redo previous action"), NULL },
+ { "EditCut", GTK_STOCK_CUT, N_("Cut"), "<CTRL>X", N_("_Cut"), NULL },
+ { "EditCopy", GTK_STOCK_COPY, N_("Copy"), "<CTRL>C", N_("Copy"), NULL },
+ { "EditPaste", GTK_STOCK_PASTE, N_("Paste"), "<CTRL>V", N_("Paste"), NULL },
+ { "EditDelete", GTK_STOCK_DELETE, N_("_Delete"), "<CTRL>Q", N_("Delete"), NULL },
+ { "EditSelectAll", NULL, N_("Select all"), "<CTRL>A", N_("Select all"), NULL },
+ { "EditDeselectAll", NULL, N_("Deselect all"), "<Shift><CTRL>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__ */
#include <config.h>
#endif /*HAVE_CONFIG_H*/
-#include <modest-widget-factory.h>
-#include <widgets/modest-window.h>
+#include "modest-widget-factory.h"
+#include "modest-window.h"
G_BEGIN_DECLS
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
#ifndef __MODEST_MSG_VIEW_H__
#define __MODEST_MSG_VIEW_H__
-#include <gtk/gtk.h>
#include <tny-stream.h>
#include <tny-msg.h>
#include <tny-mime-part.h>