main-windows when we really need to.
it adds a boolean 'create' parameter to modest_window_mgr_get_main_window,
and only if this parameter is TRUE will this function create a main_window
if it was not yet existing.
also, patch makes warning dialogs not show up if there is no main window,
including password, cert verification dialogs. thus, the user will not be
annoyed unexpectedly anymore.
pmo-trunk-r3606
const char *uri = NULL, *uid = NULL;
gint res = 0;
ModestMailOperation *mail_op = NULL;
const char *uri = NULL, *uid = NULL;
gint res = 0;
ModestMailOperation *mail_op = NULL;
- ModestWindow *win = NULL, *msg_view = NULL;
- ModestWindowMgr *win_mgr = NULL;
+ ModestWindow *main_win = NULL, *msg_view = NULL;
uri = (char *) user_data;
uri = (char *) user_data;
msg = find_message_by_url (uri, &account);
msg = find_message_by_url (uri, &account);
- if (msg == NULL) {
- return OSSO_ERROR;
+ if (!msg) {
+ g_warning ("modest: %s: Could not find message '%s'", __FUNCTION__, uri);
+ return OSSO_ERROR; /* FIXME: is this TRUE or FALSE?! */
-
- g_debug ("modest: %s: Found message", __FUNCTION__);
+
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
+ FALSE); /* don't create */
msg_header = tny_msg_get_header (msg);
uid = tny_header_get_uid (msg_header);
folder = tny_msg_get_folder (msg);
msg_header = tny_msg_get_header (msg);
uid = tny_header_get_uid (msg_header);
folder = tny_msg_get_folder (msg);
/* tny_msg_get_header () flaw:
* From tinythingy doc: You can't use the returned instance with the
* TnyFolder operations
/* tny_msg_get_header () flaw:
* From tinythingy doc: You can't use the returned instance with the
* TnyFolder operations
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
gdk_threads_enter (); /* CHECKED */
gdk_threads_enter (); /* CHECKED */
- win_mgr = modest_runtime_get_window_mgr ();
- win = modest_window_mgr_get_main_window (win_mgr);
- mail_op = modest_mail_operation_new (win ? G_OBJECT(win) : NULL);
+ mail_op = modest_mail_operation_new (main_win ? G_OBJECT(main_win) : NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_remove_msg (mail_op, header, FALSE);
g_object_unref (G_OBJECT (mail_op));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
modest_mail_operation_remove_msg (mail_op, header, FALSE);
g_object_unref (G_OBJECT (mail_op));
-
- if (modest_window_mgr_find_registered_header (win_mgr, header, &msg_view)) {
- if (MODEST_IS_MSG_VIEW_WINDOW (msg_view))
- modest_ui_actions_refresh_message_window_after_delete (MODEST_MSG_VIEW_WINDOW (msg_view));
- }
+ if (main_win) { /* no need if there's no window */
+ if (modest_window_mgr_find_registered_header (modest_runtime_get_window_mgr(),
+ header, &msg_view)) {
+ if (MODEST_IS_MSG_VIEW_WINDOW (msg_view))
+ modest_ui_actions_refresh_message_window_after_delete (MODEST_MSG_VIEW_WINDOW (msg_view));
+ }
+ }
gdk_threads_leave (); /* CHECKED */
if (header)
gdk_threads_leave (); /* CHECKED */
if (header)
* (They are not really deleted until contact is made with the server,
* so they would appear with a strike-through until then):
*/
* (They are not really deleted until contact is made with the server,
* so they would appear with a strike-through until then):
*/
- ModestHeaderView *header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (
- MODEST_MAIN_WINDOW(win), MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
- if (header_view && MODEST_IS_HEADER_VIEW (header_view))
- modest_header_view_refilter (header_view);
+ if (main_win) { /* only needed when there's a mainwindow / UI */
+
+ /* This is a GDK lock because we are an idle callback and
+ * the code below is or does Gtk+ code */
+ gdk_threads_enter (); /* CHECKED */
+ ModestHeaderView *header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (
+ MODEST_MAIN_WINDOW(main_win),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+ if (header_view && MODEST_IS_HEADER_VIEW (header_view))
+ modest_header_view_refilter (header_view);
+ gdk_threads_leave ();
+ }
static gboolean
on_idle_send_receive(gpointer user_data)
{
static gboolean
on_idle_send_receive(gpointer user_data)
{
+ ModestWindow *main_win =
+ modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE); /* don't create */
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
gdk_threads_enter (); /* CHECKED */
gdk_threads_enter (); /* CHECKED */
- /* Pick the main window if it exists */
- win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
-
/* Send & receive all if "Update automatically" is set */
/* TODO: check the auto-update parameter in the configuration */
/* Send & receive all if "Update automatically" is set */
/* TODO: check the auto-update parameter in the configuration */
- modest_ui_actions_do_send_receive_all (win);
+ modest_ui_actions_do_send_receive_all (main_win);
gdk_threads_leave (); /* CHECKED */
gdk_threads_leave (); /* CHECKED */
static gboolean
on_idle_open_default_inbox(gpointer user_data)
{
static gboolean
on_idle_open_default_inbox(gpointer user_data)
{
- if (!check_and_offer_account_creation ())
- return FALSE;
+ ModestWindow *main_win;
+ GtkWidget *folder_view;
+ if (!check_and_offer_account_creation ()) /* this has it's only lock already */
+ return FALSE;
+
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
gdk_threads_enter (); /* CHECKED */
gdk_threads_enter (); /* CHECKED */
-
- ModestWindow *win =
- modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ TRUE); /* create if non-existent */
+ if (!main_win) {
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
+ gdk_threads_leave (); /* CHECKED */
+ return FALSE; /* don't call me again */
+ }
+
/* Get the folder view */
/* Get the folder view */
- GtkWidget *folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+ folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_win),
MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view));
MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (folder_view));
static gboolean on_idle_top_application (gpointer user_data)
{
static gboolean on_idle_top_application (gpointer user_data)
{
+ ModestWindow *main_win;
+
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
gdk_threads_enter (); /* CHECKED */
/* This is a GDK lock because we are an idle callback and
* the code below is or does Gtk+ code */
gdk_threads_enter (); /* CHECKED */
-
- ModestWindow *win =
- modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
- if (win) {
+
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ TRUE); /* create if non-existent */
+ if (main_win) {
/* Ideally, we would just use gtk_widget_show(),
* but this widget is not coded correctly to support that: */
/* Ideally, we would just use gtk_widget_show(),
* but this widget is not coded correctly to support that: */
- gtk_widget_show_all (GTK_WIDGET (win));
- gtk_window_present (GTK_WINDOW (win));
- }
+ gtk_widget_show_all (GTK_WIDGET (main_win));
+ gtk_window_present (GTK_WINDOW (main_win));
+ } else
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
gdk_threads_leave (); /* CHECKED */
gdk_threads_leave (); /* CHECKED */
refresh_account (const gchar *account_name)
{
ModestWindow *win;
refresh_account (const gchar *account_name)
{
ModestWindow *win;
-
- win = MODEST_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
-
+
+ /* win must already exists here, obviously */
+ win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE);
+ if (!win) {
+ g_warning ("%s: BUG: no main window!", __FUNCTION__);
+ return;
+ }
+
/* If account_name == NULL, we must update all (option All) */
if (!account_name)
modest_ui_actions_do_send_receive_all (win);
/* If account_name == NULL, we must update all (option All) */
if (!account_name)
modest_ui_actions_do_send_receive_all (win);
{
ModestMsgViewWindowPrivate *priv;
ModestHeaderView *header_view = NULL;
{
ModestMsgViewWindowPrivate *priv;
ModestHeaderView *header_view = NULL;
- ModestMainWindow *main_window = NULL;
- ModestWindowMgr *window_mgr = NULL;
-
+ ModestWindow *main_window = NULL;
+
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
if (gtk_clipboard_get (GDK_SELECTION_PRIMARY) &&
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
if (gtk_clipboard_get (GDK_SELECTION_PRIMARY) &&
priv->rows_reordered_handler);
}
priv->rows_reordered_handler);
}
- window_mgr = modest_runtime_get_window_mgr();
- g_assert(window_mgr != NULL);
-
- main_window = MODEST_MAIN_WINDOW(
- modest_window_mgr_get_main_window(window_mgr));
-
- if(main_window == NULL)
+ main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
+ FALSE); /* don't create */
+ if (!main_window)
header_view = MODEST_HEADER_VIEW(
modest_main_window_get_child_widget(
header_view = MODEST_HEADER_VIEW(
modest_main_window_get_child_widget(
- main_window, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
-
+ MODEST_MAIN_WINDOW(main_window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
if (header_view == NULL)
return;
if (header_view == NULL)
return;
+/* FIXME: parameter checks */
ModestWindow *
modest_msg_view_window_new_with_header_model (TnyMsg *msg,
const gchar *modest_account_name,
ModestWindow *
modest_msg_view_window_new_with_header_model (TnyMsg *msg,
const gchar *modest_account_name,
ModestMsgViewWindowPrivate *priv = NULL;
TnyFolder *header_folder = NULL;
ModestHeaderView *header_view = NULL;
ModestMsgViewWindowPrivate *priv = NULL;
TnyFolder *header_folder = NULL;
ModestHeaderView *header_view = NULL;
- ModestMainWindow *main_window = NULL;
- ModestWindowMgr *window_mgr = NULL;
-
+ ModestWindow *main_window = NULL;
+
window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL);
g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL);
g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL);
modest_msg_view_window_construct (window, modest_account_name, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
modest_msg_view_window_construct (window, modest_account_name, msg_uid);
priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
/* Remember the message list's TreeModel so we can detect changes
* and change the list selection when necessary: */
- window_mgr = modest_runtime_get_window_mgr();
- g_assert(window_mgr != NULL);
- main_window = MODEST_MAIN_WINDOW(
- modest_window_mgr_get_main_window(window_mgr));
- g_assert(main_window != NULL);
+
+ main_window = modest_window_mgr_get_main_window(
+ modest_runtime_get_window_mgr(), FALSE); /* don't create */
+ if (!main_window) {
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
+ return NULL;
+ }
+
header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget(
header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget(
- main_window, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+ MODEST_MAIN_WINDOW(main_window),
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
if (header_view != NULL){
header_folder = modest_header_view_get_folder(header_view);
g_assert(header_folder != NULL);
if (header_view != NULL){
header_folder = modest_header_view_get_folder(header_view);
g_assert(header_folder != NULL);
{
GtkWidget *note;
gint response;
{
GtkWidget *note;
gint response;
- GtkWindow *main_win =
- (GtkWindow*)modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
+ ModestWindow *main_win;
+
+ if (!modest_window_mgr_main_window_exists (modest_runtime_get_window_mgr())) {
+ g_warning ("%s: don't show dialogs if there's no main window; assuming 'Cancel'",
+ __FUNCTION__);
+ return FALSE;
+ }
+ /* don't create it */
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), FALSE);
+ g_return_val_if_fail (main_win, FALSE); /* should not happen */
+
+
gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
server_name);
note = hildon_note_new_confirmation_add_buttons (
gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
server_name);
note = hildon_note_new_confirmation_add_buttons (
question,
_("mcen_bd_dialog_ok"), GTK_RESPONSE_OK,
_("mcen_bd_view"), GTK_RESPONSE_HELP, /* abusing this... */
question,
_("mcen_bd_dialog_ok"), GTK_RESPONSE_OK,
_("mcen_bd_view"), GTK_RESPONSE_HELP, /* abusing this... */
modest_platform_run_alert_dialog (const gchar* prompt,
gboolean is_question)
{
modest_platform_run_alert_dialog (const gchar* prompt,
gboolean is_question)
{
- ModestWindow *main_window =
- modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
+ ModestWindow *main_win;
+
+ if (!modest_window_mgr_main_window_exists (modest_runtime_get_window_mgr())) {
+ g_warning ("%s:\n'%s'\ndon't show dialogs if there's no main window;"
+ " assuming 'Cancel' for questions, 'Ok' otherwise", prompt, __FUNCTION__);
+ return is_question ? FALSE : TRUE;
+ }
+
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
+ g_return_val_if_fail (main_win, FALSE); /* should not happen */
gboolean retval = TRUE;
if (is_question) {
gboolean retval = TRUE;
if (is_question) {
* when it is a question.
* Obviously, we need tinymail to use more specific error codes instead,
* so we know what buttons to show. */
* when it is a question.
* Obviously, we need tinymail to use more specific error codes instead,
* so we know what buttons to show. */
- GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (main_window),
+ GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (main_win),
prompt));
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
GTK_WINDOW (dialog));
prompt));
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
GTK_WINDOW (dialog));
on_destroy_dialog (GTK_DIALOG(dialog));
} else {
/* Just show the error text and use the default response: */
on_destroy_dialog (GTK_DIALOG(dialog));
} else {
/* Just show the error text and use the default response: */
- modest_platform_run_information_dialog (GTK_WINDOW (main_window),
+ modest_platform_run_information_dialog (GTK_WINDOW (main_win),
prompt);
}
return retval;
prompt);
}
return retval;
* be called. But that's annoying when starting from the
* command line.: */
gboolean show_ui_without_top_application_method = FALSE;
* be called. But that's annoying when starting from the
* command line.: */
gboolean show_ui_without_top_application_method = FALSE;
+
+ ModestWindow *main_win;
+ int retval = 0;
+
if (argc >= 2) {
if (strcmp (argv[1], "showui") == 0)
show_ui_without_top_application_method = TRUE;
}
if (argc >= 2) {
if (strcmp (argv[1], "showui") == 0)
show_ui_without_top_application_method = TRUE;
}
-
- ModestWindow *win;
- int retval = 0;
if (!g_thread_supported())
g_thread_init (NULL);
if (!g_thread_supported())
g_thread_init (NULL);
}
/* this will create & register the window */
}
/* this will create & register the window */
- win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
- if (!win) {
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), TRUE);
+ if (!main_win) {
g_printerr ("modest: failed to get main window instance\n");
retval = 1;
goto cleanup;
g_printerr ("modest: failed to get main window instance\n");
retval = 1;
goto cleanup;
* when we receive the "top_application" D-Bus method.
*/
if (show_ui_without_top_application_method) {
* when we receive the "top_application" D-Bus method.
*/
if (show_ui_without_top_application_method) {
- gtk_widget_show_all (GTK_WIDGET(win));
+ gtk_widget_show_all (GTK_WIDGET(main_win));
/* Remove new mail notifications if exist */
modest_platform_remove_new_mail_notifications ();
/* Remove new mail notifications if exist */
modest_platform_remove_new_mail_notifications ();
show_password_warning_only ()
{
ModestWindow *main_window =
show_password_warning_only ()
{
ModestWindow *main_window =
- modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
-
+ modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); /* don't create */
+
/* Show an explanatory temporary banner: */
/* Show an explanatory temporary banner: */
- hildon_banner_show_information (
- GTK_WIDGET(main_window), NULL, _("mcen_ib_username_pw_incorrect"));
+ if (main_window)
+ hildon_banner_show_information (
+ GTK_WIDGET(main_window), NULL, _("mcen_ib_username_pw_incorrect"));
+ else
+ g_warning ("%s: %s", __FUNCTION__, _("mcen_ib_username_pw_incorrect"));
static void
show_wrong_password_dialog (TnyAccount *account)
{
/* This is easier than using a struct for the user_data: */
ModestTnyAccountStore *self = modest_runtime_get_account_store();
ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
static void
show_wrong_password_dialog (TnyAccount *account)
{
/* This is easier than using a struct for the user_data: */
ModestTnyAccountStore *self = modest_runtime_get_account_store();
ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
-
- const gchar *modest_account_name =
- modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+ ModestWindow *main_window;
+ const gchar *modest_account_name;
+
+ main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE); /* don't create */
+ if (!main_window) {
+ g_warning ("%s: password was wrong; ignoring because no main window", __FUNCTION__);
+ return;
+ }
+
+ modest_account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
if (!modest_account_name) {
g_warning ("%s: modest_tny_account_get_parent_modest_account_name_for_server_account() failed.\n",
__FUNCTION__);
if (!modest_account_name) {
g_warning ("%s: modest_tny_account_get_parent_modest_account_name_for_server_account() failed.\n",
__FUNCTION__);
}
ModestAccountSettingsDialog *dialog = dialog_as_gpointer;
}
ModestAccountSettingsDialog *dialog = dialog_as_gpointer;
- ModestWindow *main_window =
- modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
-
gboolean created_dialog = FALSE;
if (!found || !dialog) {
dialog = modest_account_settings_dialog_new ();
gboolean created_dialog = FALSE;
if (!found || !dialog) {
dialog = modest_account_settings_dialog_new ();
gboolean *cancel,
gboolean *remember)
{
gboolean *cancel,
gboolean *remember)
{
- g_signal_emit (G_OBJECT(account_store), signals[PASSWORD_REQUESTED_SIGNAL], 0,
- server_account_id, /* server_account_name */
- username, password, cancel, remember);
+ g_signal_emit (G_OBJECT(account_store), signals[PASSWORD_REQUESTED_SIGNAL], 0,
+ server_account_id, /* server_account_name */
+ username, password, cancel, remember);
}
/* This callback will be called by Tinymail when it needs the password
}
/* This callback will be called by Tinymail when it needs the password
modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), wizard);
/* always present a main window in the background
modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), wizard);
/* always present a main window in the background
- * we do it here, so we cannot end up with to wizards (as this
+ * we do it here, so we cannot end up with two wizards (as this
* function might be called in modest_window_mgr_get_main_window as well */
if (!win)
* function might be called in modest_window_mgr_get_main_window as well */
if (!win)
- win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
-
+ win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
+ TRUE); /* create if not existent */
+
/* make sure the mainwindow is visible */
gtk_widget_show_all (GTK_WIDGET(win));
gtk_window_present (GTK_WINDOW(win));
/* make sure the mainwindow is visible */
gtk_widget_show_all (GTK_WIDGET(win));
gtk_window_present (GTK_WINDOW(win));
void
modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
{
void
modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
{
/* Get main window */
mgr = modest_runtime_get_window_mgr ();
/* Get main window */
mgr = modest_runtime_get_window_mgr ();
- main_window = modest_window_mgr_get_main_window (mgr);
- }
- else {
+ main_window = modest_window_mgr_get_main_window (mgr, FALSE); /* don't create */
+ } else {
/* Move cursor to next row */
main_window = win;
/* Move cursor to next row */
main_window = win;
}
/* Disable next automatic folder selection */
}
/* Disable next automatic folder selection */
- main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
+ main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE); /* don't create */
+ if (!main_window)
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
+
folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_window),
MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
modest_folder_view_disable_next_folder_selection (MODEST_FOLDER_VIEW(folder_view));
folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (main_window),
MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
modest_folder_view_disable_next_folder_selection (MODEST_FOLDER_VIEW(folder_view));
main_window = MODEST_MAIN_WINDOW (win);
else
main_window =
main_window = MODEST_MAIN_WINDOW (win);
else
main_window =
- MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
+ MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE)); /* don't create */
/* Get the folder view widget if exists */
if (main_window)
/* Get the folder view widget if exists */
if (main_window)
TnyFolderType folder_type;
mgr = modest_runtime_get_window_mgr ();
TnyFolderType folder_type;
mgr = modest_runtime_get_window_mgr ();
- main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (mgr));
-
+ main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (mgr,
+ FALSE));/* don't create */
if (!main_window)
return;
if (!main_window)
return;
goto cleanup; /* verboten! */
/* Ask for confirmation to move */
goto cleanup; /* verboten! */
/* Ask for confirmation to move */
- main_win = modest_window_mgr_get_main_window (mgr);
+ main_win = modest_window_mgr_get_main_window (mgr, FALSE); /* don't create */
+ if (!main_win) {
+ g_warning ("%s: BUG: no main window found", __FUNCTION__);
+ goto cleanup;
+ }
+
response = modest_ui_actions_msgs_move_to_confirmation (main_win, folder,
TRUE, headers);
if (response == GTK_RESPONSE_CANCEL)
response = modest_ui_actions_msgs_move_to_confirmation (main_win, folder,
TRUE, headers);
if (response == GTK_RESPONSE_CANCEL)
TnyFolderStore *dest_folder = NULL;
TnyFolderStore *folder = NULL;
gboolean forbidden = FALSE;
TnyFolderStore *dest_folder = NULL;
TnyFolderStore *folder = NULL;
gboolean forbidden = FALSE;
+ win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), FALSE); /* don't create */
+ if (!win) {
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
+ return;
+ }
+
if (!forbidden) {
/* check the folder rules for the destination */
folder = tree_path_to_folder (dest_model, dest_row);
if (!forbidden) {
/* check the folder rules for the destination */
folder = tree_path_to_folder (dest_model, dest_row);
/* Offer the connection dialog if necessary, for the destination parent folder and source folder: */
if (modest_platform_connect_and_wait_if_network_folderstore (NULL, dest_folder) &&
modest_platform_connect_and_wait_if_network_folderstore (NULL, TNY_FOLDER_STORE (folder))) {
/* Offer the connection dialog if necessary, for the destination parent folder and source folder: */
if (modest_platform_connect_and_wait_if_network_folderstore (NULL, dest_folder) &&
modest_platform_connect_and_wait_if_network_folderstore (NULL, TNY_FOLDER_STORE (folder))) {
- ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
-
/* Do the mail operation */
/* Do the mail operation */
- mail_op =
- modest_mail_operation_new_with_error_handling ((GObject *) modest_window_mgr_get_main_window (mgr),
- modest_ui_actions_move_folder_error_handler,
- folder, NULL);
+ mail_op = modest_mail_operation_new_with_error_handling ((GObject *) win,
+ modest_ui_actions_move_folder_error_handler,
+ folder, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
gpointer user_data)
{
ModestHeaderViewPrivate *priv;
gpointer user_data)
{
ModestHeaderViewPrivate *priv;
- ModestWindowMgr *mgr = NULL;
- GObject *source = NULL;
-
- priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
+ ModestWindow *main_win;
+
+ g_return_if_fail (self);
+ priv = MODEST_HEADER_VIEW_GET_PRIVATE(self);
+
+ main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
+ FALSE); /* don't create */
+ if (!main_win) {
+ g_warning ("%s: BUG: no main window", __FUNCTION__);
+ return;
+ }
+
if (priv->folder) {
g_mutex_lock (priv->observers_lock);
tny_folder_remove_observer (priv->folder, TNY_FOLDER_OBSERVER (self));
if (priv->folder) {
g_mutex_lock (priv->observers_lock);
tny_folder_remove_observer (priv->folder, TNY_FOLDER_OBSERVER (self));
ModestMailOperation *mail_op = NULL;
GtkTreeSelection *selection;
ModestMailOperation *mail_op = NULL;
GtkTreeSelection *selection;
- /* Get main window to use it as source of mail operation */
- mgr = modest_runtime_get_window_mgr ();
- source = G_OBJECT (modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ()));
-
/* Set folder in the model */
modest_header_view_set_folder_intern (self, folder);
/* Set folder in the model */
modest_header_view_set_folder_intern (self, folder);
/* Pick my reference. Nothing to do with the mail operation */
priv->folder = g_object_ref (folder);
/* Pick my reference. Nothing to do with the mail operation */
priv->folder = g_object_ref (folder);
info->user_data = user_data;
/* Create the mail operation (source will be the parent widget) */
info->user_data = user_data;
/* Create the mail operation (source will be the parent widget) */
- mail_op = modest_mail_operation_new (source);
+ mail_op = modest_mail_operation_new (G_OBJECT(main_win));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
-modest_window_mgr_get_main_window (ModestWindowMgr *self)
+modest_window_mgr_get_main_window (ModestWindowMgr *self, gboolean create)
{
ModestWindowMgrPrivate *priv;
{
ModestWindowMgrPrivate *priv;
priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
/* create the main window, if it hasn't been created yet */
priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
/* create the main window, if it hasn't been created yet */
- if (!priv->main_window) {
+ if (!priv->main_window && create) {
/* modest_window_mgr_register_window will set priv->main_window */
modest_window_mgr_register_window (self, modest_main_window_new ());
g_debug ("%s: created main window: %p\n", __FUNCTION__, priv->main_window);
/* modest_window_mgr_register_window will set priv->main_window */
modest_window_mgr_register_window (self, modest_main_window_new ());
g_debug ("%s: created main window: %p\n", __FUNCTION__, priv->main_window);
+gboolean
+modest_window_mgr_main_window_exists (ModestWindowMgr *self)
+{
+ ModestWindowMgrPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE);
+ priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
+
+ return priv->main_window != NULL;
+}
+
+
GtkWindow *
modest_window_mgr_get_modal (ModestWindowMgr *self)
{
GtkWindow *
modest_window_mgr_get_modal (ModestWindowMgr *self)
{
/**
* modest_window_mgr_get_main_window:
* @self: a #ModestWindowMgr
/**
* modest_window_mgr_get_main_window:
* @self: a #ModestWindowMgr
+ * @create: if TRUE, create the main window if it was not yet existing
- * get the main window, or create if it's not there. don't destroy
- * it.
+ * get the main window, and depending on @create, create one if it does not exist yet
- * Returns: the main window or NULL in case of error
+ * Returns: the main window or NULL in case of error, or the main-window
+ * did not yet exist
-ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self);
+ModestWindow* modest_window_mgr_get_main_window (ModestWindowMgr *self,
+ gboolean create);
+
+
+/**
+ * modest_window_mgr_main_window_exists:
+ * @self: a #ModestWindowMgr
+ *
+ * do we have a main window?
+ *
+ * Returns: TRUE if there's a main window, FALSE otherwise
+ **/
+gboolean modest_window_mgr_main_window_exists (ModestWindowMgr *self);
+