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
This commit is contained in:
@ -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>
|
2002-03-22 Ettore Perazzoli <ettore@ximian.com>
|
||||||
|
|
||||||
* e-lang-utils.c: New.
|
* e-lang-utils.c: New.
|
||||||
|
@ -30,9 +30,15 @@
|
|||||||
#include <gdk/gdkprivate.h>
|
#include <gdk/gdkprivate.h>
|
||||||
#include <gdk/gdk.h>
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
|
#include <gtk/gtkmain.h>
|
||||||
#include <gtk/gtksignal.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-dialog-util.h>
|
||||||
|
#include <libgnomeui/gnome-uidefs.h>
|
||||||
|
|
||||||
#include <bonobo/bonobo-control.h>
|
#include <bonobo/bonobo-control.h>
|
||||||
#include <bonobo/bonobo-property-bag.h>
|
#include <bonobo/bonobo-property-bag.h>
|
||||||
@ -204,3 +210,55 @@ e_gnome_ok_cancel_dialog_parented (const char *message, GnomeReplyCallback callb
|
|||||||
|
|
||||||
return dialog;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,5 +42,7 @@ GtkWidget *e_gnome_ok_cancel_dialog_parented (const char *message,
|
|||||||
GnomeReplyCallback callback,
|
GnomeReplyCallback callback,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GtkWindow *parent);
|
GtkWindow *parent);
|
||||||
|
char *e_file_dialog_save (const char *title);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user