From 802318399981e6e3e5a2831d11b0e2b003a7e020 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 30 May 2020 13:31:52 -0700 Subject: [PATCH] Switch over the null plugins dialog code to use wxWidgets instead of gtk on Linux. (#3420) * Make the other null plugins use the same functions, and convert PS2Eext.h to use wx. --- common/include/PS2Eext.h | 43 +++--------------------------- plugins/GSnull/Linux/Config.cpp | 7 ++--- plugins/PadNull/Linux/Config.cpp | 7 ++--- plugins/PadNull/Linux/PadLinux.cpp | 1 + plugins/SPU2null/Linux/Config.cpp | 7 ++--- 5 files changed, 16 insertions(+), 49 deletions(-) diff --git a/common/include/PS2Eext.h b/common/include/PS2Eext.h index d7d5be7339..2666fca96e 100644 --- a/common/include/PS2Eext.h +++ b/common/include/PS2Eext.h @@ -32,8 +32,8 @@ #elif defined(__unix__) -#include #include +#include #define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type @@ -203,7 +203,6 @@ struct PluginConf }; #if defined(__unix__) - static void SysMessage(const char *fmt, ...) { va_list list; @@ -216,44 +215,8 @@ static void SysMessage(const char *fmt, ...) if (msg[strlen(msg) - 1] == '\n') msg[strlen(msg) - 1] = 0; - GtkWidget *dialog; - dialog = gtk_message_dialog_new(NULL, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", msg); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); -} - -static void __forceinline set_logging(GtkToggleButton *check, int &log) -{ - log = gtk_toggle_button_get_active(check); -} - -static void __forceinline PluginNullConfigure(std::string desc, int &log) -{ - GtkWidget *dialog, *label, *check_box; - - /* Create the widgets */ - dialog = gtk_dialog_new(); - label = gtk_label_new(desc.c_str()); - check_box = gtk_check_button_new_with_label("Logging"); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box), (log != 0)); - - /* Ensure that the dialog box is destroyed when the user clicks ok, and that we get the check box value. */ - g_signal_connect(check_box, "toggled", G_CALLBACK(set_logging), &log); - - /* Add all our widgets, and show everything we've added to the dialog. */ - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), check_box); - gtk_dialog_add_button(GTK_DIALOG(dialog), "Ok", 0); - - gtk_widget_show_all(dialog); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); + wxMessageDialog dialog(nullptr, msg, "Info", wxOK); + dialog.ShowModal(); } #define ENTRY_POINT /* We don't need no stinkin' entry point! */ diff --git a/plugins/GSnull/Linux/Config.cpp b/plugins/GSnull/Linux/Config.cpp index 5688e50bbc..e56398307d 100644 --- a/plugins/GSnull/Linux/Config.cpp +++ b/plugins/GSnull/Linux/Config.cpp @@ -21,6 +21,7 @@ using namespace std; #include "GS.h" #include "Config.h" +#include "null/config.inl" extern string s_strIniPath; PluginConf Ini; @@ -33,7 +34,7 @@ void CFGabout() void CFGconfigure() { LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + ConfigureLogging(); SaveConfig(); } @@ -42,7 +43,7 @@ void LoadConfig() const std::string iniFile(s_strIniPath + "/GSNull.ini"); if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); SaveConfig(); //save and return return; } @@ -56,7 +57,7 @@ void SaveConfig() const std::string iniFile(s_strIniPath + "/GSNull.ini"); if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); return; } diff --git a/plugins/PadNull/Linux/Config.cpp b/plugins/PadNull/Linux/Config.cpp index 471a21061b..e50a87f835 100644 --- a/plugins/PadNull/Linux/Config.cpp +++ b/plugins/PadNull/Linux/Config.cpp @@ -19,6 +19,7 @@ #include #include "Pad.h" +#include "null/config.inl" extern std::string s_strIniPath; PluginConf Ini; @@ -33,7 +34,7 @@ EXPORT_C_(void) PADconfigure() { LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + ConfigureLogging(); SaveConfig(); } @@ -42,7 +43,7 @@ void LoadConfig() const std::string iniFile(s_strIniPath + "/Padnull.ini"); if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); SaveConfig(); //save and return return; } @@ -56,7 +57,7 @@ void SaveConfig() const std::string iniFile(s_strIniPath + "/Padnull.ini"); if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); return; } diff --git a/plugins/PadNull/Linux/PadLinux.cpp b/plugins/PadNull/Linux/PadLinux.cpp index bfa6d5c126..78b48d85b7 100644 --- a/plugins/PadNull/Linux/PadLinux.cpp +++ b/plugins/PadNull/Linux/PadLinux.cpp @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include +#include #include "PadLinux.h" Display *GSdsp; diff --git a/plugins/SPU2null/Linux/Config.cpp b/plugins/SPU2null/Linux/Config.cpp index dc32de69ab..ced2c5da85 100644 --- a/plugins/SPU2null/Linux/Config.cpp +++ b/plugins/SPU2null/Linux/Config.cpp @@ -18,6 +18,7 @@ #include "Config.h" #include "SPU2.h" +#include "null/config.inl" using namespace std; extern string s_strIniPath; @@ -27,7 +28,7 @@ EXPORT_C_(void) SPU2configure() { LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); + ConfigureLogging(); SaveConfig(); } @@ -43,7 +44,7 @@ void LoadConfig() const std::string iniFile(s_strIniPath + "/Spu2null.ini"); if (!Ini.Open(iniFile, READ_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); SaveConfig(); //save and return return; } @@ -57,7 +58,7 @@ void SaveConfig() const std::string iniFile(s_strIniPath + "/Spu2null.ini"); if (!Ini.Open(iniFile, WRITE_FILE)) { - printf("failed to open %s\n", iniFile.c_str()); + g_plugin_log.WriteLn("failed to open %s", iniFile.c_str()); return; }