X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-ui.c;h=5f8e194b9f50c050f8da1d7401d7c4fba8e95e0a;hp=d60f0e8da3083588c4b395acbd17e18231419076;hb=45ad5247602dd395a095bc3086acab1c73997008;hpb=6f5b29a4ff90dbf29a5562222d6f9a8d3e2725eb diff --git a/src/modest-ui.c b/src/modest-ui.c index d60f0e8..5f8e194 100644 --- a/src/modest-ui.c +++ b/src/modest-ui.c @@ -39,6 +39,7 @@ #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 @@ -96,13 +97,6 @@ static void reply_forward (GtkWidget *widget, static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title); -static void _modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, - const gchar* account_name, - gchar **password, - gboolean *cancel, - gboolean *remember, - ModestMainWindow *main_window); - GType modest_ui_get_type (void) { @@ -158,7 +152,6 @@ modest_ui_init (ModestUI *obj) static void modest_ui_finalize (GObject *obj) { - ModestUIPrivate *priv = MODEST_UI_GET_PRIVATE(obj); if (priv->widget_factory) { @@ -170,7 +163,7 @@ modest_ui_finalize (GObject *obj) g_object_unref (G_OBJECT(priv->ui_manager)); priv->ui_manager = NULL; } - + G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -288,7 +281,7 @@ register_stock_icons () { 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 } +/* { MODEST_STOCK_STOP, "stop", 0, 0, NULL } */ }; static gchar *items_names [] = { @@ -301,7 +294,7 @@ register_stock_icons () MODEST_TOOLBAR_ICON_DELETE, MODEST_TOOLBAR_ICON_NEXT, MODEST_TOOLBAR_ICON_PREV, - MODEST_TOOLBAR_ICON_STOP +/* MODEST_TOOLBAR_ICON_STOP */ }; registered = TRUE; @@ -390,12 +383,6 @@ connect_signals (ModestUI *self) G_CALLBACK(_modest_ui_actions_on_online_toggle_toggled), priv->main_window); - /* account store */ - g_signal_connect (G_OBJECT (priv->account_store), - "password_requested", - G_CALLBACK(_modest_ui_actions_on_password_requested), - priv->main_window); - /* Destroy window */ g_signal_connect (G_OBJECT(priv->main_window), "destroy", @@ -535,7 +522,7 @@ _modest_ui_actions_on_new_msg (GtkWidget *widget, g_object_unref (G_OBJECT (widget_factory)); g_object_unref (G_OBJECT (account_store)); - gtk_widget_show (GTK_WIDGET (msg_win)); + gtk_widget_show_all (GTK_WIDGET (msg_win)); } static void @@ -562,6 +549,7 @@ reply_forward_func (gpointer data, gpointer user_data) 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, @@ -577,10 +565,15 @@ reply_forward_func (gpointer data, gpointer user_data) g_return_if_reached (); } - /* Set from */ - new_header = tny_msg_get_header (new_msg); - tny_header_set_from (new_header, rf_helper->from); - g_object_unref (G_OBJECT (new_header)); + if (!new_msg) { + g_warning ("Unable to create a message"); + goto cleanup; + } + +/* /\* Set from *\/ */ +/* new_header = tny_msg_get_header (new_msg); */ +/* tny_header_set_from (new_header, rf_helper->from); */ +/* g_object_unref (G_OBJECT (new_header)); */ /* Show edit window */ widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (helper->main_window)); @@ -590,12 +583,15 @@ reply_forward_func (gpointer data, gpointer user_data) MODEST_EDIT_TYPE_NEW); g_object_unref (G_OBJECT (widget_factory)); g_object_unref (G_OBJECT (account_store)); + modest_edit_msg_window_set_msg (MODEST_EDIT_MSG_WINDOW (msg_win), new_msg); - gtk_widget_show (GTK_WIDGET (msg_win)); + 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); } @@ -609,14 +605,16 @@ reply_forward (GtkWidget *widget, ModestMainWindow *main_window) { ModestHeaderView *header_view; + ModestAccountMgr *account_mgr; ModestWidgetFactory *widget_factory; TnyList *header_list; guint reply_forward_type; - ModestConf *conf; + ModestConf *conf; + ModestAccountData *default_account_data; TnyPlatformFactory *plat_factory; TnyHeader *header; TnyFolder *folder; - gchar *from, *key; + gchar *from, *key, *default_account_name; GetMsgAsyncHelper *helper; ReplyForwardHelper *rf_helper; @@ -644,9 +642,15 @@ reply_forward (GtkWidget *widget, same folder and that we reply all of them from the same account. In fact the interface currently only allows single selection */ - - /* TODO: get the from string from account */ - from = g_strdup ("Invalid"); + account_mgr = modest_tny_platform_factory_get_account_mgr_instance + (MODEST_TNY_PLATFORM_FACTORY(plat_factory)); + 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); @@ -788,8 +792,8 @@ get_msg_cb (TnyFolder *folder, TnyMsg *msg, GError **err, gpointer user_data) widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (helper->main_window)); header_view = modest_widget_factory_get_header_view (widget_factory); g_object_unref (G_OBJECT (widget_factory)); - _modest_ui_actions_on_item_not_found (header_view, - MODEST_ITEM_TYPE_MESSAGE, + _modest_ui_actions_on_item_not_found (header_view, + MODEST_ITEM_TYPE_MESSAGE, helper->main_window); return; } @@ -912,62 +916,6 @@ _modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, } } -void -_modest_ui_actions_on_password_requested (ModestTnyAccountStore *account_store, - const gchar* account_name, - gchar **password, - gboolean *cancel, - gboolean *remember, - ModestMainWindow *main_window) -{ - gchar *txt; - GtkWidget *dialog, *entry, *remember_pass_check; - - dialog = gtk_dialog_new_with_buttons (_("Password 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 (_("Please enter your password for %s"), account_name); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), gtk_label_new(txt), - FALSE, FALSE, 0); - g_free (txt); - - entry = gtk_entry_new_with_max_length (40); - gtk_entry_set_visibility (GTK_ENTRY(entry), FALSE); - gtk_entry_set_invisible_char (GTK_ENTRY(entry), 0x2022); /* bullet unichar */ - - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), entry, - TRUE, FALSE, 0); - - remember_pass_check = gtk_check_button_new_with_label (_("Remember password")); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), remember_pass_check, - TRUE, FALSE, 0); - - gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); - - if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - *password = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry))); - *cancel = FALSE; - } else { - *password = NULL; - *cancel = TRUE; - } - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check))) - *remember = TRUE; - else - *remember = FALSE; - - gtk_widget_destroy (dialog); - - while (gtk_events_pending ()) - gtk_main_iteration (); -} /****************************************************/ /* @@ -979,27 +927,29 @@ typedef struct { guint msg_id; } StatusRemoveData; + static gboolean -on_statusbar_remove_msg (StatusRemoveData *data) +progress_bar_clean (GtkWidget *bar) { - /* we need to test types, as this callback maybe called after the - * widgets have been destroyed - */ - if (GTK_IS_STATUSBAR(data->status_bar)) - gtk_statusbar_remove (GTK_STATUSBAR(data->status_bar), - 0, data->msg_id); - if (GTK_IS_PROGRESS_BAR(data->progress_bar)) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(data->progress_bar), - 1.0); - g_free (data); + 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) { - guint id; - StatusRemoveData *data; GtkWidget *status_bar, *progress_bar; if (!msg) @@ -1007,15 +957,14 @@ statusbar_push (ModestWidgetFactory *factory, guint context_id, const gchar *msg progress_bar = modest_widget_factory_get_progress_bar (factory); status_bar = modest_widget_factory_get_status_bar (factory); - - id = gtk_statusbar_push (GTK_STATUSBAR(status_bar), 0, msg); - data = g_new (StatusRemoveData, 1); - data->status_bar = status_bar; - data->progress_bar = progress_bar; - data->msg_id = id; + gtk_widget_show (GTK_WIDGET(status_bar)); + gtk_widget_show (GTK_WIDGET(progress_bar)); - g_timeout_add (1500, (GSourceFunc)on_statusbar_remove_msg, data); + 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); } /****************************************************************************/ @@ -1093,8 +1042,9 @@ _modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, factory = modest_tny_platform_factory_get_instance (); account_store = tny_platform_factory_new_account_store (factory); device = tny_account_store_get_device (account_store); - - gdk_threads_enter (); + + if (g_main_depth > 0) + gdk_threads_enter (); online = tny_device_is_online (device); if (online) { @@ -1130,7 +1080,8 @@ _modest_ui_actions_on_item_not_found (ModestHeaderView *header_view, } } gtk_widget_destroy (dialog); - gdk_threads_leave (); + if (g_main_depth > 0) + gdk_threads_leave (); } @@ -1144,7 +1095,8 @@ _modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, { GtkWidget *progress_bar; ModestWidgetFactory *widget_factory; - + char* txt; + widget_factory = modest_window_get_widget_factory (MODEST_WINDOW (main_window)); progress_bar = modest_widget_factory_get_progress_bar (widget_factory); @@ -1154,8 +1106,12 @@ _modest_ui_actions_on_header_status_update (ModestHeaderView *header_view, 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 (widget_factory, 0, msg); - + /* Free */ g_object_unref (G_OBJECT (widget_factory)); }