Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Wed, 12 Jun 2024 12:10:03 UTC Commit: 8f00b04cefd88630e1860e100ffab3e8dd81f2a2 https://github.com/geany/geany/commit/8f00b04cefd88630e1860e100ffab3e8dd81f2...
Log Message: ----------- Drop win32_message_dialog()s
There doesn't seem to be much need for these and they look a little different from the rest of Geany (or a lot different when Windows uses the dark theme and Geany the light one). Before removing the native win32 file open dialogs, win32_message_dialog() was called from the native file dialog implementations so its presence was necessary but I think normal GTK dialogs will serve their purpose well.
Modified Paths: -------------- src/dialogs.c src/win32.c src/win32.h
Modified: src/dialogs.c 35 lines changed, 1 insertions(+), 34 deletions(-) =================================================================== @@ -38,7 +38,6 @@ #include "support.h" #include "utils.h" #include "ui_utils.h" -#include "win32.h"
#include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> @@ -712,7 +711,6 @@ gboolean dialogs_show_save_as(void) }
-#ifndef G_OS_WIN32 static void show_msgbox_dialog(GtkWidget *dialog, GtkMessageType type, GtkWindow *parent) { const gchar *title; @@ -738,13 +736,10 @@ static void show_msgbox_dialog(GtkWidget *dialog, GtkMessageType type, GtkWindow gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } -#endif
/** * Shows a message box of the type @a type with @a text. - * On Unix-like systems a GTK message dialog box is shown, on Win32 systems a native Windows - * message dialog box is shown. * * @param type A @c GtkMessageType, e.g. @c GTK_MESSAGE_INFO, @c GTK_MESSAGE_WARNING, * @c GTK_MESSAGE_QUESTION, @c GTK_MESSAGE_ERROR. @@ -754,9 +749,7 @@ static void show_msgbox_dialog(GtkWidget *dialog, GtkMessageType type, GtkWindow GEANY_API_SYMBOL void dialogs_show_msgbox(GtkMessageType type, const gchar *text, ...) { -#ifndef G_OS_WIN32 GtkWidget *dialog; -#endif gchar *string; va_list args; GtkWindow *parent = (main_status.main_window_realized) ? GTK_WINDOW(main_widgets.window) : NULL; @@ -765,32 +758,22 @@ void dialogs_show_msgbox(GtkMessageType type, const gchar *text, ...) string = g_strdup_vprintf(text, args); va_end(args);
-#ifdef G_OS_WIN32 - win32_message_dialog(GTK_WIDGET(parent), type, string); -#else dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_OK, "%s", string); show_msgbox_dialog(dialog, type, parent); -#endif g_free(string); }
void dialogs_show_msgbox_with_secondary(GtkMessageType type, const gchar *text, const gchar *secondary) { GtkWindow *parent = (main_status.main_window_realized) ? GTK_WINDOW(main_widgets.window) : NULL; -#ifdef G_OS_WIN32 - /* put the two strings together because Windows message boxes don't support secondary texts */ - gchar *string = g_strconcat(text, "\n", secondary, NULL); - win32_message_dialog(GTK_WIDGET(parent), type, string); - g_free(string); -#else GtkWidget *dialog; + dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_OK, "%s", text); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", secondary); show_msgbox_dialog(dialog, type, parent); -#endif }
@@ -1317,20 +1300,6 @@ static gint show_prompt(GtkWidget *parent, response_3 = GTK_RESPONSE_YES; }
-#ifdef G_OS_WIN32 - /* our native dialog code doesn't support custom buttons */ - if (utils_str_equal(btn_3, GTK_STOCK_YES) && - utils_str_equal(btn_2, GTK_STOCK_NO) && btn_1 == NULL) - { - gchar *string = (extra_text == NULL) ? g_strdup(question_text) : - g_strconcat(question_text, "\n\n", extra_text, NULL); - - ret = win32_message_dialog(parent, GTK_MESSAGE_QUESTION, string); - ret = ret ? response_3 : response_2; - g_free(string); - return ret; - } -#endif if (parent == NULL && main_status.main_window_realized) parent = main_widgets.window;
@@ -1363,8 +1332,6 @@ static gint show_prompt(GtkWidget *parent,
/** * Shows a question message box with @a text and Yes/No buttons. - * On Unix-like systems a GTK message dialog box is shown, on Win32 systems a native Windows - * message dialog box is shown. * * @param text Printf()-style format string. * @param ... Arguments for the @a text format string.
Modified: src/win32.c 61 lines changed, 0 insertions(+), 61 deletions(-) =================================================================== @@ -60,67 +60,6 @@ #include <gdk/gdkwin32.h>
-/* 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. */ -gboolean win32_message_dialog(GtkWidget *parent, GtkMessageType type, const gchar *msg) -{ - gboolean ret = TRUE; - gint rc; - guint t; - const gchar *title; - HWND parent_hwnd = NULL; - static wchar_t w_msg[512]; - static wchar_t w_title[512]; - - switch (type) - { - case GTK_MESSAGE_ERROR: - { - t = MB_OK | MB_ICONERROR; - title = _("Error"); - break; - } - case GTK_MESSAGE_QUESTION: - { - t = MB_YESNO | MB_ICONQUESTION; - title = _("Question"); - break; - } - case GTK_MESSAGE_WARNING: - { - t = MB_OK | MB_ICONWARNING; - title = _("Warning"); - break; - } - default: - { - t = MB_OK | MB_ICONINFORMATION; - title = _("Information"); - break; - } - } - - /* convert the Unicode chars to wide chars */ - /** TODO test if LANG == C then possibly skip conversion => g_win32_getlocale() */ - MultiByteToWideChar(CP_UTF8, 0, msg, -1, w_msg, G_N_ELEMENTS(w_msg)); - MultiByteToWideChar(CP_UTF8, 0, title, -1, w_title, G_N_ELEMENTS(w_title)); - - if (parent != NULL) - parent_hwnd = GDK_WINDOW_HWND(gtk_widget_get_window(parent)); - else if (main_widgets.window != NULL) - parent_hwnd = GDK_WINDOW_HWND(gtk_widget_get_window(main_widgets.window)); - - /* display the message box */ - rc = MessageBoxW(parent_hwnd, w_msg, w_title, t); - - if (type == GTK_MESSAGE_QUESTION && rc != IDYES) - ret = FALSE; - - return ret; -} - - /* Little wrapper for _waccess(), returns errno or 0 if there was no error */ gint win32_check_write_permission(const gchar *dir) {
Modified: src/win32.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -30,8 +30,6 @@
G_BEGIN_DECLS
-gboolean win32_message_dialog(GtkWidget *parent, GtkMessageType type, const gchar *msg); - void win32_open_browser(const gchar *uri);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).