[evolution-patches] GtkHTML File Chooser Patch



We forgot about GtkHTML :-).  I didn't do the test app for this.

-JP
-- 
JP Rosevear <jpr novell com>
Novell, Inc.
? autom4te.cache
? filechooser.patch
? stamp-h1
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/ChangeLog,v
retrieving revision 1.274
diff -u -r1.274 ChangeLog
--- ChangeLog	11 Aug 2004 05:03:05 -0000	1.274
+++ ChangeLog	13 Aug 2004 16:17:23 -0000
@@ -1,3 +1,7 @@
+2004-08-13  JP Rosevear  <jpr ximian com>
+
+	* configure.in: add file chooser check
+
 2004-08-07  Runa Bhattacharjee <runab redhat com>
 	* configure.in: Added Bengali(bn) in ALL_LINGUAS.
 
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtkhtml/configure.in,v
retrieving revision 1.255
diff -u -r1.255 configure.in
--- configure.in	9 Aug 2004 05:39:01 -0000	1.255
+++ configure.in	13 Aug 2004 16:17:23 -0000
@@ -88,6 +88,16 @@
 AC_SUBST(SOUP_LIBS)
 
 dnl **************************************************
+dnl * File Chooser
+dnl **************************************************
+AC_ARG_ENABLE(file-chooser, [  --enable-file-chooser    Enable the usage of the GtkFileChooser in place of the GtkFileSelection dialog], enable_file_chooser="$enableval", enable_file_chooser="yes")
+if test "x$enable_file_chooser" = "xyes"; then
+  if $PKG_CONFIG --atleast-version=2.4.0 gtk+-2.0; then
+    AC_DEFINE(USE_GTKFILECHOOSER,1,[Use new GtkFileChooser])
+  fi
+fi
+
+dnl **************************************************
 dnl * Gnome Icon Theme
 dnl **************************************************
 PKG_CHECK_MODULES(GIT, gnome-icon-theme >= 1.2.0)
Index: components/html-editor/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/ChangeLog,v
retrieving revision 1.469
diff -u -r1.469 ChangeLog
--- components/html-editor/ChangeLog	22 Jul 2004 17:58:55 -0000	1.469
+++ components/html-editor/ChangeLog	13 Aug 2004 16:17:24 -0000
@@ -1,3 +1,9 @@
+2004-08-13  JP Rosevear  <jpr ximian com>
+
+	* menubar.c (insert_image_cb): optionally use gtk file chooser
+	(file_dialog_ok): ditto
+	(insert_file_dialog): ditto and use it in a more GtkDialog manner
+
 2004-07-22  Rodney Dawes  <dobey novell com>
 
 	* Makefile.am (gtkhtml_data, LDADD): Use GTKHTML_API_VERSION
Index: components/html-editor/menubar.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/menubar.c,v
retrieving revision 1.104
diff -u -r1.104 menubar.c
--- components/html-editor/menubar.c	4 Jun 2004 15:10:55 -0000	1.104
+++ components/html-editor/menubar.c	13 Aug 2004 16:17:24 -0000
@@ -30,6 +30,12 @@
 #include <fcntl.h>
 
 #include <gnome.h>
+#ifdef USE_GTKFILECHOOSER
+#include <gtk/gtkfilechooser.h>
+#include <gtk/gtkfilechooserdialog.h>
+#else
+#include <gtk/gtkfilesel.h>
+#endif
 #include <bonobo.h>
 
 #include "htmlengine.h"
@@ -83,15 +89,30 @@
 static void
 insert_image_cb (BonoboUIComponent *uic, GtkHTMLControlData *cd, const char *cname)
 {
-	GtkWidget *filesel = gtk_file_selection_new (_("Insert image"));
+	GtkWidget *filesel;
 	HTMLObject *img;
 
+#ifdef USE_GTKFILECHOOSER
+	filesel = gtk_file_chooser_dialog_new (_("Insert image"),
+					       NULL,
+					       GTK_FILE_CHOOSER_ACTION_OPEN,
+					       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+					       GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+					       NULL);
+	gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+#else
+	filesel = gtk_file_selection_new (_("Insert image"));
+#endif
 	if (filesel) {
 		if (gtk_dialog_run (GTK_DIALOG (filesel)) == GTK_RESPONSE_OK) {
 			const char *filename;
 			char *url = NULL;
 
+#ifdef USE_GTKFILECHOOSER
+			filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel));
+#else
 			filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
+#endif
 			if (filename)
 				url = g_strconcat ("file://", filename, NULL);
 			img = html_image_new (html_engine_get_image_factory (cd->html->engine), url,
@@ -182,12 +203,6 @@
 }
 
 static void
-file_dialog_destroy (GtkWidget *w, GtkHTMLControlData *cd)
-{
-	cd->file_dialog = NULL;
-}
-
-static void
 file_dialog_ok (GtkWidget *w, GtkHTMLControlData *cd)
 {
 	const gchar *filename;
@@ -196,8 +211,12 @@
 	gchar *data = NULL;
 	gsize len = 0;
 	const char *charset;
-	
+
+#ifdef USE_GTKFILECHOOSER
+	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (cd->file_dialog));
+#else	
 	filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (cd->file_dialog));
+#endif
 	io = g_io_channel_new_file (filename, "r", &error);
 
 	if (error || !io)
@@ -287,18 +306,27 @@
 		return;
 	}
 
+#ifdef USE_GTKFILECHOOSER
+	cd->file_dialog = gtk_file_chooser_dialog_new (html ? _("Insert: HTML File") : _("Insert: Text File"),
+						       NULL,
+						       GTK_FILE_CHOOSER_ACTION_OPEN,
+						       GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+						       GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+						       NULL);
+	gtk_dialog_set_default_response (GTK_DIALOG (cd->file_dialog), GTK_RESPONSE_OK);
+	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (cd->file_dialog), g_get_home_dir ());
+#else
 	cd->file_dialog = gtk_file_selection_new (html ? _("Insert: HTML File") : _("Insert: Text File"));
 	gtk_file_selection_set_filename (GTK_FILE_SELECTION (cd->file_dialog), "~/");
+#endif
 
-	g_signal_connect_object (GTK_FILE_SELECTION (cd->file_dialog)->cancel_button,
-				 "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (cd->file_dialog),
-				 G_CONNECT_SWAPPED);
-
-	g_signal_connect (GTK_FILE_SELECTION (cd->file_dialog)->ok_button, "clicked", G_CALLBACK (file_dialog_ok), cd);
-
-	g_signal_connect (cd->file_dialog, "destroy", G_CALLBACK (file_dialog_destroy), cd);
-
-	gtk_widget_show (cd->file_dialog);
+	if (cd->file_dialog) {
+		if (gtk_dialog_run (GTK_DIALOG (cd->file_dialog)) == GTK_RESPONSE_OK) {
+			file_dialog_ok (cd->file_dialog, cd);
+		}
+		gtk_widget_destroy (cd->file_dialog);
+		cd->file_dialog = NULL;
+	}
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]