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 /e-util | |
parent | 2db9eff43ee816ad22b00a3808d6b4e7f0df228b (diff) | |
download | gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.gz gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.tar.zst gsoc2013-evolution-71f83089ccbb07760d3db525053a324d34717f43.zip |
Bug 597533 - e_file_dialog_save() does not pass parent window
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-dialog-utils.c | 59 | ||||
-rw-r--r-- | e-util/e-dialog-utils.h | 27 |
2 files changed, 39 insertions, 47 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 */ |