SF.net SVN: geany:[4428] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Tue Nov 17 21:47:06 UTC 2009


Revision: 4428
          http://geany.svn.sourceforge.net/geany/?rev=4428&view=rev
Author:   eht16
Date:     2009-11-17 21:47:06 +0000 (Tue, 17 Nov 2009)

Log Message:
-----------
Implement GTK_FILE_CHOOSER_ACTION_OPEN mode in ui_setup_open_button_callback().

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/ui_utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-11-17 21:10:29 UTC (rev 4427)
+++ trunk/ChangeLog	2009-11-17 21:47:06 UTC (rev 4428)
@@ -2,6 +2,9 @@
 
  * doc/geany.txt, doc/geany.html:
    Fix slightly wrong description of how to insert Unicode characters.
+ * src/ui_utils.c:
+   Implement GTK_FILE_CHOOSER_ACTION_OPEN mode in
+   ui_setup_open_button_callback().
 
 
 2009-11-16  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2009-11-17 21:10:29 UTC (rev 4427)
+++ trunk/src/ui_utils.c	2009-11-17 21:47:06 UTC (rev 4428)
@@ -1620,6 +1620,11 @@
 		if (g_path_is_absolute(locale_path) && g_file_test(locale_path, G_FILE_TEST_IS_DIR))
 			gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
 	}
+	else if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
+	{
+		if (g_path_is_absolute(locale_path))
+			gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), locale_path);
+	}
 	g_free(locale_path);
 
 	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
@@ -1647,18 +1652,34 @@
 	gchar *utf8_path;
 
 	/* TODO: extend for other actions */
-	g_return_if_fail(action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+	g_return_if_fail(action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+					 action == GTK_FILE_CHOOSER_ACTION_OPEN);
 
 	if (title == NULL)
 		title = (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ?
 			_("Select Folder") : _("Select File");
 
+	if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
+	{
 #ifdef G_OS_WIN32
-	utf8_path = win32_show_project_folder_dialog(ui_widgets.prefs_dialog, title,
+		utf8_path = win32_show_project_folder_dialog(ui_widgets.prefs_dialog, title,
 						gtk_entry_get_text(GTK_ENTRY(entry)));
 #else
-	utf8_path = run_file_chooser(title, action, gtk_entry_get_text(GTK_ENTRY(entry)));
+		utf8_path = run_file_chooser(title, action, gtk_entry_get_text(GTK_ENTRY(entry)));
 #endif
+	}
+	else if (action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+	{
+		gchar *path = g_path_get_dirname(gtk_entry_get_text(GTK_ENTRY(entry)));
+#ifdef G_OS_WIN32
+		/* TODO this doesn't work on Windows yet, we need a more generic win32_show_file_dialog() */
+		/*utf8_path = win32_show_file_dialog(TRUE, ui_widgets.prefs_dialog, path);*/
+		utf8_path = NULL;
+#else
+		utf8_path = run_file_chooser(title, action, path);
+#endif
+		g_free(path);
+	}
 
 	if (utf8_path != NULL)
 	{


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list