From e0807422c3f39ad1114d6456964d1c007b5a92c8 Mon Sep 17 00:00:00 2001 From: Javier Fernandez Garcia-Boente Date: Thu, 7 Jun 2007 14:08:32 +0000 Subject: [PATCH] * Fixes: NB#56474 * New dimmig rule for tools menu options pmo-trunk-r2102 --- src/maemo/modest-main-window.c | 80 ++++++++++++++++++++++++++++++++++++-- src/modest-mail-operation.c | 6 +++ src/modest-ui-actions.c | 53 +++++++++++++++++++++---- src/modest-ui-dimming-rules.c | 2 + src/widgets/modest-main-window.h | 18 +++++++++ 5 files changed, 148 insertions(+), 11 deletions(-) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index c9af125..3bc7edc 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -67,6 +67,11 @@ #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions" +#define XALIGN 0.5 +#define YALIGN 0.5 +#define XSPACE 1 +#define YSPACE 0 + /* 'private'/'protected' functions */ static void modest_main_window_class_init (ModestMainWindowClass *klass); static void modest_main_window_init (ModestMainWindow *obj); @@ -117,6 +122,10 @@ static void on_refresh_account_action_activated (GtkAction *action, static void on_send_receive_csm_activated (GtkMenuItem *item, gpointer user_data); + + +static GtkWidget * create_empty_view (void); + /* list my signals */ enum { /* MY_SIGNAL_1, */ @@ -131,6 +140,7 @@ struct _ModestMainWindowPrivate { GtkWidget *main_paned; GtkWidget *main_vbox; GtkWidget *contents_widget; + GtkWidget *empty_view; /* Progress observers */ GtkWidget *progress_bar; @@ -153,6 +163,9 @@ struct _ModestMainWindowPrivate { /* Optimized view enabled */ gboolean optimized_view; + /* Optimized view enabled */ + gboolean send_receive_in_progress; + ModestHeaderView *header_view; ModestFolderView *folder_view; @@ -269,6 +282,7 @@ modest_main_window_init (ModestMainWindow *obj) priv->contents_widget = NULL; priv->accounts_popup = NULL; priv->details_widget = NULL; + priv->empty_view = NULL; priv->progress_widgets = NULL; priv->progress_bar = NULL; @@ -280,6 +294,7 @@ modest_main_window_init (ModestMainWindow *obj) priv->merge_ids = NULL; priv->optimized_view = FALSE; + priv->send_receive_in_progress = FALSE; priv->progress_bar_timeout = 0; } @@ -328,7 +343,6 @@ modest_main_window_get_child_widget (ModestMainWindow *self, } - static void restore_settings (ModestMainWindow *self) { @@ -715,7 +729,10 @@ modest_main_window_new (void) if (!priv->header_view) g_printerr ("modest: cannot instantiate header view\n"); modest_header_view_set_style (priv->header_view, MODEST_HEADER_VIEW_STYLE_TWOLINES); - + + /* Empty view */ + priv->empty_view = create_empty_view (); + /* Create scrolled windows */ folder_win = gtk_scrolled_window_new (NULL, NULL); priv->contents_widget = gtk_scrolled_window_new (NULL, NULL); @@ -1248,6 +1265,20 @@ set_alignment (GtkWidget *widget, } static GtkWidget * +create_empty_view (void) +{ + GtkLabel *label = NULL; + GtkWidget *align = NULL; + + align = gtk_alignment_new(XALIGN, YALIGN, XSPACE, YSPACE); + label = GTK_LABEL(gtk_label_new (_("mcen_ia_nomessages"))); + gtk_label_set_justify (label, GTK_JUSTIFY_CENTER); + gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET(label)); + + return GTK_WIDGET(align); +} + +static GtkWidget * create_details_widget (TnyAccount *account) { GtkWidget *vbox; @@ -1344,6 +1375,39 @@ create_details_widget (TnyAccount *account) } void +modest_main_window_notify_send_receive_initied (ModestMainWindow *self) +{ + GtkAction *action = NULL; + GtkWidget *widget = NULL; + + g_return_if_fail (MODEST_IS_MAIN_WINDOW (self)); + + action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu"); + gtk_action_set_sensitive (action, FALSE); + action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveCancelSendingMenu"); + gtk_action_set_sensitive (action, FALSE); + widget = modest_window_get_action_widget (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions"); + gtk_widget_set_sensitive (widget, FALSE); +} + +void +modest_main_window_notify_send_receive_completed (ModestMainWindow *self) +{ + GtkAction *action = NULL; + GtkWidget *widget = NULL; + + g_return_if_fail (MODEST_IS_MAIN_WINDOW (self)); + + action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu"); + gtk_action_set_sensitive (action, TRUE); + action = modest_window_get_action (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveCancelSendingMenu"); + gtk_action_set_sensitive (action, TRUE); + widget = modest_window_get_action_widget (MODEST_WINDOW(self), "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions"); + gtk_widget_set_sensitive (widget, TRUE); +} + + +void modest_main_window_set_contents_style (ModestMainWindow *self, ModestMainWindowContentsStyle style) { @@ -1357,15 +1421,20 @@ modest_main_window_set_contents_style (ModestMainWindow *self, set if there are details, because it could happen when we're selecting different accounts consecutively */ if ((priv->contents_style == style) && - (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS)) + (priv->contents_style != MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS)) return; /* Remove previous child. Delete it if it was an account details widget */ GtkWidget *content = gtk_bin_get_child (GTK_BIN (priv->contents_widget)); if (content) { - if (priv->contents_style != MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS) + if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) g_object_ref (content); + else if (priv->contents_style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY) { + g_object_ref (priv->empty_view); + gtk_container_remove (GTK_CONTAINER (content), priv->empty_view); + } + gtk_container_remove (GTK_CONTAINER (priv->contents_widget), content); } @@ -1389,6 +1458,9 @@ modest_main_window_set_contents_style (ModestMainWindow *self, } break; } + case MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY: + wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET (priv->empty_view)); + break; default: g_return_if_reached (); } diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 4384bf0..c93874c 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -172,6 +172,7 @@ modest_mail_operation_class_init (ModestMailOperationClass *klass) NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + } static void @@ -768,6 +769,9 @@ static gboolean notify_update_account_queue (gpointer data) { ModestMailOperation *mail_op = MODEST_MAIL_OPERATION (data); + ModestMailOperationPrivate *priv = NULL; + + priv = MODEST_MAIL_OPERATION_GET_PRIVATE(mail_op); modest_mail_operation_notify_end (mail_op); g_object_unref (mail_op); @@ -1050,6 +1054,7 @@ modest_mail_operation_update_account (ModestMailOperation *self, MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND, "cannot get tny store account for %s\n", account_name); modest_mail_operation_notify_end (self); + return FALSE; } @@ -1064,6 +1069,7 @@ modest_mail_operation_update_account (ModestMailOperation *self, MODEST_MAIL_OPERATION_ERROR_ITEM_NOT_FOUND, "cannot get tny transport account for %s\n", account_name); modest_mail_operation_notify_end (self); + return FALSE; } diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 8715a8f..959cc97 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -120,6 +120,13 @@ static void reply_forward (ReplyForwardAction action, ModestWindow static gchar* ask_for_folder_name (GtkWindow *parent_window, const gchar *title); + +static void _on_send_receive_progress_changed (ModestMailOperation *mail_op, + ModestMailOperationState *state, + gpointer user_data); + + + void modest_ui_actions_on_about (GtkAction *action, ModestWindow *win) { @@ -1057,6 +1064,14 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) acc_name = g_strdup (account_name); } + /* Set send/receive operation in progress */ + modest_main_window_notify_send_receive_initied (MODEST_MAIN_WINDOW(win)); + + mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win)); + g_signal_connect (G_OBJECT(mail_op), "progress-changed", + G_CALLBACK (_on_send_receive_progress_changed), + win); + /* Send & receive. */ /* TODO: The spec wants us to first do any pending deletions, before receiving. */ /* Receive and then send. The operation is tagged initially as @@ -1064,7 +1079,6 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win) receive and then a send. The operation changes its type internally, so the progress objects will receive the proper progress information */ - mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_RECEIVE, G_OBJECT(win)); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_update_account (mail_op, acc_name); g_object_unref (G_OBJECT (mail_op)); @@ -1220,7 +1234,8 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, { ModestConf *conf; GtkWidget *header_view; - + gboolean folder_empty = FALSE; + g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window)); header_view = modest_main_window_get_child_widget(main_window, @@ -1245,13 +1260,23 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view, g_object_unref (account); } + /* Set folder on header view */ - modest_main_window_set_contents_style (main_window, - MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view), - TNY_FOLDER (folder_store)); - modest_widget_memory_restore (conf, G_OBJECT(header_view), - MODEST_CONF_HEADER_VIEW_KEY); + TNY_FOLDER (folder_store)); + + /* Set main view style */ + folder_empty = tny_folder_get_all_count (TNY_FOLDER (folder_store)) == 0; + if (folder_empty) { + modest_main_window_set_contents_style (main_window, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY); + } + else { + modest_main_window_set_contents_style (main_window, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS); + modest_widget_memory_restore (conf, G_OBJECT(header_view), + MODEST_CONF_HEADER_VIEW_KEY); + } } else { /* Update the active account */ modest_window_set_active_account (MODEST_WINDOW (main_window), NULL); @@ -3013,3 +3038,17 @@ modest_ui_actions_on_search_messages (GtkAction *action, ModestWindow *window) modest_platform_show_search_messages (GTK_WINDOW (window)); } + + +static void +_on_send_receive_progress_changed (ModestMailOperation *mail_op, + ModestMailOperationState *state, + gpointer user_data) +{ + g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data)); + + /* Set send/receive operation finished */ + if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS) + modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data)); + +} diff --git a/src/modest-ui-dimming-rules.c b/src/modest-ui-dimming-rules.c index d5f9254..6968a16 100644 --- a/src/modest-ui-dimming-rules.c +++ b/src/modest-ui-dimming-rules.c @@ -424,6 +424,7 @@ modest_ui_dimming_rules_on_delete_msgs (ModestWindow *win, gpointer user_data) } + /* *********************** static utility functions ******************** */ static gboolean @@ -767,3 +768,4 @@ _msg_sent_in_progress (ModestWindow *win) return result; } + diff --git a/src/widgets/modest-main-window.h b/src/widgets/modest-main-window.h index 6a4b130..361bbfc 100644 --- a/src/widgets/modest-main-window.h +++ b/src/widgets/modest-main-window.h @@ -77,6 +77,7 @@ typedef enum _ModestMainWindowStyle { typedef enum _ModestMainWindowContentsStyle { MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS, + MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY, } ModestMainWindowContentsStyle; /* toolbar modes */ @@ -173,6 +174,23 @@ ModestMainWindowStyle modest_main_window_get_style (ModestMainWindo void modest_main_window_set_contents_style (ModestMainWindow *self, ModestMainWindowContentsStyle style); +/** + * modest_main_window_notify_send_receive_initied: + * @self: the #ModestMainWindow + * + * Notifies main window that send/receive operaiton was just started. + **/ +void +modest_main_window_notify_send_receive_initied (ModestMainWindow *self); + +/** + * modest_main_window_notify_send_receive_completed: + * @self: the #ModestMainWindow + * + * Notifies main window that send/receive operaiton was completed. + **/ +void +modest_main_window_notify_send_receive_completed (ModestMainWindow *self); G_END_DECLS -- 1.7.9.5