aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garnacho Parro <carlosg@gnome.org>2004-08-13 04:36:31 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-08-13 04:36:31 +0800
commitf52c23ee48a781d2a3d364661e0cf46554cc1274 (patch)
tree613d1b3168141be0212662f10e4e1a6c5b0e8d9a
parenta064dadb0c3612bccea6e2a8518edf2da53e9804 (diff)
downloadgsoc2013-evolution-f52c23ee48a781d2a3d364661e0cf46554cc1274.tar.gz
gsoc2013-evolution-f52c23ee48a781d2a3d364661e0cf46554cc1274.tar.zst
gsoc2013-evolution-f52c23ee48a781d2a3d364661e0cf46554cc1274.zip
Optionally use GtkFileChooser if compiled against Gtk+ >= 2.4.0
2004-08-12 Carlos Garnacho Parro <carlosg@gnome.org> * e-dialog-utils.c: Optionally use GtkFileChooser if compiled against Gtk+ >= 2.4.0 svn path=/trunk/; revision=26893
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-dialog-utils.c58
2 files changed, 52 insertions, 11 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index cae9acbc05..a441f4fb33 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,8 @@
+2004-08-12 Carlos Garnacho Parro <carlosg@gnome.org>
+
+ * e-dialog-utils.c: Optionally use GtkFileChooser if compiled
+ against Gtk+ >= 2.4.0
+
2004-08-10 Not Zed <NotZed@Ximian.com>
** See bug #61840, and others.
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c
index 751a89be68..702ee053ca 100644
--- a/e-util/e-dialog-utils.c
+++ b/e-util/e-dialog-utils.c
@@ -30,9 +30,17 @@
#include <gdk/gdkx.h>
-#include <gtk/gtkfilesel.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkplug.h>
+#include <gtk/gtkversion.h>
+
+#ifdef USE_GTKFILECHOOSER
+#include <gtk/gtkfilechooser.h>
+#include <gtk/gtkfilechooserdialog.h>
+#include <gtk/gtkstock.h>
+#else
+#include <gtk/gtkfilesel.h>
+#endif
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
@@ -242,7 +250,11 @@ save_ok (GtkWidget *widget, gpointer data)
int btn = GTK_RESPONSE_YES;
fs = gtk_widget_get_toplevel (widget);
+#ifdef USE_GTKFILECHOOSER
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs));
+#else
path = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs));
+#endif
if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
GtkWidget *dlg;
@@ -265,25 +277,49 @@ save_ok (GtkWidget *widget, gpointer data)
gtk_main_quit ();
}
+#ifdef USE_GTKFILECHOOSER
+static void
+filechooser_response (GtkWidget *fc, gint response_id, gpointer data)
+{
+ if (response_id == GTK_RESPONSE_ACCEPT)
+ save_ok (fc, data);
+ else
+ gtk_widget_destroy (fc);
+}
+#endif
+
char *
e_file_dialog_save (const char *title)
{
- GtkFileSelection *fs;
+ GtkWidget *selection;
char *path, *filename = NULL;
-
- fs = GTK_FILE_SELECTION (gtk_file_selection_new (title));
+
+#ifdef USE_GTKFILECHOOSER
+ selection = gtk_file_chooser_dialog_new (title,
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (selection), GTK_RESPONSE_ACCEPT);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (selection), g_get_home_dir ());
+
+ g_signal_connect (G_OBJECT (selection), "response", G_CALLBACK (filechooser_response), &filename);
+#else
+ selection = gtk_file_selection_new (title);
path = g_strdup_printf ("%s/", g_get_home_dir ());
- gtk_file_selection_set_filename (fs, path);
+ gtk_file_selection_set_filename (GTK_FILE_SELECTION (selection), path);
g_free (path);
+
+ g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->ok_button), "clicked", G_CALLBACK (save_ok), &filename);
+ g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (selection)->cancel_button), "clicked", G_CALLBACK (gtk_main_quit), NULL);
+#endif
- g_signal_connect (fs->ok_button, "clicked", G_CALLBACK (save_ok), &filename);
- g_signal_connect (fs->cancel_button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
-
- gtk_widget_show (GTK_WIDGET (fs));
- gtk_grab_add (GTK_WIDGET (fs));
+ gtk_widget_show (GTK_WIDGET (selection));
+ gtk_grab_add (GTK_WIDGET (selection));
gtk_main ();
- gtk_widget_destroy (GTK_WIDGET (fs));
+ gtk_widget_destroy (GTK_WIDGET (selection));
return filename;
}