diff options
Diffstat (limited to 'e-util/e-dialog-utils.c')
-rw-r--r-- | e-util/e-dialog-utils.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c index f155b83145..0102c45167 100644 --- a/e-util/e-dialog-utils.c +++ b/e-util/e-dialog-utils.c @@ -30,9 +30,15 @@ #include <gdk/gdkprivate.h> #include <gdk/gdk.h> +#include <gtk/gtkmain.h> #include <gtk/gtksignal.h> +#include <gtk/gtkfilesel.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> +#include <libgnome/gnome-util.h> #include <libgnomeui/gnome-dialog-util.h> +#include <libgnomeui/gnome-uidefs.h> #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-property-bag.h> @@ -204,3 +210,55 @@ e_gnome_ok_cancel_dialog_parented (const char *message, GnomeReplyCallback callb return dialog; } + +static void +save_ok (GtkWidget *widget, gpointer data) +{ + GtkWidget *fs; + char **filename = data; + char *path; + int btn = GNOME_YES; + + fs = gtk_widget_get_toplevel (widget); + path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); + + if (g_file_test (path, G_FILE_TEST_ISFILE)) { + GtkWidget *dlg; + + dlg = gnome_question_dialog_modal (_("A file by that name already exists.\n" + "Overwrite it?"), NULL, NULL); + btn = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + } + + if (btn == GNOME_YES) + *filename = g_strdup (path); + + gtk_main_quit (); +} + +char * +e_file_dialog_save (const char *title) +{ + GtkFileSelection *fs; + char *path, *filename = NULL; + + fs = GTK_FILE_SELECTION (gtk_file_selection_new (title)); + path = g_strdup_printf ("%s/", g_get_home_dir ()); + gtk_file_selection_set_filename (fs, path); + g_free (path); + + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + GTK_SIGNAL_FUNC (save_ok), &filename); + gtk_signal_connect (GTK_OBJECT (fs->cancel_button), "clicked", + GTK_SIGNAL_FUNC (gtk_main_quit), NULL); + + gtk_widget_show (GTK_WIDGET (fs)); + gtk_grab_add (GTK_WIDGET (fs)); + gtk_main (); + + gtk_widget_destroy (GTK_WIDGET (fs)); + + return filename; +} + + |