SF.net SVN: geany: [2094] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Fri Dec 7 16:31:38 UTC 2007


Revision: 2094
          http://geany.svn.sourceforge.net/geany/?rev=2094&view=rev
Author:   eht16
Date:     2007-12-07 08:31:38 -0800 (Fri, 07 Dec 2007)

Log Message:
-----------
Fix wrong file filters in project-related file dialogs on Windows.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/project.c
    trunk/src/ui_utils.c
    trunk/src/win32.c
    trunk/src/win32.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-12-07 14:13:05 UTC (rev 2093)
+++ trunk/ChangeLog	2007-12-07 16:31:38 UTC (rev 2094)
@@ -1,5 +1,11 @@
 2007-12-07  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
+ * src/project.c, src/ui_utils.c, src/win32.c, src/win32.h:
+   Fix wrong file filters in project-related file dialogs on Windows.
+
+
+2007-12-07  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
  * doc/geany.html, doc/geany.txt, src/callbacks.c, src/document.c,
    src/document.h, src/encodings.c, src/encodings.h, src/keyfile.c,
    src/main.c:

Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c	2007-12-07 14:13:05 UTC (rev 2093)
+++ trunk/src/project.c	2007-12-07 16:31:38 UTC (rev 2094)
@@ -71,8 +71,8 @@
 
 
 static gboolean update_config(const PropertyDialogElements *e);
-static void on_file_save_button_clicked(GtkButton *button, GtkWidget *entry);
-static void on_file_open_button_clicked(GtkButton *button, GtkWidget *entry);
+static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e);
+static void on_file_open_button_clicked(GtkButton *button, PropertyDialogElements *e);
 static gboolean close_open_project();
 static gboolean load_config(const gchar *filename);
 static gboolean write_config();
@@ -142,7 +142,7 @@
 	gtk_entry_set_width_chars(GTK_ENTRY(e->file_name), 30);
 	button = gtk_button_new();
 	g_signal_connect((gpointer) button, "clicked",
-				G_CALLBACK(on_file_save_button_clicked), e->file_name);
+				G_CALLBACK(on_file_save_button_clicked), e);
 	image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
 	gtk_container_add(GTK_CONTAINER(button), image);
 	bbox = gtk_hbox_new(FALSE, 6);
@@ -230,7 +230,7 @@
 	if (! close_open_project()) return;
 
 #ifdef G_OS_WIN32
-	file = win32_show_project_open_dialog(_("Open Project"), dir, FALSE);
+	file = win32_show_project_open_dialog(app->window, _("Open Project"), dir, FALSE, TRUE);
 	if (file != NULL)
 	{
 		// try to load the config
@@ -714,14 +714,14 @@
 #endif
 
 
-static void on_file_save_button_clicked(GtkButton *button, GtkWidget *entry)
+static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e)
 {
 #ifdef G_OS_WIN32
-	gchar *path = win32_show_project_open_dialog(_("Choose Project Filename"),
-						gtk_entry_get_text(GTK_ENTRY(entry)), TRUE);
+	gchar *path = win32_show_project_open_dialog(e->dialog, _("Choose Project Filename"),
+						gtk_entry_get_text(GTK_ENTRY(e->file_name)), TRUE, TRUE);
 	if (path != NULL)
 	{
-		gtk_entry_set_text(GTK_ENTRY(entry), path);
+		gtk_entry_set_text(GTK_ENTRY(e->file_name), path);
 		g_free(path);
 	}
 #else
@@ -738,19 +738,19 @@
 	gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
 	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 
-	run_dialog(dialog, entry);
+	run_dialog(dialog, e->file_name);
 #endif
 }
 
 
-static void on_file_open_button_clicked(GtkButton *button, GtkWidget *entry)
+static void on_file_open_button_clicked(GtkButton *button, PropertyDialogElements *e)
 {
 #ifdef G_OS_WIN32
-	gchar *path = win32_show_project_open_dialog(_("Choose Project Run Command"),
-						gtk_entry_get_text(GTK_ENTRY(entry)), FALSE);
+	gchar *path = win32_show_project_open_dialog(e->dialog, _("Choose Project Run Command"),
+						gtk_entry_get_text(GTK_ENTRY(e->run_cmd)), FALSE, FALSE);
 	if (path != NULL)
 	{
-		gtk_entry_set_text(GTK_ENTRY(entry), path);
+		gtk_entry_set_text(GTK_ENTRY(e->run_cmd), path);
 		g_free(path);
 	}
 #else
@@ -767,7 +767,7 @@
 	gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
 	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 
-	run_dialog(dialog, entry);
+	run_dialog(dialog, e->run_cmd);
 #endif
 }
 

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2007-12-07 14:13:05 UTC (rev 2093)
+++ trunk/src/ui_utils.c	2007-12-07 16:31:38 UTC (rev 2094)
@@ -1340,7 +1340,7 @@
 			_("Select Folder") : _("Select File");
 
 #ifdef G_OS_WIN32
-	utf8_path = win32_show_project_folder_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)));

Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c	2007-12-07 14:13:05 UTC (rev 2093)
+++ trunk/src/win32.c	2007-12-07 16:31:38 UTC (rev 2094)
@@ -96,20 +96,20 @@
 }
 
 
-static gchar *win32_get_filters(gboolean exe)
+static gchar *win32_get_filters(gboolean project_files)
 {
 	gchar *string;
 	gint i, len;
 
-	if (exe)
+	if (project_files)
 	{
-		string = g_strconcat(_("Executables"), "\t", "*.exe;*.bat;*.cmd", "\t",
+		string = g_strconcat(_("Geany project files"), "\t", "*." GEANY_PROJECT_EXT, "\t",
 			filetypes[GEANY_FILETYPES_ALL]->title, "\t",
 			filetypes[GEANY_FILETYPES_ALL]->pattern[0], "\t", NULL);
 	}
 	else
 	{
-		string = g_strconcat(_("Geany project files"), "\t", "*." GEANY_PROJECT_EXT, "\t",
+		string = g_strconcat(_("Executables"), "\t", "*.exe;*.bat;*.cmd", "\t",
 			filetypes[GEANY_FILETYPES_ALL]->title, "\t",
 			filetypes[GEANY_FILETYPES_ALL]->pattern[0], "\t", NULL);
 	}
@@ -163,15 +163,19 @@
 
 /* Shows a folder selection dialog.
  * The selected folder name is returned. */
-gchar *win32_show_project_folder_dialog(const gchar *title, const gchar *initial_dir)
+gchar *win32_show_project_folder_dialog(GtkWidget *parent, const gchar *title,
+										const gchar *initial_dir)
 {
 	BROWSEINFO bi;
 	LPCITEMIDLIST pidl;
 	gchar *fname = g_malloc(MAX_PATH);
 	gchar *dir = get_dir(initial_dir);
 
+	if (parent == NULL)
+		parent = app->window;
+
 	memset(&bi, 0, sizeof bi);
-	bi.hwndOwner = GDK_WINDOW_HWND(app->window->window);
+	bi.hwndOwner = GDK_WINDOW_HWND(parent->window);
 	bi.pidlRoot = NULL;
 	bi.lpszTitle = title;
 	bi.lpfn = BrowseCallbackProc;
@@ -194,17 +198,24 @@
 
 /* Shows a file open dialog.
  * If allow_new_file is set, the file to be opened doesn't have to exist.
- * The selected file name is returned. */
-gchar *win32_show_project_open_dialog(const gchar *title, const gchar *initial_dir, gboolean allow_new_file)
+ * The selected file name is returned.
+ * If project_file_filter is set, the file open dialog will have a file filter for Geany project
+ * files, a filter for executables otherwise. */
+gchar *win32_show_project_open_dialog(GtkWidget *parent, const gchar *title,
+								      const gchar *initial_dir, gboolean allow_new_file,
+								      gboolean project_file_filter)
 {
 	OPENFILENAME of;
 	gint retval;
 	gchar *fname = g_malloc(2048);
-	gchar *filters = win32_get_filters(FALSE);
+	gchar *filters = win32_get_filters(project_file_filter);
 	gchar *dir = get_dir(initial_dir);
 
 	fname[0] = '\0';
 
+	if (parent == NULL)
+		parent = app->window;
+
 	/* initialise file dialog info struct */
 	memset(&of, 0, sizeof of);
 #ifdef OPENFILENAME_SIZE_VERSION_400
@@ -212,7 +223,7 @@
 #else
 	of.lStructSize = sizeof of;
 #endif
-	of.hwndOwner = GDK_WINDOW_HWND(app->window->window);
+	of.hwndOwner = GDK_WINDOW_HWND(parent->window);
 	of.lpstrFilter = filters;
 
 	of.lpstrCustomFilter = NULL;
@@ -569,7 +580,7 @@
 
 	if (app->window != NULL)
 		parent_hwnd = GDK_WINDOW_HWND(app->window->window);
-	
+
 	ret = MessageBoxW(parent_hwnd, w_msg, w_title, MB_YESNOCANCEL | MB_ICONQUESTION);
 	switch(ret)
 	{

Modified: trunk/src/win32.h
===================================================================
--- trunk/src/win32.h	2007-12-07 14:13:05 UTC (rev 2093)
+++ trunk/src/win32.h	2007-12-07 16:31:38 UTC (rev 2094)
@@ -44,14 +44,14 @@
 /* Just a simple wrapper function to open a browser window */
 void win32_open_browser(const gchar *uri);
 
-/* Shows a file open dialog.
- * If allow_new_file is set, the file to be opened doesn't have to exist.
- * The selected file name is returned. */
-gchar *win32_show_project_open_dialog(const gchar *title, const gchar *initial_dir, gboolean allow_new_file);
+gchar *win32_show_project_open_dialog(GtkWidget *parent, const gchar *title,
+								      const gchar *initial_dir, gboolean allow_new_file,
+								      gboolean project_file_filter);
 
 /* Shows a folder selection dialog.
  * The selected folder name is returned. */
-gchar *win32_show_project_folder_dialog(const gchar *title, const gchar *initial_dir);
+gchar *win32_show_project_folder_dialog(GtkWidget *parent, const gchar *title,
+										const gchar *initial_dir);
 
 gint win32_check_write_permission(const gchar *dir);
 


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