diff options
author | JP Rosevear <jpr@ximian.com> | 2002-03-30 05:30:46 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2002-03-30 05:30:46 +0800 |
commit | 9104b3079ae9654573f488774490d6bd27a347b8 (patch) | |
tree | fddd5b40c4db481cdb959c3fca5653bac0716696 /e-util | |
parent | ca20bbf97ee0b88cfe16ec0445095fb1495ca215 (diff) | |
download | gsoc2013-evolution-9104b3079ae9654573f488774490d6bd27a347b8.tar.gz gsoc2013-evolution-9104b3079ae9654573f488774490d6bd27a347b8.tar.zst gsoc2013-evolution-9104b3079ae9654573f488774490d6bd27a347b8.zip |
open a file selection dialog with the given title and return the selected
2002-03-29 JP Rosevear <jpr@ximian.com>
* e-dialog-utils.c (e_file_dialog_save): open a file selection
dialog with the given title and return the selected file name
(save_ok): if the ok button is clicked, make sure the file doesn't
already exist and if it does, see if the user wants to over write
it
* e-dialog-utils.h: new proto
svn path=/trunk/; revision=16284
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/ChangeLog | 10 | ||||
-rw-r--r-- | e-util/e-dialog-utils.c | 58 | ||||
-rw-r--r-- | e-util/e-dialog-utils.h | 2 |
3 files changed, 70 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 6ea7c05660..375de2f381 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,13 @@ +2002-03-29 JP Rosevear <jpr@ximian.com> + + * e-dialog-utils.c (e_file_dialog_save): open a file selection + dialog with the given title and return the selected file name + (save_ok): if the ok button is clicked, make sure the file doesn't + already exist and if it does, see if the user wants to over write + it + + * e-dialog-utils.h: new proto + 2002-03-22 Ettore Perazzoli <ettore@ximian.com> * e-lang-utils.c: New. 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; +} + + diff --git a/e-util/e-dialog-utils.h b/e-util/e-dialog-utils.h index 1e1b8af22f..275f8ec264 100644 --- a/e-util/e-dialog-utils.h +++ b/e-util/e-dialog-utils.h @@ -42,5 +42,7 @@ GtkWidget *e_gnome_ok_cancel_dialog_parented (const char *message, GnomeReplyCallback callback, gpointer data, GtkWindow *parent); +char *e_file_dialog_save (const char *title); + #endif |