#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);
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, */
GtkWidget *main_paned;
GtkWidget *main_vbox;
GtkWidget *contents_widget;
+ GtkWidget *empty_view;
/* Progress observers */
GtkWidget *progress_bar;
/* Optimized view enabled */
gboolean optimized_view;
+ /* Optimized view enabled */
+ gboolean send_receive_in_progress;
+
ModestHeaderView *header_view;
ModestFolderView *folder_view;
priv->contents_widget = NULL;
priv->accounts_popup = NULL;
priv->details_widget = NULL;
+ priv->empty_view = NULL;
priv->progress_widgets = NULL;
priv->progress_bar = NULL;
priv->merge_ids = NULL;
priv->optimized_view = FALSE;
+ priv->send_receive_in_progress = FALSE;
priv->progress_bar_timeout = 0;
}
}
-
static void
restore_settings (ModestMainWindow *self)
{
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);
}
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;
}
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)
{
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);
}
}
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 ();
}
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+
}
static void
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);
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;
}
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;
}
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)
{
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
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));
{
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,
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);
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));
+
+}
}
+
/* *********************** static utility functions ******************** */
static gboolean
return result;
}
+
typedef enum _ModestMainWindowContentsStyle {
MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS,
MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS,
+ MODEST_MAIN_WINDOW_CONTENTS_STYLE_EMPTY,
} ModestMainWindowContentsStyle;
/* toolbar modes */
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