From 323689b6584196bce37251b2ec3c81d52c815f62 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Fri, 21 May 2004 09:12:15 +0000 Subject: set a default error parent fallback. (e_error_newv): if parent is null, 2004-05-21 Not Zed * e-error.c (e_error_default_parent): set a default error parent fallback. (e_error_newv): if parent is null, see if we have a default still alive, and use that. warn if not. svn path=/trunk/; revision=26031 --- widgets/misc/e-error.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'widgets/misc/e-error.c') diff --git a/widgets/misc/e-error.c b/widgets/misc/e-error.c index 2a2fd7426b..9310ef9bfc 100644 --- a/widgets/misc/e-error.c +++ b/widgets/misc/e-error.c @@ -67,6 +67,7 @@ struct _e_error_table { }; static GHashTable *error_table; +static GSList *ee_parent_list; /* ********************************************************************** */ @@ -394,8 +395,12 @@ e_error_newv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap) dialog = (GtkDialog *)gtk_dialog_new(); gtk_dialog_set_has_separator(dialog, FALSE); + 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"); domain = alloca(strlen(tag)+1); strcpy(domain, tag); @@ -567,4 +572,29 @@ e_error_run(GtkWindow *parent, const char *tag, const char *arg0, ...) return res; } +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(struct _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); + } +} -- cgit v1.2.3