Fix wrong file filters in project-related file dialogs on Windows.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2094 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
80532b616d
commit
0573e49653
@ -1,3 +1,9 @@
|
||||
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,
|
||||
|
@ -71,8 +71,8 @@ typedef struct _PropertyDialogElements
|
||||
|
||||
|
||||
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 @@ void project_new()
|
||||
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 @@ void project_open()
|
||||
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 @@ static void run_dialog(GtkWidget *dialog, GtkWidget *entry)
|
||||
#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 @@ static void on_file_save_button_clicked(GtkButton *button, GtkWidget *entry)
|
||||
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 @@ static void on_file_open_button_clicked(GtkButton *button, GtkWidget *entry)
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -1340,7 +1340,7 @@ static void ui_path_box_open_clicked(GtkButton *button, gpointer user_data)
|
||||
_("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)));
|
||||
|
33
src/win32.c
33
src/win32.c
@ -96,20 +96,20 @@ static gchar *win32_get_file_filters()
|
||||
}
|
||||
|
||||
|
||||
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 @@ INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
|
||||
|
||||
/* 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 @@ gchar *win32_show_project_folder_dialog(const gchar *title, const gchar *initial
|
||||
|
||||
/* 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 @@ gchar *win32_show_project_open_dialog(const gchar *title, const gchar *initial_d
|
||||
#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 @@ gint win32_message_dialog_unsaved(const gchar *msg)
|
||||
|
||||
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)
|
||||
{
|
||||
|
10
src/win32.h
10
src/win32.h
@ -44,14 +44,14 @@ gint win32_message_dialog_unsaved(const gchar *msg);
|
||||
/* 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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user