* ModestWindowMgr is now the responsible of showing the accounts wizard if there is no account
pmo-drop-split-view-r6405
*/
#include <string.h>
+#include <hildon/hildon-program.h>
#include "modest-hildon2-window-mgr.h"
#include "modest-msg-edit-window.h"
#include "modest-main-window.h"
#include "modest-ui-actions.h"
#include "modest-debug.h"
#include "modest-tny-folder.h"
-#include <hildon/hildon-program.h>
+#include "modest-folder-window.h"
+#include "modest-accounts-window.h"
/* 'private'/'protected' functions */
static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass);
static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self);
static gboolean window_can_close (ModestWindow *window);
static gboolean window_has_modals (ModestWindow *window);
+static ModestWindow *modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self);
typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
struct _ModestHildon2WindowMgrPrivate {
GList *window_list;
GMutex *queue_lock;
GQueue *modal_windows;
-
+
gboolean fullscreen_mode;
-
+
GHashTable *destroy_handlers;
GHashTable *viewer_handlers;
GSList *window_state_uids;
-
+
guint closing_time;
GSList *modal_handler_uids;
mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
+ mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window;
g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
gtk_window_set_destroy_with_parent (window, TRUE);
}
+static ModestWindow *
+modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
+{
+ ModestWindow *window = NULL;
+ ModestAccountMgr *mgr;
+ GSList *account_names;
+ gint count;
+
+ mgr = modest_runtime_get_account_mgr ();
+ account_names = modest_account_mgr_account_names (mgr, TRUE);
+ count = g_slist_length (account_names);
+
+ if (count > 1) {
+ window = MODEST_WINDOW (modest_accounts_window_new ());
+ } else {
+ window = MODEST_WINDOW (modest_folder_window_new (NULL));
+ if (count == 1)
+ modest_folder_window_set_account (MODEST_FOLDER_WINDOW (window),
+ account_names->data);
+ }
+ modest_account_mgr_free_account_names (account_names);
+ modest_window_mgr_register_window (self, window, NULL);
+
+ return window;
+}
{
ShowHelper *helper = (ShowHelper *) user_data;
ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
-
+
priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL));
modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (self),
MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
- /* Load previous osso state, for instance if we are being restored from
+ /* Load previous osso state, for instance if we are being restored from
* hibernation: */
modest_osso_load_state ();
- /* Restore window & widget settings */
+ /* Restore window & widget settings */
priv->wait_for_settings = TRUE;
restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
priv->wait_for_settings = FALSE;
/* Check if accounts exist and show the account wizard if not */
- gboolean accounts_exist =
+ 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
+ /* 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));
/* update the toggle buttons status */
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage");
- modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+ if (action)
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsFindInMessageMenu");
- modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
-
+ if (action)
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
}
static void
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
-
+
toggle = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage"));
gtk_toggle_action_set_active (toggle, FALSE);
modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view));
GtkWidget *reply_button = NULL, *menu = NULL;
const gchar *action_name;
GtkAction *action;
-
+
parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
priv->next_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageNext");
priv->prev_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageBack");
toolbar_resize (MODEST_MSG_VIEW_WINDOW (self));
-
+
/* Add to window */
hildon_window_add_toolbar (HILDON_WINDOW (self),
GTK_TOOLBAR (parent_priv->toolbar));
- /* Set reply button tap and hold menu */
+ /* Set reply button tap and hold menu */
reply_button = gtk_ui_manager_get_widget (parent_priv->ui_manager,
"/ToolBar/ToolbarMessageReply");
menu = gtk_ui_manager_get_widget (parent_priv->ui_manager,
"/ToolbarReplyCSM");
- gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
+ if (menu && reply_button)
+ gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
}
if (show_toolbar) {
action_name = "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarNormalScreenMenu";
action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
- modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
- show_toolbar);
+ if (action)
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ show_toolbar);
}
static void
ShowHelper *helper = (ShowHelper *) user_data;
GtkWidget *folder_win = helper->folder_win;
ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
-
+ ModestAccountMgr *mgr;
+
priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL));
wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view));
restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
priv->wait_for_settings = FALSE;
- /* 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));
- } else {
+ /* Update the menus if there are accounts */
+ mgr = modest_runtime_get_account_mgr();
+ if (modest_account_mgr_has_accounts(mgr, TRUE))
update_menus (MODEST_MAIN_WINDOW (self));
- }
/* Never call this function again (NOTE that it could happen
as we hide the main window instead of closing it while
/* Disconnect signals. Will be freed by the destroy notify */
handlers = (MainSignalHandlers *) data;
- g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
+ g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
handlers->queue_handler);
- g_signal_handler_disconnect (modest_runtime_get_window_mgr (),
+ g_signal_handler_disconnect (modest_runtime_get_window_mgr (),
handlers->window_list_handler);
- g_signal_handler_disconnect (modest_runtime_get_account_store (),
- handlers->get_password_handler);
+ g_signal_handler_disconnect (modest_runtime_get_account_store (),
+ handlers->get_password_handler);
g_free (handlers);
/* Wait for remaining tasks */
while (gtk_events_pending ())
gtk_main_iteration ();
-
+
gtk_main_quit ();
} else {
ModestMailOperation *mail_op;
modest_mail_operation_shutdown (mail_op, modest_runtime_get_account_store ());
g_object_unref (mail_op);
}
-
+
gdk_threads_leave ();
return FALSE;
if (!show_ui_without_top_application_method) {
g_print ("modest: use 'modest showui' to start from cmdline with UI\n");
- }
-
+ }
+
if (!g_thread_supported())
g_thread_init (NULL);
retval = 1;
goto cleanup;
}
-
+
if (!gtk_init_check (&argc, &argv)) {
g_printerr ("modest: failed to initialize gtk\n");
retval = 1;
handlers = g_malloc0 (sizeof (MainSignalHandlers));
/* Connect to the "queue-emtpy" signal */
- handlers->queue_handler =
+ handlers->queue_handler =
g_signal_connect (modest_runtime_get_mail_operation_queue (),
"queue-empty",
G_CALLBACK (on_queue_empty),
handlers);
/* Connect to the "window-list-emtpy" signal */
- handlers->window_list_handler =
+ handlers->window_list_handler =
g_signal_connect (modest_runtime_get_window_mgr (),
"window-list-empty",
G_CALLBACK (on_window_list_empty),
handlers);
/* Connect to the "password-requested" signal */
- handlers->get_password_handler =
+ handlers->get_password_handler =
g_signal_connect (modest_runtime_get_account_store (),
"password_requested",
G_CALLBACK (modest_ui_actions_on_password_requested),
*/
if (show_ui_without_top_application_method) {
ModestWindow *window;
+ ModestWindowMgr *mgr;
-#ifdef MODEST_TOOLKIT_HILDON2
- ModestAccountMgr *mgr;
- GSList *account_names;
- gint count;
-
- mgr = modest_runtime_get_account_mgr ();
- account_names = modest_account_mgr_account_names (mgr,TRUE);
- count = g_slist_length (account_names);
-
- if (count > 1) {
- window = MODEST_WINDOW (modest_accounts_window_new ());
- } else {
- window = MODEST_WINDOW (modest_folder_window_new (NULL));
- if (count == 1)
- modest_folder_window_set_account (MODEST_FOLDER_WINDOW (window),
- account_names->data);
- }
- modest_account_mgr_free_account_names (account_names);
- modest_window_mgr_register_window (modest_runtime_get_window_mgr (), window, NULL);
- gtk_widget_show (GTK_WIDGET (window));
-#else
-
- /* this will create & register the window */
- window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
- TRUE);
+ mgr = modest_runtime_get_window_mgr();
+ window = modest_window_mgr_show_initial_window (mgr);
if (!window) {
g_printerr ("modest: failed to get main window instance\n");
retval = 1;
goto cleanup;
}
-#endif
/* Remove new mail notifications if exist */
modest_platform_remove_new_mail_notifications (FALSE);
}
-
+
gtk_main ();
cleanup:
#include "modest-account-mgr-helpers.h"
#include "modest-mail-operation.h"
#include "modest-text-utils.h"
-
-#ifdef MODEST_HAVE_EASYSETUP
-#ifdef MODEST_TOOLKIT_HILDON2
-#include "modest-easysetup-wizard-dialog.h"
-#else
-#include "easysetup/modest-easysetup-wizard-dialog.h"
-#endif
-#endif /* MODEST_HAVE_EASYSETUP */
-
#include <modest-widget-memory.h>
#include <tny-error.h>
#include <tny-simple-list.h>
}
void
-modest_ui_actions_on_accounts (GtkAction *action,
+modest_ui_actions_on_accounts (GtkAction *action,
ModestWindow *win)
{
/* This is currently only implemented for Maemo */
if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) {
- if (!modest_ui_actions_run_account_setup_wizard (win))
+ if (!modest_ui_actions_run_account_setup_wizard (win))
g_debug ("%s: wizard was already running", __FUNCTION__);
-
+
return;
} else {
/* Show the list of accounts */
GtkWindow *account_win = GTK_WINDOW (modest_account_view_window_new ());
-
+
/* The accounts dialog must be modal */
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (account_win), (GtkWindow *) win);
modest_utils_show_dialog_and_forget (GTK_WINDOW (win), GTK_DIALOG (account_win));
* possiblities.
*/
#ifndef MODEST_TOOLKIT_GTK /* Defined in config.h */
-
+
/* Create the window if necessary: */
GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
modest_connection_specific_smtp_window_fill_with_connections (
TnyHeader *header,
ModestWindow **win);
static GList *modest_window_mgr_get_window_list_default (ModestWindowMgr *self);
+static ModestWindow *modest_window_mgr_show_initial_window_default (ModestWindowMgr *self);
/* list my signals */
enum {
mgr_class->close_all_windows = modest_window_mgr_close_all_windows_default;
mgr_class->find_registered_header = modest_window_mgr_find_registered_header_default;
mgr_class->get_window_list = modest_window_mgr_get_window_list_default;
+ mgr_class->show_initial_window = modest_window_mgr_show_initial_window_default;
g_type_class_add_private (gobject_class, sizeof(ModestWindowMgrPrivate));
return result;
}
-void
+void
modest_window_mgr_register_banner (ModestWindowMgr *self)
{
ModestWindowMgrPrivate *priv;
priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
priv->banner_counter++;
-
}
-void
+void
modest_window_mgr_unregister_banner (ModestWindowMgr *self)
{
ModestWindowMgrPrivate *priv;
if (modest_window_mgr_num_windows (self) == 0)
g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0);
}
+
+ModestWindow *
+modest_window_mgr_show_initial_window (ModestWindowMgr *self)
+{
+ ModestWindow *window = NULL;
+
+ /* Call the children */
+ window = MODEST_WINDOW_MGR_GET_CLASS (self)->show_initial_window (self);
+
+ if (window) {
+ ModestAccountMgr *mgr;
+
+ /* Show the initial window */
+ gtk_widget_show (GTK_WIDGET (window));
+
+ /* If there are no accounts then show the account wizard */
+ mgr = modest_runtime_get_account_mgr();
+ if (!modest_account_mgr_has_accounts (mgr, TRUE))
+ modest_ui_actions_run_account_setup_wizard (window);
+ }
+
+ return window;
+}
+
+static ModestWindow *
+modest_window_mgr_show_initial_window_default (ModestWindowMgr *self)
+{
+ /* By default it returns the main window creating it if
+ needed */
+ return modest_window_mgr_get_main_window (self, TRUE);
+}
GObjectClass parent_class;
/* Virtuals */
- gboolean (*register_window) (ModestWindowMgr *self,
- ModestWindow *window,
+ gboolean (*register_window) (ModestWindowMgr *self,
+ ModestWindow *window,
ModestWindow *parent);
void (*unregister_window) (ModestWindowMgr *self,
ModestWindow *window);
void (*set_modal) (ModestWindowMgr *self,
GtkWindow *window,
GtkWindow *parent);
- gboolean (*find_registered_header) (ModestWindowMgr *self,
+ gboolean (*find_registered_header) (ModestWindowMgr *self,
TnyHeader *header,
ModestWindow **win);
GList * (*get_window_list) (ModestWindowMgr *self);
-
+ ModestWindow * (*show_initial_window) (ModestWindowMgr *self);
/* Signals */
void (*window_list_empty) (ModestWindowMgr *self);
* Returns: a #ModestMsgEditWindow
*/
GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self);
-
+
+/**
+ * modest_window_mgr_show_initial_window:
+ * @self: a #ModestWindowMgr
+ *
+ * This function determines which is the window that should be
+ * initially launched. After that it shows that window. If there is no
+ * account available this function also launches the account setup
+ * wizard.
+ *
+ * Returns: the initial window. NULL if something goes wrong
+ **/
+ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self);
+
G_END_DECLS
#endif /* __MODEST_WINDOW_MGR_H__ */
-