From e06b88c4fda627599d7c1a33ddec0a35a4374e4f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 13 Oct 2009 16:24:10 +0200 Subject: Bug #594471 - Shouldn't call e_error_new/run with NULL 'parent' --- plugins/backup-restore/backup-restore.c | 2 +- plugins/external-editor/external-editor.c | 38 ++++++++++++++++++++------ plugins/face/face.c | 6 ++-- plugins/groupwise-features/camel-gw-listener.c | 5 ++-- plugins/groupwise-features/mail-retract.c | 4 +-- plugins/groupwise-features/process-meeting.c | 7 +++-- plugins/groupwise-features/proxy-login.c | 15 +++++----- plugins/groupwise-features/proxy-login.h | 3 +- plugins/groupwise-features/proxy.c | 14 +++++----- plugins/groupwise-features/share-folder.c | 4 +-- plugins/itip-formatter/itip-formatter.c | 6 ++-- plugins/startup-wizard/startup-wizard.c | 7 +---- 12 files changed, 65 insertions(+), 46 deletions(-) (limited to 'plugins') diff --git a/plugins/backup-restore/backup-restore.c b/plugins/backup-restore/backup-restore.c index 6df2763698..82309a787f 100644 --- a/plugins/backup-restore/backup-restore.c +++ b/plugins/backup-restore/backup-restore.c @@ -170,7 +170,7 @@ action_settings_backup_cb (GtkAction *action, if (mask & BR_OK) backup (filename, (mask & BR_START) ? TRUE: FALSE); } else { - e_error_run (NULL, "org.gnome.backup-restore:insufficient-permissions", NULL); + e_error_run (parent, "org.gnome.backup-restore:insufficient-permissions", NULL); } g_free (filename); diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c index 88858c0211..adc9678550 100644 --- a/plugins/external-editor/external-editor.c +++ b/plugins/external-editor/external-editor.c @@ -196,11 +196,23 @@ update_composer_text (GArray *array) return FALSE; } +struct run_error_dialog_data +{ + EMsgComposer *composer; + const gchar *text; +}; + /* needed because the new thread needs to call g_idle_add () */ static gboolean -run_error_dialog (gchar *text) +run_error_dialog (struct run_error_dialog_data *data) { - e_error_run (NULL, text, NULL); + g_return_val_if_fail (data != NULL, FALSE); + + e_error_run (GTK_WINDOW (data->composer), data->text, NULL); + enable_composer (data->composer); + + g_free (data); + return FALSE; } @@ -246,10 +258,15 @@ async_external_editor (EMsgComposer *composer) content = gtkhtml_editor_get_text_plain (GTKHTML_EDITOR (composer), &length); g_file_set_contents (filename, content, length, NULL); } else { + struct run_error_dialog_data *data = g_new0 (struct run_error_dialog_data, 1); + + data->composer = composer; + data->text = "org.gnome.evolution.plugins.external-editor:no-temp-file"; + g_warning ("Temporary file fd is null"); - g_idle_add ((GSourceFunc) run_error_dialog, - (gpointer)"org.gnome.evolution.plugins.external-editor:no-temp-file"); - g_idle_add ((GSourceFunc) enable_composer, composer); + + /* run_error_dialog also calls enable_composer */ + g_idle_add ((GSourceFunc) run_error_dialog, data); return; } @@ -289,10 +306,15 @@ async_external_editor (EMsgComposer *composer) editor_cmd_line = g_strconcat (editor_cmd, " ", filename, NULL); if (!g_spawn_command_line_sync (editor_cmd_line, NULL, NULL, &status, NULL)) { + struct run_error_dialog_data *data = g_new0 (struct run_error_dialog_data, 1); + g_warning ("Unable to launch %s: ", editor_cmd_line); - g_idle_add ((GSourceFunc) run_error_dialog, - (gpointer)"org.gnome.evolution.plugins.external-editor:editor-not-launchable"); - g_idle_add ((GSourceFunc) enable_composer, composer); + + data->composer = composer; + data->text = "org.gnome.evolution.plugins.external-editor:editor-not-launchable"; + + /* run_error_dialog also calls enable_composer */ + g_idle_add ((GSourceFunc) run_error_dialog, data); g_free (filename); g_free (editor_cmd_line); diff --git a/plugins/face/face.c b/plugins/face/face.c index 1bb56c2bff..3e462da5b1 100644 --- a/plugins/face/face.c +++ b/plugins/face/face.c @@ -97,7 +97,7 @@ action_face_cb (GtkAction *action, if (height != 48 || width != 48) { d (printf ("\n\a Invalid Image Size. Please choose a 48*48 image\n\a")); - e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-image-size", NULL, NULL); + e_error_run (GTK_WINDOW (filesel), "org.gnome.evolution.plugins.face:invalid-image-size", NULL, NULL); } else { file_contents = g_base64_encode ((guchar *) file_contents, length); g_file_set_contents (filename, file_contents, -1, &error); @@ -105,12 +105,12 @@ action_face_cb (GtkAction *action, } } else { d (printf ("File too big")); - e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-file-size", NULL, NULL); + e_error_run (GTK_WINDOW (filesel), "org.gnome.evolution.plugins.face:invalid-file-size", NULL, NULL); } } else { d (printf ("\n\a File cannot be read\n\a")); - e_error_run (NULL, "org.gnome.evolution.plugins.face:file-not-found", NULL, NULL); + e_error_run (GTK_WINDOW (filesel), "org.gnome.evolution.plugins.face:file-not-found", NULL, NULL); } } gtk_widget_destroy (filesel); diff --git a/plugins/groupwise-features/camel-gw-listener.c b/plugins/groupwise-features/camel-gw-listener.c index 72b810feea..52b37fc92a 100644 --- a/plugins/groupwise-features/camel-gw-listener.c +++ b/plugins/groupwise-features/camel-gw-listener.c @@ -32,6 +32,7 @@ #include "e-util/e-error.h" #include #include +#include /*stores some info about all currently existing groupwise accounts list of GwAccountInfo structures */ @@ -541,7 +542,7 @@ get_addressbook_names_from_server (gchar *source_url) /*FIXME: This error message should be relocated to addressbook and should reflect * that it actually failed to get the addressbooks*/ - e_error_run (NULL, "mail:gw-accountsetup-error", poa_address, NULL); + e_error_run (e_shell_get_active_window (NULL), "mail:gw-accountsetup-error", poa_address, NULL); return NULL; } @@ -653,7 +654,7 @@ add_addressbook_sources (EAccount *account) if (!is_frequent_contacts) { /* display warning message */ - e_error_run (NULL, "addressbook:gw-book-list-init", NULL); + e_error_run (e_shell_get_active_window (NULL), "addressbook:gw-book-list-init", NULL); } return TRUE; } diff --git a/plugins/groupwise-features/mail-retract.c b/plugins/groupwise-features/mail-retract.c index 9581c0132b..1de2dfdead 100644 --- a/plugins/groupwise-features/mail-retract.c +++ b/plugins/groupwise-features/mail-retract.c @@ -79,7 +79,7 @@ gw_retract_mail_cb (GtkAction *action, EShellView *shell_view) cnc = get_cnc (store); if (cnc && E_IS_GW_CONNECTION(cnc)) { - confirm_dialog = gtk_dialog_new_with_buttons (_("Message Retract"), NULL, + confirm_dialog = gtk_dialog_new_with_buttons (_("Message Retract"), GTK_WINDOW (e_shell_view_get_shell_window (shell_view)), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_YES, GTK_RESPONSE_YES, GTK_STOCK_NO, GTK_RESPONSE_NO, NULL); @@ -100,7 +100,7 @@ gw_retract_mail_cb (GtkAction *action, EShellView *shell_view) if (n == GTK_RESPONSE_YES) { if (e_gw_connection_retract_request (cnc, id, NULL, FALSE, FALSE) != E_GW_CONNECTION_STATUS_OK ) - e_error_run (NULL, "org.gnome.evolution.message.retract:retract-failure", NULL); + e_error_run (GTK_WINDOW (e_shell_view_get_shell_window (shell_view)), "org.gnome.evolution.message.retract:retract-failure", NULL); else { GtkWidget *dialog; dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, _("Message retracted successfully")); diff --git a/plugins/groupwise-features/process-meeting.c b/plugins/groupwise-features/process-meeting.c index 90ac465a43..e1e5e185ee 100644 --- a/plugins/groupwise-features/process-meeting.c +++ b/plugins/groupwise-features/process-meeting.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -175,7 +176,7 @@ process_meeting (ECalendarView *cal_view, icalparameter_partstat status) else msg = "org.gnome.evolution.process_meeting:recurrence-decline"; - response = e_error_run (NULL, msg, NULL); + response = e_error_run (GTK_WINDOW (gtk_widget_get_toplevel ((GtkWidget *)cal_view)), msg, NULL); if (response == GTK_RESPONSE_YES) { icalproperty *prop; const gchar *uid = icalcomponent_get_uid (r_data->icalcomp); @@ -345,7 +346,7 @@ object_created_cb (CompEditor *ce, gpointer data) gtk_widget_hide (GTK_WIDGET (ce)); - response = e_error_run (NULL, "org.gnome.evolution.process_meeting:resend-retract", NULL); + response = e_error_run (GTK_WINDOW (gtk_widget_get_toplevel ((GtkWidget *)ce)), "org.gnome.evolution.process_meeting:resend-retract", NULL); if (response == GTK_RESPONSE_NO) { free_thread_data (data); return; @@ -388,7 +389,7 @@ gw_resend_meeting_cb (GtkAction *action, EShellView *shell_view) else msg = "org.gnome.evolution.process_meeting:resend"; - response = e_error_run (NULL, msg, NULL); + response = e_error_run (GTK_WINDOW (e_shell_view_get_shell_window (shell_view)), msg, NULL); if (response == GTK_RESPONSE_YES) { mod = CALOBJ_MOD_ALL; } else if (response == GTK_RESPONSE_CANCEL) { diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c index f230a880d3..d4a4475a61 100644 --- a/plugins/groupwise-features/proxy-login.c +++ b/plugins/groupwise-features/proxy-login.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -274,7 +275,7 @@ proxy_login_get_cnc (EAccount *account, GtkWindow *password_dlg_parrent) } static void -proxy_login_cb (GtkDialog *dialog, gint state) +proxy_login_cb (GtkDialog *dialog, gint state, GtkWindow *parent) { GtkWidget *account_name_tbox; proxyLoginPrivate *priv; @@ -287,7 +288,7 @@ proxy_login_cb (GtkDialog *dialog, gint state) switch (state) { case GTK_RESPONSE_OK: gtk_widget_destroy (priv->main); - proxy_soap_login (proxy_name); + proxy_soap_login (proxy_name, parent); g_object_unref (pld); break; case GTK_RESPONSE_CANCEL: @@ -302,7 +303,7 @@ proxy_login_cb (GtkDialog *dialog, gint state) } static void -proxy_soap_login (gchar *email) +proxy_soap_login (gchar *email, GtkWindow *error_parent) { EAccountList *accounts = e_get_account_list (); EAccount *srcAccount; @@ -319,7 +320,7 @@ proxy_soap_login (gchar *email) if (email[i]=='@') name = g_strndup(email, i); else { - e_error_run (NULL, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); + e_error_run (error_parent, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); return; } @@ -327,7 +328,7 @@ proxy_soap_login (gchar *email) If so, it is violating the (li)unix philosophy of User creation. So dont care about that scenario*/ if (e_account_list_find (accounts, E_ACCOUNT_FIND_ID_ADDRESS, email) != NULL) { - e_error_run (NULL, "org.gnome.evolution.proxy-login:already-loggedin", email, NULL); + e_error_run (error_parent, "org.gnome.evolution.proxy-login:already-loggedin", email, NULL); g_free (name); return; } @@ -362,7 +363,7 @@ proxy_soap_login (gchar *email) g_free (parent_source_url); camel_url_free (parent); } else { - e_error_run (NULL, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); + e_error_run (error_parent, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); return; } @@ -524,7 +525,7 @@ gw_proxy_login_cb (GtkAction *action, EShellView *shell_view) ); proxy_login_setup_tree_view (); proxy_login_update_tree (); - g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(proxy_login_cb), NULL); + g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(proxy_login_cb), e_shell_view_get_shell_window (shell_view)); gtk_widget_show (GTK_WIDGET (priv->main)); g_free (uri); diff --git a/plugins/groupwise-features/proxy-login.h b/plugins/groupwise-features/proxy-login.h index 150684c140..65e28cdf78 100644 --- a/plugins/groupwise-features/proxy-login.h +++ b/plugins/groupwise-features/proxy-login.h @@ -52,11 +52,10 @@ struct _proxyLoginClass { GType proxy_login_get_type (void); proxyLogin * proxy_login_new (void); -static void proxy_login_cb (GtkDialog *dialog, gint state); static void proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data); static void proxy_login_setup_tree_view (void); proxyLogin* proxy_dialog_new (void); -static void proxy_soap_login (gchar *email); +static void proxy_soap_login (gchar *email, GtkWindow *error_parent); gchar *parse_email_for_name (gchar *email); static void proxy_login_update_tree (void); static void proxy_login_tree_view_changed_cb(GtkDialog *dialog); diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c index a31b49112b..545e98787d 100644 --- a/plugins/groupwise-features/proxy.c +++ b/plugins/groupwise-features/proxy.c @@ -301,7 +301,7 @@ proxy_get_permissions_from_dialog (EAccount *account) } static gint -proxy_dialog_store_widgets_data (EAccount *account, gint32 dialog) +proxy_dialog_store_widgets_data (EAccount *account, gint32 dialog, GtkWindow *parent) { GtkTreeIter iter; GtkTreeSelection* account_select; @@ -330,7 +330,7 @@ proxy_dialog_store_widgets_data (EAccount *account, gint32 dialog) tmp = destinations; if (!tmp) { - e_error_run (NULL, "org.gnome.evolution.proxy:no-user",NULL ,NULL); + e_error_run (parent, "org.gnome.evolution.proxy:no-user",NULL ,NULL); return -1; } @@ -342,11 +342,11 @@ proxy_dialog_store_widgets_data (EAccount *account, gint32 dialog) continue; if (g_strrstr (email, "@") == NULL) { - e_error_run (NULL, "org.gnome.evolution.proxy:invalid-user", email, NULL); + e_error_run (parent, "org.gnome.evolution.proxy:invalid-user", email, NULL); return -1; } if (! g_ascii_strcasecmp(e_gw_connection_get_user_email (prd->cnc), email)) { - e_error_run (NULL, "org.gnome.evolution.proxy:invalid-user", email, NULL); + e_error_run (parent, "org.gnome.evolution.proxy:invalid-user", email, NULL); return -1; } @@ -365,7 +365,7 @@ proxy_dialog_store_widgets_data (EAccount *account, gint32 dialog) return 0; } - e_error_run (NULL, "org.gnome.evolution.proxy:user-is-proxy",email ,NULL); + e_error_run (parent, "org.gnome.evolution.proxy:user-is-proxy",email ,NULL); return -1; } } @@ -792,7 +792,7 @@ proxy_add_ok (GtkWidget *button, EAccount *account) prd = g_object_get_data ((GObject *)account, "prd"); priv = prd->priv; - if (proxy_dialog_store_widgets_data (account, PROXY_ADD_DIALOG) < 0) + if (proxy_dialog_store_widgets_data (account, PROXY_ADD_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0) return; proxy_update_tree_view (account); @@ -809,7 +809,7 @@ proxy_edit_ok (GtkWidget *button, EAccount *account) prd = g_object_get_data ((GObject *)account, "prd"); priv = prd->priv; - if ( proxy_dialog_store_widgets_data (account, PROXY_EDIT_DIALOG) < 0) + if ( proxy_dialog_store_widgets_data (account, PROXY_EDIT_DIALOG, GTK_WINDOW (gtk_widget_get_toplevel (button))) < 0) return; proxy_update_tree_view (account); diff --git a/plugins/groupwise-features/share-folder.c b/plugins/groupwise-features/share-folder.c index 67c58f05fd..62a832be0d 100644 --- a/plugins/groupwise-features/share-folder.c +++ b/plugins/groupwise-features/share-folder.c @@ -339,10 +339,10 @@ add_clicked(GtkButton *button, ShareFolder *sf) email = e_destination_get_email (tmp->data); /* You can't share a folder with yourself*/ if (g_strrstr (email, "@") == NULL || (!g_ascii_strcasecmp (email , self_email))) - e_error_run (NULL, "org.gnome.evolution.mail_shared_folder:invalid-user",email ,NULL); + e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))), "org.gnome.evolution.mail_shared_folder:invalid-user",email ,NULL); else { if (!g_ascii_strcasecmp (email, "" )) { - e_error_run (NULL, "org.gnome.evolution.mail_shared_folder:no-user",NULL); + e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))), "org.gnome.evolution.mail_shared_folder:no-user",NULL); return; } diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c index 94f9081ecd..a0daa6f156 100644 --- a/plugins/itip-formatter/itip-formatter.c +++ b/plugins/itip-formatter/itip-formatter.c @@ -1307,7 +1307,7 @@ update_attendee_status (struct _itip_puri *pitip) if ((a->status == ICAL_PARTSTAT_DELEGATED) && (del_prop = find_attendee (org_icalcomp, itip_strip_mailto (a->delto))) && !(find_attendee (icalcomp, itip_strip_mailto (a->delto)))) { gint response; delegate = icalproperty_get_attendee (del_prop); - response = e_error_run (NULL, "org.gnome.itip-formatter:add-delegate", + response = e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (pitip->view)), "org.gnome.itip-formatter:add-delegate", itip_strip_mailto (a->value), itip_strip_mailto (delegate), NULL); if (response == GTK_RESPONSE_YES) { @@ -1325,7 +1325,7 @@ update_attendee_status (struct _itip_puri *pitip) gint response; if (a->delfrom && *a->delfrom) { - response = e_error_run (NULL, "org.gnome.itip-formatter:add-delegate", + response = e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (pitip->view)), "org.gnome.itip-formatter:add-delegate", itip_strip_mailto (a->delfrom), itip_strip_mailto (a->value), NULL); if (response == GTK_RESPONSE_YES) { @@ -1344,7 +1344,7 @@ update_attendee_status (struct _itip_puri *pitip) } } - response = e_error_run (NULL, "org.gnome.itip-formatter:add-unknown-attendee", NULL); + response = e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (pitip->view)), "org.gnome.itip-formatter:add-unknown-attendee", NULL); if (response == GTK_RESPONSE_YES) { change_status (icalcomp, itip_strip_mailto (a->value), a->status); diff --git a/plugins/startup-wizard/startup-wizard.c b/plugins/startup-wizard/startup-wizard.c index e04a005206..7b691853fd 100644 --- a/plugins/startup-wizard/startup-wizard.c +++ b/plugins/startup-wizard/startup-wizard.c @@ -210,16 +210,11 @@ 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); @@ -232,7 +227,7 @@ startup_wizard_commit (EPlugin *ep, EMConfigTargetAccount *target) import_iterator = import_importers; import_importer = import_iterator->data; - import_dialog = e_error_new(parent, "shell:importing", _("Importing data."), NULL); + import_dialog = e_error_new (e_shell_get_active_window (shell), "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(); -- cgit v1.2.3