#
# Makefile.am
-# Time-stamp: <2007-01-30 00:21:56 (djcb)>
+# Time-stamp: <2007-02-07 23:11:40 (djcb)>
SUBDIRS=$(MODEST_PLATFORM) widgets
DIST_SUBDIRS = widgets gtk maemo
$(MODEST_GSTUFF_CFLAGS)\
$(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) \
$(MODEST_LIBTINYMAIL_MAEMO_CFLAGS) \
- -I ${top_srcdir}/src/widgets \
-I$(MODEST_PLATFORM) \
-DPREFIX=\"@prefix@\" \
-DMODEST_LOCALEDIR=\"$(MODEST_LOCALEDIR)\" \
modest-tny-platform-factory.h \
modest-tny-send-queue.c\
modest-tny-send-queue.h\
+ modest-ui-actions.c\
modest-ui-actions.h\
- modest-ui.c\
- modest-ui.h\
- modest-widget-factory.c \
- modest-widget-factory.h \
modest-widget-memory-priv.h \
modest-widget-memory.c\
modest-widget-memory.h
#
# Makefile.am
-# Time-stamp: <2007-02-06 17:27:20 (djcb)>
+# Time-stamp: <2007-02-07 22:26:18 (djcb)>
#
#
# use Automake 'trick' ==> convenience static libraries, which
$(MODEST_GSTUFF_CFLAGS) \
$(MODEST_LIBTINYMAIL_GNOME_DESKTOP_CFLAGS) \
-DMODEST_PLATFORM_ID=$(MODEST_PLATFORM_ID) \
- -I ${top_srcdir}/src/widgets \
-I ${top_srcdir}/src \
-DPREFIX=\"@prefix@\" \
-DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \
modest-account-assistant.h \
modest-account-view-window.c \
modest-account-view-window.h \
- modest-edit-msg-window.c \
+ modest-msg-edit-window.c \
modest-icon-names.h \
modest-main-window.c \
modest-main-window-ui.h \
modest-msg-view-window.c \
- modest-msg-view-window.h \
modest-store-widget.c \
modest-store-widget.h \
modest-transport-widget.c \
pixmap_DATA = $(PIXMAP_FILES)
UI_FILES=\
- ui/modest-ui.xml \
- ui/modest-edit-msg-window-ui.xml \
- ui/modest-msg-view-window-ui.xml
-
+ ui/modest-main-window-ui.xml \
+ ui/modest-msg-view-window-ui.xml \
+ ui/modest-msg-edit-window-ui.xml
uidir = $(datadir)/modest/ui
ui_DATA = $(UI_FILES)
*/
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <camel/camel-url.h>
+#include <widgets/modest-combo-box.h>
#include "modest-account-assistant.h"
#include "modest-store-widget.h"
#include "modest-transport-widget.h"
typedef struct _ModestAccountAssistantPrivate ModestAccountAssistantPrivate;
struct _ModestAccountAssistantPrivate {
- ModestWidgetFactory *factory;
ModestAccountMgr *account_mgr;
GtkWidget *account_name;
/* FIXME: we could have these widgets cached instead of
creating them every time */
- priv->store_widget = modest_store_widget_new (priv->factory, proto);
+ priv->store_widget = modest_store_widget_new (proto);
if (proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP) {
g_signal_connect (priv->store_widget,
"data_changed",
add_receiving_page (ModestAccountAssistant *self)
{
GtkWidget *page, *box, *combo;
-
+ ModestPairList *protos;
ModestAccountAssistantPrivate *priv;
priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(self);
gtk_label_new(_("Server type")),
FALSE,FALSE,6);
- combo = modest_widget_factory_get_combo_box (priv->factory,
- MODEST_COMBO_BOX_TYPE_STORE_PROTOS);
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_STORE);
+ combo = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+
g_signal_connect (G_OBJECT(combo), "changed",
G_CALLBACK(on_receiving_combo_box_changed), self);
if (priv->transport_widget)
gtk_container_remove (GTK_CONTAINER(priv->transport_holder),
priv->transport_widget);
-
- priv->transport_widget = modest_transport_widget_new (priv->factory,
- modest_protocol_info_get_protocol(chosen));
+ priv->transport_widget =
+ modest_transport_widget_new (modest_protocol_info_get_protocol(chosen));
gtk_container_add (GTK_CONTAINER(priv->transport_holder),
priv->transport_widget);
add_sending_page (ModestAccountAssistant *self)
{
GtkWidget *page, *box, *combo;
-
+ ModestPairList *protos;
ModestAccountAssistantPrivate *priv;
priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(self);
gtk_box_pack_start (GTK_BOX(box),
gtk_label_new(_("Server type")),
FALSE,FALSE,0);
+
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_TRANSPORT);
+ combo = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
- combo = modest_widget_factory_get_combo_box (priv->factory,
- MODEST_COMBO_BOX_TYPE_TRANSPORT_PROTOS);
g_signal_connect (G_OBJECT(combo), "changed",
G_CALLBACK(on_sending_combo_box_changed), self);
static void
modest_account_assistant_init (ModestAccountAssistant *obj)
{
- ModestAccountAssistantPrivate *priv;
-
+ ModestAccountAssistantPrivate *priv;
priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(obj);
- priv->factory = NULL;
+
priv->account_mgr = NULL;
priv->store_widget = NULL;
ModestAccountAssistantPrivate *priv;
priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(obj);
-
- if (priv->factory) {
- g_object_unref (G_OBJECT(priv->factory));
- priv->factory = NULL;
- }
if (priv->account_mgr) {
g_object_unref (G_OBJECT(priv->account_mgr));
priv->account_mgr = NULL;
}
-
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
-modest_account_assistant_new (ModestAccountMgr *account_mgr, ModestWidgetFactory *factory)
+modest_account_assistant_new (ModestAccountMgr *account_mgr)
{
GObject *obj;
ModestAccountAssistant *self;
ModestAccountAssistantPrivate *priv;
-
- g_return_val_if_fail (factory, NULL);
+
g_return_val_if_fail (account_mgr, NULL);
obj = g_object_new(MODEST_TYPE_ACCOUNT_ASSISTANT, NULL);
self = MODEST_ACCOUNT_ASSISTANT(obj);
priv = MODEST_ACCOUNT_ASSISTANT_GET_PRIVATE(self);
-
- g_object_ref (factory);
- priv->factory = factory;
-
+
g_object_ref (account_mgr);
priv->account_mgr = account_mgr;
#ifndef __MODEST_ACCOUNT_ASSISTANT_H__
#define __MODEST_ACCOUNT_ASSISTANT_H__
-#include <modest-widget-factory.h>
+#include <gtk/gtkassistant.h>
#include <modest-account-mgr.h>
G_BEGIN_DECLS
typedef struct _ModestAccountAssistantClass ModestAccountAssistantClass;
struct _ModestAccountAssistant {
- GtkAssistant parent;
+ GtkAssistant parent;
/* insert public members, if any */
};
/* void (* my_event) (ModestAccountAssistant* obj); */
};
-/* member functions */
-GType modest_account_assistant_get_type (void) G_GNUC_CONST;
+GType modest_account_assistant_get_type (void) G_GNUC_CONST;
-GtkWidget* modest_account_assistant_new (ModestAccountMgr* account_mgr,
- ModestWidgetFactory *factory);
+GtkWidget* modest_account_assistant_new (ModestAccountMgr* account_mgr);
G_END_DECLS
*/
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
#include <modest-runtime.h>
#include <modest-account-mgr-helpers.h>
+#include <widgets/modest-account-view.h>
#include <string.h>
#include "modest-account-view-window.h"
#include "modest-account-assistant.h"
LAST_SIGNAL
};
-
typedef struct _ModestAccountViewWindowPrivate ModestAccountViewWindowPrivate;
struct _ModestAccountViewWindowPrivate {
- ModestWidgetFactory *widget_factory;
GtkWidget *add_button;
GtkWidget *edit_button;
GtkWidget *remove_button;
static void
modest_account_view_window_init (ModestAccountViewWindow *obj)
{
- ModestAccountViewWindowPrivate *priv;
-
- priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj);
-
- priv->widget_factory = NULL;
+ /* empty */
}
static void
modest_account_view_window_finalize (GObject *obj)
{
- ModestAccountViewWindowPrivate *priv;
-
- priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj);
-
- if (priv->widget_factory) {
- g_object_unref (G_OBJECT(priv->widget_factory));
- priv->widget_factory = NULL;
- }
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
ModestAccountViewWindowPrivate *priv;
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
- assistant = modest_account_assistant_new (modest_runtime_get_account_mgr(),
- priv->widget_factory);
+ assistant = modest_account_assistant_new (modest_runtime_get_account_mgr());
gtk_window_set_transient_for (GTK_WINDOW(assistant),
GTK_WINDOW(self));
GtkWidget *main_hbox, *main_vbox, *button_box;
GtkWidget *close_button;
GtkWidget *close_hbox;
- ModestAccountView *account_view;
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
main_vbox = gtk_vbox_new (FALSE, 6);
main_hbox = gtk_hbox_new (FALSE, 6);
- account_view = modest_widget_factory_get_account_view (priv->widget_factory);
- priv->account_view = account_view;
- gtk_widget_set_size_request (GTK_WIDGET(account_view), 300, 400);
+ priv->account_view = modest_account_view_new (modest_runtime_get_account_mgr());
+ gtk_widget_set_size_request (GTK_WIDGET(priv->account_view), 300, 400);
- sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(account_view));
+ sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(priv->account_view));
g_signal_connect (G_OBJECT(sel), "changed", G_CALLBACK(on_selection_changed),
self);
button_box = button_box_new (self);
- gtk_box_pack_start (GTK_BOX(main_hbox), GTK_WIDGET(account_view), TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX(main_hbox), GTK_WIDGET(priv->account_view), TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX(main_hbox), button_box, FALSE, FALSE,2);
gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 2);
GtkWidget*
-modest_account_view_window_new (ModestWidgetFactory *factory)
+modest_account_view_window_new (void)
{
GObject *obj;
ModestAccountViewWindowPrivate *priv;
-
- g_return_val_if_fail (factory, NULL);
obj = g_object_new(MODEST_TYPE_ACCOUNT_VIEW_WINDOW, NULL);
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(obj);
- g_object_ref (G_OBJECT(factory));
- priv->widget_factory = factory;
-
gtk_window_set_resizable (GTK_WINDOW(obj), FALSE);
-
gtk_window_set_title (GTK_WINDOW(obj), _("Accounts"));
gtk_window_set_type_hint (GTK_WINDOW(obj), GDK_WINDOW_TYPE_HINT_DIALOG);
#ifndef __MODEST_ACCOUNT_VIEW_WINDOW_H__
#define __MODEST_ACCOUNT_VIEW_WINDOW_H__
-#include <modest-widget-factory.h>
+#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
/* member functions */
GType modest_account_view_window_get_type (void) G_GNUC_CONST;
-GtkWidget* modest_account_view_window_new (ModestWidgetFactory *factory);
+GtkWidget* modest_account_view_window_new (void);
G_END_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.
- */
-#include <glib/gi18n.h>
-#include <string.h>
-#include <tny-account-store.h>
-#include <tny-simple-list.h>
-#include <modest-conf.h>
-#include <modest-runtime.h>
-#include <modest-tny-msg.h>
-#include <modest-window-priv.h>
-#include <modest-edit-msg-window.h>
-#include <modest-widget-memory.h>
-#include <widgets/modest-edit-msg-window-ui.h>
-#include <modest-account-mgr-helpers.h>
-
-static void modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass);
-static void modest_edit_msg_window_init (ModestEditMsgWindow *obj);
-static void modest_edit_msg_window_finalize (GObject *obj);
-
-/* list my signals */
-enum {
- /* MY_SIGNAL_1, */
- /* MY_SIGNAL_2, */
- LAST_SIGNAL
-};
-
-typedef struct _ModestEditMsgWindowPrivate ModestEditMsgWindowPrivate;
-struct _ModestEditMsgWindowPrivate {
-
- GtkWidget *toolbar;
- GtkWidget *menubar;
-
- GtkWidget *msg_body;
- GtkWidget *from_field;
- GtkWidget *to_field;
- GtkWidget *cc_field;
- GtkWidget *bcc_field;
- GtkWidget *subject_field;
-};
-
-#define MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
- MODEST_TYPE_EDIT_MSG_WINDOW, \
- ModestEditMsgWindowPrivate))
-/* globals */
-static GtkWindowClass *parent_class = NULL;
-
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
-GType
-modest_edit_msg_window_get_type (void)
-{
- static GType my_type = 0;
- if (!my_type) {
- static const GTypeInfo my_info = {
- sizeof(ModestEditMsgWindowClass),
- NULL, /* base init */
- NULL, /* base finalize */
- (GClassInitFunc) modest_edit_msg_window_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof(ModestEditMsgWindow),
- 1, /* n_preallocs */
- (GInstanceInitFunc) modest_edit_msg_window_init,
- NULL
- };
- my_type = g_type_register_static (MODEST_TYPE_WINDOW,
- "ModestEditMsgWindow",
- &my_info, 0);
- }
- return my_type;
-}
-
-static void
-modest_edit_msg_window_class_init (ModestEditMsgWindowClass *klass)
-{
- GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class->finalize = modest_edit_msg_window_finalize;
-
- g_type_class_add_private (gobject_class, sizeof(ModestEditMsgWindowPrivate));
-}
-
-static void
-modest_edit_msg_window_init (ModestEditMsgWindow *obj)
-{
- ModestEditMsgWindowPrivate *priv;
- priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj);
-
- priv->toolbar = NULL;
- priv->menubar = NULL;
- priv->msg_body = NULL;
- priv->from_field = NULL;
- priv->to_field = NULL;
- priv->cc_field = NULL;
- priv->bcc_field = NULL;
- priv->subject_field = NULL;
-}
-
-static void
-save_settings (ModestEditMsgWindow *self)
-{
- modest_widget_memory_save (modest_runtime_get_conf (),
- G_OBJECT(self), "modest-edit-msg-window");
-}
-
-
-static void
-restore_settings (ModestEditMsgWindow *self)
-{
- modest_widget_memory_restore (modest_runtime_get_conf (),
- G_OBJECT(self), "modest-edit-msg-window");
-}
-
-
-static void
-init_window (ModestEditMsgWindow *obj)
-{
- GtkWidget *to_button, *cc_button, *bcc_button;
- GtkWidget *header_table;
- GtkWidget *main_vbox;
- ModestEditMsgWindowPrivate *priv;
- ModestWindowPrivate *parent_priv;
-
- priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj);
- parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
-
- to_button = gtk_button_new_with_label (_("To..."));
- 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 (modest_runtime_get_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);
- 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);
-
- gtk_table_attach (GTK_TABLE(header_table), gtk_label_new (_("From:")),
- 0,1,0,1, GTK_SHRINK, 0, 0, 0);
- gtk_table_attach (GTK_TABLE(header_table), to_button, 0,1,1,2, GTK_SHRINK, 0, 0, 0);
- gtk_table_attach (GTK_TABLE(header_table), cc_button, 0,1,2,3, GTK_SHRINK, 0, 0, 0);
- gtk_table_attach (GTK_TABLE(header_table), bcc_button, 0,1,3,4, GTK_SHRINK, 0, 0, 0);
- gtk_table_attach (GTK_TABLE(header_table), gtk_label_new (_("Subject:")),
- 0,1,4,5, GTK_SHRINK, 0, 0, 0);
-
- gtk_table_attach_defaults (GTK_TABLE(header_table), priv->from_field, 1,2,0,1);
- gtk_table_attach_defaults (GTK_TABLE(header_table), priv->to_field, 1,2,1,2);
- gtk_table_attach_defaults (GTK_TABLE(header_table), priv->cc_field, 1,2,2,3);
- gtk_table_attach_defaults (GTK_TABLE(header_table), priv->bcc_field, 1,2,3,4);
- gtk_table_attach_defaults (GTK_TABLE(header_table), priv->subject_field,1,2,4,5);
-
- priv->msg_body = gtk_text_view_new ();
-
- main_vbox = gtk_vbox_new (FALSE, 6);
-
- 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_widget_show_all (GTK_WIDGET(main_vbox));
- gtk_container_add (GTK_CONTAINER(obj), main_vbox);
-}
-
-
-static void
-modest_edit_msg_window_finalize (GObject *obj)
-{
- G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
-
-
-
-static gboolean
-on_delete_event (GtkWidget *widget, GdkEvent *event, ModestEditMsgWindow *self)
-{
- save_settings (self);
- return FALSE;
-}
-
-
-ModestWindow *
-modest_edit_msg_window_new (ModestEditType type)
-{
- GObject *obj;
- ModestEditMsgWindowPrivate *priv;
- ModestWindowPrivate *parent_priv;
- GtkActionGroup *action_group;
- GError *error = NULL;
-
- g_return_val_if_fail (type < MODEST_EDIT_TYPE_NUM, NULL);
-
- obj = g_object_new(MODEST_TYPE_EDIT_MSG_WINDOW, NULL);
- priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE(obj);
- parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
-
- parent_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 (parent_priv->ui_manager, action_group, 0);
- g_object_unref (action_group);
-
- /* Load the UI definition */
- gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-edit-msg-window-ui.xml", &error);
- if (error) {
- g_printerr ("modest: could not merge modest-edit-msg-window-ui.xml: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- }
- /* ****** */
-
- /* Add accelerators */
- gtk_window_add_accel_group (GTK_WINDOW (obj),
- gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
-
-
- /* Toolbar / Menubar */
- priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
- priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
-
- 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));
-
- gtk_window_set_title (GTK_WINDOW(obj), "Modest");
- gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
-
- g_signal_connect (G_OBJECT(obj), "delete-event",
- G_CALLBACK(on_delete_event), obj);
-
- return (ModestWindow *) (obj);
-}
-
-void
-modest_edit_msg_window_set_msg (ModestEditMsgWindow *self, TnyMsg *msg)
-{
- TnyHeader *header;
- GtkTextBuffer *buf;
- const gchar *to, *cc, *bcc, *subject;
- ModestEditMsgWindowPrivate *priv;
- gchar *body;
-
- g_return_if_fail (MODEST_IS_EDIT_MSG_WINDOW (self));
- g_return_if_fail (TNY_IS_MSG (msg));
-
- priv = MODEST_EDIT_MSG_WINDOW_GET_PRIVATE (self);
-
- header = tny_msg_get_header (msg);
- to = tny_header_get_to (header);
- cc = tny_header_get_cc (header);
- bcc = tny_header_get_bcc (header);
- subject = tny_header_get_subject (header);
-
- if (to)
- gtk_entry_set_text (GTK_ENTRY(priv->to_field), to);
- if (cc)
- gtk_entry_set_text (GTK_ENTRY(priv->cc_field), cc);
- if (bcc)
- gtk_entry_set_text (GTK_ENTRY(priv->bcc_field), bcc);
- if (subject)
- gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
-
- buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body));
- body = modest_tny_msg_get_body (msg, FALSE);
- if (body)
- gtk_text_buffer_set_text (buf, body, -1);
- g_free (body);
-
- /* TODO: lower priority, select in the From: combo to the
- value that comes from msg <- not sure, should it be
- allowed? */
-
- /* TODO: set attachments */
-}
-
-MsgData *
-modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *edit_window)
-{
- MsgData *data;
- GtkTextBuffer *buf;
- GtkTextIter b, e;
- const gchar *account_name;
- gchar *from_string = NULL;
- 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_name = (gchar*)modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field));
- if (account_name)
- from_string = modest_account_mgr_get_from_string (
- modest_runtime_get_account_mgr(), account_name);
- if (!from_string) {
- g_printerr ("modest: cannot get from string\n");
- return NULL;
- }
-
- 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 = from_string, /* will be freed when data is freed */
- 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);
-}
{ "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) },
+ { "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) },
+ { "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 },
{ "EditDeselectAll", NULL, N_("Deselect all"), "<Shift><CTRL>A", N_("Deselect all"), NULL },
/* VIEW */
- { "ToggleView", GTK_STOCK_CDROM, N_("_Toggle view"), NULL, N_("Toggle the list view"), G_CALLBACK(_modest_ui_actions_toggle_view) },
-
+ { "ToggleView", GTK_STOCK_CDROM, N_("_Toggle view"), NULL, N_("Toggle the list view"), G_CALLBACK(modest_ui_actions_toggle_view) },
/* 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) },
+ { "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) },
- { "ActionsFolderNew", NULL, N_("New Folder"), NULL, N_("Create a new folder"), G_CALLBACK (_modest_ui_actions_on_new_folder) },
- { "ActionsFolderDelete", NULL, N_("Delete Folder"), NULL, N_("Delete the folder"), G_CALLBACK (_modest_ui_actions_on_delete_folder) },
- { "ActionsFolderRename", NULL, N_("Rename Folder"), NULL, N_("Rename the folder"), G_CALLBACK (_modest_ui_actions_on_rename_folder) },
- { "ActionsFolderMoveToTrash", NULL, N_("Move Folder to Trash"), NULL, N_("Move folder to Trash"), G_CALLBACK (_modest_ui_actions_on_move_to_trash_folder) },
+ { "ActionsDelete", MODEST_STOCK_DELETE, N_("Delete message"), NULL, N_("Delete messages"), G_CALLBACK (modest_ui_actions_on_delete) },
+ { "ActionsFolderNew", NULL, N_("New Folder"), NULL, N_("Create a new folder"), G_CALLBACK (modest_ui_actions_on_new_folder) },
+ { "ActionsFolderDelete", NULL, N_("Delete Folder"), NULL, N_("Delete the folder"), G_CALLBACK (modest_ui_actions_on_delete_folder) },
+ { "ActionsFolderRename", NULL, N_("Rename Folder"), NULL, N_("Rename the folder"), G_CALLBACK (modest_ui_actions_on_rename_folder) },
+ { "ActionsFolderMoveToTrash", NULL, N_("Move Folder to Trash"), NULL, N_("Move folder to Trash"), G_CALLBACK (modest_ui_actions_on_move_to_trash_folder) },
/* 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) },
+ { "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) },
+ { "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) },
+ { "HelpAbout", GTK_STOCK_ABOUT, N_("About"), NULL, N_("About Modest"), G_CALLBACK (modest_ui_actions_on_about) },
};
#include <gtk/gtktreeviewcolumn.h>
#include <modest-runtime.h>
-#include "modest-main-window.h"
-#include "modest-window-priv.h"
+#include <widgets/modest-main-window.h>
+#include <widgets/modest-window-priv.h>
+#include <widgets/modest-msg-edit-window.h>
+#include "modest-account-view-window.h"
+
+
#include "modest-widget-memory.h"
-#include "modest-ui.h"
+#include "modest-ui-actions.h"
#include "modest-main-window-ui.h"
-#include "modest-account-view-window.h"
#include "modest-account-mgr.h"
#include "modest-conf.h"
-#include "modest-edit-msg-window.h"
#include <modest-tny-msg.h>
#include "modest-mail-operation.h"
#include "modest-icon-names.h"
GdkEventButton *event,
GtkWidget *menu);
+static void connect_signals (ModestMainWindow *self);
+
+
/* list my signals */
enum {
/* MY_SIGNAL_1, */
GtkWidget *msg_paned;
GtkWidget *main_paned;
- ModestHeaderView *header_view;
- ModestFolderView *folder_view;
- ModestMsgView *msg_preview;
+ GtkWidget *online_toggle;
+ GtkWidget *folder_info_label;
};
modest_main_window_init (ModestMainWindow *obj)
{
ModestMainWindowPrivate *priv;
-
+ TnyFolderStoreQuery *query;
+
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
priv->folder_paned = NULL;
priv->msg_paned = NULL;
priv->main_paned = NULL;
- priv->header_view = NULL;
- priv->folder_view = NULL;
- priv->msg_preview = NULL;
+
+ /* folder view */
+ query = tny_folder_store_query_new ();
+ tny_folder_store_query_add_item (query, NULL,
+ TNY_FOLDER_STORE_QUERY_OPTION_SUBSCRIBED);
+
+ obj->folder_view =
+ MODEST_FOLDER_VIEW(modest_folder_view_new (modest_runtime_get_account_store(),
+ query));
+ if (!obj->folder_view)
+ g_printerr ("modest: cannot instantiate folder view\n");
+ g_object_unref (G_OBJECT (query));
+
+ /* header view */
+ obj->header_view =
+ MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
+ if (!obj->header_view)
+ g_printerr ("modest: cannot instantiate header view\n");
+
+ /* msg preview */
+ obj->msg_preview = MODEST_MSG_VIEW(modest_msg_view_new (NULL));
+ if (!obj->msg_preview)
+ g_printerr ("modest: cannot instantiate msgpreiew\n");
+
+ /* online/offline combo */
+ priv->online_toggle = gtk_toggle_button_new ();
+
+ /* label with number of items, unread items for
+ the current folder */
+ priv->folder_info_label = gtk_label_new (NULL);
+
+ /* status bar */
+ obj->status_bar = gtk_statusbar_new ();
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(obj->status_bar),
+ FALSE);
+
+ /* progress bar */
+ obj->progress_bar = gtk_progress_bar_new ();
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(obj->progress_bar), 1.0);
+ gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR(obj->progress_bar),
+ PANGO_ELLIPSIZE_END);
}
static void
}
-static ModestHeaderView*
-header_view_new (ModestMainWindow *self)
-{
- ModestHeaderView *header_view;
-
- header_view = modest_widget_factory_get_header_view
- (modest_runtime_get_widget_factory());
- modest_header_view_set_style
- (header_view, MODEST_HEADER_VIEW_STYLE_DETAILS);
-
- return header_view;
-}
-
-
static void
restore_sizes (ModestMainWindow *self)
{
"modest-msg-paned");
modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned),
"modest-main-paned");
- modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),
- "header-view");
- modest_widget_memory_restore (conf,G_OBJECT(self),
- "modest-main-window");
+ modest_widget_memory_restore (conf, G_OBJECT(self->header_view),"header-view");
+ modest_widget_memory_restore (conf,G_OBJECT(self), "modest-main-window");
}
"modest-msg-paned");
modest_widget_memory_save (conf, G_OBJECT(priv->main_paned),
"modest-main-paned");
- modest_widget_memory_save (conf, G_OBJECT(priv->header_view), "header-view");
+ modest_widget_memory_save (conf, G_OBJECT(self->header_view), "header-view");
+}
+
+
+static void
+on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+{
+ GtkWidget *icon;
+ const gchar *icon_name;
+ ModestMainWindowPrivate *priv;
+
+ g_return_if_fail (device);
+ g_return_if_fail (self);
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ icon_name = online ? GTK_STOCK_CONNECT : GTK_STOCK_DISCONNECT;
+ icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
+
+ /* Block handlers in order to avoid unnecessary calls */
+ //g_signal_handler_block (G_OBJECT (priv->online_toggle), priv->toggle_button_signal);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(priv->online_toggle), online);
+ //g_signal_handler_unblock (G_OBJECT (online_toggle), priv->toggle_button_signal);
+
+ gtk_button_set_image (GTK_BUTTON(priv->online_toggle), icon);
+ //statusbar_push (widget_factory, 0, online ? _("Modest went online") : _("Modest went offline"));
+
+ /* If Modest has became online and the header view has a
+ header selected then show it */
+ /* FIXME: there is a race condition if some account needs to
+ ask the user for a password */
+
+/* if (online) { */
+/* GtkTreeSelection *selected; */
+
+/* selected = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view)); */
+/* _modest_header_view_change_selection (selected, header_view); */
+/* } */
+}
+
+void
+on_online_toggle_toggled (GtkToggleButton *toggle, ModestMainWindow *self)
+{
+ gboolean online;
+ TnyDevice *device;
+ ModestMainWindowPrivate *priv;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ device = tny_account_store_get_device
+ (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()));
+
+ online = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(priv->online_toggle));
+
+ if (online)
+ tny_device_force_online (device);
+ else
+ tny_device_force_offline (device);
+
+ g_object_unref (G_OBJECT (device));
}
+static gboolean
+on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMainWindow *self)
+{
+ save_sizes (self);
+ return FALSE;
+}
+
+
+static void
+connect_signals (ModestMainWindow *self)
+{
+ ModestWindowPrivate *parent_priv;
+ ModestMainWindowPrivate *priv;
+ TnyDevice *device;
+ ModestTnyAccountStore *account_store;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+ account_store = modest_runtime_get_account_store ();
+ device = tny_account_store_get_device(TNY_ACCOUNT_STORE(account_store));
+
+ /* folder view */
+ g_signal_connect (G_OBJECT(self->folder_view), "folder_selection_changed",
+ G_CALLBACK(modest_ui_actions_on_folder_selection_changed), self);
+ g_signal_connect (G_OBJECT(self->folder_view), "folder_moved",
+ G_CALLBACK(modest_ui_actions_on_folder_moved), NULL);
+ g_signal_connect (G_OBJECT(self->folder_view), "button-press-event",
+ G_CALLBACK (on_folder_view_button_press_event),self);
+ g_signal_connect (self->folder_view,"popup-menu",
+ G_CALLBACK (on_folder_view_button_press_event),self);
+
+ /* header view */
+ g_signal_connect (G_OBJECT(self->header_view), "status_update",
+ G_CALLBACK(modest_ui_actions_on_header_status_update), self);
+ g_signal_connect (G_OBJECT(self->header_view), "header_selected",
+ G_CALLBACK(modest_ui_actions_on_header_selected), self);
+ g_signal_connect (G_OBJECT(self->header_view), "header_activated",
+ G_CALLBACK(modest_ui_actions_on_header_activated), self);
+ g_signal_connect (G_OBJECT(self->header_view), "item_not_found",
+ G_CALLBACK(modest_ui_actions_on_item_not_found), self);
+ g_signal_connect (G_OBJECT(self->header_view), "button-press-event",
+ G_CALLBACK (on_header_view_button_press_event), self);
+ g_signal_connect (G_OBJECT(self->header_view),"popup-menu",
+ G_CALLBACK (on_header_view_button_press_event), self);
+
+ /* msg preview */
+ g_signal_connect (G_OBJECT(self->msg_preview), "link_clicked",
+ G_CALLBACK(modest_ui_actions_on_msg_link_clicked), self);
+ g_signal_connect (G_OBJECT(self->msg_preview), "link_hover",
+ G_CALLBACK(modest_ui_actions_on_msg_link_hover), self);
+ g_signal_connect (G_OBJECT(self->msg_preview), "attachment_clicked",
+ G_CALLBACK(modest_ui_actions_on_msg_attachment_clicked), self);
+
+ /* Account store */
+ g_signal_connect (G_OBJECT (modest_runtime_get_account_store()), "accounts_reloaded",
+ G_CALLBACK (modest_ui_actions_on_accounts_reloaded), self);
+
+ /* Device */
+ g_signal_connect (G_OBJECT(device), "connection_changed",
+ G_CALLBACK(on_connection_changed), self);
+ g_signal_connect (G_OBJECT(priv->online_toggle), "toggled",
+ G_CALLBACK(on_online_toggle_toggled), NULL);
+
+ /* window */
+ //g_signal_connect (G_OBJECT(self), "destroy", G_CALLBACK(on_main_window_destroy), NULL);
+ g_signal_connect (G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self);
+}
+
+
static GtkWidget*
wrapped_in_scrolled_window (GtkWidget *widget, gboolean needs_viewport)
{
}
-static gboolean
-on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMainWindow *self)
-{
- save_sizes (self);
- return FALSE;
-}
ModestWindow *
modest_main_window_new (void)
{
GObject *obj;
+ ModestMainWindow *self;
ModestMainWindowPrivate *priv;
ModestWindowPrivate *parent_priv;
GtkWidget *main_vbox;
GtkWidget *status_hbox;
GtkWidget *header_win, *folder_win;
- ModestWidgetFactory *widget_factory;
GtkActionGroup *action_group;
GError *error = NULL;
-
-
+
obj = g_object_new(MODEST_TYPE_MAIN_WINDOW, NULL);
- priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
- parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
+ self = MODEST_MAIN_WINDOW(obj);
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
/* ***************** */
parent_priv->ui_manager = gtk_ui_manager_new();
action_group = gtk_action_group_new ("ModestMainWindowActions");
-
- widget_factory = modest_runtime_get_widget_factory ();
/* Add common actions */
gtk_action_group_add_actions (action_group,
g_object_unref (action_group);
/* Load the UI definition */
- gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-ui.xml", &error);
+ gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager,
+ MODEST_UIDIR "modest-main-window-ui.xml", &error);
if (error != NULL) {
- g_printerr ("modest: could not merge modest-ui.xml: %s", error->message);
+ g_printerr ("modest: could not merge modest-main-window-ui.xml: %s", error->message);
g_error_free (error);
error = NULL;
}
parent_priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
parent_priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
- gtk_toolbar_set_tooltips (GTK_TOOLBAR (parent_priv->toolbar), TRUE);
-
- /* widgets from factory */
- priv->folder_view = modest_widget_factory_get_folder_view (widget_factory);
- priv->header_view = header_view_new (MODEST_MAIN_WINDOW(obj));
- priv->msg_preview = modest_widget_factory_get_msg_preview (widget_factory);
-
- folder_win = wrapped_in_scrolled_window (GTK_WIDGET(priv->folder_view),
- FALSE);
- header_win = wrapped_in_scrolled_window (GTK_WIDGET(priv->header_view),
- FALSE);
-
- /* Connect platform specific signals */
- g_signal_connect (priv->header_view,
- "button-press-event",
- G_CALLBACK (on_header_view_button_press_event),
- obj);
- g_signal_connect (priv->header_view,
- "popup-menu",
- G_CALLBACK (on_header_view_button_press_event),
- obj);
- g_signal_connect (priv->folder_view,
- "button-press-event",
- G_CALLBACK (on_folder_view_button_press_event),
- obj);
- g_signal_connect (priv->folder_view,
- "popup-menu",
- G_CALLBACK (on_folder_view_button_press_event),
- obj);
+ gtk_toolbar_set_tooltips (GTK_TOOLBAR (parent_priv->toolbar), TRUE);
+ folder_win = wrapped_in_scrolled_window (GTK_WIDGET(self->folder_view), FALSE);
+ header_win = wrapped_in_scrolled_window (GTK_WIDGET(self->header_view), FALSE);
/* paned */
priv->folder_paned = gtk_vpaned_new ();
gtk_paned_add1 (GTK_PANED(priv->main_paned), folder_win);
gtk_paned_add2 (GTK_PANED(priv->main_paned), priv->msg_paned);
gtk_paned_add1 (GTK_PANED(priv->msg_paned), header_win);
- gtk_paned_add2 (GTK_PANED(priv->msg_paned), GTK_WIDGET(priv->msg_preview));
+ gtk_paned_add2 (GTK_PANED(priv->msg_paned), GTK_WIDGET(self->msg_preview));
- gtk_widget_show (GTK_WIDGET(priv->header_view));
+ gtk_widget_show (GTK_WIDGET(self->header_view));
/* status bar / progress */
status_hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX(status_hbox),
- modest_widget_factory_get_folder_info_label (widget_factory),
- FALSE,FALSE, 6);
- gtk_box_pack_start (GTK_BOX(status_hbox),
- modest_widget_factory_get_status_bar(widget_factory),
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX(status_hbox),
- modest_widget_factory_get_progress_bar(widget_factory),
- FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(status_hbox),
- modest_widget_factory_get_online_toggle(widget_factory),
- FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(status_hbox), priv->folder_info_label, FALSE,FALSE, 6);
+ gtk_box_pack_start (GTK_BOX(status_hbox), self->status_bar, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX(status_hbox), self->progress_bar,FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(status_hbox), priv->online_toggle,FALSE, FALSE, 0);
/* putting it all together... */
main_vbox = gtk_vbox_new (FALSE, 6);
gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
gtk_widget_show_all (main_vbox);
- g_signal_connect (G_OBJECT(obj), "delete-event",
- G_CALLBACK(on_delete_event), obj);
-
+ /* Init toggle in correct state */
+ //modest_ui_actions_on_connection_changed (device, tny_device_is_online (device), self);
+
+ connect_signals (MODEST_MAIN_WINDOW(obj));
return (ModestWindow *) obj;
}
NULL, NULL,
event->button, event->time);
}
-
return TRUE;
}
--- /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.
+ */
+#include <glib/gi18n.h>
+#include <string.h>
+#include <tny-account-store.h>
+#include <tny-simple-list.h>
+#include <modest-conf.h>
+#include <modest-runtime.h>
+#include <modest-tny-msg.h>
+
+#include <widgets/modest-window-priv.h>
+#include <widgets/modest-msg-edit-window.h>
+#include <widgets/modest-msg-edit-window-ui.h>
+#include <widgets/modest-combo-box.h>
+
+#include <modest-widget-memory.h>
+#include <modest-account-mgr-helpers.h>
+
+static void modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass);
+static void modest_msg_edit_window_init (ModestMsgEditWindow *obj);
+static void modest_msg_edit_window_finalize (GObject *obj);
+
+/* list my signals */
+enum {
+ /* MY_SIGNAL_1, */
+ /* MY_SIGNAL_2, */
+ LAST_SIGNAL
+};
+
+typedef struct _ModestMsgEditWindowPrivate ModestMsgEditWindowPrivate;
+struct _ModestMsgEditWindowPrivate {
+
+ GtkWidget *toolbar;
+ GtkWidget *menubar;
+
+ GtkWidget *msg_body;
+ GtkWidget *from_field;
+ GtkWidget *to_field;
+ GtkWidget *cc_field;
+ GtkWidget *bcc_field;
+ GtkWidget *subject_field;
+};
+
+#define MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+ MODEST_TYPE_MSG_EDIT_WINDOW, \
+ ModestMsgEditWindowPrivate))
+/* globals */
+static GtkWindowClass *parent_class = NULL;
+
+/* uncomment the following if you have defined any signals */
+/* static guint signals[LAST_SIGNAL] = {0}; */
+
+GType
+modest_msg_edit_window_get_type (void)
+{
+ static GType my_type = 0;
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestMsgEditWindowClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_msg_edit_window_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestMsgEditWindow),
+ 1, /* n_preallocs */
+ (GInstanceInitFunc) modest_msg_edit_window_init,
+ NULL
+ };
+ my_type = g_type_register_static (MODEST_TYPE_WINDOW,
+ "ModestMsgEditWindow",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_msg_edit_window_class_init (ModestMsgEditWindowClass *klass)
+{
+ GObjectClass *gobject_class;
+ gobject_class = (GObjectClass*) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_msg_edit_window_finalize;
+
+ g_type_class_add_private (gobject_class, sizeof(ModestMsgEditWindowPrivate));
+}
+
+static void
+modest_msg_edit_window_init (ModestMsgEditWindow *obj)
+{
+ ModestMsgEditWindowPrivate *priv;
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
+
+ priv->toolbar = NULL;
+ priv->menubar = NULL;
+ priv->msg_body = NULL;
+ priv->from_field = NULL;
+ priv->to_field = NULL;
+ priv->cc_field = NULL;
+ priv->bcc_field = NULL;
+ priv->subject_field = NULL;
+}
+
+static void
+save_settings (ModestMsgEditWindow *self)
+{
+ modest_widget_memory_save (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
+}
+
+
+static void
+restore_settings (ModestMsgEditWindow *self)
+{
+ modest_widget_memory_restore (modest_runtime_get_conf (),
+ G_OBJECT(self), "modest-edit-msg-window");
+}
+
+
+
+static ModestPairList*
+get_transports (void)
+{
+ ModestAccountMgr *account_mgr;
+ GSList *transports = NULL;
+ GSList *cursor, *accounts;
+
+ account_mgr = modest_runtime_get_account_mgr();
+ cursor = accounts = modest_account_mgr_account_names (account_mgr, NULL);
+ while (cursor) {
+ gchar *account_name = (gchar*)cursor->data;
+ gchar *from_string = modest_account_mgr_get_from_string (account_mgr,
+ account_name);
+ if (!from_string) {
+ /* something went wrong: ignore this one */
+ g_free (account_name);
+ cursor->data = NULL;
+ } else {
+ ModestPair *pair;
+ pair = modest_pair_new ((gpointer) account_name,
+ (gpointer) from_string , TRUE);
+ transports = g_slist_prepend (transports, pair);
+ } /* don't free account name; it's freed when the transports list is freed */
+ cursor = cursor->next;
+ }
+ g_slist_free (accounts);
+ return transports;
+}
+
+
+
+static void
+init_window (ModestMsgEditWindow *obj)
+{
+ GtkWidget *to_button, *cc_button, *bcc_button;
+ GtkWidget *header_table;
+ GtkWidget *main_vbox;
+ ModestMsgEditWindowPrivate *priv;
+ ModestWindowPrivate *parent_priv;
+ ModestPairList *protos;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
+
+ to_button = gtk_button_new_with_label (_("To..."));
+ cc_button = gtk_button_new_with_label (_("Cc..."));
+ bcc_button = gtk_button_new_with_label (_("Bcc..."));
+
+
+ protos = get_transports ();
+ priv->from_field = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+
+ 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);
+
+ gtk_table_attach (GTK_TABLE(header_table), gtk_label_new (_("From:")),
+ 0,1,0,1, GTK_SHRINK, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE(header_table), to_button, 0,1,1,2, GTK_SHRINK, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE(header_table), cc_button, 0,1,2,3, GTK_SHRINK, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE(header_table), bcc_button, 0,1,3,4, GTK_SHRINK, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE(header_table), gtk_label_new (_("Subject:")),
+ 0,1,4,5, GTK_SHRINK, 0, 0, 0);
+
+ gtk_table_attach_defaults (GTK_TABLE(header_table), priv->from_field, 1,2,0,1);
+ gtk_table_attach_defaults (GTK_TABLE(header_table), priv->to_field, 1,2,1,2);
+ gtk_table_attach_defaults (GTK_TABLE(header_table), priv->cc_field, 1,2,2,3);
+ gtk_table_attach_defaults (GTK_TABLE(header_table), priv->bcc_field, 1,2,3,4);
+ gtk_table_attach_defaults (GTK_TABLE(header_table), priv->subject_field,1,2,4,5);
+
+ priv->msg_body = gtk_text_view_new ();
+
+ main_vbox = gtk_vbox_new (FALSE, 6);
+
+ 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_widget_show_all (GTK_WIDGET(main_vbox));
+ gtk_container_add (GTK_CONTAINER(obj), main_vbox);
+}
+
+
+static void
+modest_msg_edit_window_finalize (GObject *obj)
+{
+ G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+
+
+static gboolean
+on_delete_event (GtkWidget *widget, GdkEvent *event, ModestMsgEditWindow *self)
+{
+ save_settings (self);
+ return FALSE;
+}
+
+
+ModestWindow *
+modest_msg_edit_window_new (ModestEditType type)
+{
+ GObject *obj;
+ ModestMsgEditWindowPrivate *priv;
+ ModestWindowPrivate *parent_priv;
+ GtkActionGroup *action_group;
+ GError *error = NULL;
+
+ g_return_val_if_fail (type < MODEST_EDIT_TYPE_NUM, NULL);
+
+ obj = g_object_new(MODEST_TYPE_MSG_EDIT_WINDOW, NULL);
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(obj);
+ parent_priv = MODEST_WINDOW_GET_PRIVATE(obj);
+
+ parent_priv->ui_manager = gtk_ui_manager_new();
+ action_group = gtk_action_group_new ("ModestMsgEditWindowActions");
+
+ /* Add common actions */
+ gtk_action_group_add_actions (action_group,
+ modest_msg_edit_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_action_entries),
+ obj);
+ gtk_action_group_add_toggle_actions (action_group,
+ modest_msg_edit_toggle_action_entries,
+ G_N_ELEMENTS (modest_msg_edit_toggle_action_entries),
+ obj);
+ gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ /* Load the UI definition */
+ gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager,
+ MODEST_UIDIR "modest-msg-edit-window-ui.xml",
+ &error);
+ if (error) {
+ g_printerr ("modest: could not merge modest-msg-edit-window-ui.xml: %s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ /* ****** */
+
+ /* Add accelerators */
+ gtk_window_add_accel_group (GTK_WINDOW (obj),
+ gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
+
+
+ /* Toolbar / Menubar */
+ priv->toolbar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar");
+ priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
+
+ gtk_toolbar_set_tooltips (GTK_TOOLBAR (priv->toolbar), TRUE);
+
+ /* Init window */
+ init_window (MODEST_MSG_EDIT_WINDOW(obj));
+
+ restore_settings (MODEST_MSG_EDIT_WINDOW(obj));
+
+ gtk_window_set_title (GTK_WINDOW(obj), "Modest");
+ gtk_window_set_icon_from_file (GTK_WINDOW(obj), MODEST_APP_ICON, NULL);
+
+ g_signal_connect (G_OBJECT(obj), "delete-event",
+ G_CALLBACK(on_delete_event), obj);
+
+ return (ModestWindow *) (obj);
+}
+
+void
+modest_msg_edit_window_set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
+{
+ TnyHeader *header;
+ GtkTextBuffer *buf;
+ const gchar *to, *cc, *bcc, *subject;
+ ModestMsgEditWindowPrivate *priv;
+ gchar *body;
+
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
+ g_return_if_fail (TNY_IS_MSG (msg));
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ header = tny_msg_get_header (msg);
+ to = tny_header_get_to (header);
+ cc = tny_header_get_cc (header);
+ bcc = tny_header_get_bcc (header);
+ subject = tny_header_get_subject (header);
+
+ if (to)
+ gtk_entry_set_text (GTK_ENTRY(priv->to_field), to);
+ if (cc)
+ gtk_entry_set_text (GTK_ENTRY(priv->cc_field), cc);
+ if (bcc)
+ gtk_entry_set_text (GTK_ENTRY(priv->bcc_field), bcc);
+ if (subject)
+ gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
+
+ buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(priv->msg_body));
+ body = modest_tny_msg_get_body (msg, FALSE);
+ if (body)
+ gtk_text_buffer_set_text (buf, body, -1);
+ g_free (body);
+
+ /* TODO: lower priority, select in the From: combo to the
+ value that comes from msg <- not sure, should it be
+ allowed? */
+
+ /* TODO: set attachments */
+}
+
+MsgData *
+modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *edit_window)
+{
+ MsgData *data;
+ GtkTextBuffer *buf;
+ GtkTextIter b, e;
+ const gchar *account_name;
+ gchar *from_string = NULL;
+ ModestMsgEditWindowPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW (edit_window), NULL);
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (edit_window);
+
+ account_name = (gchar*)modest_combo_box_get_active_id (MODEST_COMBO_BOX (priv->from_field));
+ if (account_name)
+ from_string = modest_account_mgr_get_from_string (
+ modest_runtime_get_account_mgr(), account_name);
+ if (!from_string) {
+ g_printerr ("modest: cannot get from string\n");
+ return NULL;
+ }
+
+ 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 = from_string, /* will be freed when data is freed */
+ 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_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window,
+ MsgData *data)
+{
+ g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (edit_window));
+
+ g_free (data->from);
+ g_free (data->body);
+ g_slice_free (MsgData, data);
+}
#include <tny-account-store.h>
#include <tny-simple-list.h>
#include <modest-tny-msg.h>
-#include <modest-msg-view-window.h>
-#include <modest-main-window-ui.h>
+
+#include <widgets/modest-msg-view-window.h>
+#include "modest-main-window-ui.h"
+#include <widgets/modest-window-priv.h>
+
#include <modest-widget-memory.h>
#include <modest-runtime.h>
-#include <modest-window-priv.h>
static void modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass);
static void modest_msg_view_window_init (ModestMsgViewWindow *obj);
obj);
gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
g_object_unref (action_group);
-
+
/* Load the UI definition */
- gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager, MODEST_UIDIR "modest-msg-view-window-ui.xml",
+ gtk_ui_manager_add_ui_from_file (parent_priv->ui_manager,
+ MODEST_UIDIR "modest-msg-view-window-ui.xml",
&error);
if (error) {
g_printerr ("modest: could not merge modest-msg-view-window-ui.xml: %s\n", error->message);
*/
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <widgets/modest-combo-box.h>
#include "modest-store-widget.h"
#include <string.h>
GtkWidget *remember_pwd;
ModestProtocol proto;
- ModestWidgetFactory *factory;
};
#define MODEST_STORE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_STORE_WIDGET, \
static GtkWidget*
imap_pop_configuration (ModestStoreWidget *self)
{
+ ModestPairList *protos;
ModestStoreWidgetPrivate *priv;
GtkWidget *label, *box, *hbox;
-
+ GtkWidget *combo;
+
priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
box = gtk_vbox_new (FALSE, 6);
gtk_label_set_markup (GTK_LABEL(label),_("<b>Security</b>"));
gtk_box_pack_start (GTK_BOX(box), label, FALSE, FALSE, 0);
- priv->security = modest_widget_factory_get_combo_box (priv->factory,
- MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS);
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_SECURITY);
+ priv->security = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+
hbox = gtk_hbox_new (FALSE, 6);
label = gtk_label_new(NULL);
gtk_label_set_text (GTK_LABEL(label),_("Connection type:"));
gtk_label_set_text (GTK_LABEL(label),_("Authentication:"));
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX(hbox), modest_widget_factory_get_combo_box
- (priv->factory, MODEST_COMBO_BOX_TYPE_AUTH_PROTOS),
- FALSE, FALSE, 0);
+
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
+ combo = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+ gtk_box_pack_start (GTK_BOX(hbox), combo, FALSE, FALSE, 0);
priv->remember_pwd =
gtk_check_button_new_with_label (_("Remember password"));
gtk_box_pack_start (GTK_BOX(hbox),priv->remember_pwd,
static void
modest_store_widget_finalize (GObject *obj)
{
- ModestStoreWidgetPrivate *priv;
- priv = MODEST_STORE_WIDGET_GET_PRIVATE(obj);
-
- if (priv->factory) {
- g_object_unref (priv->factory);
- priv->factory = NULL;
- }
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
GtkWidget*
-modest_store_widget_new (ModestWidgetFactory *factory, ModestProtocol proto)
+modest_store_widget_new (ModestProtocol proto)
{
GObject *obj;
GtkWidget *w;
ModestStoreWidgetPrivate *priv;
g_return_val_if_fail (proto, NULL);
- g_return_val_if_fail (factory, NULL);
obj = g_object_new(MODEST_TYPE_STORE_WIDGET, NULL);
self = MODEST_STORE_WIDGET(obj);
priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
- g_object_ref (factory);
- priv->factory = factory;
-
priv->proto = proto;
if (proto == MODEST_PROTOCOL_STORE_POP || proto == MODEST_PROTOCOL_STORE_IMAP)
#ifndef __MODEST_STORE_WIDGET_H__
#define __MODEST_STORE_WIDGET_H__
-#include <modest-widget-factory.h>
+#include <gtk/gtkvbox.h>
+#include <modest-protocol-info.h>
G_BEGIN_DECLS
/* member functions */
GType modest_store_widget_get_type (void) G_GNUC_CONST;
-GtkWidget* modest_store_widget_new (ModestWidgetFactory *factory,
- ModestProtocol proto);
+GtkWidget* modest_store_widget_new (ModestProtocol proto);
gboolean modest_store_widget_get_remember_password (ModestStoreWidget *self);
const gchar* modest_store_widget_get_username (ModestStoreWidget *self);
/* insert (c)/licensing information) */
#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <widgets/modest-combo-box.h>
+#include <modest-protocol-info.h>
#include "modest-transport-widget.h"
#include <string.h>
+
+
/* 'private'/'protected' functions */
static void modest_transport_widget_class_init (ModestTransportWidgetClass *klass);
static void modest_transport_widget_init (ModestTransportWidget *obj);
typedef struct _ModestTransportWidgetPrivate ModestTransportWidgetPrivate;
struct _ModestTransportWidgetPrivate {
ModestProtocol proto;
- ModestWidgetFactory *factory;
-
GtkWidget *servername;
GtkWidget *username;
GtkWidget *auth;
static void
modest_transport_widget_finalize (GObject *obj)
{
- ModestTransportWidgetPrivate *priv;
- priv = MODEST_TRANSPORT_WIDGET_GET_PRIVATE(obj);
-
- if (priv->factory) {
- g_object_unref (priv->factory);
- priv->factory = NULL;
- }
-
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
smtp_configuration (ModestTransportWidget *self)
{
ModestTransportWidgetPrivate *priv;
- GtkWidget *label, *box, *hbox;
+ GtkWidget *label, *box, *hbox, *combo;
+ ModestPairList *protos;
priv = MODEST_TRANSPORT_WIDGET_GET_PRIVATE(self);
box = gtk_vbox_new (FALSE, 6);
label = gtk_label_new(NULL);
gtk_label_set_text (GTK_LABEL(label),_("Connection type:"));
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX(hbox), modest_widget_factory_get_combo_box
- (priv->factory, MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS),
- FALSE, FALSE,0);
- gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0);
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
+ combo = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+ gtk_box_pack_start (GTK_BOX(hbox), combo, FALSE, FALSE,0);
+ gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0);
+
hbox = gtk_hbox_new (FALSE, 6);
label = gtk_label_new(NULL);
gtk_label_set_text (GTK_LABEL(label),_("Authentication:"));
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6);
- gtk_box_pack_start (GTK_BOX(hbox), modest_widget_factory_get_combo_box
- (priv->factory, MODEST_COMBO_BOX_TYPE_AUTH_PROTOS),
- FALSE, FALSE, 0);
+
+ protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
+ combo = modest_combo_box_new (protos);
+ modest_pair_list_free (protos);
+
+ gtk_box_pack_start (GTK_BOX(hbox), combo, FALSE, FALSE, 0);
priv->remember_pwd =
gtk_check_button_new_with_label (_("Remember password"));
gtk_box_pack_start (GTK_BOX(hbox),priv->remember_pwd,
GtkWidget*
-modest_transport_widget_new (ModestWidgetFactory *factory, ModestProtocol proto)
+modest_transport_widget_new (ModestProtocol proto)
{
GObject *obj;
GtkWidget *w;
ModestTransportWidgetPrivate *priv;
g_return_val_if_fail (proto, NULL);
- g_return_val_if_fail (factory, NULL);
obj = g_object_new(MODEST_TYPE_TRANSPORT_WIDGET, NULL);
self = MODEST_TRANSPORT_WIDGET(obj);
priv = MODEST_TRANSPORT_WIDGET_GET_PRIVATE(self);
- g_object_ref (factory);
- priv->factory = factory;
-
priv->proto = proto;
if (proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
#ifndef __MODEST_TRANSPORT_WIDGET_H__
#define __MODEST_TRANSPORT_WIDGET_H__
-#include <modest-widget-factory.h>
-
G_BEGIN_DECLS
+#include <gtk/gtkvbox.h>
+
/* convenience macros */
#define MODEST_TYPE_TRANSPORT_WIDGET (modest_transport_widget_get_type())
#define MODEST_TRANSPORT_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_TRANSPORT_WIDGET,ModestTransportWidget))
/* member functions */
GType modest_transport_widget_get_type (void) G_GNUC_CONST;
-GtkWidget* modest_transport_widget_new (ModestWidgetFactory *factory, ModestProtocol proto);
+GtkWidget* modest_transport_widget_new (ModestProtocol proto);
gboolean modest_transport_widget_get_remember_password (ModestTransportWidget *self);
gboolean modest_transport_widget_get_requires_auth (ModestTransportWidget *self);
+++ /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="ViewMenu" action="View">
- <menuitem name="ViewToFieldMenu" action="ViewToField"/>
- <menuitem name="ViewCcFieldMenu" action="ViewCcField"/>
- <menuitem name="ViewBccFieldMenu" action="ViewBccField"/>
- </menu>
-
- </menubar>
-
- <toolbar name="ToolBar">
- <toolitem action="ActionsSend"/>
- </toolbar>
-
-</ui>
\ No newline at end of file
--- /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"/>
+ <separator/>
+ <menuitem name="ActionsFolderNewMenu" action="ActionsFolderNew"/>
+ <menuitem name="ActionsFolderDeleteMenu" action="ActionsFolderDelete"/>
+ <menuitem name="ActionsFolderRenameMenu" action="ActionsFolderRename"/>
+ <menuitem name="ActionsFolderMoveToTrashMenu" action="ActionsFolderMoveToTrash"/>
+ </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"/>
+ <separator/>
+ <toolitem name="ToggleView" action="ToggleView"/>
+ </toolbar>
+
+ <popup name="HeaderViewContextMenu">
+ <menuitem action="ActionsReply"/>
+ <menuitem action="ActionsForward"/>
+ </popup>
+
+ <popup name="FolderViewContextMenu">
+ <menuitem action="ActionsFolderNew"/>
+ <menuitem action="ActionsFolderDelete"/>
+ <menuitem action="ActionsFolderRename"/>
+ <menuitem action="ActionsFolderMoveToTrash"/>
+ </popup>
+
+</ui>
\ No newline at end of file
--- /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="ViewMenu" action="View">
+ <menuitem name="ViewToFieldMenu" action="ViewToField"/>
+ <menuitem name="ViewCcFieldMenu" action="ViewCcField"/>
+ <menuitem name="ViewBccFieldMenu" action="ViewBccField"/>
+ </menu>
+
+ </menubar>
+
+ <toolbar name="ToolBar">
+ <toolitem action="ActionsSend"/>
+ </toolbar>
+
+</ui>
\ No newline at end of file
+++ /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"/>
- <separator/>
- <menuitem name="ActionsFolderNewMenu" action="ActionsFolderNew"/>
- <menuitem name="ActionsFolderDeleteMenu" action="ActionsFolderDelete"/>
- <menuitem name="ActionsFolderRenameMenu" action="ActionsFolderRename"/>
- <menuitem name="ActionsFolderMoveToTrashMenu" action="ActionsFolderMoveToTrash"/>
- </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"/>
- <separator/>
- <toolitem name="ToggleView" action="ToggleView"/>
- </toolbar>
-
- <popup name="HeaderViewContextMenu">
- <menuitem action="ActionsReply"/>
- <menuitem action="ActionsForward"/>
- </popup>
-
- <popup name="FolderViewContextMenu">
- <menuitem action="ActionsFolderNew"/>
- <menuitem action="ActionsFolderDelete"/>
- <menuitem action="ActionsFolderRename"/>
- <menuitem action="ActionsFolderMoveToTrash"/>
- </popup>
-
-</ui>
\ No newline at end of file
#include <modest-runtime.h>
#include <modest-defs.h>
-#include <modest-ui.h>
#include <modest-tny-account-store.h>
#include <modest-tny-platform-factory.h>
#include <modest-mail-operation.h>
#include <modest-account-mgr.h>
#include <modest-account-mgr-helpers.h>
+#include <widgets/modest-main-window.h>
+
+
static gchar* check_account (const gchar *account);
static int start_ui (const gchar* mailto, const gchar *cc, const gchar *bcc,
const gchar* subject, const gchar *body);
const gchar* subject, const gchar *body)
{
ModestWindow *win = NULL;
- ModestUI *modest_ui = NULL;
gint retval = 0;
- modest_ui = modest_ui_new ();
+ //odest_ui = modest_ui_new ();
if (mailto||cc||bcc||subject||body) {
g_warning ("FIXME: implement this");
/* body, /\* body *\/ */
/* NULL); /\* attachments *\/ */
} else
- win = modest_ui_main_window (modest_ui);
+ win = modest_main_window_new ();
if (win) {
gtk_widget_show_all (GTK_WIDGET (win));
gtk_main();
}
- if (modest_ui)
- g_object_unref (G_OBJECT(modest_ui));
return retval;
}
#include <modest-local-folder-info.h>
#include <modest-account-mgr.h>
#include <modest-account-mgr-helpers.h>
+#include <modest-icon-names.h>
#if MODEST_PLATFORM_ID==2 /* maemo/hildon */
#include <libosso.h>
-static gboolean hildon_init (void);
+static gboolean init_hildon (void);
#endif /* MODEST_PLATFORM_ID==2 */
static gboolean init_header_columns (ModestConf *conf, gboolean overwrite);
static gboolean init_local_folders (void);
static gboolean init_default_account_maybe (ModestAccountMgr *acc_mgr);
static void init_i18n (void);
-static void debug_g_type_init (void);
-static void debug_logging_init (void);
+static void init_stock_icons (void);
+static void init_debug_g_type (void);
+static void init_debug_logging (void);
static ModestSingletons *_singletons = NULL;
}
init_i18n();
- debug_g_type_init();
- debug_logging_init();
+ init_debug_g_type();
+ init_debug_logging();
g_thread_init(NULL);
gdk_threads_init ();
}
#if MODEST_PLATFORM_ID==2
- if (!hildon_init ()) {
+ if (!init_hildon ()) {
modest_runtime_uninit ();
g_printerr ("modest: failed to initialize hildon\n");
return FALSE;
g_printerr ("modest: failed to initialize graphical ui\n");
return FALSE;
}
+
+ init_stock_icons ();
return TRUE;
}
}
-ModestWidgetFactory*
-modest_runtime_get_widget_factory (void)
-{
- g_return_val_if_fail (_singletons, NULL);
- return modest_singletons_get_widget_factory (_singletons);
-}
-
-
ModestTnySendQueue*
modest_runtime_get_send_queue (TnyTransportAccount *account)
{
static void
-debug_g_type_init (void)
+init_debug_g_type (void)
{
GTypeDebugFlags gflags;
ModestRuntimeDebugFlags mflags;
}
static void
-debug_logging_init (void)
+init_debug_logging (void)
{
ModestRuntimeDebugFlags mflags;
mflags = modest_runtime_get_debug_flags ();
#if MODEST_PLATFORM_ID==2
static gboolean
-hildon_init (void)
+init_hildon (void)
{
osso_context_t *osso_context =
osso_initialize(PACKAGE, PACKAGE_VERSION,
}
}
#endif /* MODEST_PLATFORM_ID==2 */
+
+
+/*
+ * This function registers our custom toolbar icons, so they can be
+ * themed. The idea of this function was taken from the gtk-demo
+ */
+static void
+init_stock_icons (void)
+{
+ static gboolean registered = FALSE;
+
+ if (!registered) {
+ GdkPixbuf *pixbuf;
+ GtkIconFactory *factory;
+ gint i;
+
+ static GtkStockItem items[] = {
+ { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL },
+ { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL },
+ { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL },
+ { MODEST_STOCK_REPLY, "reply", 0, 0, NULL },
+ { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL },
+ { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL },
+ { MODEST_STOCK_DELETE, "delete", 0, 0, NULL },
+ { MODEST_STOCK_NEXT, "next", 0, 0, NULL },
+ { MODEST_STOCK_PREV, "prev", 0, 0, NULL },
+/* { MODEST_STOCK_STOP, "stop", 0, 0, NULL } */
+ };
+
+ static gchar *items_names [] = {
+ MODEST_TOOLBAR_ICON_MAIL_SEND,
+ MODEST_TOOLBAR_ICON_NEW_MAIL,
+ MODEST_TOOLBAR_ICON_SEND_RECEIVE,
+ MODEST_TOOLBAR_ICON_REPLY,
+ MODEST_TOOLBAR_ICON_REPLY_ALL,
+ MODEST_TOOLBAR_ICON_FORWARD,
+ MODEST_TOOLBAR_ICON_DELETE,
+ MODEST_TOOLBAR_ICON_NEXT,
+ MODEST_TOOLBAR_ICON_PREV,
+/* MODEST_TOOLBAR_ICON_STOP */
+ };
+
+ registered = TRUE;
+
+ /* Register our stock items */
+ gtk_stock_add (items, G_N_ELEMENTS (items));
+
+ /* Add our custom icon factory to the list of defaults */
+ factory = gtk_icon_factory_new ();
+ gtk_icon_factory_add_default (factory);
+
+ /* Register icons to accompany stock items */
+ for (i = 0; i < G_N_ELEMENTS (items); i++) {
+ pixbuf = NULL;
+ pixbuf = gdk_pixbuf_new_from_file (items_names[i], NULL);
+
+ if (pixbuf != NULL) {
+ GtkIconSet *icon_set;
+ GdkPixbuf *transparent;
+
+ transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
+
+ icon_set = gtk_icon_set_new_from_pixbuf (transparent);
+ gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
+ gtk_icon_set_unref (icon_set);
+ g_object_unref (pixbuf);
+ g_object_unref (transparent);
+ }
+ else
+ g_warning ("failed to load %s icon", items_names[i]);
+ }
+ /* Drop our reference to the factory, GTK will hold a reference. */
+ g_object_unref (factory);
+ }
+}
#include <modest-cache-mgr.h>
#include <modest-mail-operation-queue.h>
#include <modest-tny-account-store.h>
-#include <modest-widget-factory.h>
#include <modest-tny-send-queue.h>
G_BEGIN_DECLS
/**
- * modest_runtime_get_widget_factory:
- *
- * get the #ModestWidgetFactory singleton instance
- *
- * Returns: the #ModestCacheMgr singleton
- **/
-ModestWidgetFactory* modest_runtime_get_widget_factory (void);
-
-
-
-/**
* modest_runtime_get_send_queue:
* @account: a valid TnyTransportAccount
*
ModestTnyAccountStore *account_store;
ModestCacheMgr *cache_mgr;
ModestMailOperationQueue *mail_op_queue;
- ModestWidgetFactory *widget_factory;
};
#define MODEST_SINGLETONS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_SINGLETONS, \
priv->account_store = NULL;
priv->cache_mgr = NULL;
priv->mail_op_queue = NULL;
- priv->widget_factory = NULL;
priv->conf = modest_conf_new ();
if (!priv->conf) {
g_printerr ("modest: cannot create modest mail operation queue instance\n");
return;
}
-
- /* don't initialize widget_factory here, but do it lazily, so we can
- * instaniatie modest-singletons before gtk_init
- */
}
ModestSingletonsPrivate *priv;
priv = MODEST_SINGLETONS_GET_PRIVATE(obj);
- if (priv->widget_factory) {
- g_object_unref (G_OBJECT(priv->widget_factory));
- check_object_is_dead ((GObject*)priv->widget_factory,
- "priv->widget_factory");
- priv->widget_factory = NULL;
- }
-
if (priv->account_store) {
g_object_unref (G_OBJECT(priv->account_store));
check_object_is_dead ((GObject*)priv->account_store,
priv->account_store = NULL;
}
-
if (priv->account_mgr) {
g_object_unref (G_OBJECT(priv->account_mgr));
check_object_is_dead ((GObject*)priv->account_mgr,
g_return_val_if_fail (self, NULL);
return MODEST_SINGLETONS_GET_PRIVATE(self)->mail_op_queue;
}
-
-
-ModestWidgetFactory*
-modest_singletons_get_widget_factory (ModestSingletons *self)
-{
- ModestSingletonsPrivate *priv;
-
- g_return_val_if_fail (self, NULL);
-
- priv = MODEST_SINGLETONS_GET_PRIVATE(self);
-
- if (G_UNLIKELY(!priv->widget_factory))
- priv->widget_factory = modest_widget_factory_new (priv->account_store);
- if (G_UNLIKELY(!priv->widget_factory)) {
- g_printerr ("modest: cannot create modest widget factory instance\n");
- return NULL;
- }
- return priv->widget_factory;
-}
-
#include <modest-tny-account-store.h>
#include <modest-mail-operation-queue.h>
#include <modest-cache-mgr.h>
-#include <modest-widget-factory.h>
G_BEGIN_DECLS
**/
ModestTnyAccountStore* modest_singletons_get_account_store (ModestSingletons *self);
-
-/**
- * modest_singletons_get_widget_factory:
- * @self: a valid #ModestSingletons instance
- *
- * get the #ModestWidgetFactory singleton instance
- * don't use this function directly, use the modest-runtime
- * functions instead.
- *
- * Returns: the #ModestWidgetFactory singleton
- **/
-ModestWidgetFactory* modest_singletons_get_widget_factory (ModestSingletons *self);
-
/**
* modest_singletons_get_cache_mgr:
* @self: a valid #ModestSingletons instance
--- /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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /*HAVE_CONFIG_H*/
+
+#include <glib/gi18n.h>
+#include <string.h>
+#include <modest-runtime.h>
+#include "modest-ui-actions.h"
+#include "modest-tny-platform-factory.h"
+
+#include <widgets/modest-main-window.h>
+#include "modest-account-view-window.h"
+#include <widgets/modest-msg-view-window.h>
+
+#include "modest-account-mgr-helpers.h"
+#include "modest-mail-operation.h"
+#include <modest-widget-memory.h>
+#include <tny-error.h>
+#include <tny-simple-list.h>
+#include <tny-msg-view.h>
+#include <tny-device.h>
+
+
+typedef struct _GetMsgAsyncHelper {
+ ModestMainWindow *main_window;
+ TnyIterator *iter;
+ GFunc func;
+ gpointer user_data;
+} GetMsgAsyncHelper;
+
+typedef enum _ReplyForwardAction {
+ ACTION_REPLY,
+ ACTION_REPLY_TO_ALL,
+ ACTION_FORWARD
+} ReplyForwardAction;
+
+typedef struct _ReplyForwardHelper {
+guint reply_forward_type;
+ ReplyForwardAction action;
+ gchar *from;
+} ReplyForwardHelper;
+
+
+static void reply_forward_func (gpointer data, gpointer user_data);
+static void read_msg_func (gpointer data, gpointer user_data);
+static void get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err,
+ gpointer user_data);
+
+static void reply_forward (GtkWidget *widget, ReplyForwardAction action,
+ ModestMainWindow *main_window);
+
+static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title);
+
+
+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_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about),
+ _("Copyright (c) 2006, Nokia Corporation\n"
+ "All rights reserved."));
+ gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about),
+ _("a modest e-mail client\n\n"
+ "design and implementation: Dirk-Jan C. Binnema\n"
+ "contributions from the fine people at KernelConcepts and Igalia\n"
+ "uses the tinymail email framework written by Philip van Hoof"));
+ gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
+ gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), "http://modest.garage.maemo.org");
+
+ gtk_dialog_run (GTK_DIALOG (about));
+ gtk_widget_destroy(about);
+}
+
+void
+modest_ui_actions_on_delete (GtkWidget *widget, ModestMainWindow *main_window)
+{
+ TnyList *header_list;
+ TnyIterator *iter;
+ GtkTreeModel *model;
+
+ if (!main_window->header_view)
+ return;
+
+ header_list = modest_header_view_get_selected_headers (main_window->header_view);
+
+ if (header_list) {
+ iter = tny_list_create_iterator (header_list);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (main_window->header_view));
+ if (GTK_IS_TREE_MODEL_SORT (model))
+ model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model));
+ do {
+ TnyHeader *header;
+ ModestMailOperation *mail_op;
+
+ header = TNY_HEADER (tny_iterator_get_current (iter));
+ /* TODO: thick grain mail operation involving
+ a list of objects. Composite pattern ??? */
+ mail_op = modest_mail_operation_new ();
+
+ /* TODO: add confirmation dialog */
+
+ /* Move to trash */
+ modest_mail_operation_remove_msg (mail_op, header, TRUE);
+
+ /* Remove from tree model */
+ if (modest_mail_operation_get_status (mail_op) ==
+ MODEST_MAIL_OPERATION_STATUS_SUCCESS)
+ tny_list_remove (TNY_LIST (model), G_OBJECT (header));
+ else {
+ /* TODO: error handling management */
+ const GError *error;
+ error = modest_mail_operation_get_error (mail_op);
+ g_warning (error->message);
+ }
+
+ g_object_unref (G_OBJECT (mail_op));
+ g_object_unref (header);
+ tny_iterator_next (iter);
+
+ } while (!tny_iterator_is_done (iter));
+ }
+}
+
+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 (main_window));
+}
+
+void
+modest_ui_actions_on_accounts (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ GtkWidget *account_win;
+ account_win = modest_account_view_window_new ();
+
+ gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW (main_window));
+ gtk_widget_show (account_win);
+}
+
+void
+modest_ui_actions_on_new_msg (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ ModestWindow *msg_win;
+ msg_win = modest_msg_edit_window_new (MODEST_EDIT_TYPE_NEW);
+ gtk_widget_show_all (GTK_WIDGET (msg_win));
+}
+
+
+void
+modest_ui_actions_on_open (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ /* FIXME */
+
+}
+
+
+static void
+reply_forward_func (gpointer data, gpointer user_data)
+{
+ TnyMsg *msg, *new_msg;
+ GetMsgAsyncHelper *helper;
+ ReplyForwardHelper *rf_helper;
+ ModestWindow *msg_win;
+ ModestEditType edit_type;
+
+ msg = TNY_MSG (data);
+ helper = (GetMsgAsyncHelper *) user_data;
+ rf_helper = (ReplyForwardHelper *) helper->user_data;
+
+ /* Create reply mail */
+ switch (rf_helper->action) {
+ case ACTION_REPLY:
+ new_msg =
+ modest_mail_operation_create_reply_mail (msg,
+ rf_helper->from,
+ rf_helper->reply_forward_type,
+ MODEST_MAIL_OPERATION_REPLY_MODE_SENDER);
+ break;
+ case ACTION_REPLY_TO_ALL:
+ new_msg =
+ modest_mail_operation_create_reply_mail (msg, rf_helper->from, rf_helper->reply_forward_type,
+ MODEST_MAIL_OPERATION_REPLY_MODE_ALL);
+ edit_type = MODEST_EDIT_TYPE_REPLY;
+ break;
+ case ACTION_FORWARD:
+ new_msg =
+ modest_mail_operation_create_forward_mail (msg, rf_helper->from, rf_helper->reply_forward_type);
+ edit_type = MODEST_EDIT_TYPE_FORWARD;
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ if (!new_msg) {
+ g_warning ("Unable to create a message");
+ goto cleanup;
+ }
+
+ /* Show edit window */
+ msg_win = modest_msg_edit_window_new (MODEST_EDIT_TYPE_NEW);
+ modest_msg_edit_window_set_msg (MODEST_MSG_EDIT_WINDOW (msg_win),
+ new_msg);
+ gtk_widget_show_all (GTK_WIDGET (msg_win));
+
+ /* Clean */
+ g_object_unref (G_OBJECT (new_msg));
+
+ cleanup:
+ g_free (rf_helper->from);
+ g_slice_free (ReplyForwardHelper, rf_helper);
+}
+
+/*
+ * Common code for the reply and forward actions
+ */
+static void
+reply_forward (GtkWidget *widget, ReplyForwardAction action,
+ ModestMainWindow *main_window)
+{
+ ModestAccountMgr *account_mgr;
+ TnyList *header_list;
+ guint reply_forward_type;
+ ModestConf *conf;
+ ModestAccountData *default_account_data;
+ TnyHeader *header;
+ TnyFolder *folder;
+ gchar *from, *key, *default_account_name;
+ GetMsgAsyncHelper *helper;
+ ReplyForwardHelper *rf_helper;
+
+ if (!main_window->header_view)
+ return;
+
+ header_list = modest_header_view_get_selected_headers (main_window->header_view);
+ if (!header_list)
+ return;
+
+ conf = modest_runtime_get_conf ();
+
+ /* Get reply or forward type */
+ key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE,
+ (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE);
+ reply_forward_type = modest_conf_get_int (conf, key, NULL);
+ g_free (key);
+
+ /* We assume that we can only select messages of the
+ same folder and that we reply all of them from the
+ same account. In fact the interface currently only
+ allows single selection */
+ account_mgr = modest_runtime_get_account_mgr();
+ default_account_name = modest_account_mgr_get_default_account (account_mgr);
+ default_account_data =
+ modest_account_mgr_get_account_data (account_mgr,
+ (const gchar*) default_account_name);
+ from = g_strdup (default_account_data->email);
+ modest_account_mgr_free_account_data (account_mgr, default_account_data);
+ g_free (default_account_name);
+
+ /* Fill helpers */
+ rf_helper = g_slice_new0 (ReplyForwardHelper);
+ rf_helper->reply_forward_type = reply_forward_type;
+ rf_helper->action = action;
+ rf_helper->from = from;
+
+ helper = g_slice_new0 (GetMsgAsyncHelper);
+ helper->main_window = main_window;
+ helper->func = reply_forward_func;
+ helper->iter = tny_list_create_iterator (header_list);
+ helper->user_data = rf_helper;
+
+ header = TNY_HEADER (tny_iterator_get_current (helper->iter));
+ folder = tny_header_get_folder (header);
+
+ /* The callback will call it per each header */
+ tny_folder_get_msg_async (folder, header, get_msg_cb, helper);
+
+ /* Clean */
+ g_object_unref (G_OBJECT (header));
+ g_object_unref (G_OBJECT (folder));
+}
+
+void
+modest_ui_actions_on_reply (GtkWidget *widget, ModestMainWindow *main_window)
+{
+ reply_forward (widget, ACTION_REPLY, main_window);
+}
+
+void
+modest_ui_actions_on_forward (GtkWidget *widget, ModestMainWindow *main_window)
+{
+ reply_forward (widget, ACTION_FORWARD, main_window);
+}
+
+void
+modest_ui_actions_on_reply_all (GtkWidget *widget,ModestMainWindow *main_window)
+{
+ reply_forward (widget, ACTION_REPLY_TO_ALL, main_window);
+}
+
+void
+modest_ui_actions_on_next (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ if (main_window->header_view)
+ modest_header_view_select_next (main_window->header_view);
+}
+
+void
+modest_ui_actions_toggle_view (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ ModestConf *conf;
+
+ if (!main_window->header_view)
+ return;
+ conf = modest_runtime_get_conf ();
+
+ /* what is saved/restored is depending on the style; thus; we save with
+ * old style, then update the style, and restore for this new style*/
+ modest_widget_memory_save (conf, G_OBJECT(main_window->header_view), "header-view");
+
+ if (modest_header_view_get_style (main_window->header_view) == MODEST_HEADER_VIEW_STYLE_DETAILS)
+ modest_header_view_set_style (main_window->header_view,
+ MODEST_HEADER_VIEW_STYLE_TWOLINES);
+ else
+ modest_header_view_set_style (main_window->header_view,
+ MODEST_HEADER_VIEW_STYLE_DETAILS);
+
+ modest_widget_memory_restore (conf, G_OBJECT(main_window->header_view),
+ "header-view");
+}
+
+
+
+/*
+ * Marks a message as read and passes it to the msg preview widget
+ */
+static void
+read_msg_func (gpointer data, gpointer user_data)
+{
+ TnyMsg *msg;
+ TnyHeader *header;
+ GetMsgAsyncHelper *helper;
+ TnyHeaderFlags header_flags;
+
+ msg = TNY_MSG (data);
+ helper = (GetMsgAsyncHelper *) user_data;
+
+ if (!helper->main_window->msg_preview)
+ return;
+
+ /* mark message as seen; _set_flags crashes, bug in tinymail? */
+ header = TNY_HEADER (tny_iterator_get_current (helper->iter));
+ header_flags = tny_header_get_flags (header);
+ tny_header_set_flags (header, header_flags | TNY_HEADER_FLAG_SEEN);
+ g_object_unref (G_OBJECT (header));
+
+ /* Set message on msg view */
+ modest_msg_view_set_message (helper->main_window->msg_preview,
+ msg);
+}
+
+/*
+ * This function is a generic handler for the tny_folder_get_msg_async
+ * call. It expects as user_data a #GetMsgAsyncHelper. This helper
+ * contains a user provided function that is called inside this
+ * method. This will allow us to use this callback in many different
+ * places. This callback performs the common actions for the
+ * get_msg_async call, more specific actions will be done by the user
+ * function
+ */
+static void
+get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err, gpointer user_data)
+{
+ GetMsgAsyncHelper *helper;
+
+ helper = (GetMsgAsyncHelper *) user_data;
+
+ if ((*err && ((*err)->code == TNY_FOLDER_ERROR_GET_MSG)) || !msg) {
+ ModestHeaderView *header_view =
+ helper->main_window->header_view;
+ if (header_view)
+ modest_ui_actions_on_item_not_found (header_view,
+ MODEST_ITEM_TYPE_MESSAGE,
+ helper->main_window);
+ return;
+ }
+
+ /* Call user function */
+ helper->func (msg, user_data);
+
+ /* Process next element (if exists) */
+ tny_iterator_next (helper->iter);
+ if (tny_iterator_is_done (helper->iter)) {
+ TnyList *headers;
+ headers = tny_iterator_get_list (helper->iter);
+ /* Free resources */
+ g_object_unref (G_OBJECT (headers));
+ g_object_unref (G_OBJECT (helper->iter));
+ g_slice_free (GetMsgAsyncHelper, helper);
+ } else {
+ TnyHeader *header;
+ header = TNY_HEADER (tny_iterator_get_current (helper->iter));
+ tny_folder_get_msg_async (folder, header,
+ get_msg_cb, helper);
+ g_object_unref (G_OBJECT(header));
+ }
+}
+
+void
+modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
+ TnyHeader *header,
+ ModestMainWindow *main_window)
+{
+ TnyFolder *folder;
+ GetMsgAsyncHelper *helper;
+ TnyList *list;
+
+ if (!main_window->msg_preview)
+ return;
+
+ /* when there's no header, clear the msgview */
+ if (!header) {
+ modest_msg_view_set_message (main_window->msg_preview, NULL);
+ return;
+ }
+
+ folder = tny_header_get_folder (TNY_HEADER(header));
+
+ /* Create list */
+ list = tny_simple_list_new ();
+ tny_list_prepend (list, G_OBJECT (header));
+
+ /* Fill helper data */
+ helper = g_slice_new0 (GetMsgAsyncHelper);
+ helper->main_window = main_window;
+ helper->iter = tny_list_create_iterator (list);
+ helper->func = read_msg_func;
+
+ tny_folder_get_msg_async (TNY_FOLDER(folder),
+ header, get_msg_cb,
+ helper);
+
+ /* Frees */
+ g_object_unref (G_OBJECT (folder));
+}
+
+
+
+void
+modest_ui_actions_on_header_activated (ModestHeaderView *folder_view,
+ TnyHeader *header,
+ ModestMainWindow *main_window)
+{
+ ModestWindow *win;
+ TnyFolder *folder = NULL;
+ TnyMsg *msg = NULL;
+
+ if (!header)
+ return;
+
+ folder = tny_header_get_folder (header);
+ if (!folder) {
+ g_printerr ("modest: cannot get folder for header\n");
+ goto cleanup;
+ }
+
+ /* FIXME: make async?; check error */
+ msg = tny_folder_get_msg (folder, header, NULL);
+ if (!msg) {
+ g_printerr ("modest: cannot get msg for header\n");
+ goto cleanup;
+ }
+
+ win = modest_msg_view_window_new (msg);
+ gtk_window_set_transient_for (GTK_WINDOW (win),
+ GTK_WINDOW (main_window));
+
+ gtk_widget_show_all (GTK_WIDGET(win));
+
+cleanup:
+ if (folder)
+ g_object_unref (G_OBJECT (folder));
+ if (msg)
+ g_object_unref (G_OBJECT (folder));
+}
+
+
+
+
+
+void
+modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
+ TnyFolder *folder,
+ gboolean selected,
+ ModestMainWindow *main_window)
+{
+// GtkLabel *folder_info_label;
+ gchar *txt;
+ ModestConf *conf;
+
+/* folder_info_label = */
+/* GTK_LABEL (modest_widget_factory_get_folder_info_label */
+/* (modest_runtime_get_widget_factory())); */
+
+/* if (!folder) { */
+/* gtk_label_set_label (GTK_LABEL(folder_info_label), ""); */
+/* return; */
+/* } */
+
+
+ if (!main_window->header_view)
+ return;
+
+ conf = modest_runtime_get_conf ();
+
+ if (!selected) { /* the folder was unselected; save it's settings */
+ modest_widget_memory_save (conf, G_OBJECT (main_window->header_view),
+ "header-view");
+ gtk_window_set_title (GTK_WINDOW(main_window), "Modest");
+ modest_header_view_set_folder (main_window->header_view, NULL);
+ } else { /* the folder was selected */
+ if (folder) { /* folder may be NULL */
+ guint num, unread;
+ gchar *title;
+
+ num = tny_folder_get_all_count (folder);
+ unread = tny_folder_get_unread_count (folder);
+
+ title = g_strdup_printf ("Modest: %s",
+ tny_folder_get_name (folder));
+
+ gtk_window_set_title (GTK_WINDOW(main_window), title);
+ g_free (title);
+
+ txt = g_strdup_printf (_("%d %s, %d unread"),
+ num, num==1 ? _("item") : _("items"), unread);
+ //gtk_label_set_label (GTK_LABEL(folder_info_label), txt);
+ g_free (txt);
+ }
+ modest_header_view_set_folder (main_window->header_view, folder);
+ modest_widget_memory_restore (conf, G_OBJECT(main_window->header_view),
+ "header-view");
+ }
+}
+
+
+/****************************************************/
+/*
+ * below some stuff to clearup statusbar messages after 1,5 seconds....
+ */
+static gboolean
+progress_bar_clean (GtkWidget *bar)
+{
+ if (GTK_IS_PROGRESS_BAR(bar)) {
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR(bar), "");
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(bar), 1.0);
+ }
+ return FALSE;
+}
+
+static gboolean
+statusbar_clean (GtkWidget *bar)
+{
+ if (GTK_IS_STATUSBAR(bar))
+ gtk_statusbar_push (GTK_STATUSBAR(bar), 0, "");
+ return FALSE;
+}
+
+
+static void
+statusbar_push (ModestMainWindow *main_window, guint context_id, const gchar *msg)
+{
+ if (!msg)
+ return;
+
+ if (main_window->progress_bar) {
+ gtk_widget_show (main_window->progress_bar);
+ g_timeout_add (3000, (GSourceFunc)progress_bar_clean,
+ main_window->progress_bar);
+ }
+
+ if (main_window->status_bar) {
+ gtk_widget_show (main_window->status_bar);
+ gtk_statusbar_push (GTK_STATUSBAR(main_window->status_bar), 0, msg);
+ g_timeout_add (1500, (GSourceFunc)statusbar_clean, main_window->status_bar);
+ }
+
+}
+/****************************************************************************/
+
+void
+modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,
+ ModestItemType type,
+ ModestMainWindow *main_window)
+{
+ GtkWidget *dialog;
+ gchar *txt, *item;
+ gboolean online;
+ TnyDevice *device;
+ TnyAccountStore *account_store;
+
+ item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message";
+
+ /* Get device. Do not ask the platform factory for it, because
+ it returns always a new one */
+ account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
+ device = tny_account_store_get_device (account_store);
+
+ if (g_main_depth > 0)
+ 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 (main_window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ _("The %s you selected cannot be found"),
+ item);
+ gtk_dialog_run (GTK_DIALOG(dialog));
+ } else {
+
+ dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
+ GTK_WINDOW (main_window),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ txt = g_strdup_printf (_("This %s is not available in offline mode.\n"
+ "Do you want to get online?"), item);
+ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ gtk_label_new (txt), FALSE, FALSE, 0);
+ gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
+ g_free (txt);
+
+ gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
+ if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ tny_device_force_online (device);
+ }
+ }
+ gtk_widget_destroy (dialog);
+ if (g_main_depth > 0)
+ gdk_threads_leave ();
+}
+
+
+
+void
+modest_ui_actions_on_header_status_update (ModestHeaderView *header_view,
+ const gchar *msg, gint num,
+ gint total, ModestMainWindow *main_window)
+{
+ char* txt;
+
+ if (!main_window->progress_bar)
+ return;
+
+ if (total != 0)
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(main_window->progress_bar),
+ (gdouble)num/(gdouble)total);
+ else
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR(main_window->progress_bar));
+
+ txt = g_strdup_printf (_("Downloading %d of %d"), num, total);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR(main_window->progress_bar), txt);
+ g_free (txt);
+
+ statusbar_push (main_window, 0, msg);
+}
+
+
+void
+modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview, const gchar* link,
+ ModestMainWindow *main_window)
+{
+ statusbar_push (main_window, 0, link);
+
+ /* TODO: do something */
+}
+
+
+void
+modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview, const gchar* link,
+ ModestMainWindow *main_window)
+{
+ gchar *msg;
+
+ msg = g_strdup_printf (_("Opening %s..."), link);
+ statusbar_push (main_window, 0, msg);
+ g_free (msg);
+
+ /* TODO: do something */
+}
+
+void
+modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview,
+ int index,
+ ModestMainWindow *main_window)
+{
+ gchar *msg;
+
+ msg = g_strdup_printf (_("Opening attachment %d..."), index);
+ statusbar_push (main_window, 0, msg);
+
+ g_free (msg);
+ /* TODO: do something */
+}
+
+void
+modest_ui_actions_on_send (GtkWidget *widget,
+ ModestMsgEditWindow *edit_window)
+{
+ TnyTransportAccount *transport_account;
+ ModestMailOperation *mail_operation;
+ MsgData *data;
+ gchar *account_name, *from;
+ ModestAccountMgr *account_mgr;
+
+
+ data = modest_msg_edit_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 */
+ account_mgr = modest_runtime_get_account_mgr();
+ account_name = modest_account_mgr_get_default_account (account_mgr);
+ if (!account_name) {
+ g_printerr ("modest: no default account found\n");
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+ return;
+ }
+ transport_account =
+ TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_tny_account_by_account
+ (modest_runtime_get_account_store(),
+ account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT));
+ if (!transport_account) {
+ g_printerr ("modest: no transport account found for '%s'\n", account_name);
+ g_free (account_name);
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+ return;
+ }
+ from = modest_account_mgr_get_from_string (account_mgr, account_name);
+
+ mail_operation = modest_mail_operation_new ();
+ modest_mail_operation_send_new_mail (mail_operation,
+ transport_account,
+ from,
+ data->to,
+ data->cc,
+ data->bcc,
+ data->subject,
+ data->body,
+ NULL);
+ /* Frees */
+ g_free (from);
+ g_free (account_name);
+ g_object_unref (G_OBJECT (mail_operation));
+ g_object_unref (G_OBJECT (transport_account));
+
+ modest_msg_edit_window_free_msg_data (edit_window, data);
+
+ /* Save settings and close the window */
+ /* save_settings (edit_window) */
+ gtk_widget_destroy (GTK_WIDGET (edit_window));
+}
+
+/*
+ * Shows a dialog with an entry that asks for some text. The returned
+ * value must be freed by the caller. The dialog window title will be
+ * set to @title.
+ */
+static gchar *
+ask_for_folder_name (GtkWindow *parent_window,
+ const gchar *title)
+{
+ GtkWidget *dialog, *entry;
+ gchar *folder_name = NULL;
+
+ /* Ask for folder name */
+ dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
+ parent_window,
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ gtk_label_new(title),
+ FALSE, FALSE, 0);
+
+ entry = gtk_entry_new_with_max_length (40);
+ gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
+ entry,
+ TRUE, FALSE, 0);
+
+ gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
+
+ if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+ folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+
+ gtk_widget_destroy (dialog);
+
+ return folder_name;
+}
+
+void
+modest_ui_actions_on_new_folder (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ TnyFolder *parent_folder;
+
+ if (!main_window->folder_view)
+ return;
+
+ parent_folder = modest_folder_view_get_selected (main_window->folder_view);
+
+ if (parent_folder) {
+ gchar *folder_name;
+
+ folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
+ _("Please enter a name for the new folder"));
+
+ if (folder_name != NULL && strlen (folder_name) > 0) {
+ TnyFolder *new_folder;
+ ModestMailOperation *mail_op;
+
+ mail_op = modest_mail_operation_new ();
+ new_folder = modest_mail_operation_create_folder (mail_op,
+ TNY_FOLDER_STORE (parent_folder),
+ (const gchar *) folder_name);
+ if (new_folder) {
+ /* TODO: tinymail should do this.
+ Update view */
+ modest_folder_view_add_subfolder (main_window->folder_view, new_folder);
+
+ /* Free new folder */
+ g_object_unref (new_folder);
+ }
+ g_object_unref (mail_op);
+ }
+ g_object_unref (parent_folder);
+ }
+}
+
+void
+modest_ui_actions_on_rename_folder (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ TnyFolder *folder;
+
+ if (!main_window->folder_view)
+ return;
+
+ folder = modest_folder_view_get_selected (main_window->folder_view);
+
+ if (folder) {
+ gchar *folder_name;
+
+ folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
+ _("Please enter a new name for the folder"));
+
+ if (folder_name != NULL && strlen (folder_name) > 0) {
+ ModestMailOperation *mail_op;
+ const GError *error;
+
+ mail_op = modest_mail_operation_new ();
+ modest_mail_operation_rename_folder (mail_op,
+ folder,
+ (const gchar *) folder_name);
+
+ error = modest_mail_operation_get_error (mail_op);
+ if (!error)
+ /* TODO: tinymail should do this.
+ Update view */
+ modest_folder_view_rename (main_window->folder_view);
+
+ /* TODO: else ? notify error ? */
+
+ g_object_unref (mail_op);
+ }
+ g_object_unref (folder);
+ }
+}
+
+static void
+delete_folder (ModestMainWindow *main_window,
+ gboolean move_to_trash)
+{
+ TnyFolder *folder;
+ ModestMailOperation *mail_op;
+
+ if (!main_window->folder_view)
+ return;
+
+ folder = modest_folder_view_get_selected (main_window->folder_view);
+
+ mail_op = modest_mail_operation_new ();
+ modest_mail_operation_remove_folder (mail_op, folder, move_to_trash);
+ g_object_unref (mail_op);
+}
+
+void
+modest_ui_actions_on_delete_folder (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ delete_folder (main_window, FALSE);
+}
+
+void
+modest_ui_actions_on_move_to_trash_folder (GtkWidget *widget,
+ ModestMainWindow *main_window)
+{
+ delete_folder (main_window, TRUE);
+}
+
+void
+modest_ui_actions_on_accounts_reloaded (TnyAccountStore *store, gpointer user_data)
+{
+ /* FIXME */
+ /* ModestFolderView *folder_view; */
+
+/* folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory()); */
+/* modest_folder_view_update_model (folder_view, store); */
+}
+
+void
+modest_ui_actions_on_folder_moved (ModestFolderView *folder_view, TnyFolder *folder,
+ TnyFolderStore *parent, gboolean *done,
+ gpointer user_data)
+{
+ ModestMailOperation *mail_op;
+ const GError *error;
+
+ *done = TRUE;
+
+ /* Try to move the folder */
+ mail_op = modest_mail_operation_new ();
+ modest_mail_operation_move_folder (mail_op, folder, parent);
+
+ error = modest_mail_operation_get_error (mail_op);
+ if (error)
+ *done = FALSE;
+
+ g_object_unref (G_OBJECT (mail_op));
+}
#ifndef __MODEST_UI_ACTIONS_H__
#define __MODEST_UI_ACTIONS_H__
-#include "modest-main-window.h"
-#include "modest-edit-msg-window.h"
+#include <widgets/modest-main-window.h>
+#include <widgets/modest-msg-edit-window.h>
G_BEGIN_DECLS
/* Menu & toolbar actions */
-void _modest_ui_actions_on_about (GtkWidget *widget, ModestMainWindow *main_window);
+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_delete (GtkWidget *widget, ModestMainWindow *main_window);
-void _modest_ui_actions_on_quit (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_accounts (GtkWidget *widget, ModestMainWindow *main_window);
-void _modest_ui_actions_on_new_msg (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_reply (GtkWidget *widget, ModestMainWindow *main_window);
-void _modest_ui_actions_on_forward (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_reply_all (GtkWidget *widget, ModestMainWindow *main_window);
-void _modest_ui_actions_on_next (GtkWidget *widget, ModestMainWindow *main_window);
+void modest_ui_actions_on_next (GtkWidget *widget, ModestMainWindow *main_window);
-void _modest_ui_actions_toggle_view (GtkWidget *widget, ModestMainWindow *main_window);
+void modest_ui_actions_toggle_view (GtkWidget *widget, ModestMainWindow *main_window);
/* Widget actions */
-void _modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
+void modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
TnyHeader *header,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_header_activated (ModestHeaderView *folder_view,
+void modest_ui_actions_on_header_activated (ModestHeaderView *folder_view,
TnyHeader *header,
ModestMainWindow *main_window);
-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,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle,
+void modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,
+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,
+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,
+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,
+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,
+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);
+void modest_ui_actions_on_send (GtkWidget *widget,
+ ModestMsgEditWindow *edit_window);
-void _modest_ui_actions_on_new_folder (GtkWidget *widget,
+void modest_ui_actions_on_new_folder (GtkWidget *widget,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_rename_folder (GtkWidget *widget,
+void modest_ui_actions_on_rename_folder (GtkWidget *widget,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_delete_folder (GtkWidget *widget,
+void modest_ui_actions_on_delete_folder (GtkWidget *widget,
ModestMainWindow *main_window);
-void _modest_ui_actions_on_move_to_trash_folder (GtkWidget *widget,
+void modest_ui_actions_on_move_to_trash_folder (GtkWidget *widget,
ModestMainWindow *main_window);
+void modest_ui_actions_on_connection_changed (TnyDevice *device, gboolean online,
+ ModestMainWindow *main_window);
+
+
+void modest_ui_actions_on_accounts_reloaded (TnyAccountStore *store,
+ gpointer user_data);
+
+void modest_ui_actions_on_folder_moved (ModestFolderView *folder_view,
+ TnyFolder *folder,
+ TnyFolderStore *parent,
+ gboolean *done,
+ gpointer user_data);
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 {
- ModestWindow *main_window;
- GtkUIManager *ui_manager;
- guint toggle_button_signal;
-};
-
-G_END_DECLS
-#endif /* __MODEST_UI_PRIV_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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /*HAVE_CONFIG_H*/
-
-#include <glib/gi18n.h>
-#include <string.h>
-#include <modest-runtime.h>
-#include "modest-ui-priv.h"
-#include "modest-ui.h"
-#include "modest-ui-actions.h"
-#include "modest-icon-names.h"
-#include "modest-tny-platform-factory.h"
-#include "modest-account-view-window.h"
-#include "modest-account-mgr-helpers.h"
-#include "modest-main-window.h"
-#include "modest-mail-operation.h"
-#include "modest-msg-view-window.h"
-#include <modest-widget-memory.h>
-#include <tny-error.h>
-#include <tny-simple-list.h>
-#include <tny-msg-view.h>
-#include <tny-device.h>
-
-#define MODEST_UI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
- MODEST_TYPE_UI, \
- ModestUIPrivate))
-
-typedef struct _GetMsgAsyncHelper {
- ModestMainWindow *main_window;
- TnyIterator *iter;
- GFunc func;
- gpointer user_data;
-} GetMsgAsyncHelper;
-
-typedef enum _ReplyForwardAction {
- ACTION_REPLY,
- ACTION_REPLY_TO_ALL,
- ACTION_FORWARD
-} ReplyForwardAction;
-
-typedef struct _ReplyForwardHelper {
- guint reply_forward_type;
- ReplyForwardAction action;
- gchar *from;
-} ReplyForwardHelper;
-
-/* globals */
-static GObjectClass *parent_class = NULL;
-
-/* 'private'/'protected' functions */
-static void modest_ui_class_init (ModestUIClass *klass);
-static void modest_ui_init (ModestUI *obj);
-static void modest_ui_finalize (GObject *obj);
-
-static void register_stock_icons ();
-static void connect_signals (ModestUI *self);
-
-static void reply_forward_func (gpointer data,
- gpointer user_data);
-static void read_msg_func (gpointer data,
- gpointer user_data);
-static void get_msg_cb (TnyFolder *folder,
- TnyMsg *msg,
- GError **err,
- gpointer user_data);
-
-static void reply_forward (GtkWidget *widget,
- ReplyForwardAction action,
- ModestMainWindow *main_window);
-
-static gchar* ask_for_folder_name (GtkWindow *parent_window,
- const gchar *title);
-
-static void _modest_ui_actions_on_connection_changed (TnyDevice *device,
- gboolean online,
- ModestUI *modest_ui);
-
-
-static void _modest_ui_actions_on_accounts_reloaded (TnyAccountStore *store,
- gpointer user_data);
-
-static void _modest_ui_actions_on_folder_moved (ModestFolderView *folder_view,
- TnyFolder *folder,
- TnyFolderStore *parent,
- gboolean *done,
- gpointer user_data);
-
-GType
-modest_ui_get_type (void)
-{
- static GType my_type = 0;
- if (!my_type) {
- static const GTypeInfo my_info = {
- sizeof(ModestUIClass),
- NULL, /* base init */
- NULL, /* base finalize */
- (GClassInitFunc) modest_ui_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof(ModestUI),
- 1, /* n_preallocs */
- (GInstanceInitFunc) modest_ui_init,
- NULL
- };
- my_type = g_type_register_static (G_TYPE_OBJECT,
- "ModestUI",
- &my_info, 0);
- }
- return my_type;
-}
-
-
-static void
-modest_ui_class_init (ModestUIClass *klass)
-{
- GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class->finalize = modest_ui_finalize;
-
- g_type_class_add_private (gobject_class, sizeof(ModestUIPrivate));
-
-}
-
-
-static void
-modest_ui_init (ModestUI *obj)
-{
- ModestUIPrivate *priv;
-
- priv = MODEST_UI_GET_PRIVATE(obj);
-
- priv->main_window = NULL;
-}
-
-
-static void
-modest_ui_finalize (GObject *obj)
-{
- ModestUIPrivate *priv = MODEST_UI_GET_PRIVATE(obj);
-
- if (priv->ui_manager) {
- g_object_unref (G_OBJECT(priv->ui_manager));
- priv->ui_manager = NULL;
- }
-
- priv->main_window = NULL;
-
- G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
-
-
-ModestUI*
-modest_ui_new (void)
-{
- GObject *obj;
- ModestUIPrivate *priv;
-
- obj = g_object_new(MODEST_TYPE_UI, NULL);
- priv = MODEST_UI_GET_PRIVATE(obj);
-
- /* Register our own icons as stock icons in order to
- use them with the UI manager */
- register_stock_icons ();
-
- return MODEST_UI(obj);
-}
-
-static gboolean
-on_main_window_destroy (GtkObject *widget, ModestUI *self)
-{
- /* FIXME: check if there any viewer/editing windows opened */
- gtk_main_quit ();
- return FALSE;
-}
-
-
-ModestWindow *
-modest_ui_main_window (ModestUI *self)
-{
- ModestUIPrivate *priv;
-
- g_return_val_if_fail (self, NULL);
- priv = MODEST_UI_GET_PRIVATE(self);
-
- if (!priv->main_window) {
- priv->main_window = modest_main_window_new ();
- connect_signals (self);
- }
-
- if (!priv->main_window)
- g_printerr ("modest: could not create main window\n");
-
- return priv->main_window;
-}
-
-ModestWindow *
-modest_ui_edit_window (ModestUI *self, ModestEditType edit_type)
-{
- ModestUIPrivate *priv;
- ModestWindow *edit_window;
-
- g_return_val_if_fail (self, NULL);
- priv = MODEST_UI_GET_PRIVATE(self);
-
- /* Create window */
- edit_window = modest_edit_msg_window_new (edit_type);
-
- /* Connect Edit Window signals */
-/* connect_edit_window_signals (self); */
-
- return edit_window;
-}
-
-/*
- * This function registers our custom toolbar icons, so they can be
- * themed. The idea of this function was taken from the gtk-demo
- */
-static void
-register_stock_icons ()
-{
- static gboolean registered = FALSE;
-
- if (!registered) {
- GdkPixbuf *pixbuf;
- GtkIconFactory *factory;
- gint i;
-
- static GtkStockItem items[] = {
- { MODEST_STOCK_MAIL_SEND, "send mail", 0, 0, NULL },
- { MODEST_STOCK_NEW_MAIL, "new mail", 0, 0, NULL },
- { MODEST_STOCK_SEND_RECEIVE, "send receive", 0, 0, NULL },
- { MODEST_STOCK_REPLY, "reply", 0, 0, NULL },
- { MODEST_STOCK_REPLY_ALL, "reply all", 0, 0, NULL },
- { MODEST_STOCK_FORWARD, "forward", 0, 0, NULL },
- { MODEST_STOCK_DELETE, "delete", 0, 0, NULL },
- { MODEST_STOCK_NEXT, "next", 0, 0, NULL },
- { MODEST_STOCK_PREV, "prev", 0, 0, NULL },
-/* { MODEST_STOCK_STOP, "stop", 0, 0, NULL } */
- };
-
- static gchar *items_names [] = {
- MODEST_TOOLBAR_ICON_MAIL_SEND,
- MODEST_TOOLBAR_ICON_NEW_MAIL,
- MODEST_TOOLBAR_ICON_SEND_RECEIVE,
- MODEST_TOOLBAR_ICON_REPLY,
- MODEST_TOOLBAR_ICON_REPLY_ALL,
- MODEST_TOOLBAR_ICON_FORWARD,
- MODEST_TOOLBAR_ICON_DELETE,
- MODEST_TOOLBAR_ICON_NEXT,
- MODEST_TOOLBAR_ICON_PREV,
-/* MODEST_TOOLBAR_ICON_STOP */
- };
-
- registered = TRUE;
-
- /* Register our stock items */
- gtk_stock_add (items, G_N_ELEMENTS (items));
-
- /* Add our custom icon factory to the list of defaults */
- factory = gtk_icon_factory_new ();
- gtk_icon_factory_add_default (factory);
-
- /* Register icons to accompany stock items */
- for (i = 0; i < G_N_ELEMENTS (items); i++) {
- pixbuf = NULL;
- pixbuf = gdk_pixbuf_new_from_file (items_names[i], NULL);
-
- if (pixbuf != NULL) {
- GtkIconSet *icon_set;
- GdkPixbuf *transparent;
-
- transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
-
- icon_set = gtk_icon_set_new_from_pixbuf (transparent);
- gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
- gtk_icon_set_unref (icon_set);
- g_object_unref (pixbuf);
- g_object_unref (transparent);
- }
- else
- g_warning ("failed to load %s icon", items_names[i]);
- }
- /* Drop our reference to the factory, GTK will hold a reference. */
- g_object_unref (factory);
- }
-}
-
-/* FIXME: uninit these as well */
-static void
-connect_signals (ModestUI *self)
-{
- TnyDevice *device;
- TnyAccountStore *account_store;
- ModestUIPrivate *priv;
- ModestFolderView *folder_view;
- ModestHeaderView *header_view;
- ModestMsgView *msg_view;
- GtkWidget *toggle;
- ModestWidgetFactory *widget_factory;
-
- priv = MODEST_UI_GET_PRIVATE(self);
-
- widget_factory = modest_runtime_get_widget_factory ();
-
- folder_view = modest_widget_factory_get_folder_view (widget_factory);
- header_view = modest_widget_factory_get_header_view (widget_factory);
- msg_view = modest_widget_factory_get_msg_preview (widget_factory);
- toggle = modest_widget_factory_get_online_toggle (widget_factory);
- account_store = TNY_ACCOUNT_STORE(modest_runtime_get_account_store());
- device = tny_account_store_get_device (account_store);
-
- /* folder view */
- g_signal_connect (G_OBJECT(folder_view), "folder_selection_changed",
- G_CALLBACK(_modest_ui_actions_on_folder_selection_changed),
- priv->main_window);
- g_signal_connect (G_OBJECT(folder_view), "folder_moved",
- G_CALLBACK(_modest_ui_actions_on_folder_moved),
- NULL);
-
- /* header view */
- g_signal_connect (G_OBJECT(header_view), "status_update",
- 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->main_window);
- g_signal_connect (G_OBJECT(header_view), "header_activated",
- G_CALLBACK(_modest_ui_actions_on_header_activated),
- priv->main_window);
- g_signal_connect (G_OBJECT(header_view), "item_not_found",
- 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->main_window);
- g_signal_connect (G_OBJECT(msg_view), "link_hover",
- 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->main_window);
-
- /* Account store */
- g_signal_connect (G_OBJECT (account_store), "accounts_reloaded",
- G_CALLBACK (_modest_ui_actions_on_accounts_reloaded),
- priv->main_window);
-
- /* Device */
- g_signal_connect (G_OBJECT(device), "connection_changed",
- G_CALLBACK(_modest_ui_actions_on_connection_changed),
- self);
-
- priv->toggle_button_signal=
- g_signal_connect (G_OBJECT(toggle), "toggled",
- G_CALLBACK(_modest_ui_actions_on_online_toggle_toggled),
- 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),
- self);
-}
-
-
-/* ***************************************************************** */
-/* M O D E S T U I A C T I O N S */
-/* ***************************************************************** */
-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_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about),
- _("Copyright (c) 2006, Nokia Corporation\n"
- "All rights reserved."));
- gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about),
- _("a modest e-mail client\n\n"
- "design and implementation: Dirk-Jan C. Binnema\n"
- "contributions from the fine people at KernelConcepts and Igalia\n"
- "uses the tinymail email framework written by Philip van Hoof"));
- gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
- gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), "http://modest.garage.maemo.org");
-
- gtk_dialog_run (GTK_DIALOG (about));
- gtk_widget_destroy(about);
-}
-
-void
-_modest_ui_actions_on_delete (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- ModestWidgetFactory *widget_factory;
- ModestHeaderView *header_view;
- TnyList *header_list;
- TnyIterator *iter;
- GtkTreeModel *model;
-
- widget_factory = modest_runtime_get_widget_factory ();
- header_view = modest_widget_factory_get_header_view (widget_factory);
- header_list = modest_header_view_get_selected_headers (header_view);
-
- if (header_list) {
- iter = tny_list_create_iterator (header_list);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
- if (GTK_IS_TREE_MODEL_SORT (model))
- model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (model));
- do {
- TnyHeader *header;
- ModestMailOperation *mail_op;
-
- header = TNY_HEADER (tny_iterator_get_current (iter));
- /* TODO: thick grain mail operation involving
- a list of objects. Composite pattern ??? */
- mail_op = modest_mail_operation_new ();
-
- /* TODO: add confirmation dialog */
-
- /* Move to trash */
- modest_mail_operation_remove_msg (mail_op, header, TRUE);
-
- /* Remove from tree model */
- if (modest_mail_operation_get_status (mail_op) ==
- MODEST_MAIL_OPERATION_STATUS_SUCCESS)
- tny_list_remove (TNY_LIST (model), G_OBJECT (header));
- else {
- /* TODO: error handling management */
- const GError *error;
- error = modest_mail_operation_get_error (mail_op);
- g_warning (error->message);
- }
-
- g_object_unref (G_OBJECT (mail_op));
- g_object_unref (header);
- tny_iterator_next (iter);
-
- } while (!tny_iterator_is_done (iter));
- }
-}
-
-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 (main_window));
-}
-
-void
-_modest_ui_actions_on_accounts (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- GtkWidget *account_win;
- account_win = modest_account_view_window_new (modest_runtime_get_widget_factory());
-
- gtk_window_set_transient_for (GTK_WINDOW (account_win),
- GTK_WINDOW (main_window));
-
- gtk_widget_show (account_win);
-}
-
-void
-_modest_ui_actions_on_new_msg (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- ModestWindow *msg_win;
- msg_win = modest_edit_msg_window_new (MODEST_EDIT_TYPE_NEW);
- gtk_widget_show_all (GTK_WIDGET (msg_win));
-}
-
-
-void
-_modest_ui_actions_on_open (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- /* FIXME */
-
-}
-
-
-static void
-reply_forward_func (gpointer data, gpointer user_data)
-{
- TnyMsg *msg, *new_msg;
- GetMsgAsyncHelper *helper;
- ReplyForwardHelper *rf_helper;
- ModestWindow *msg_win;
- ModestEditType edit_type;
-
- msg = TNY_MSG (data);
- helper = (GetMsgAsyncHelper *) user_data;
- rf_helper = (ReplyForwardHelper *) helper->user_data;
-
- /* Create reply mail */
- switch (rf_helper->action) {
- case ACTION_REPLY:
- new_msg =
- modest_mail_operation_create_reply_mail (msg,
- rf_helper->from,
- rf_helper->reply_forward_type,
- MODEST_MAIL_OPERATION_REPLY_MODE_SENDER);
- break;
- case ACTION_REPLY_TO_ALL:
- new_msg =
- modest_mail_operation_create_reply_mail (msg, rf_helper->from, rf_helper->reply_forward_type,
- MODEST_MAIL_OPERATION_REPLY_MODE_ALL);
- edit_type = MODEST_EDIT_TYPE_REPLY;
- break;
- case ACTION_FORWARD:
- new_msg =
- modest_mail_operation_create_forward_mail (msg, rf_helper->from, rf_helper->reply_forward_type);
- edit_type = MODEST_EDIT_TYPE_FORWARD;
- break;
- default:
- g_return_if_reached ();
- }
-
- if (!new_msg) {
- g_warning ("Unable to create a message");
- goto cleanup;
- }
-
- /* Show edit window */
- msg_win = modest_edit_msg_window_new (MODEST_EDIT_TYPE_NEW);
- modest_edit_msg_window_set_msg (MODEST_EDIT_MSG_WINDOW (msg_win),
- new_msg);
- gtk_widget_show_all (GTK_WIDGET (msg_win));
-
- /* Clean */
- g_object_unref (G_OBJECT (new_msg));
-
- cleanup:
- g_free (rf_helper->from);
- g_slice_free (ReplyForwardHelper, rf_helper);
-}
-
-/*
- * Common code for the reply and forward actions
- */
-static void
-reply_forward (GtkWidget *widget,
- ReplyForwardAction action,
- ModestMainWindow *main_window)
-{
- ModestHeaderView *header_view;
- ModestAccountMgr *account_mgr;
- TnyList *header_list;
- guint reply_forward_type;
- ModestConf *conf;
- ModestAccountData *default_account_data;
- TnyHeader *header;
- TnyFolder *folder;
- gchar *from, *key, *default_account_name;
- GetMsgAsyncHelper *helper;
- ReplyForwardHelper *rf_helper;
-
- conf = modest_runtime_get_conf ();
-
- /* Get reply or forward type */
- key = g_strdup_printf ("%s/%s", MODEST_CONF_NAMESPACE,
- (action == ACTION_FORWARD) ? MODEST_CONF_FORWARD_TYPE : MODEST_CONF_REPLY_TYPE);
- reply_forward_type = modest_conf_get_int (conf, key, NULL);
- g_free (key);
-
- /* Get the list of headers */
- header_view = modest_widget_factory_get_header_view (modest_runtime_get_widget_factory());
- header_list = modest_header_view_get_selected_headers (header_view);
- if (!header_list)
- return;
-
- /* We assume that we can only select messages of the
- same folder and that we reply all of them from the
- same account. In fact the interface currently only
- allows single selection */
- account_mgr = modest_runtime_get_account_mgr();
- default_account_name = modest_account_mgr_get_default_account (account_mgr);
- default_account_data =
- modest_account_mgr_get_account_data (account_mgr,
- (const gchar*) default_account_name);
- from = g_strdup (default_account_data->email);
- modest_account_mgr_free_account_data (account_mgr, default_account_data);
- g_free (default_account_name);
-
- /* Fill helpers */
- rf_helper = g_slice_new0 (ReplyForwardHelper);
- rf_helper->reply_forward_type = reply_forward_type;
- rf_helper->action = action;
- rf_helper->from = from;
-
- helper = g_slice_new0 (GetMsgAsyncHelper);
- helper->main_window = main_window;
- helper->func = reply_forward_func;
- helper->iter = tny_list_create_iterator (header_list);
- helper->user_data = rf_helper;
-
- header = TNY_HEADER (tny_iterator_get_current (helper->iter));
- folder = tny_header_get_folder (header);
-
- /* The callback will call it per each header */
- tny_folder_get_msg_async (folder, header, get_msg_cb, helper);
-
- /* Clean */
- g_object_unref (G_OBJECT (header));
- g_object_unref (G_OBJECT (folder));
-}
-
-void
-_modest_ui_actions_on_reply (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- reply_forward (widget, ACTION_REPLY, main_window);
-}
-
-void
-_modest_ui_actions_on_forward (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- reply_forward (widget, ACTION_FORWARD, main_window);
-}
-
-void
-_modest_ui_actions_on_reply_all (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- reply_forward (widget, ACTION_REPLY_TO_ALL, main_window);
-}
-
-void
-_modest_ui_actions_on_next (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- ModestHeaderView *header_view;
-
- header_view = modest_widget_factory_get_header_view
- (modest_runtime_get_widget_factory());
-
- modest_header_view_select_next (header_view);
-}
-
-void
-_modest_ui_actions_toggle_view (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- ModestConf *conf;
- ModestHeaderView *header_view;
-
- header_view = modest_widget_factory_get_header_view
- (modest_runtime_get_widget_factory());
-
- conf = modest_runtime_get_conf ();
-
- /* what is saved/restored is depending on the style; thus; we save with
- * old style, then update the style, and restore for this new style*/
- modest_widget_memory_save (conf, G_OBJECT(header_view), "header-view");
-
- if (modest_header_view_get_style (header_view) == MODEST_HEADER_VIEW_STYLE_DETAILS)
- modest_header_view_set_style (header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES);
- else
- modest_header_view_set_style (header_view, MODEST_HEADER_VIEW_STYLE_DETAILS);
-
- modest_widget_memory_restore (conf, G_OBJECT(header_view), "header-view");
-}
-
-
-
-/*
- * Marks a message as read and passes it to the msg preview widget
- */
-static void
-read_msg_func (gpointer data, gpointer user_data)
-{
- ModestMsgView *msg_view;
- TnyMsg *msg;
- TnyHeader *header;
- GetMsgAsyncHelper *helper;
- TnyHeaderFlags header_flags;
-
- msg = TNY_MSG (data);
- helper = (GetMsgAsyncHelper *) user_data;
-
- /* mark message as seen; _set_flags crashes, bug in tinymail? */
- header = TNY_HEADER (tny_iterator_get_current (helper->iter));
- header_flags = tny_header_get_flags (header);
- tny_header_set_flags (header, header_flags | TNY_HEADER_FLAG_SEEN);
- g_object_unref (G_OBJECT (header));
-
- /* Set message on msg view */
- msg_view = modest_widget_factory_get_msg_preview
- (modest_runtime_get_widget_factory());
- modest_msg_view_set_message (msg_view, msg);
-}
-
-/*
- * This function is a generic handler for the tny_folder_get_msg_async
- * call. It expects as user_data a #GetMsgAsyncHelper. This helper
- * contains a user provided function that is called inside this
- * method. This will allow us to use this callback in many different
- * places. This callback performs the common actions for the
- * get_msg_async call, more specific actions will be done by the user
- * function
- */
-static void
-get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err, gpointer user_data)
-{
- GetMsgAsyncHelper *helper;
-
- helper = (GetMsgAsyncHelper *) user_data;
-
- if ((*err && ((*err)->code == TNY_FOLDER_ERROR_GET_MSG)) || !msg) {
- ModestHeaderView *header_view;
- header_view = modest_widget_factory_get_header_view
- (modest_runtime_get_widget_factory());
- _modest_ui_actions_on_item_not_found (header_view,
- MODEST_ITEM_TYPE_MESSAGE,
- helper->main_window);
- return;
- }
-
- /* Call user function */
- helper->func (msg, user_data);
-
- /* Process next element (if exists) */
- tny_iterator_next (helper->iter);
- if (tny_iterator_is_done (helper->iter)) {
- TnyList *headers;
- headers = tny_iterator_get_list (helper->iter);
- /* Free resources */
- g_object_unref (G_OBJECT (headers));
- g_object_unref (G_OBJECT (helper->iter));
- g_slice_free (GetMsgAsyncHelper, helper);
- } else {
- TnyHeader *header;
- header = TNY_HEADER (tny_iterator_get_current (helper->iter));
- tny_folder_get_msg_async (folder, header,
- get_msg_cb, helper);
- g_object_unref (G_OBJECT(header));
- }
-}
-
-void
-_modest_ui_actions_on_header_selected (ModestHeaderView *folder_view,
- TnyHeader *header,
- ModestMainWindow *main_window)
-{
- TnyFolder *folder;
- GetMsgAsyncHelper *helper;
- TnyList *list;
-
- /* when there's no header, clear the msgview */
- if (!header) {
- ModestMsgView *msg_view;
- msg_view = modest_widget_factory_get_msg_preview
- (modest_runtime_get_widget_factory());
- modest_msg_view_set_message (msg_view, NULL);
- return;
- }
-
- folder = tny_header_get_folder (TNY_HEADER(header));
-
- /* Create list */
- list = tny_simple_list_new ();
- tny_list_prepend (list, G_OBJECT (header));
-
- /* Fill helper data */
- helper = g_slice_new0 (GetMsgAsyncHelper);
- helper->main_window = main_window;
- helper->iter = tny_list_create_iterator (list);
- helper->func = read_msg_func;
-
- tny_folder_get_msg_async (TNY_FOLDER(folder),
- header, get_msg_cb,
- helper);
-
- /* Frees */
- g_object_unref (G_OBJECT (folder));
-}
-
-
-
-void
-_modest_ui_actions_on_header_activated (ModestHeaderView *folder_view,
- TnyHeader *header,
- ModestMainWindow *main_window)
-{
- ModestWindow *win;
- TnyFolder *folder = NULL;
- TnyMsg *msg = NULL;
-
- if (!header)
- return;
-
- folder = tny_header_get_folder (header);
- if (!folder) {
- g_printerr ("modest: cannot get folder for header\n");
- goto cleanup;
- }
-
- /* FIXME: make async?; check error */
- msg = tny_folder_get_msg (folder, header, NULL);
- if (!msg) {
- g_printerr ("modest: cannot get msg for header\n");
- goto cleanup;
- }
-
- win = modest_msg_view_window_new (msg);
- gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (main_window));
-
- gtk_widget_show_all (GTK_WIDGET(win));
-
-cleanup:
- if (folder)
- g_object_unref (G_OBJECT (folder));
- if (msg)
- g_object_unref (G_OBJECT (folder));
-}
-
-
-
-
-
-void
-_modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
- TnyFolder *folder,
- gboolean selected,
- ModestMainWindow *main_window)
-{
- GtkLabel *folder_info_label;
- gchar *txt;
- ModestConf *conf;
- ModestHeaderView *header_view;
-
- folder_info_label =
- GTK_LABEL (modest_widget_factory_get_folder_info_label
- (modest_runtime_get_widget_factory()));
-
- if (!folder) {
- gtk_label_set_label (GTK_LABEL(folder_info_label), "");
- return;
- }
-
- header_view = modest_widget_factory_get_header_view (modest_runtime_get_widget_factory());
- conf = modest_runtime_get_conf ();
-
- if (!selected) { /* the folder was unselected; save it's settings */
- modest_widget_memory_save (conf, G_OBJECT (header_view),
- "header-view");
- gtk_window_set_title (GTK_WINDOW(main_window), "Modest");
- modest_header_view_set_folder (header_view, NULL);
- } else { /* the folder was selected */
- if (folder) { /* folder may be NULL */
- guint num, unread;
- gchar *title;
-
- num = tny_folder_get_all_count (folder);
- unread = tny_folder_get_unread_count (folder);
-
- title = g_strdup_printf ("Modest: %s",
- tny_folder_get_name (folder));
-
- gtk_window_set_title (GTK_WINDOW(main_window), title);
- g_free (title);
-
- txt = g_strdup_printf (_("%d %s, %d unread"),
- num, num==1 ? _("item") : _("items"), unread);
- gtk_label_set_label (GTK_LABEL(folder_info_label), txt);
- g_free (txt);
- }
- modest_header_view_set_folder (header_view, folder);
- modest_widget_memory_restore (conf, G_OBJECT(header_view),
- "header-view");
- }
-}
-
-
-/****************************************************/
-/*
- * below some stuff to clearup statusbar messages after 1,5 seconds....
- */
-static gboolean
-progress_bar_clean (GtkWidget *bar)
-{
- if (GTK_IS_PROGRESS_BAR(bar)) {
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR(bar), "");
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(bar), 1.0);
- }
- return FALSE;
-}
-
-static gboolean
-statusbar_clean (GtkWidget *bar)
-{
- if (GTK_IS_STATUSBAR(bar))
- gtk_statusbar_push (GTK_STATUSBAR(bar), 0, "");
- return FALSE;
-}
-
-
-static void
-statusbar_push (ModestWidgetFactory *factory, guint context_id, const gchar *msg)
-{
- GtkWidget *status_bar, *progress_bar;
-
- if (!msg)
- return;
-
- progress_bar = modest_widget_factory_get_progress_bar (factory);
- status_bar = modest_widget_factory_get_status_bar (factory);
-
- gtk_widget_show (GTK_WIDGET(status_bar));
- gtk_widget_show (GTK_WIDGET(progress_bar));
-
- gtk_statusbar_push (GTK_STATUSBAR(status_bar), 0, msg);
-
- g_timeout_add (1500, (GSourceFunc)statusbar_clean, status_bar);
- g_timeout_add (3000, (GSourceFunc)progress_bar_clean, progress_bar);
-}
-/****************************************************************************/
-
-static void
-_modest_ui_actions_on_connection_changed (TnyDevice *device,
- gboolean online,
- ModestUI *self)
-{
- GtkWidget *online_toggle;
- ModestHeaderView *header_view;
- ModestWidgetFactory *widget_factory;
- ModestUIPrivate *priv;
- GtkWidget *icon;
- const gchar *icon_name;
-
- g_return_if_fail (device);
- g_return_if_fail (self);
-
- priv = MODEST_UI_GET_PRIVATE (self);
-
- icon_name = online ? GTK_STOCK_CONNECT : GTK_STOCK_DISCONNECT;
- icon = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
-
- widget_factory = modest_runtime_get_widget_factory ();
- header_view = modest_widget_factory_get_header_view (widget_factory);
- online_toggle = modest_widget_factory_get_online_toggle (widget_factory);
-
- /* Block handlers in order to avoid unnecessary calls */
- g_signal_handler_block (G_OBJECT (online_toggle), priv->toggle_button_signal);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(online_toggle), online);
- g_signal_handler_unblock (G_OBJECT (online_toggle), priv->toggle_button_signal);
-
- gtk_button_set_image (GTK_BUTTON(online_toggle), icon);
- statusbar_push (widget_factory, 0,
- online ? _("Modest went online") : _("Modest went offline"));
-
- /* If Modest has became online and the header view has a
- header selected then show it */
- /* FIXME: there is a race condition if some account needs to
- ask the user for a password */
-
-/* if (online) { */
-/* GtkTreeSelection *selected; */
-
-/* selected = gtk_tree_view_get_selection (GTK_TREE_VIEW (header_view)); */
-/* _modest_header_view_change_selection (selected, header_view); */
-/* } */
-}
-
-void
-_modest_ui_actions_on_online_toggle_toggled (GtkToggleButton *toggle,
- ModestMainWindow *main_window)
-{
- gboolean online;
- TnyDevice *device;
-
- device = tny_account_store_get_device
- (TNY_ACCOUNT_STORE(modest_runtime_get_account_store()));
-
- online = gtk_toggle_button_get_active (toggle);
-
- if (online)
- tny_device_force_online (device);
- else
- tny_device_force_offline (device);
-
- g_object_unref (G_OBJECT (device));
-}
-
-void
-_modest_ui_actions_on_item_not_found (ModestHeaderView *header_view,
- ModestItemType type,
- ModestMainWindow *main_window)
-{
- GtkWidget *dialog;
- gchar *txt, *item;
- gboolean online;
- TnyDevice *device;
- TnyAccountStore *account_store;
-
- item = (type == MODEST_ITEM_TYPE_FOLDER) ? "folder" : "message";
-
- /* Get device. Do not ask the platform factory for it, because
- it returns always a new one */
- account_store = TNY_ACCOUNT_STORE (modest_runtime_get_account_store ());
- device = tny_account_store_get_device (account_store);
-
- if (g_main_depth > 0)
- 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 (main_window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- _("The %s you selected cannot be found"),
- item);
- gtk_dialog_run (GTK_DIALOG(dialog));
- } else {
-
- dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
- GTK_WINDOW (main_window),
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- NULL);
-
- txt = g_strdup_printf (_("This %s is not available in offline mode.\n"
- "Do you want to get online?"), item);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- gtk_label_new (txt), FALSE, FALSE, 0);
- gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
- g_free (txt);
-
- gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
- tny_device_force_online (device);
- }
- }
- gtk_widget_destroy (dialog);
- if (g_main_depth > 0)
- gdk_threads_leave ();
-}
-
-
-
-void
-_modest_ui_actions_on_header_status_update (ModestHeaderView *header_view,
- const gchar *msg,
- gint num,
- gint total,
- ModestMainWindow *main_window)
-{
- GtkWidget *progress_bar;
- char* txt;
-
- progress_bar = modest_widget_factory_get_progress_bar
- (modest_runtime_get_widget_factory());
- if (total != 0)
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress_bar),
- (gdouble)num/(gdouble)total);
- else
- gtk_progress_bar_pulse (GTK_PROGRESS_BAR(progress_bar));
-
- txt = g_strdup_printf (_("Downloading %d of %d"), num, total);
- gtk_progress_bar_set_text (GTK_PROGRESS_BAR(progress_bar), txt);
- g_free (txt);
-
- statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
-}
-
-
-
-void
-_modest_ui_actions_on_msg_link_hover (ModestMsgView *msgview,
- const gchar* link,
- ModestMainWindow *main_window)
-{
- statusbar_push (modest_runtime_get_widget_factory(), 0, link);
-
- /* TODO: do something */
-}
-
-
-void
-_modest_ui_actions_on_msg_link_clicked (ModestMsgView *msgview,
- const gchar* link,
- ModestMainWindow *main_window)
-{
- gchar *msg;
-
- msg = g_strdup_printf (_("Opening %s..."), link);
- statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
- g_free (msg);
-
- /* TODO: do something */
-}
-
-void
-_modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview,
- int index,
- ModestMainWindow *main_window)
-{
- gchar *msg;
-
- msg = g_strdup_printf (_("Opening attachment %d..."), index);
- statusbar_push (modest_runtime_get_widget_factory(), 0, msg);
-
- g_free (msg);
- /* TODO: do something */
-}
-
-void
-_modest_ui_actions_on_send (GtkWidget *widget,
- ModestEditMsgWindow *edit_window)
-{
- TnyTransportAccount *transport_account;
- ModestMailOperation *mail_operation;
- MsgData *data;
- gchar *account_name, *from;
- ModestAccountMgr *account_mgr;
-
-
- 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 */
- account_mgr = modest_runtime_get_account_mgr();
- account_name = modest_account_mgr_get_default_account (account_mgr);
- if (!account_name) {
- g_printerr ("modest: no default account found\n");
- modest_edit_msg_window_free_msg_data (edit_window, data);
- return;
- }
- transport_account =
- TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_tny_account_by_account
- (modest_runtime_get_account_store(),
- account_name,
- TNY_ACCOUNT_TYPE_TRANSPORT));
- if (!transport_account) {
- g_printerr ("modest: no transport account found for '%s'\n", account_name);
- g_free (account_name);
- modest_edit_msg_window_free_msg_data (edit_window, data);
- return;
- }
- from = modest_account_mgr_get_from_string (account_mgr, account_name);
-
- mail_operation = modest_mail_operation_new ();
- modest_mail_operation_send_new_mail (mail_operation,
- transport_account,
- from,
- data->to,
- data->cc,
- data->bcc,
- data->subject,
- data->body,
- NULL);
- /* Frees */
- g_free (from);
- g_free (account_name);
- 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));
-}
-
-/*
- * Shows a dialog with an entry that asks for some text. The returned
- * value must be freed by the caller. The dialog window title will be
- * set to @title.
- */
-static gchar *
-ask_for_folder_name (GtkWindow *parent_window,
- const gchar *title)
-{
- GtkWidget *dialog, *entry;
- gchar *folder_name = NULL;
-
- /* Ask for folder name */
- dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
- parent_window,
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_REJECT,
- GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- gtk_label_new(title),
- FALSE, FALSE, 0);
-
- entry = gtk_entry_new_with_max_length (40);
- gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
- entry,
- TRUE, FALSE, 0);
-
- gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
-
- if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
- folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
-
- gtk_widget_destroy (dialog);
-
- return folder_name;
-}
-
-void
-_modest_ui_actions_on_new_folder (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- TnyFolder *parent_folder;
- ModestFolderView *folder_view;
-
- folder_view = modest_widget_factory_get_folder_view
- (modest_runtime_get_widget_factory());
- parent_folder = modest_folder_view_get_selected (folder_view);
-
- if (parent_folder) {
- gchar *folder_name;
-
- folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
- _("Please enter a name for the new folder"));
-
- if (folder_name != NULL && strlen (folder_name) > 0) {
- TnyFolder *new_folder;
- ModestMailOperation *mail_op;
-
- mail_op = modest_mail_operation_new ();
- new_folder = modest_mail_operation_create_folder (mail_op,
- TNY_FOLDER_STORE (parent_folder),
- (const gchar *) folder_name);
- if (new_folder) {
- /* TODO: tinymail should do this.
- Update view */
- modest_folder_view_add_subfolder (folder_view, new_folder);
-
- /* Free new folder */
- g_object_unref (new_folder);
- }
- g_object_unref (mail_op);
- }
- g_object_unref (parent_folder);
- }
-}
-
-void
-_modest_ui_actions_on_rename_folder (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- TnyFolder *folder;
- ModestFolderView *folder_view;
-
- folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory());
- folder = modest_folder_view_get_selected (folder_view);
-
- if (folder) {
- gchar *folder_name;
-
- folder_name = ask_for_folder_name (GTK_WINDOW (main_window),
- _("Please enter a new name for the folder"));
-
- if (folder_name != NULL && strlen (folder_name) > 0) {
- ModestMailOperation *mail_op;
- const GError *error;
-
- mail_op = modest_mail_operation_new ();
- modest_mail_operation_rename_folder (mail_op,
- folder,
- (const gchar *) folder_name);
-
- error = modest_mail_operation_get_error (mail_op);
- if (!error)
- /* TODO: tinymail should do this.
- Update view */
- modest_folder_view_rename (folder_view);
-
- /* TODO: else ? notify error ? */
-
- g_object_unref (mail_op);
- }
- g_object_unref (folder);
- }
-}
-
-static void
-delete_folder (ModestMainWindow *main_window,
- gboolean move_to_trash)
-{
- TnyFolder *folder;
- ModestFolderView *folder_view;
- ModestMailOperation *mail_op;
-
- folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory());
- folder = modest_folder_view_get_selected (folder_view);
-
- mail_op = modest_mail_operation_new ();
- modest_mail_operation_remove_folder (mail_op, folder, move_to_trash);
- g_object_unref (mail_op);
-}
-
-void
-_modest_ui_actions_on_delete_folder (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- delete_folder (main_window, FALSE);
-}
-
-void
-_modest_ui_actions_on_move_to_trash_folder (GtkWidget *widget,
- ModestMainWindow *main_window)
-{
- delete_folder (main_window, TRUE);
-}
-
-static void
-_modest_ui_actions_on_accounts_reloaded (TnyAccountStore *store, gpointer user_data)
-{
- ModestFolderView *folder_view;
-
- folder_view = modest_widget_factory_get_folder_view (modest_runtime_get_widget_factory());
- modest_folder_view_update_model (folder_view, store);
-}
-
-static void
-_modest_ui_actions_on_folder_moved (ModestFolderView *folder_view,
- TnyFolder *folder,
- TnyFolderStore *parent,
- gboolean *done,
- gpointer user_data)
-{
- ModestMailOperation *mail_op;
- const GError *error;
-
- *done = TRUE;
-
- /* Try to move the folder */
- mail_op = modest_mail_operation_new ();
- modest_mail_operation_move_folder (mail_op, folder, parent);
-
- error = modest_mail_operation_get_error (mail_op);
- if (error)
- *done = FALSE;
-
- g_object_unref (G_OBJECT (mail_op));
-}
+++ /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_H__
-#define __MODEST_UI_H__
-
-#include <glib-object.h>
-#include <tny-account-store.h>
-#include <gtk/gtkactiongroup.h>
-#include <widgets/modest-window.h>
-#include <widgets/modest-edit-msg-window.h>
-
-G_BEGIN_DECLS
-
-/* convenience macros */
-#define MODEST_TYPE_UI (modest_ui_get_type())
-#define MODEST_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_UI,ModestUI))
-#define MODEST_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_UI,GObject))
-#define MODEST_IS_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_UI))
-#define MODEST_IS_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_UI))
-#define MODEST_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_UI,ModestUIClass))
-
-typedef struct _ModestUI ModestUI;
-typedef struct _ModestUIClass ModestUIClass;
-
-struct _ModestUI {
- GObject parent;
- /* insert public members, if any */
-};
-
-struct _ModestUIClass {
- GObjectClass parent_class;
- /* insert signal callback declarations, eg. */
-};
-
-/**
- * modest_ui_get_type:
- *
- * get the GType for ModestUI
- *
- * Returns: the GType
- */
-GType modest_ui_get_type (void) G_GNUC_CONST;
-
-/**
- * modest_ui_new:
- * @account_store: a #TnyAccountStore
- *
- * Returns: a new ModestUI, or NULL in case of error
- */
-ModestUI* modest_ui_new (void);
-
-
-/**
- * modest_ui_main_window:
- * @modest_ui: a ModestUI instance
- *
- * 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 #ModestMainWindow, or NULL in case of error
- */
-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__ */
+++ /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.
- */
-
-#include <glib/gi18n.h>
-#include <gdk/gdkkeysyms.h>
-#include <tny-gtk-account-list-model.h>
-#include <tny-gtk-folder-store-tree-model.h>
-#include <tny-account-store.h>
-#include <tny-simple-list.h>
-#include <tny-device.h>
-#include <tny-folder-store-query.h>
-#include "modest-widget-factory.h"
-#include "modest-widget-memory.h"
-#include <modest-protocol-info.h>
-#include "modest-tny-platform-factory.h"
-
-#include <modest-account-mgr.h>
-#include <modest-account-mgr-helpers.h>
-#include <modest-runtime.h>
-
-#include "modest-mail-operation.h"
-#include "widgets/modest-header-view-priv.h"
-
-/* 'private'/'protected' functions */
-static void modest_widget_factory_class_init (ModestWidgetFactoryClass *klass);
-static void modest_widget_factory_init (ModestWidgetFactory *obj);
-static void modest_widget_factory_finalize (GObject *obj);
-
-
-/* list my signals */
-enum {
- /* MY_SIGNAL_1, */
- /* MY_SIGNAL_2, */
- LAST_SIGNAL
-};
-
-typedef struct _ModestWidgetFactoryPrivate ModestWidgetFactoryPrivate;
-struct _ModestWidgetFactoryPrivate {
-
- ModestTnyAccountStore *account_store;
-
- ModestHeaderView *header_view;
- ModestFolderView *folder_view;
- ModestMsgView *msg_preview;
-
- GtkWidget *progress_bar;
- GtkWidget *status_bar;
- GtkWidget *folder_info_label;
-
- GtkWidget *online_toggle;
-};
-#define MODEST_WIDGET_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
- MODEST_TYPE_WIDGET_FACTORY, \
- ModestWidgetFactoryPrivate))
-/* globals */
-static GObjectClass *parent_class = NULL;
-
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
-GType
-modest_widget_factory_get_type (void)
-{
- static GType my_type = 0;
- if (!my_type) {
- static const GTypeInfo my_info = {
- sizeof(ModestWidgetFactoryClass),
- NULL, /* base init */
- NULL, /* base finalize */
- (GClassInitFunc) modest_widget_factory_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof(ModestWidgetFactory),
- 1, /* n_preallocs */
- (GInstanceInitFunc) modest_widget_factory_init,
- NULL
- };
- my_type = g_type_register_static (G_TYPE_OBJECT,
- "ModestWidgetFactory",
- &my_info, 0);
- }
- return my_type;
-}
-
-static void
-modest_widget_factory_class_init (ModestWidgetFactoryClass *klass)
-{
- GObjectClass *gobject_class;
- gobject_class = (GObjectClass*) klass;
-
- parent_class = g_type_class_peek_parent (klass);
- gobject_class->finalize = modest_widget_factory_finalize;
-
- g_type_class_add_private (gobject_class, sizeof(ModestWidgetFactoryPrivate));
-}
-
-static void
-modest_widget_factory_init (ModestWidgetFactory *obj)
-{
- ModestWidgetFactoryPrivate *priv;
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
-
- priv->account_store = NULL;
-
- priv->progress_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(priv->progress_bar),
- 1.0);
- gtk_progress_bar_set_ellipsize (GTK_PROGRESS_BAR(priv->progress_bar),
- PANGO_ELLIPSIZE_END);
- priv->status_bar = gtk_statusbar_new ();
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(priv->status_bar),
- FALSE);
-}
-
-
-static void
-modest_widget_factory_finalize (GObject *obj)
-{
- /* no need to unref account_store; we don't own the reference */
-
- G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
-
-
-static gboolean
-init_widgets (ModestWidgetFactory *self)
-{
- ModestWidgetFactoryPrivate *priv;
- TnyFolderStoreQuery *query;
-
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
-
- /* folder view */
- query = tny_folder_store_query_new ();
- tny_folder_store_query_add_item (query, NULL, TNY_FOLDER_STORE_QUERY_OPTION_SUBSCRIBED);
-
- priv->folder_view = MODEST_FOLDER_VIEW(modest_folder_view_new (priv->account_store,query));
- if (!priv->folder_view) {
- g_printerr ("modest: cannot instantiate folder view\n");
- return FALSE;
- }
- g_object_unref (G_OBJECT (query));
-
- /* header view */
- priv->header_view =
- MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
- if (!priv->header_view) {
- g_printerr ("modest: cannot instantiate header view\n");
- return FALSE;
- }
-
- /* msg preview */
- priv->msg_preview = MODEST_MSG_VIEW(modest_msg_view_new (NULL));
- if (!priv->msg_preview) {
- g_printerr ("modest: cannot instantiate header view\n");
- return FALSE;
- }
-
- /* online/offline combo */
- priv->online_toggle = gtk_toggle_button_new ();
-
- /* label with number of items, unread items for
- the current folder */
- priv->folder_info_label = gtk_label_new (NULL);
-
- return TRUE;
-}
-
-
-ModestWidgetFactory*
-modest_widget_factory_new (ModestTnyAccountStore *account_store)
-{
- GObject *obj;
- ModestWidgetFactoryPrivate *priv;
-
- g_return_val_if_fail (account_store, NULL);
-
- obj = g_object_new (MODEST_TYPE_WIDGET_FACTORY, NULL);
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(obj);
-
- priv->account_store = account_store;
-
- if (!init_widgets (MODEST_WIDGET_FACTORY(obj))) {
- g_printerr ("modest: widget factory failed to init widgets\n");
- g_object_unref (obj);
- return NULL;
- }
-
- return MODEST_WIDGET_FACTORY(obj);
-}
-
-
-
-
-ModestFolderView*
-modest_widget_factory_get_folder_view (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->folder_view;
-}
-
-
-ModestHeaderView*
-modest_widget_factory_get_header_view (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->header_view;
-}
-
-
-ModestMsgView*
-modest_widget_factory_get_msg_preview (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->msg_preview;
-}
-
-
-ModestAccountView*
-modest_widget_factory_get_account_view (ModestWidgetFactory *self)
-{
- return modest_account_view_new (modest_runtime_get_account_mgr());
-}
-
-
-
-GtkWidget*
-modest_widget_factory_get_progress_bar (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->progress_bar;
-}
-
-
-GtkWidget*
-modest_widget_factory_get_status_bar (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->status_bar;
-}
-
-
-
-static const GSList*
-get_transports (ModestWidgetFactory *self)
-{
- ModestWidgetFactoryPrivate *priv;
- ModestAccountMgr *account_mgr;
- GSList *transports = NULL;
- GSList *cursor, *accounts;
-
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
-
- account_mgr = modest_runtime_get_account_mgr();
- cursor = accounts = modest_account_mgr_account_names (account_mgr, NULL);
- while (cursor) {
- gchar *account_name = (gchar*)cursor->data;
- gchar *from_string = modest_account_mgr_get_from_string (account_mgr,
- account_name);
- if (!from_string) {
- /* something went wrong: ignore this one */
- g_free (account_name);
- cursor->data = NULL;
- } else {
- ModestPair *pair;
- pair = modest_pair_new ((gpointer) account_name,
- (gpointer) from_string , TRUE);
- transports = g_slist_prepend (transports, pair);
- } /* don't free account name; it's freed when the transports list is freed */
- cursor = cursor->next;
- }
- g_slist_free (accounts);
- return transports;
-}
-
-
-GtkWidget*
-modest_widget_factory_get_combo_box (ModestWidgetFactory *self, ModestComboBoxType type)
-{
- ModestWidgetFactoryPrivate *priv;
- ModestPairList *protos = NULL;
- GtkWidget* combo_box;
-
- g_return_val_if_fail (self, NULL);
-
- priv = MODEST_WIDGET_FACTORY_GET_PRIVATE(self);
-
- switch (type) {
- case MODEST_COMBO_BOX_TYPE_STORE_PROTOS:
- protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_STORE);
- break;
- case MODEST_COMBO_BOX_TYPE_TRANSPORT_PROTOS:
- protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_TRANSPORT);
- break;
- case MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS:
- protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_SECURITY);
- break;
- case MODEST_COMBO_BOX_TYPE_AUTH_PROTOS:
- protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
- break;
- case MODEST_COMBO_BOX_TYPE_TRANSPORTS:
- protos = (ModestPairList *) get_transports (self);
- break;
- default:
- g_warning ("invalid combo box type: %d", type);
- return NULL;
- }
-
- combo_box = modest_combo_box_new (protos);
- g_slist_free (protos);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box), 0);
-
- return combo_box;
-}
-
-
-
-GtkWidget*
-modest_widget_factory_get_online_toggle (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->online_toggle;
-}
-
-
-
-GtkWidget*
-modest_widget_factory_get_folder_info_label (ModestWidgetFactory *self)
-{
- g_return_val_if_fail (self, NULL);
- return MODEST_WIDGET_FACTORY_GET_PRIVATE(self)->folder_info_label;
-}
+++ /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_WIDGET_FACTORY_H__
-#define __MODEST_WIDGET_FACTORY_H__
-
-#include "modest-account-mgr.h"
-#include "modest-tny-account-store.h"
-#include "widgets/modest-header-view.h"
-#include "widgets/modest-folder-view.h"
-#include "widgets/modest-msg-view.h"
-#include "widgets/modest-account-view.h"
-#include "widgets/modest-combo-box.h"
-
-G_BEGIN_DECLS
-
-/* convenience macros */
-#define MODEST_TYPE_WIDGET_FACTORY (modest_widget_factory_get_type())
-#define MODEST_WIDGET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_WIDGET_FACTORY,ModestWidgetFactory))
-#define MODEST_WIDGET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_WIDGET_FACTORY,GObject))
-#define MODEST_IS_WIDGET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_WIDGET_FACTORY))
-#define MODEST_IS_WIDGET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_WIDGET_FACTORY))
-#define MODEST_WIDGET_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_WIDGET_FACTORY,ModestWidgetFactoryClass))
-
-typedef struct _ModestWidgetFactory ModestWidgetFactory;
-typedef struct _ModestWidgetFactoryClass ModestWidgetFactoryClass;
-
-struct _ModestWidgetFactory {
- GObject parent;
-};
-
-struct _ModestWidgetFactoryClass {
- GObjectClass parent_class;
-};
-
-
-typedef enum _ModestComboBoxType {
- MODEST_COMBO_BOX_TYPE_STORE_PROTOS,
- MODEST_COMBO_BOX_TYPE_TRANSPORT_PROTOS,
- MODEST_COMBO_BOX_TYPE_SECURITY_PROTOS,
- MODEST_COMBO_BOX_TYPE_AUTH_PROTOS,
- MODEST_COMBO_BOX_TYPE_TRANSPORTS,
- MODEST_COMBO_BOX_TYPE_REMOTE_STORES
-} ModestComboBoxType;
-
-
-/**
- * modest_widget_factory_get_type
- *
- * get the GType for ModestWidgetFactory
- *
- * Returns: the GType
- */
-GType modest_widget_factory_get_type (void) G_GNUC_CONST;
-
-
-/**
- * modest_widget_factory_new
- * @account_store: a valid ModestTnyAccountStore instance
- *
- * instantiates a ModestWidgetFactory
- *
- * Returns: a new ModestWidgetFactory, or NULL in case of error
- */
-ModestWidgetFactory* modest_widget_factory_new (ModestTnyAccountStore *account_store);
-
-
-/**
- * modest_widget_factory_get_folder_view
- * @self: a ModestWidgetFactory instance
- *
- * return the folder tree widget (ie. the widget with the list of folders);
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: a folder tree view, or NULL in case of error
- */
-ModestFolderView* modest_widget_factory_get_folder_view (ModestWidgetFactory *self);
-
-
-/**
- * modest_widget_factory_get_header_view
- * @self: a ModestWidgetFactory instance
- *
- * return the header tree widget (ie. the widget with the list of headers);
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: a header tree view, or NULL in case of error
- */
-ModestHeaderView* modest_widget_factory_get_header_view (ModestWidgetFactory *self);
-
-
-/**
- * modest_widget_factory_get_msg_preview
- * @self: a ModestWidgetFactory instance
- *
- * return the message preview widget (ie. the widget with shows the currently selected message);
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: a header tree view, or NULL in case of error
- */
-ModestMsgView* modest_widget_factory_get_msg_preview (ModestWidgetFactory *self);
-
-
-/**
- * modest_widget_factory_get_account_view
- * @self: a ModestWidgetFactory instance
- *
- * return an account view widget (ie. the widget that shows a list of accounts)
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: the account view, or NULL in case of error
- */
-ModestAccountView* modest_widget_factory_get_account_view (ModestWidgetFactory *self);
-
-
-/**
- * modest_widget_factory_get_progress_bar
- * @self: a ModestWidgetFactory instance
- *
- * return an progress bar widget
- * if the widget factory was created with 'auto_connect', then this progress bar
- * will automatically update for changes in the other widgets
- * NOTE the naming inconsistency: GtkProgressBar vs GtkStatusbar
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: the progress bar widget
- */
-GtkWidget* modest_widget_factory_get_progress_bar (ModestWidgetFactory *self);
-
-
-
-/**
- * modest_widget_factory_get_status_bar
- * @self: a ModestWidgetFactory instance
- *
- * return an status bar widget
- * if the widget factory was created with 'auto_connect', then this status bar
- * will automatically update for changes in the other widgets
- * NOTE the naming inconsistency: GtkProgressBar vs GtkStatusbar
- *
- * This factory will always return the
- * same widget, and takes care of its lifetime - users should *not* destroy it.
- *
- * Returns: the status bar widget
- */
-GtkWidget* modest_widget_factory_get_status_bar (ModestWidgetFactory *self);
-
-/**
- * modest_widget_factory_get_store
- * @self: a ModestWidgetFactory instance
- * @type: the type of items we want a combo box for
- *
- * return a combobox with with the given items
- *
- * Returns: the combo box
- */
-GtkWidget* modest_widget_factory_get_combo_box (ModestWidgetFactory *self,
- ModestComboBoxType type);
-
-
-/**
- * modest_widget_factory_get_online_toggle
- * @self: a ModestWidgetFactory instance
- *
- * return a toggle which with one can see whether online/offline mode is active.
- * In case of auto-connect, this will automatically be sync'd with the
- * account_store / device
- *
- * Returns: the toggle button
- */
-GtkWidget* modest_widget_factory_get_online_toggle (ModestWidgetFactory *self);
-
-/**
- * modest_widget_factory_get_folder_info_label
- * @self: a ModestWidgetFactory instance
- *
- * return a label with the number of items, unread items in the current folder
- *
- * Returns: the label
- */
-GtkWidget* modest_widget_factory_get_folder_info_label (ModestWidgetFactory *self);
-
-G_END_DECLS
-
-#endif /* __MODEST_WIDGET_FACTORY_H__ */
-
modest-account-view.h \
modest-combo-box.c \
modest-combo-box.h \
- modest-edit-msg-window.h \
- modest-edit-msg-window-ui.h \
+ modest-msg-edit-window.h \
+ modest-msg-edit-window-ui.h \
modest-msg-view-window.h \
modest-folder-view.c \
modest-folder-view.h \
renderer, "text",
COLUMN_DISPLAY_NAME, NULL);
}
-
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX(obj), 0);
return GTK_WIDGET(obj);
}
+++ /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__ */
+++ /dev/null
-/* Copyright (c) 2006,2007 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_EDIT_MSG_WINDOW_H__
-#define __MODEST_EDIT_MSG_WINDOW_H__
-
-#include <tny-msg.h>
-#include <modest-window.h>
-
-G_BEGIN_DECLS
-
-/* convenience macros */
-#define MODEST_TYPE_EDIT_MSG_WINDOW (modest_edit_msg_window_get_type())
-#define MODEST_EDIT_MSG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_EDIT_MSG_WINDOW,ModestEditMsgWindow))
-#define MODEST_EDIT_MSG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_EDIT_MSG_WINDOW,ModestWindow))
-#define MODEST_IS_EDIT_MSG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_EDIT_MSG_WINDOW))
-#define MODEST_IS_EDIT_MSG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_EDIT_MSG_WINDOW))
-#define MODEST_EDIT_MSG_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_EDIT_MSG_WINDOW,ModestEditMsgWindowClass))
-
-typedef struct _ModestEditMsgWindow ModestEditMsgWindow;
-typedef struct _ModestEditMsgWindowClass ModestEditMsgWindowClass;
-
-struct _ModestEditMsgWindow {
- ModestWindow parent;
- /* insert public members, if any */
-};
-
-struct _ModestEditMsgWindowClass {
- ModestWindowClass parent_class;
- /* insert signal callback declarations, eg. */
- /* void (* my_event) (ModestEditMsgWindow* obj); */
-};
-
-typedef enum {
- MODEST_EDIT_TYPE_NEW,
- MODEST_EDIT_TYPE_REPLY,
- MODEST_EDIT_TYPE_FORWARD,
- MODEST_EDIT_TYPE_VIEW,
-
- MODEST_EDIT_TYPE_NUM
-} ModestEditType;
-
-typedef struct _MsgData {
- gchar *from, *to, *cc, *bcc, *subject, *body;
-} MsgData;
-
-
-/**
- * modest_edit_msg_window_get_type:
- *
- * get the GType for the #ModestEditMsgWindow class
- *
- * Returns: a GType for #ModestEditMsgWindow
- */
-GType modest_edit_msg_window_get_type (void) G_GNUC_CONST;
-
-
-/**
- * modest_edit_msg_window_new:
- *
- * instantiates a new #ModestEditMsgWindow widget
- *
- * Returns: a new #ModestEditMsgWindow, or NULL in case of error
- */
-ModestWindow* modest_edit_msg_window_new (ModestEditType type);
-
-
-/**
- * modest_edit_msg_window_set_msg:
- * @self: a #ModestEditMsgWindow
- * @msg: a #TnyMsg
- *
- * shows the message @msg in a #ModestEditMsgWindow
- **/
-void modest_edit_msg_window_set_msg (ModestEditMsgWindow *self,
- TnyMsg *msg);
-
-
-/**
- * modest_edit_msg_window_get_msg_data:
- * @self: a #ModestEditMsgWindow
- *
- * gets the message data already present in the edit message
- * window. The message data must be freed with
- * modest_edit_msg_window_free_msg_data
- *
- * Returns: the message data
- **/
-MsgData * modest_edit_msg_window_get_msg_data (ModestEditMsgWindow *self);
-
-/**
- * modest_edit_msg_window_free_msg_data:
- * @self: a #ModestEditMsgWindow
- * @data:
- *
- * frees the message data passed as argument
- **/
-void modest_edit_msg_window_free_msg_data (ModestEditMsgWindow *self,
- MsgData *data);
-G_END_DECLS
-
-#endif /* __MODEST_EDIT_MSG_WINDOW_H__ */
-
GList *list, *tmp = NULL;
GtkTreeModel *tree_model = NULL;
GtkTreeIter iter;
+
+ g_return_val_if_fail (self, NULL);
priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
#ifndef __MODEST_MAIN_WINDOW_H__
#define __MODEST_MAIN_WINDOW_H__
-#include "modest-widget-factory.h"
-#include "modest-window.h"
+#include <gtk/gtkwidget.h>
+#include <widgets/modest-window.h>
+#include <widgets/modest-header-view.h>
+#include <widgets/modest-folder-view.h>
+#include <widgets/modest-msg-view.h>
+
G_BEGIN_DECLS
struct _ModestMainWindow {
ModestWindow parent;
+
+ /* public members;
+ * NOTE: these can be NULL as not all frontends
+ * (gtk, maemo, ...) may use all of them.
+ */
+ ModestHeaderView *header_view;
+ ModestFolderView *folder_view;
+ ModestMsgView *msg_preview;
+
+ GtkWidget *status_bar;
+ GtkWidget *progress_bar;
};
struct _ModestMainWindowClass {
*/
ModestWindow* modest_main_window_new (void);
+
G_END_DECLS
#endif /* __MODEST_MAIN_WINDOW_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_MSG_EDIT_WINDOW_UI_H__
+#define __MODEST_MSG_EDIT_WINDOW_UI_H__
+
+#include <glib/gi18n.h>
+#include "modest-icon-names.h"
+#include "modest-ui-actions.h"
+
+G_BEGIN_DECLS
+
+static const GtkActionEntry modest_msg_edit_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_msg_edit_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_MSG_EDIT_WINDOW_UI_H__ */
--- /dev/null
+/* Copyright (c) 2006,2007 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_MSG_EDIT_WINDOW_H__
+#define __MODEST_MSG_EDIT_WINDOW_H__
+
+#include <tny-msg.h>
+#include <widgets/modest-window.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_MSG_EDIT_WINDOW (modest_msg_edit_window_get_type())
+#define MODEST_MSG_EDIT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindow))
+#define MODEST_MSG_EDIT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MSG_EDIT_WINDOW,ModestWindow))
+#define MODEST_IS_MSG_EDIT_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MSG_EDIT_WINDOW))
+#define MODEST_IS_MSG_EDIT_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MSG_EDIT_WINDOW))
+#define MODEST_MSG_EDIT_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MSG_EDIT_WINDOW,ModestMsgEditWindowClass))
+
+typedef struct _ModestMsgEditWindow ModestMsgEditWindow;
+typedef struct _ModestMsgEditWindowClass ModestMsgEditWindowClass;
+
+struct _ModestMsgEditWindow {
+ ModestWindow parent;
+ /* insert public members, if any */
+};
+
+struct _ModestMsgEditWindowClass {
+ ModestWindowClass parent_class;
+ /* insert signal callback declarations, eg. */
+ /* void (* my_event) (ModestMsgEditWindow* obj); */
+};
+
+typedef enum {
+ MODEST_EDIT_TYPE_NEW,
+ MODEST_EDIT_TYPE_REPLY,
+ MODEST_EDIT_TYPE_FORWARD,
+ MODEST_EDIT_TYPE_VIEW,
+
+ MODEST_EDIT_TYPE_NUM
+} ModestEditType;
+
+typedef struct _MsgData {
+ gchar *from, *to, *cc, *bcc, *subject, *body;
+} MsgData;
+
+
+/**
+ * modest_msg_edit_window_get_type:
+ *
+ * get the GType for the #ModestMsgEditWindow class
+ *
+ * Returns: a GType for #ModestMsgEditWindow
+ */
+GType modest_msg_edit_window_get_type (void) G_GNUC_CONST;
+
+
+/**
+ * modest_msg_edit_window_new:
+ *
+ * instantiates a new #ModestMsgEditWindow widget
+ *
+ * Returns: a new #ModestMsgEditWindow, or NULL in case of error
+ */
+ModestWindow* modest_msg_edit_window_new (ModestEditType type);
+
+
+/**
+ * modest_msg_edit_window_set_msg:
+ * @self: a #ModestMsgEditWindow
+ * @msg: a #TnyMsg
+ *
+ * shows the message @msg in a #ModestMsgEditWindow
+ **/
+void modest_msg_edit_window_set_msg (ModestMsgEditWindow *self,
+ TnyMsg *msg);
+
+
+/**
+ * modest_msg_edit_window_get_msg_data:
+ * @self: a #ModestMsgEditWindow
+ *
+ * gets the message data already present in the edit message
+ * window. The message data must be freed with
+ * modest_msg_edit_window_free_msg_data
+ *
+ * Returns: the message data
+ **/
+MsgData * modest_msg_edit_window_get_msg_data (ModestMsgEditWindow *self);
+
+/**
+ * modest_msg_edit_window_free_msg_data:
+ * @self: a #ModestMsgEditWindow
+ * @data:
+ *
+ * frees the message data passed as argument
+ **/
+void modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *self,
+ MsgData *data);
+G_END_DECLS
+
+#endif /* __MODEST_MSG_EDIT_WINDOW_H__ */
+
#define __MODEST_MSG_VIEW_WINDOW_H__
#include <tny-msg.h>
-#include <modest-window.h>
+#include <widgets/modest-window.h>
G_BEGIN_DECLS
#include <gtk/gtkuimanager.h>
#include <tny-account-store.h>
#include "modest-tny-platform-factory.h"
-#include "modest-widget-factory.h"
G_BEGIN_DECLS
#include <glib-object.h>
#include <tny-account-store.h>
-#include "modest-widget-factory.h"
G_BEGIN_DECLS