diff --git a/common/include/Utilities/gtkGuiTools.h b/common/include/Utilities/gtkGuiTools.h
new file mode 100644
index 0000000000..e50520a894
--- /dev/null
+++ b/common/include/Utilities/gtkGuiTools.h
@@ -0,0 +1,133 @@
+/* PCSX2 - PS2 Emulator for PCs
+ * Copyright (C) 2002-2010 PCSX2 Dev Team
+ *
+ * PCSX2 is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with PCSX2.
+ * If not, see .
+ */
+
+#pragma once
+
+// ----------------------------------------------------------------------------
+// gtkGuiTools.h
+//
+// This file is meant to contain utility classes for users of GTK, for purposes
+// of GTK 2/3 compatibility, and other helpful routines to help avoid repeatedly
+// implementing the same code.
+//
+// ----------------------------------------------------------------------------
+
+#include
+#include
+
+// They've gotten rid of the GtkHBox and GtkVBox in GTK3 in favor of using the
+// more general GtkBox and supplying an orientation. While this is probably a
+// move in the right direction, for compatability, it's easier to define our
+// own hbox and vbox routines that invoke the old or the new version, depending
+// on what it's built for.
+//
+
+static GtkWidget *ps_gtk_hbox_new(int padding = 5)
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_hbox_new(false, padding);
+#else
+ return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding);
+#endif
+}
+
+static GtkWidget *ps_gtk_vbox_new(int padding = 5)
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_vbox_new(false, padding);
+#else
+ return gtk_box_new(GTK_ORIENTATION_VERTICAL, padding);
+#endif
+}
+
+// Similarly, GtkHScale and GtkVScale make way for GtkScale.
+static GtkWidget *ps_gtk_hscale_new_with_range(double g_min, double g_max, int g_step = 5)
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_hscale_new_with_range(g_min, g_max, g_step);
+#else
+ return gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, g_min, g_max, g_step);
+#endif
+}
+
+static GtkWidget *ps_gtk_vscale_new_with_range(double g_min, double g_max, int g_step = 5)
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_vscale_new_with_range(g_min, g_max, g_step);
+#else
+ return gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, g_min, g_max, g_step);
+#endif
+}
+
+// And so on and so forth...
+static GtkWidget *ps_gtk_hseparator_new()
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_hseparator_new();
+#else
+ return gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
+#endif
+}
+
+static GtkWidget *ps_gtk_vseparator_new()
+{
+#if GTK_MAJOR_VERSION < 3
+ return gtk_vseparator_new();
+#else
+ return gtk_separator_new(GTK_ORIENTATION_VERTICAL);
+#endif
+}
+
+// These two routines have been rewritten over and over. May as well include a copy.
+// Renaming so as not to interfere with existing versions.
+static void pcsx2_message(const char *fmt, ...)
+{
+ va_list list;
+ char msg[512];
+
+ va_start(list, fmt);
+ vsprintf(msg, fmt, list);
+ va_end(list);
+
+ 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 pcsx2_message(const wchar_t *fmt, ...)
+{
+ va_list list;
+ va_start(list, fmt);
+ wxString msg;
+ msg.PrintfV(fmt, list);
+ va_end(list);
+
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "%s", msg.ToUTF8().data());
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+}
diff --git a/common/src/Utilities/CMakeLists.txt b/common/src/Utilities/CMakeLists.txt
index 380089bddf..8dcee537f3 100644
--- a/common/src/Utilities/CMakeLists.txt
+++ b/common/src/Utilities/CMakeLists.txt
@@ -55,6 +55,7 @@ set(UtilitiesHeaders
../../include/Utilities/EventSource.h
../../include/Utilities/Exceptions.h
../../include/Utilities/FixedPointTypes.h
+ ../../include/Utilities/gtkGuiTools.h
../../include/Utilities/General.h
../../include/Utilities/MakeUnique.h
../../include/Utilities/MemcpyFast.h
diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp
index ce7059ac36..bc365e2608 100644
--- a/plugins/spu2-x/src/Linux/Config.cpp
+++ b/plugins/spu2-x/src/Linux/Config.cpp
@@ -333,12 +333,12 @@ void DisplayDialog()
latency_label = gtk_label_new("Latency:");
const int min_latency = SynchMode == 0 ? LATENCY_MIN_TIMESTRETCH : LATENCY_MIN;
- latency_slide = spu2x_gtk_hscale_new_with_range(min_latency, LATENCY_MAX, 5);
+ latency_slide = ps_gtk_hscale_new_with_range(min_latency, LATENCY_MAX, 5);
gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS);
volume_label = gtk_label_new("Volume:");
- volume_slide = spu2x_gtk_hscale_new_with_range(0, 100, 5);
+ volume_slide = ps_gtk_hscale_new_with_range(0, 100, 5);
gtk_range_set_value(GTK_RANGE(volume_slide), FinalVolume * 100);
sync_label = gtk_label_new("Synchronization Mode:");
@@ -350,17 +350,17 @@ void DisplayDialog()
advanced_button = gtk_button_new_with_label("Advanced...");
- main_box = spu2x_gtk_hbox_new(5);
+ main_box = ps_gtk_hbox_new(5);
- mixing_box = spu2x_gtk_vbox_new(5);
+ mixing_box = ps_gtk_vbox_new(5);
mixing_frame = gtk_frame_new("Mixing Settings:");
gtk_container_add(GTK_CONTAINER(mixing_frame), mixing_box);
- output_box = spu2x_gtk_vbox_new(5);
+ output_box = ps_gtk_vbox_new(5);
output_frame = gtk_frame_new("Output Settings:");
- debug_box = spu2x_gtk_vbox_new(5);
+ debug_box = ps_gtk_vbox_new(5);
debug_frame = gtk_frame_new("Debug Settings:");
gtk_container_add(GTK_CONTAINER(debug_box), debug_check);
diff --git a/plugins/spu2-x/src/Linux/ConfigDebug.cpp b/plugins/spu2-x/src/Linux/ConfigDebug.cpp
index 47f71a0ca4..ea98e2068c 100644
--- a/plugins/spu2-x/src/Linux/ConfigDebug.cpp
+++ b/plugins/spu2-x/src/Linux/ConfigDebug.cpp
@@ -180,10 +180,10 @@ void DisplayDialog()
"OK", GTK_RESPONSE_ACCEPT,
NULL);
- main_box = spu2x_gtk_hbox_new(5);
+ main_box = ps_gtk_hbox_new(5);
// Message Section
- msg_box = spu2x_gtk_vbox_new(5);
+ msg_box = ps_gtk_vbox_new(5);
msg_console_check = gtk_check_button_new_with_label("Show In Console");
msg_key_check = gtk_check_button_new_with_label("KeyOn/Off Events");
@@ -213,7 +213,7 @@ void DisplayDialog()
gtk_container_add(GTK_CONTAINER(msg_frame), msg_box);
// Log Section
- log_box = spu2x_gtk_vbox_new(5);
+ log_box = ps_gtk_vbox_new(5);
log_access_check = gtk_check_button_new_with_label("Log Register/DMA Actions");
log_dma_check = gtk_check_button_new_with_label("Log DMA Writes");
@@ -231,7 +231,7 @@ void DisplayDialog()
gtk_container_add(GTK_CONTAINER(log_frame), log_box);
// Dump Section
- dump_box = spu2x_gtk_vbox_new(5);
+ dump_box = ps_gtk_vbox_new(5);
dump_core_check = gtk_check_button_new_with_label("Dump Core and Voice State");
dump_mem_check = gtk_check_button_new_with_label("Dump Memory Contents");
diff --git a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp
index 195e5189eb..4d3d8cc4b1 100644
--- a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp
+++ b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp
@@ -107,18 +107,18 @@ void DisplayDialog()
default_button = gtk_button_new_with_label("Reset to Defaults");
seq_label = gtk_label_new("Sequence Length");
- seq_slide = spu2x_gtk_hscale_new_with_range(SequenceLen_Min, SequenceLen_Max, 2);
+ seq_slide = ps_gtk_hscale_new_with_range(SequenceLen_Min, SequenceLen_Max, 2);
gtk_range_set_value(GTK_RANGE(seq_slide), SequenceLenMS);
seek_label = gtk_label_new("Seek Window Size");
- seek_slide = spu2x_gtk_hscale_new_with_range(SeekWindow_Min, SeekWindow_Max, 2);
+ seek_slide = ps_gtk_hscale_new_with_range(SeekWindow_Min, SeekWindow_Max, 2);
gtk_range_set_value(GTK_RANGE(seek_slide), SeekWindowMS);
over_label = gtk_label_new("Overlap");
- over_slide = spu2x_gtk_hscale_new_with_range(Overlap_Min, Overlap_Max, 2);
+ over_slide = ps_gtk_hscale_new_with_range(Overlap_Min, Overlap_Max, 2);
gtk_range_set_value(GTK_RANGE(over_slide), OverlapMS);
- adv_box = spu2x_gtk_vbox_new(5);
+ adv_box = ps_gtk_vbox_new(5);
gtk_box_pack_start(GTK_BOX(adv_box), main_label, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(adv_box), default_button, TRUE, TRUE, 5);
diff --git a/plugins/spu2-x/src/Linux/Dialogs.cpp b/plugins/spu2-x/src/Linux/Dialogs.cpp
index dff79589b6..981ffe97e4 100644
--- a/plugins/spu2-x/src/Linux/Dialogs.cpp
+++ b/plugins/spu2-x/src/Linux/Dialogs.cpp
@@ -64,42 +64,6 @@ void SysMessage(const wchar_t *fmt, ...)
}
#endif
-GtkWidget *spu2x_gtk_hbox_new(int padding = 5)
-{
-#if GTK_MAJOR_VERSION < 3
- return gtk_hbox_new(false, padding);
-#else
- return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding);
-#endif
-}
-
-GtkWidget *spu2x_gtk_vbox_new(int padding = 5)
-{
-#if GTK_MAJOR_VERSION < 3
- return gtk_vbox_new(false, padding);
-#else
- return gtk_box_new(GTK_ORIENTATION_VERTICAL, padding);
-#endif
-}
-
-GtkWidget *spu2x_gtk_hscale_new_with_range(double g_min, double g_max, int g_step = 5)
-{
-#if GTK_MAJOR_VERSION < 3
- return gtk_hscale_new_with_range(g_min, g_max, g_step);
-#else
- return gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, g_min, g_max, g_step);
-#endif
-}
-
-GtkWidget *spu2x_gtk_vscale_new_with_range(double g_min, double g_max, int g_step = 5)
-{
-#if GTK_MAJOR_VERSION < 3
- return gtk_vscale_new_with_range(g_min, g_max, g_step);
-#else
- return gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, g_min, g_max, g_step);
-#endif
-}
-
void DspUpdate()
{
}
diff --git a/plugins/spu2-x/src/Linux/Dialogs.h b/plugins/spu2-x/src/Linux/Dialogs.h
index 1dabd7739e..ab87818342 100644
--- a/plugins/spu2-x/src/Linux/Dialogs.h
+++ b/plugins/spu2-x/src/Linux/Dialogs.h
@@ -20,6 +20,7 @@
#include "../Global.h"
#include "../Config.h"
+#include "Utilities/gtkGuiTools.h"
namespace DebugConfig
{
@@ -42,11 +43,4 @@ extern void CfgReadStr(const wchar_t *Section, const wchar_t *Name, wxString &Da
extern int CfgReadInt(const wchar_t *Section, const wchar_t *Name, int Default);
extern float CfgReadFloat(const wchar_t *Section, const wchar_t *Name, float Default);
-#if defined(__unix__)
-extern GtkWidget *spu2x_gtk_hbox_new(int padding);
-extern GtkWidget *spu2x_gtk_vbox_new(int padding);
-extern GtkWidget *spu2x_gtk_hscale_new_with_range(double g_min, double g_max, int g_step);
-extern GtkWidget *spu2x_gtk_vscale_new_with_range(double g_min, double g_max, int g_step);
-#endif
-
#endif