Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 12 May 2024 20:00:13 UTC Commit: ee8f885acf554c494b00f0f3a80a3c17676838ca https://github.com/geany/geany/commit/ee8f885acf554c494b00f0f3a80a3c17676838...
Log Message: ----------- Remove usage of windows-native dialogs from ui_utils.c and win32.c/h
Modified Paths: -------------- src/ui_utils.c src/win32.c src/win32.h
Modified: src/ui_utils.c 16 lines changed, 0 insertions(+), 16 deletions(-) =================================================================== @@ -1964,7 +1964,6 @@ void ui_setup_open_button_callback(GtkWidget *open_btn, const gchar *title, }
-#ifndef G_OS_WIN32 static gchar *run_file_chooser(const gchar *title, GtkFileChooserAction action, const gchar *utf8_path) { @@ -2000,19 +1999,14 @@ static gchar *run_file_chooser(const gchar *title, GtkFileChooserAction action, gtk_widget_destroy(dialog); return ret_path; } -#endif
gchar *ui_get_project_directory(const gchar *path) { gchar *utf8_path; const gchar *title = _("Select Project Base Path");
-#ifdef G_OS_WIN32 - utf8_path = win32_show_folder_dialog(ui_widgets.prefs_dialog, title, path); -#else utf8_path = run_file_chooser(title, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, path); -#endif
return utf8_path; } @@ -2035,22 +2029,12 @@ static void ui_path_box_open_clicked(GtkButton *button, gpointer user_data)
if (action == GTK_FILE_CHOOSER_ACTION_OPEN) { -#ifdef G_OS_WIN32 - utf8_path = win32_show_file_dialog(GTK_WINDOW(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))); -#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 - utf8_path = win32_show_folder_dialog(ui_widgets.prefs_dialog, title, - gtk_entry_get_text(GTK_ENTRY(entry))); -#else utf8_path = run_file_chooser(title, action, path); -#endif g_free(path); }
Modified: src/win32.c 89 lines changed, 0 insertions(+), 89 deletions(-) =================================================================== @@ -181,95 +181,6 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p }
-/* Shows a folder selection dialog. - * initial_dir is expected in UTF-8 - * The selected folder name is returned. */ -gchar *win32_show_folder_dialog(GtkWidget *parent, const gchar *title, const gchar *initial_dir) -{ - BROWSEINFOW bi; - LPITEMIDLIST pidl; - gchar *result = NULL; - wchar_t fname[MAX_PATH]; - wchar_t w_title[512]; - - MultiByteToWideChar(CP_UTF8, 0, title, -1, w_title, G_N_ELEMENTS(w_title)); - - if (parent == NULL) - parent = main_widgets.window; - - memset(&bi, 0, sizeof bi); - bi.hwndOwner = GDK_WINDOW_HWND(gtk_widget_get_window(parent)); - bi.pidlRoot = NULL; - bi.lpszTitle = w_title; - bi.lpfn = BrowseCallbackProc; - bi.lParam = (LPARAM) get_dir_for_path(initial_dir); - bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_USENEWUI; - - pidl = SHBrowseForFolderW(&bi); - - /* convert the strange Windows folder list item something into an usual path string ;-) */ - if (pidl != NULL) - { - if (SHGetPathFromIDListW(pidl, fname)) - { - result = g_malloc0(MAX_PATH * 2); - WideCharToMultiByte(CP_UTF8, 0, fname, -1, result, MAX_PATH * 2, NULL, NULL); - } - CoTaskMemFree(pidl); - } - return result; -} - - -/* initial_dir can be NULL to use the current working directory. - * Returns: the selected filename */ -gchar *win32_show_file_dialog(GtkWindow *parent, const gchar *title, const gchar *initial_file) -{ - OPENFILENAMEW of; - gint retval; - gchar tmp[MAX_PATH]; - wchar_t w_file[MAX_PATH]; - wchar_t w_title[512]; - - w_file[0] = '\0'; - - if (initial_file != NULL) - MultiByteToWideChar(CP_UTF8, 0, initial_file, -1, w_file, G_N_ELEMENTS(w_file)); - - MultiByteToWideChar(CP_UTF8, 0, title, -1, w_title, G_N_ELEMENTS(w_title)); - - /* initialise file dialog info struct */ - memset(&of, 0, sizeof of); - of.lStructSize = sizeof of; - of.hwndOwner = GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(parent))); - - of.lpstrFile = w_file; - of.nMaxFile = 2048; - of.lpstrFileTitle = NULL; - of.lpstrTitle = w_title; - of.lpstrDefExt = L""; - of.Flags = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_ENABLESIZING; - of.lpfnHook = win32_dialog_explorer_hook_proc; - retval = GetOpenFileNameW(&of); - - if (! retval) - { - if (CommDlgExtendedError()) - { - gchar *error = g_strdup_printf( - "File dialog box error (%x)", (gint) CommDlgExtendedError()); - win32_message_dialog(NULL, GTK_MESSAGE_ERROR, error); - g_free(error); - } - return NULL; - } - - WideCharToMultiByte(CP_UTF8, 0, w_file, -1, tmp, sizeof(tmp), NULL, NULL); - - return g_strdup(tmp); -} - - /* Creates a native Windows message box of the given type and returns always TRUE * or FALSE representing th pressed Yes or No button. * If type is not GTK_MESSAGE_QUESTION, it returns always TRUE. */
Modified: src/win32.h 4 lines changed, 0 insertions(+), 4 deletions(-) =================================================================== @@ -30,15 +30,11 @@
G_BEGIN_DECLS
-gchar *win32_show_file_dialog(GtkWindow *parent, const gchar *title, const gchar *initial_dir); - gboolean win32_message_dialog(GtkWidget *parent, GtkMessageType type, const gchar *msg);
void win32_open_browser(const gchar *uri);
-gchar *win32_show_folder_dialog(GtkWidget *parent, const gchar *title, const gchar *initial_dir); - gint win32_check_write_permission(const gchar *dir);
void win32_init_debug_code(void);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).