[evolution] Kill the default parent window hack in e-error.c.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Kill the default parent window hack in e-error.c.
- Date: Fri, 4 Sep 2009 21:09:02 +0000 (UTC)
commit 983fce5e535e4e203815767cf6899f6dc8c5242a
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Sep 4 17:07:15 2009 -0400
Kill the default parent window hack in e-error.c.
Fix as many cases that relied on it as I could find, but there may be
more cases out there. They should be fixed too. Passing a NULL parent
window to e_error_new() is illegal and will emit a runtime warning.
calendar/gui/e-calendar-view.c | 6 ++++-
calendar/gui/gnome-cal.c | 20 ++++++++++++---
e-util/e-error.c | 34 ++-----------------------
e-util/e-error.h | 2 -
mail/em-folder-utils.c | 41 ++++++++++++++++++++++++++----
mail/mail-autofilter.c | 8 +++++-
mail/mail-mt.c | 11 +++++++-
mail/mail-session.c | 10 +++++++-
mail/mail-vfolder.c | 18 ++++++++++++-
modules/mail/e-mail-junk-hook.c | 11 +++++++-
plugins/startup-wizard/startup-wizard.c | 7 ++++-
shell/e-shell-importer.c | 7 ++++-
12 files changed, 122 insertions(+), 53 deletions(-)
---
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 7450cd1..805ec93 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -1242,11 +1242,15 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
icalcomponent *icalcomp;
ECalComponentTransparency transparency;
ECal *default_client = NULL;
+ gpointer parent;
guint32 flags = 0;
gboolean readonly = FALSE;
g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (cal_view));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
priv = cal_view->priv;
default_client = e_cal_model_get_default_client (priv->model);
@@ -1259,7 +1263,7 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view,
if (e_cal_is_read_only (default_client, &readonly, NULL) && readonly) {
GtkWidget *widget;
- widget = e_error_new (NULL, "calendar:prompt-read-only-cal", e_source_peek_name (e_cal_get_source (default_client)), NULL);
+ widget = e_error_new (parent, "calendar:prompt-read-only-cal", e_source_peek_name (e_cal_get_source (default_client)), NULL);
g_signal_connect ((GtkDialog *)widget, "response", G_CALLBACK (gtk_widget_destroy),
widget);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 690c700..b56c37d 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1869,10 +1869,14 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
ECalLoadState state;
gchar *msg;
GtkWidget *w = NULL;
+ gpointer parent;
gchar *id;
priv = gcal->priv;
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
source = e_cal_get_source (ecal);
state = e_cal_get_load_state (ecal);
@@ -1895,7 +1899,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
return;
}
- w = e_error_new(NULL, "calendar:server-version", NULL);
+ w = e_error_new(parent, "calendar:server-version", NULL);
/*e_calendar_utils_show_error_silent (w); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w));
g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id);
@@ -1916,7 +1920,7 @@ client_cal_opened_cb (ECal *ecal, ECalendarStatus status, GnomeCalendar *gcal)
return;
}
- w = e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:unable-to-load-the-calendar", e_cal_get_error_message (status), NULL);
+ w = e_error_new(parent, "calendar:unable-to-load-the-calendar", e_cal_get_error_message (status), NULL);
/*e_calendar_utils_show_error_silent (w); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(w));
g_signal_connect(w, "destroy", G_CALLBACK(non_intrusive_error_remove), id);
@@ -2040,11 +2044,15 @@ backend_error_cb (ECal *client, const gchar *message, gpointer data)
{
GnomeCalendar *gcal;
GtkDialog *dialog;
+ gpointer parent;
gchar *uristr;
gchar *id;
gcal = GNOME_CALENDAR (data);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
uristr = get_uri_without_password (e_cal_get_uri (client));
id = g_strdup ("calendar:error-on-loading-the-calendar");
@@ -2054,7 +2062,7 @@ backend_error_cb (ECal *client, const gchar *message, gpointer data)
return;
}
- dialog = (GtkDialog *)e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:error-on-loading-the-calendar", uristr, message, NULL);
+ dialog = (GtkDialog *)e_error_new(parent, "calendar:error-on-loading-the-calendar", uristr, message, NULL);
/* e_calendar_utils_show_error_silent(GTK_WIDGET (dialog)); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, id, g_object_ref(dialog));
@@ -2070,12 +2078,16 @@ backend_died_cb (ECal *ecal, gpointer data)
GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
ESource *source;
+ gpointer parent;
const gchar *id;
GtkWidget *w = NULL;
gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (gcal));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
/* FIXME What about default sources? */
/* Make sure the source doesn't go away on us since we use it below */
@@ -2098,7 +2110,7 @@ backend_died_cb (ECal *ecal, gpointer data)
return;
}
- w = e_error_new(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))), "calendar:backend_died", NULL);
+ w = e_error_new(parent, "calendar:backend_died", NULL);
/* e_calendar_utils_show_error_silent (w); KILL-BONOBO */
g_hash_table_insert (non_intrusive_error_table, (gpointer) id, g_object_ref(w));
g_signal_connect((GtkObject *)w, "destroy", G_CALLBACK(non_intrusive_error_remove), (gpointer) id);
diff --git a/e-util/e-error.c b/e-util/e-error.c
index b672e1d..ee3c47e 100644
--- a/e-util/e-error.c
+++ b/e-util/e-error.c
@@ -66,7 +66,6 @@ struct _e_error_table {
};
static GHashTable *error_table;
-static GSList *ee_parent_list;
/* ********************************************************************** */
@@ -433,12 +432,12 @@ e_error_newv(GtkWindow *parent, const gchar *tag, const gchar *arg0, va_list ap)
gtk_container_set_border_width (GTK_CONTAINER (action_area), 12);
gtk_container_set_border_width (GTK_CONTAINER (content_area), 0);
- if (parent == NULL && ee_parent_list)
- parent = (GtkWindow *)ee_parent_list->data;
if (parent)
gtk_window_set_transient_for ((GtkWindow *)dialog, parent);
else
- g_warning("No parent set, or default parent available for error dialog");
+ g_warning (
+ "Something called %s() with a NULL parent window. "
+ "This is no longer legal, please fix it.", G_STRFUNC);
domain = alloca(strlen(tag)+1);
strcpy(domain, tag);
@@ -668,30 +667,3 @@ e_error_count_buttons (GtkDialog *dialog)
return n_buttons;
}
-
-static void
-remove_parent(GtkWidget *w, GtkWidget *parent)
-{
- ee_parent_list = g_slist_remove(ee_parent_list, parent);
-}
-
-/**
- * e_error_default_parent:
- * @parent:
- *
- * Bit of a hack, set a default parent that will be used to parent any
- * error boxes if none is supplied.
- *
- * This may be called multiple times, and the last call will be the
- * main default. This function will keep track of the parents
- * destruction state.
- **/
-void
-e_error_default_parent(GtkWindow *parent)
-{
- if (g_slist_find(ee_parent_list, parent) == NULL) {
- ee_parent_list = g_slist_prepend(ee_parent_list, parent);
- g_signal_connect(parent, "destroy", G_CALLBACK(remove_parent), parent);
- }
-}
-
diff --git a/e-util/e-error.h b/e-util/e-error.h
index 7b9685a..38de4c8 100644
--- a/e-util/e-error.h
+++ b/e-util/e-error.h
@@ -56,6 +56,4 @@ gint e_error_runv(GtkWindow *parent, const gchar *tag, const gchar *arg0, va_lis
guint e_error_count_buttons (GtkDialog *dialog);
-void e_error_default_parent(GtkWindow *parent);
-
#endif /* !_E_ERROR_H */
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 700e445..0379607 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -290,8 +290,18 @@ emfu_copy_folder_selected (const gchar *uri, gpointer data)
}
if (cfd->delete && fromstore == local_store && emfu_is_special_local_folder (cfd->fi->full_name)) {
- GtkWidget *w = e_error_new (NULL,
- "mail:no-rename-special-folder", cfd->fi->full_name, NULL);
+ EShell *shell;
+ GtkWindow *parent;
+ GtkWidget *w;
+ GList *windows;
+
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
+ w = e_error_new (
+ parent, "mail:no-rename-special-folder",
+ cfd->fi->full_name, NULL);
em_utils_show_error_silent (w);
goto fail;
}
@@ -379,8 +389,18 @@ emfu_delete_done (CamelFolder *folder, gboolean removed, CamelException *ex, gpo
GtkWidget *dialog = data;
if (ex && camel_exception_is_set (ex)) {
- GtkWidget *w = e_error_new (NULL,
- "mail:no-delete-folder", folder->full_name, camel_exception_get_description (ex), NULL);
+ EShell *shell;
+ GtkWindow *parent;
+ GtkWidget *w;
+ GList *windows;
+
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
+ w = e_error_new (
+ parent, "mail:no-delete-folder",
+ folder->full_name, camel_exception_get_description (ex), NULL);
em_utils_show_error_silent (w);
camel_exception_clear (ex);
}
@@ -406,14 +426,23 @@ emfu_delete_response (GtkWidget *dialog, gint response, gpointer data)
void
em_folder_utils_delete_folder (CamelFolder *folder)
{
+ EShell *shell;
+ GtkWindow *parent;
CamelStore *local_store;
GtkWidget *dialog;
+ GList *windows;
gint flags = 0;
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
local_store = e_mail_local_get_store ();
if (folder->parent_store == local_store && emfu_is_special_local_folder (folder->full_name)) {
- dialog = e_error_new (NULL, "mail:no-delete-special-folder", folder->full_name, NULL);
+ dialog = e_error_new (
+ parent, "mail:no-delete-special-folder",
+ folder->full_name, NULL);
em_utils_show_error_silent (dialog);
return;
}
@@ -426,7 +455,7 @@ em_folder_utils_delete_folder (CamelFolder *folder)
camel_object_ref (folder);
- dialog = e_error_new(NULL,
+ dialog = e_error_new (parent,
(folder->parent_store && CAMEL_IS_VEE_STORE(folder->parent_store))?"mail:ask-delete-vfolder":"mail:ask-delete-folder",
folder->full_name, NULL);
g_object_set_data_full ((GObject *) dialog, "folder", folder, camel_object_unref);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index ece7e75..02fbbfb 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -420,7 +420,10 @@ mail_filter_delete_uri(CamelStore *store, const gchar *uri)
deleted = rule_context_delete_uri ((RuleContext *) fc, euri, g_str_equal);
if (deleted) {
+ EShell *shell;
+ GtkWindow *parent;
GtkWidget *dialog;
+ GList *windows;
GString *s;
GList *l;
@@ -431,7 +434,10 @@ mail_filter_delete_uri(CamelStore *store, const gchar *uri)
l = l->next;
}
- dialog = e_error_new(NULL, "mail:filter-updated", s->str, euri, NULL);
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+ dialog = e_error_new(parent, "mail:filter-updated", s->str, euri, NULL);
g_string_free(s, TRUE);
em_utils_show_info_silent (dialog);
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 7281ce6..6c25d7a 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -292,9 +292,12 @@ static void error_response(GtkObject *o, gint button, gpointer data)
void
mail_msg_check_error (gpointer msg)
{
+ EShell *shell;
+ GtkWindow *parent;
MailMsg *m = msg;
gchar *what;
GtkDialog *gd;
+ GList *windows;
#ifdef MALLOC_CHECK
checkmem(m);
@@ -322,12 +325,16 @@ mail_msg_check_error (gpointer msg)
return;
}
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
if (m->info->desc
&& (what = m->info->desc (m))) {
- gd = (GtkDialog *)e_error_new(NULL, "mail:async-error", what, camel_exception_get_description(&m->ex), NULL);
+ gd = (GtkDialog *)e_error_new(parent, "mail:async-error", what, camel_exception_get_description(&m->ex), NULL);
g_free(what);
} else
- gd = (GtkDialog *)e_error_new(NULL, "mail:async-error-nodescribe", camel_exception_get_description(&m->ex), NULL);
+ gd = (GtkDialog *)e_error_new(parent, "mail:async-error-nodescribe", camel_exception_get_description(&m->ex), NULL);
g_hash_table_insert(active_errors, m->info, gd);
g_signal_connect(gd, "response", G_CALLBACK(error_response), m->info);
diff --git a/mail/mail-session.c b/mail/mail-session.c
index 27fdaf9..2d1a1ff 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -322,6 +322,9 @@ user_message_response (GtkDialog *dialog, gint button, struct _user_message_msg
static void
user_message_exec (struct _user_message_msg *m)
{
+ EShell *shell;
+ GtkWindow *parent;
+ GList *windows;
const gchar *error_type;
if (!m->ismain && user_message_dialog != NULL) {
@@ -350,7 +353,12 @@ user_message_exec (struct _user_message_msg *m)
g_return_if_reached ();
}
- user_message_dialog = e_error_new (NULL, error_type, m->prompt, NULL);
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
+ user_message_dialog = e_error_new (
+ parent, error_type, m->prompt, NULL);
g_object_set (
user_message_dialog, "allow_shrink", TRUE,
"allow_grow", TRUE, NULL);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 96d60ab..69ba7d4 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -600,11 +600,17 @@ done:
UNLOCK();
if (changed->str[0]) {
+ EShell *shell;
+ GtkWindow *parent;
GtkWidget *dialog;
+ GList *windows;
const gchar *data_dir;
gchar *user;
- dialog = e_error_new(NULL, "mail:vfolder-updated", changed->str, uri, NULL);
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+ dialog = e_error_new (parent, "mail:vfolder-updated", changed->str, uri, NULL);
em_utils_show_info_silent (dialog);
data_dir = em_utils_get_data_dir ();
@@ -1095,9 +1101,17 @@ vfolder_edit_rule(const gchar *uri)
g_signal_connect(gd, "response", G_CALLBACK(edit_rule_response), NULL);
gtk_widget_show((GtkWidget *)gd);
} else {
+ EShell *shell;
+ GtkWindow *parent;
GtkWidget *w;
+ GList *windows;
+
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
/* TODO: we should probably just create it ... */
- w = e_error_new(NULL, "mail:vfolder-notexist", uri, NULL);
+ w = e_error_new(parent, "mail:vfolder-notexist", uri, NULL);
em_utils_show_error_silent (w);
}
diff --git a/modules/mail/e-mail-junk-hook.c b/modules/mail/e-mail-junk-hook.c
index 2687223..f19b502 100644
--- a/modules/mail/e-mail-junk-hook.c
+++ b/modules/mail/e-mail-junk-hook.c
@@ -25,6 +25,8 @@
#include <camel/camel-junk-plugin.h>
#include "e-util/e-error.h"
+#include "shell/e-shell.h"
+
#include "mail/em-junk.h"
#include "mail/em-utils.h"
#include "mail/mail-session.h"
@@ -48,10 +50,17 @@ static GType mail_junk_hook_type;
static gboolean
mail_junk_hook_idle_cb (struct ErrorData *data)
{
+ EShell *shell;
+ GtkWindow *parent;
GtkWidget *widget;
+ GList *windows;
+
+ shell = e_shell_get_default ();
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
widget = e_error_new (
- NULL, data->error_message, data->error->message, NULL);
+ parent, data->error_message, data->error->message, NULL);
em_utils_show_error_silent (widget);
g_error_free (data->error);
diff --git a/plugins/startup-wizard/startup-wizard.c b/plugins/startup-wizard/startup-wizard.c
index 14c4c6c..15660df 100644
--- a/plugins/startup-wizard/startup-wizard.c
+++ b/plugins/startup-wizard/startup-wizard.c
@@ -210,11 +210,16 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
{
EShell *shell;
EShellSettings *shell_settings;
+ GtkWindow *parent;
+ GList *windows;
gchar *location;
shell = e_shell_get_default ();
shell_settings = e_shell_get_shell_settings (shell);
+ windows = e_shell_get_watched_windows (shell);
+ parent = (windows != NULL) ? GTK_WINDOW (windows->data) : NULL;
+
/* Use System Timezone by default */
e_shell_settings_set_boolean (
shell_settings, "cal-use-system-timezone", TRUE);
@@ -227,7 +232,7 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target)
import_iterator = import_importers;
import_importer = import_iterator->data;
- import_dialog = e_error_new(NULL, "shell:importing", _("Importing data."), NULL);
+ import_dialog = e_error_new(parent, "shell:importing", _("Importing data."), NULL);
g_signal_connect(import_dialog, "response", G_CALLBACK(import_dialog_response), NULL);
import_label = gtk_label_new(_("Please wait"));
import_progress = gtk_progress_bar_new();
diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c
index aba3546..fbc1b30 100644
--- a/shell/e-shell-importer.c
+++ b/shell/e-shell-importer.c
@@ -528,7 +528,12 @@ import_assistant_apply (GtkAssistant *assistant, ImportData *data)
}
if (done) {
- data->import_dialog = e_error_new(NULL, "shell:importing", msg, NULL);
+ gpointer parent;
+
+ parent = gtk_widget_get_parent (data->assistant);
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ data->import_dialog = e_error_new(parent, "shell:importing", msg, NULL);
g_signal_connect(data->import_dialog, "response", G_CALLBACK(import_dialog_response), data);
data->import_label = gtk_label_new(_("Please wait"));
data->import_progress = gtk_progress_bar_new();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]