Index: components/html-editor/engine.c
===================================================================
--- components/html-editor/engine.c	(revision 8594)
+++ components/html-editor/engine.c	(working copy)
@@ -227,6 +227,27 @@
 }
 
 static void
+impl_set_file_path (PortableServer_Servant servant, const CORBA_char * file_path, CORBA_Environment * ev)
+{
+	EditorEngine *e = html_editor_engine_from_servant (servant);
+
+	g_free (e->cd->file_path);
+
+	if (file_path && *file_path)
+		e->cd->file_path = g_strdup (file_path);
+	else
+		e->cd->file_path = NULL;
+}
+
+static CORBA_char *
+impl_get_file_path (PortableServer_Servant servant, CORBA_Environment * ev)
+{
+	EditorEngine *e = html_editor_engine_from_servant (servant);
+
+	return CORBA_string_dup (e->cd->file_path ? e->cd->file_path : "");
+}
+
+static void
 engine_object_finalize (GObject *object)
 {
 	EditorEngine *e = EDITOR_ENGINE (object);
@@ -270,6 +291,8 @@
 	epv->ignoreWord               = impl_ignore_word;
 	epv->hasUndo                  = impl_has_undo;
 	epv->dropUndo                 = impl_drop_undo;
+	epv->setFilePath              = impl_set_file_path;
+	epv->getFilePath              = impl_get_file_path;
 }
 
 BONOBO_TYPE_FUNC_FULL (
Index: components/html-editor/menubar.c
===================================================================
--- components/html-editor/menubar.c	(revision 8594)
+++ components/html-editor/menubar.c	(working copy)
@@ -102,6 +102,12 @@
 					       GTK_STOCK_OPEN, GTK_RESPONSE_OK,
 					       NULL);
 	gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK);
+
+	if (cd->file_path)
+		gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), cd->file_path);
+	else
+		gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ());
+
 	if (filesel) {
 		if (gtk_dialog_run (GTK_DIALOG (filesel)) == GTK_RESPONSE_OK) {
 			char *url = NULL;
@@ -111,6 +117,13 @@
 					      NULL, NULL, 0, 0, 0, 0, 0, NULL, HTML_VALIGN_NONE, FALSE);
 			html_engine_paste_object (cd->html->engine, img, 1);
 			g_free (url);
+
+			url = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (filesel));
+
+			if (url) {
+				g_free (cd->file_path);
+				cd->file_path = url;
+			}
 		}
 		gtk_widget_destroy (filesel);
 	}
@@ -306,11 +319,24 @@
 						       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 ());
 
+	if (cd->file_path)
+		gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (cd->file_dialog), cd->file_path);
+	else
+		gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (cd->file_dialog), g_get_home_dir ());
+
 	if (cd->file_dialog) {
 		if (gtk_dialog_run (GTK_DIALOG (cd->file_dialog)) == GTK_RESPONSE_OK) {
+			gchar *path;
+
 			file_dialog_ok (cd->file_dialog, cd);
+
+			path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (cd->file_dialog));
+
+			if (path) {
+				g_free (cd->file_path);
+				cd->file_path = path;
+			}
 		}
 		gtk_widget_destroy (cd->file_dialog);
 		cd->file_dialog = NULL;
Index: components/html-editor/ChangeLog
===================================================================
--- components/html-editor/ChangeLog	(revision 8594)
+++ components/html-editor/ChangeLog	(working copy)
@@ -1,3 +1,17 @@
+2007-10-16  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #271551
+
+	* Editor.idl: (setFilePath), (getFilePath): New interface functions
+	to set/get path to be opened when inserting images/files.
+	* engine.c: (impl_set_file_path), (impl_get_file_path),
+	(editor_engine_class_init): Use proper implementation functions.
+	* control-data.h: (struct _GtkHTMLControlData): New property to 
+	store last selected folder and reuse it next time.
+	* control-data.c: (gtk_html_control_data_destroy): Free new property.
+	* menubar.c: (insert_image_cb), (insert_file_dialog): Use new control
+	data property when opening file chooser and store back last folder.
+
 2007-09-27  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #434631
Index: components/html-editor/Editor.idl
===================================================================
--- components/html-editor/Editor.idl	(revision 8594)
+++ components/html-editor/Editor.idl	(working copy)
@@ -90,6 +90,12 @@
 		 * is there any undo event in undo queue?
 		 */
 		boolean hasUndo ();
+
+		/*
+		 * set/get file path to open when inserting images/files into the editor
+		 */
+		void setFilePath (in string path);
+		string getFilePath ();
 	};
 	
 	struct URLRequestEvent {
Index: components/html-editor/control-data.c
===================================================================
--- components/html-editor/control-data.c	(revision 8594)
+++ components/html-editor/control-data.c	(working copy)
@@ -93,5 +93,7 @@
 	if (cd->paragraph_style_store)
 		g_object_unref (cd->paragraph_style_store);
 
+	g_free (cd->file_path);
+
 	g_free (cd);
 }
Index: components/html-editor/control-data.h
===================================================================
--- components/html-editor/control-data.h	(revision 8594)
+++ components/html-editor/control-data.h	(working copy)
@@ -111,6 +111,9 @@
 	gboolean file_html;
 
 	GtkListStore *paragraph_style_store;
+
+	/* file path used in dialog when choosing files */
+	gchar *file_path;
 };
 
 GtkHTMLControlData * gtk_html_control_data_new       (GtkHTML *html, GtkWidget *vbox);
