diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-10-07 00:13:15 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-10-07 09:09:29 +0800 |
commit | 71f83089ccbb07760d3db525053a324d34717f43 (patch) | |
tree | deafafafc541c215d74fd154c16e1d3925a8c2e0 | |
parent | 2db9eff43ee816ad22b00a3808d6b4e7f0df228b (diff) | |
download | gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.gz gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.bz2 gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.lz gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.xz gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.zst gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.zip |
Bug 597533 - e_file_dialog_save() does not pass parent window
-rw-r--r-- | e-util/e-dialog-utils.c | 59 | ||||
-rw-r--r-- | e-util/e-dialog-utils.h | 27 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-actions.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-memopad.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-taskpad.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-view-actions.c | 8 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-view-actions.c | 8 |
7 files changed, 74 insertions, 52 deletions
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index f16680ac28..334375c755 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -72,48 +72,34 @@ e_notice (gpointer parent, GtkMessageType type, const gchar *format, ...) gtk_widget_destroy (dialog); } -static void -save_ok (GtkWidget *widget, gpointer data) +gchar * +e_file_dialog_save (GtkWindow *parent, + const gchar *title, + const gchar *fname) { - GtkWidget *fs; - gchar **filename = data; + GtkWidget *dialog; + gchar *filename = NULL; gchar *uri; - fs = gtk_widget_get_toplevel (widget); - uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (fs)); - - if (e_file_can_save((GtkWindow *)widget, uri)) { - e_file_update_save_path(gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(fs)), TRUE); - *filename = uri; - } - - gtk_main_quit (); -} - -static void -filechooser_response (GtkWidget *fc, gint response_id, gpointer data) -{ - if (response_id == GTK_RESPONSE_OK) - save_ok (fc, data); - else - gtk_widget_destroy (fc); -} + g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL); -gchar * -e_file_dialog_save (const gchar *title, const gchar *fname) -{ - GtkWidget *selection; - gchar *filename = NULL; + dialog = e_file_get_save_filesel ( + parent, title, fname, GTK_FILE_CHOOSER_ACTION_SAVE); - selection = e_file_get_save_filesel(NULL, title, fname, GTK_FILE_CHOOSER_ACTION_SAVE); + if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) + goto exit; - g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (filechooser_response), &filename); + uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); - gtk_widget_show (GTK_WIDGET (selection)); - gtk_grab_add (GTK_WIDGET (selection)); - gtk_main (); + if (e_file_can_save (GTK_WINDOW (dialog), uri)) { + e_file_update_save_path ( + gtk_file_chooser_get_current_folder_uri ( + GTK_FILE_CHOOSER (dialog)), TRUE); + filename = uri; /* FIXME This looks wrong. */ + } - gtk_widget_destroy (GTK_WIDGET (selection)); +exit: + gtk_widget_destroy (dialog); return filename; } @@ -129,7 +115,10 @@ e_file_dialog_save (const gchar *title, const gchar *fname) * no signals connected and is not shown. **/ GtkWidget * -e_file_get_save_filesel (GtkWindow *parent, const gchar *title, const gchar *name, GtkFileChooserAction action) +e_file_get_save_filesel (GtkWindow *parent, + const gchar *title, + const gchar *name, + GtkFileChooserAction action) { GtkWidget *filesel; gchar *uri; diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h index 3af21ffb0d..b4f305bdd5 100644 --- a/e-util/e-dialog-utils.h +++ b/e-util/e-dialog-utils.h @@ -25,16 +25,19 @@ #include <gtk/gtk.h> -void e_notice (gpointer parent, - GtkMessageType type, - const gchar *format, - ...); +void e_notice (gpointer parent, + GtkMessageType type, + const gchar *format, + ...); +gchar * e_file_dialog_save (GtkWindow *parent, + const gchar *title, + const gchar *fname); +GtkWidget * e_file_get_save_filesel (GtkWindow *parent, + const gchar *title, + const gchar *name, + GtkFileChooserAction action); +gboolean e_file_can_save (GtkWindow *parent, + const gchar *uri); +gboolean e_file_check_local (const gchar *name); -gchar *e_file_dialog_save (const gchar *title, const gchar *fname); - -GtkWidget * e_file_get_save_filesel (GtkWindow *parent, const gchar *title, const gchar *name, GtkFileChooserAction action); - -gboolean e_file_can_save(GtkWindow *parent, const gchar *uri); -gboolean e_file_check_local(const gchar *name); - -#endif +#endif /* E_DIALOG_UTILS_H */ diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index 2338fdb247..408d02ffc3 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -1065,6 +1065,8 @@ static void action_event_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; ECalShellContent *cal_shell_content; GnomeCalendarViewType view_type; GnomeCalendar *calendar; @@ -1076,6 +1078,9 @@ action_event_save_as_cb (GtkAction *action, gchar *filename = NULL; gchar *string = NULL; + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + cal_shell_content = cal_shell_view->priv->cal_shell_content; calendar = e_cal_shell_content_get_calendar (cal_shell_content); view_type = gnome_calendar_get_view (calendar); @@ -1088,7 +1093,8 @@ action_event_save_as_cb (GtkAction *action, client = event->comp_data->client; icalcomp = event->comp_data->icalcomp; - filename = e_file_dialog_save (_("Save As..."), NULL); + filename = e_file_dialog_save ( + GTK_WINDOW (shell_window), _("Save As..."), NULL); if (filename == NULL) goto exit; diff --git a/modules/calendar/e-cal-shell-view-memopad.c b/modules/calendar/e-cal-shell-view-memopad.c index 1c4e863345..7d4c1a501f 100644 --- a/modules/calendar/e-cal-shell-view-memopad.c +++ b/modules/calendar/e-cal-shell-view-memopad.c @@ -233,6 +233,8 @@ static void action_calendar_memopad_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; ECalShellContent *cal_shell_content; EMemoTable *memo_table; ECalModelComponent *comp_data; @@ -240,6 +242,9 @@ action_calendar_memopad_save_as_cb (GtkAction *action, gchar *filename; gchar *string; + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + cal_shell_content = cal_shell_view->priv->cal_shell_content; memo_table = e_cal_shell_content_get_memo_table (cal_shell_content); @@ -248,7 +253,8 @@ action_calendar_memopad_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save (_("Save as..."), NULL); + filename = e_file_dialog_save ( + GTK_WINDOW (shell_window), _("Save as..."), NULL); if (filename == NULL) return; diff --git a/modules/calendar/e-cal-shell-view-taskpad.c b/modules/calendar/e-cal-shell-view-taskpad.c index 0301d9c1a1..3e83e04fcc 100644 --- a/modules/calendar/e-cal-shell-view-taskpad.c +++ b/modules/calendar/e-cal-shell-view-taskpad.c @@ -301,6 +301,8 @@ static void action_calendar_taskpad_save_as_cb (GtkAction *action, ECalShellView *cal_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; ECalShellContent *cal_shell_content; ECalendarTable *task_table; ECalModelComponent *comp_data; @@ -308,6 +310,9 @@ action_calendar_taskpad_save_as_cb (GtkAction *action, gchar *filename; gchar *string; + shell_view = E_SHELL_VIEW (cal_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + cal_shell_content = cal_shell_view->priv->cal_shell_content; task_table = e_cal_shell_content_get_task_table (cal_shell_content); @@ -316,7 +321,8 @@ action_calendar_taskpad_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save (_("Save as..."), NULL); + filename = e_file_dialog_save ( + GTK_WINDOW (shell_window), _("Save as..."), NULL); if (filename == NULL) return; diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c index 463e01f71b..ab8be53d04 100644 --- a/modules/calendar/e-memo-shell-view-actions.c +++ b/modules/calendar/e-memo-shell-view-actions.c @@ -471,6 +471,8 @@ static void action_memo_save_as_cb (GtkAction *action, EMemoShellView *memo_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; EMemoShellContent *memo_shell_content; EMemoTable *memo_table; ECalModelComponent *comp_data; @@ -478,6 +480,9 @@ action_memo_save_as_cb (GtkAction *action, gchar *filename; gchar *string; + shell_view = E_SHELL_VIEW (memo_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + memo_shell_content = memo_shell_view->priv->memo_shell_content; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); @@ -486,7 +491,8 @@ action_memo_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save (_("Save as..."), NULL); + filename = e_file_dialog_save ( + GTK_WINDOW (shell_window), _("Save as..."), NULL); if (filename == NULL) return; diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index 2592df2481..fb7b89b049 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -598,6 +598,8 @@ static void action_task_save_as_cb (GtkAction *action, ETaskShellView *task_shell_view) { + EShellView *shell_view; + EShellWindow *shell_window; ETaskShellContent *task_shell_content; ECalendarTable *task_table; ECalModelComponent *comp_data; @@ -605,6 +607,9 @@ action_task_save_as_cb (GtkAction *action, gchar *filename; gchar *string; + shell_view = E_SHELL_VIEW (task_shell_view); + shell_window = e_shell_view_get_shell_window (shell_view); + task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); @@ -613,7 +618,8 @@ action_task_save_as_cb (GtkAction *action, comp_data = list->data; g_slist_free (list); - filename = e_file_dialog_save (_("Save as..."), NULL); + filename = e_file_dialog_save ( + GTK_WINDOW (shell_window), _("Save as..."), NULL); if (filename == NULL) return; |