static void connect_signals (ModestMainWindow *self);
-static void restore_settings (ModestMainWindow *self);
+static void restore_settings (ModestMainWindow *self, gboolean do_folder_view_too);
static void save_state (ModestWindow *self);
static void modest_main_window_show_toolbar (ModestWindow *window,
static void on_send_receive_csm_activated (GtkMenuItem *item,
gpointer user_data);
+static void
+_on_msg_count_changed (ModestHeaderView *header_view,
+ TnyFolder *folder,
+ TnyFolderChange *change,
+ ModestMainWindow *main_window);
+
static GtkWidget * create_empty_view (void);
LAST_SIGNAL
};
-
typedef struct _ModestMainWindowPrivate ModestMainWindowPrivate;
struct _ModestMainWindowPrivate {
GtkWidget *msg_paned;
guint progress_bar_timeout;
+ /* Signal handler UIDs */
+ gint queue_changed_handler_uid;
};
#define MODEST_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_MAIN_WINDOW, \
static const GtkActionEntry modest_header_view_action_entries [] = {
/* Header View CSM actions */
- { "HeaderViewCSMOpen", NULL, N_("mcen_me_inbox_open"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_new_folder) },
+ { "HeaderViewCSMOpen", NULL, N_("mcen_me_inbox_open"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_open) },
{ "HeaderViewCSMReply", NULL, N_("mcen_me_inbox_reply"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_reply) },
{ "HeaderViewCSMReplyAll", NULL, N_("mcen_me_inbox_replytoall"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_reply_all) },
{ "HeaderViewCSMForward", NULL, N_("mcen_me_inbox_forward"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_forward) },
priv->accounts_popup = NULL;
priv->details_widget = NULL;
priv->empty_view = NULL;
-
priv->progress_widgets = NULL;
priv->progress_bar = NULL;
priv->current_toolbar_mode = TOOLBAR_MODE_NORMAL;
-
priv->style = MODEST_MAIN_WINDOW_STYLE_SPLIT;
priv->contents_style = MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS;
-
priv->merge_ids = NULL;
-
priv->optimized_view = FALSE;
priv->send_receive_in_progress = FALSE;
priv->progress_bar_timeout = 0;
+ priv->queue_changed_handler_uid = 0;
}
static void
priv->progress_bar_timeout = 0;
}
+ /* Disconnect signal handlers */
+ if (priv->queue_changed_handler_uid)
+ g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
+ priv->queue_changed_handler_uid);
+
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
static void
-restore_settings (ModestMainWindow *self)
+restore_settings (ModestMainWindow *self, gboolean do_folder_view_too)
{
ModestConf *conf;
ModestMainWindowPrivate *priv;
MODEST_CONF_MAIN_WINDOW_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->header_view),
MODEST_CONF_HEADER_VIEW_KEY);
- modest_widget_memory_restore (conf, G_OBJECT(priv->folder_view),
+
+ if (do_folder_view_too)
+ modest_widget_memory_restore (conf, G_OBJECT(priv->folder_view),
MODEST_CONF_FOLDER_VIEW_KEY);
modest_widget_memory_restore (conf, G_OBJECT(priv->main_paned),
MODEST_CONF_MAIN_PANED_KEY);
MODEST_CONF_MAIN_WINDOW_KEY);
modest_widget_memory_save (conf, G_OBJECT(priv->main_paned),
MODEST_CONF_MAIN_PANED_KEY);
- modest_widget_memory_save (conf, G_OBJECT(priv->header_view),
- MODEST_CONF_HEADER_VIEW_KEY);
+/* modest_widget_memory_save (conf, G_OBJECT(priv->header_view), */
+/* MODEST_CONF_HEADER_VIEW_KEY); */
modest_widget_memory_save (conf, G_OBJECT(priv->folder_view),
MODEST_CONF_FOLDER_VIEW_KEY);
}
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
-
+
/* folder view */
g_signal_connect (G_OBJECT(priv->folder_view), "key-press-event",
G_CALLBACK(on_inner_widgets_key_pressed), self);
G_CALLBACK(_folder_view_csm_menu_activated),
self);
/* header view */
-/* g_signal_connect (G_OBJECT(priv->header_view), "status_update", */
-/* G_CALLBACK(modest_ui_actions_on_header_status_update), self); */
g_signal_connect (G_OBJECT(priv->header_view), "header_selected",
G_CALLBACK(modest_ui_actions_on_header_selected), self);
g_signal_connect (G_OBJECT(priv->header_view), "header_activated",
G_CALLBACK(modest_ui_actions_on_item_not_found), self);
g_signal_connect (G_OBJECT(priv->header_view), "key-press-event",
G_CALLBACK(on_inner_widgets_key_pressed), self);
+ g_signal_connect (G_OBJECT(priv->header_view), "msg_count_changed",
+ G_CALLBACK(_on_msg_count_changed), self);
/* Header view CSM */
menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/HeaderViewCSM");
G_CALLBACK (modest_main_window_window_state_event),
NULL);
g_signal_connect (G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self);
-
+
/* Mail Operation Queue */
- g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
- "queue-changed",
- G_CALLBACK (on_queue_changed),
- self);
+ priv->queue_changed_handler_uid =
+ g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+ "queue-changed", G_CALLBACK (on_queue_changed), self);
/* Track changes in the device name */
g_signal_connect (G_OBJECT(modest_runtime_get_conf ()),
- "key_changed",
- G_CALLBACK (on_configuration_key_changed),
+ "key_changed", G_CALLBACK (on_configuration_key_changed),
self);
/* Track account changes. We need to refresh the toolbar */
g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
- "account_update",
- G_CALLBACK (on_account_update),
+ "account_update", G_CALLBACK (on_account_update),
self);
/* Account store */
- g_signal_connect (G_OBJECT (modest_runtime_get_account_store()), "password_requested",
+ g_signal_connect (G_OBJECT (modest_runtime_get_account_store()),
+ "password_requested",
G_CALLBACK (modest_ui_actions_on_password_requested), self);
/* Device */
- g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+ g_signal_connect (G_OBJECT(modest_runtime_get_account_store()),
+ "connecting-finished",
G_CALLBACK(on_account_store_connecting_finished), self);
}
gboolean
sync_accounts_cb (ModestMainWindow *win)
{
- modest_ui_actions_on_send_receive (NULL, MODEST_WINDOW (win));
+ modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win));
return FALSE; /* Do not call this idle handler again. */
}
#endif
}
+static void
+modest_main_window_on_show (GtkWidget *self, gpointer user_data)
+{
+ GtkWidget *folder_win = (GtkWidget *) user_data;
+ ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ priv->folder_view = MODEST_FOLDER_VIEW(modest_folder_view_new (NULL));
+ if (!priv->folder_view)
+ g_printerr ("modest: cannot instantiate folder view\n");
+
+ gtk_widget_show (GTK_WIDGET (priv->folder_view));
+
+ /* Connect signals */
+ connect_signals ((ModestMainWindow*)self);
+
+ modest_folder_view_set_style (priv->folder_view,
+ MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
+
+
+ /* Set account store */
+ tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
+ TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+
+
+ /* Check if accounts exist and show the account wizard if not */
+ gboolean accounts_exist =
+ modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
+
+
+ if (!accounts_exist)
+ {
+ /* This is necessary to have the main window shown behind the dialog
+ It's an ugly hack... jschmid */
+ gtk_widget_show_all(GTK_WIDGET(self));
+ modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self));
+ }
+
+ wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view));
+ wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET(priv->header_view));
+
+ /* Load previous osso state, for instance if we are being restored from
+ * hibernation: */
+ modest_osso_load_state();
+
+ /* Restore window & widget settings */
+ restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
+}
ModestWindow*
modest_main_window_new (void)
ModestDimmingRulesGroup *toolbar_rules_group = NULL;
GtkActionGroup *action_group = NULL;
GError *error = NULL;
- TnyFolderStoreQuery *query = NULL;
GdkPixbuf *window_icon = NULL;
ModestConf *conf = NULL;
GtkAction *action = NULL;
/* Get device name */
modest_maemo_utils_get_device_name ();
- /* 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 (query));
- if (!priv->folder_view)
- g_printerr ("modest: cannot instantiate folder view\n");
- g_object_unref (G_OBJECT (query));
- modest_folder_view_set_style (priv->folder_view,
- MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
-
/* header view */
priv->header_view =
MODEST_HEADER_VIEW(modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_DETAILS));
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
- wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view));
- wrap_in_scrolled_window (priv->contents_widget, GTK_WIDGET(priv->header_view));
-
/* paned */
priv->main_paned = gtk_hpaned_new ();
gtk_paned_pack1 (GTK_PANED(priv->main_paned), folder_win, TRUE, TRUE);
window_icon = modest_platform_get_icon (MODEST_APP_ICON);
gtk_window_set_icon (GTK_WINDOW (self), window_icon);
- /* Connect signals */
- connect_signals (self);
-
- /* Set account store */
- tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
- TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+
/* Do send & receive when we are idle */
/* TODO: Enable this again. I have commented it out because,
* at least in scratchbox, this can cause us to start a second
*/
g_signal_connect (G_OBJECT(app), "notify::is-topmost",
G_CALLBACK (on_hildon_program_is_topmost_notify), self);
+
+ g_signal_connect (G_OBJECT(self), "show",
+ G_CALLBACK (modest_main_window_on_show), folder_win);
- /* Load previous osso state, for instance if we are being restored from
- * hibernation: */
- modest_osso_load_state();
- /* Restore window & widget settings */
- restore_settings (MODEST_MAIN_WINDOW(self));
+ restore_settings (MODEST_MAIN_WINDOW(self), FALSE);
return MODEST_WINDOW(self);
}
if (last_updated > 0)
last_updated_string = modest_text_utils_get_display_date(last_updated);
else
- last_updated_string = g_strdup (_("FIXME: Never"));
+ last_updated_string = g_strdup (_("mcen_va_never"));
label = g_strdup_printf ("%s: %s", _("mcen_ti_lastupdated"), last_updated_string);
gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
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);
+/* 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);
}
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);
+/* 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);
}
+static void
+_on_msg_count_changed (ModestHeaderView *header_view,
+ TnyFolder *folder,
+ TnyFolderChange *change,
+ ModestMainWindow *main_window)
+{
+ gboolean folder_empty = FALSE;
+ TnyFolderChangeChanged changed;
+
+ g_return_if_fail (MODEST_IS_MAIN_WINDOW (main_window));
+ g_return_if_fail (TNY_IS_FOLDER(folder));
+ g_return_if_fail (TNY_IS_FOLDER_CHANGE(change));
+
+ changed = tny_folder_change_get_changed (change);
+
+ /* If something changes */
+ if ((changed) & TNY_FOLDER_CHANGE_CHANGED_ALL_COUNT)
+ folder_empty = (tny_folder_change_get_new_all_count (change) == 0);
+ else
+ folder_empty = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+
+ /* Set contents style of headers view */
+ 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);
+ }
+
+}
+
void
modest_main_window_set_contents_style (ModestMainWindow *self,
ModestMainWindowContentsStyle style)