2007-07-25 Murray Cumming <murrayc@murrayc.com>
+ * src/maemo/modest-maemo-utils.h:
+ * src/maemo/modest-maemo-utils.c: Added
+ modest_maemo_show_information_note_in_main_context_and_forget().
+ * src/modest-tny-account-store.c: (modest_tny_account_store_alert):
+ Use the new function to show simple error dialogs in the main
+ context, though question dialogs are still in the current context,
+ which is unfortunately usually not the main context. This should
+ fix some hangs.
+
+2007-07-25 Murray Cumming <murrayc@murrayc.com>
+
* src/modest-tny-account-store.c: (get_password):
Never save the entered username and password in gconf,
because the UI spec says we should not. This helps
}
#endif
+/* user_data for the idle callback: */
+typedef struct
+{
+ GtkWindow *parent_window;
+ gchar *message;
+} ModestIdleNoteInfo;
+
+static gboolean
+on_idle_show_information(gpointer user_data)
+{
+ ModestIdleNoteInfo *info = (ModestIdleNoteInfo*)user_data;
+
+ modest_maemo_show_information_note_and_forget (info->parent_window, info->message);
+
+ g_free (info->message);
+ g_slice_free (ModestIdleNoteInfo, info);
+
+ return FALSE; /* Don't call this again. */
+}
+
+void modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, const gchar* message)
+{
+ ModestIdleNoteInfo *info = g_slice_new (ModestIdleNoteInfo);
+ info->parent_window = parent_window;
+ info->message = g_strdup (message);
+
+ g_idle_add (on_idle_show_information, info);
+}
+
void modest_maemo_show_dialog_and_forget (GtkWindow *parent_window, GtkDialog *dialog)
{
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window);
gtk_widget_show (GTK_WIDGET (dialog));
}
+
+
void
modest_maemo_set_thumbable_scrollbar (GtkScrolledWindow *win, gboolean thumbable)
{
*/
void modest_maemo_show_information_note_and_forget (GtkWindow *parent_window, const gchar* message);
+/** modest_maemo_show_information_note_in_main_context_and_forget:
+ * @parent_window: The window for which the note should be transient.
+ * @message: The text to show.
+ *
+ * This calls modest_maemo_show_information_note_and_forget() in an idle handler.
+ * This should be used when you are not sure that you are in the main context,
+ * because you should try to use GTK+ UI code only in the main context.
+ */
+void modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, const gchar* message);
+
/** modest_maemo_show_dialog_and_forget:
* @parent_window: The window for which the note should be transient.
* @message: The dialog to show.
if (!prompt)
return FALSE;
-#ifdef MODEST_PLATFORM_MAEMO
- /* The Tinymail documentation says that we should show Yes and No buttons,
- * 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 = NULL;
- if (question) {
- dialog = GTK_WIDGET (hildon_note_new_confirmation (NULL,
+ ModestWindow *main_window =
+ modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
+ gboolean retval = TRUE;
+ if (question) {
+ /* The Tinymail documentation says that we should show Yes and No buttons,
+ * when it is a question.
+ * Obviously, we need tinymail to use more specific error codes instead,
+ * so we know what buttons to show. */
+
+ /* TODO: Do this in the main context: */
+ GtkWidget *dialog = GTK_WIDGET (hildon_note_new_confirmation (GTK_WINDOW (main_window),
prompt));
+ const int response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (question) {
+ retval = (response == GTK_RESPONSE_YES) ||
+ (response == GTK_RESPONSE_OK);
+ }
+
+ gtk_widget_destroy (dialog);
+
} else {
- dialog = GTK_WIDGET (hildon_note_new_information (NULL,
- prompt));
+ /* Just show the error text and use the default response: */
+ modest_maemo_show_information_note_in_main_context_and_forget (GTK_WINDOW (main_window),
+ prompt);
}
-#else
-
- GtkMessageType gtktype = GTK_MESSAGE_ERROR;
- switch (type)
- {
- case TNY_ALERT_TYPE_INFO:
- gtktype = GTK_MESSAGE_INFO;
- break;
- case TNY_ALERT_TYPE_WARNING:
- gtktype = GTK_MESSAGE_WARNING;
- break;
- case TNY_ALERT_TYPE_ERROR:
- default:
- gtktype = GTK_MESSAGE_ERROR;
- break;
- }
-
- GtkWidget *dialog = gtk_message_dialog_new (NULL, 0,
- gtktype, GTK_BUTTONS_YES_NO, prompt);
-#endif /* #ifdef MODEST_PLATFORM_MAEMO */
-
- gboolean retval = TRUE;
- const int response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (question) {
- retval = (response == GTK_RESPONSE_YES) ||
- (response == GTK_RESPONSE_OK);
- }
-
- gtk_widget_destroy (dialog);
/* TODO: Don't free this when we no longer strdup the message for testers. */
g_free (prompt);