From 99f7e639722ef0ee3f3181b7ad1b473615089d71 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 28 Apr 2018 11:59:17 -0500 Subject: [PATCH] Use GTK_MAJOR_VERSION macro instead of custom one. --- gtk/configure.ac | 1 - gtk/src/gtk_binding.cpp | 3 ++- gtk/src/gtk_display_driver_opengl.cpp | 2 +- gtk/src/gtk_display_driver_xv.cpp | 2 +- gtk/src/gtk_preferences.cpp | 9 +++++---- gtk/src/gtk_s9x.h | 2 +- gtk/src/gtk_s9xwindow.cpp | 23 ++++++++++++----------- gtk/src/gtk_s9xwindow.h | 2 +- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/gtk/configure.ac b/gtk/configure.ac index 9aeb56fe..3e45519b 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -199,7 +199,6 @@ GTK3_WARNING=no if test yes = "$with_gtk3" -a no = "$with_gtk2"; then GTK_VERSION="gtk+-3.0" GTK3_WARNING=yes - CFLAGS="$CFLAGS -DUSE_GTK3" else GTK_VERSION="gtk+-2.0 >= 2.16" fi diff --git a/gtk/src/gtk_binding.cpp b/gtk/src/gtk_binding.cpp index f89658d3..0df9a680 100644 --- a/gtk/src/gtk_binding.cpp +++ b/gtk/src/gtk_binding.cpp @@ -1,9 +1,10 @@ #include #include #include +#include #include #include -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 #include #endif diff --git a/gtk/src/gtk_display_driver_opengl.cpp b/gtk/src/gtk_display_driver_opengl.cpp index 896e71c3..b4168faa 100644 --- a/gtk/src/gtk_display_driver_opengl.cpp +++ b/gtk/src/gtk_display_driver_opengl.cpp @@ -770,7 +770,7 @@ S9xOpenGLDisplayDriver::create_window (int width, int height) XMapWindow (display, xwindow); XSync (display, False); -#if USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow); #else gdk_window = gdk_window_foreign_new (xwindow); diff --git a/gtk/src/gtk_display_driver_xv.cpp b/gtk/src/gtk_display_driver_xv.cpp index 3e423b65..cdc50177 100644 --- a/gtk/src/gtk_display_driver_xv.cpp +++ b/gtk/src/gtk_display_driver_xv.cpp @@ -76,7 +76,7 @@ S9xXVDisplayDriver::create_window (int width, int height) XMapWindow (display, xwindow); XSync (display, False); -#if USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 gdk_window = gdk_x11_window_foreign_new_for_display (gtk_widget_get_display (drawing_area), xwindow); #else gdk_window = gdk_window_foreign_new (xwindow); diff --git a/gtk/src/gtk_preferences.cpp b/gtk/src/gtk_preferences.cpp index 9831f3b0..a0a43152 100644 --- a/gtk/src/gtk_preferences.cpp +++ b/gtk/src/gtk_preferences.cpp @@ -2,9 +2,6 @@ #include #include #include -#ifdef USE_GTK3 -#include -#endif #include "gtk_preferences.h" #include "gtk_config.h" @@ -14,6 +11,10 @@ #include "gtk_display.h" #include "gtk_binding.h" +#if GTK_MAJOR_VERSION >= 3 +#include +#endif + #define SAME_GAME _("Same location as current game") gboolean @@ -565,7 +566,7 @@ event_about_clicked (GtkButton *widget, gpointer data) gtk_widget_hide (about_dialog->get_widget ("preferences_splash")); -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 GtkCssProvider *provider; GtkStyleContext *context; diff --git a/gtk/src/gtk_s9x.h b/gtk/src/gtk_s9x.h index f877b9ff..054422ac 100644 --- a/gtk/src/gtk_s9x.h +++ b/gtk/src/gtk_s9x.h @@ -36,7 +36,7 @@ extern Snes9xWindow *top_level; extern Snes9xConfig *gui_config; -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 #define GDK_COMPAT_WINDOW_XID(window) (gdk_x11_window_get_xid (window)) #else #define GDK_COMPAT_WINDOW_XID(window) (GDK_WINDOW_XWINDOW (window)) diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index d8b33db9..5a835e32 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -1,9 +1,6 @@ #include #include #include -#ifdef USE_GTK3 -#include -#endif #include #ifdef USE_XV @@ -24,6 +21,10 @@ #include "gtk_netplay.h" #endif +#if GTK_MAJOR_VERSION >= 3 +#include +#endif + static gboolean event_main_window_delete (GtkWidget *widget, GdkEvent *event, @@ -133,7 +134,7 @@ event_open_netplay (GtkWidget *widget, gpointer data) return TRUE; } -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 static gboolean event_drawingarea_draw (GtkWidget *widget, cairo_t *cr, @@ -147,9 +148,9 @@ event_drawingarea_draw (GtkWidget *widget, return FALSE; } -#endif -#ifndef USE_GTK3 +#else + static gboolean event_drawingarea_expose (GtkWidget *widget, GdkEventExpose *event, @@ -623,13 +624,13 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) : } drawing_area = GTK_DRAWING_AREA (get_widget ("drawingarea")); -#ifndef USE_GTK3 +#if GTK_MAJOR_VERSION < 3 gtk_widget_set_double_buffered (GTK_WIDGET (drawing_area), FALSE); #endif gtk_widget_realize (window); gtk_widget_realize (GTK_WIDGET (drawing_area)); -#ifndef USE_GTK3 +#if GTK_MAJOR_VERSION < 3 gdk_window_set_back_pixmap (gtk_widget_get_window (window), NULL, FALSE); gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (drawing_area)), NULL, FALSE); #endif @@ -646,7 +647,7 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) : gtk_widget_hide (get_widget ("sync_clients_separator")); #endif -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 g_signal_connect_data (drawing_area, "draw", G_CALLBACK (event_drawingarea_draw), @@ -1966,7 +1967,7 @@ Snes9xWindow::get_cairo (void) GtkWidget *drawing_area = GTK_WIDGET (this->drawing_area); -#ifndef USE_GTK3 +#if GTK_MAJOR_VERSION < 3 cr = gdk_cairo_create (gtk_widget_get_window (drawing_area)); #else GtkAllocation allocation; @@ -1988,7 +1989,7 @@ Snes9xWindow::release_cairo (void) { if (cairo_owned) { -#ifndef USE_GTK3 +#if GTK_MAJOR_VERSION < 3 cairo_destroy (cr); #else gdk_window_end_draw_frame (gtk_widget_get_window (GTK_WIDGET (drawing_area)), gdk_drawing_context); diff --git a/gtk/src/gtk_s9xwindow.h b/gtk/src/gtk_s9xwindow.h index 5fe8655b..9e692db4 100644 --- a/gtk/src/gtk_s9xwindow.h +++ b/gtk/src/gtk_s9xwindow.h @@ -83,7 +83,7 @@ class Snes9xWindow : public GtkBuilderWindow GtkWidget *recent_menu; cairo_t *cr; int cairo_owned; -#ifdef USE_GTK3 +#if GTK_MAJOR_VERSION >= 3 GdkDrawingContext *gdk_drawing_context; cairo_region_t *cairo_region; #endif