aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-error.c
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc/e-error.c')
-rw-r--r--widgets/misc/e-error.c30
1 files changed, 30 insertions, 0 deletions
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);
+ }
+}