[gtk] Allow Gtk3 usage
parent
460046776b
commit
c9d2b4ac79
|
@ -58,6 +58,7 @@ option(ENABLE_TESTS "Enable unit tests? (Default: off)" OFF)
|
|||
option(ENABLE_DATA "Install data from content submodule? (Default: on)" ON)
|
||||
option(ENABLE_GLES "Build for OpenGL ES 2.0 instead of OpenGL 2.1 (Default: off)" OFF)
|
||||
option(USE_GTKGLEXT "Use libgtkglext1 for GTK2 frontend (Default: on)" ON)
|
||||
option(USE_GTK3 "Use Gtk3 in GTK2 frontend (Default: off)" OFF)
|
||||
|
||||
if(ENABLE_GLES)
|
||||
add_definitions(-DGL_ES)
|
||||
|
@ -65,6 +66,11 @@ if(ENABLE_GLES)
|
|||
set(USE_GTKGLEXT OFF)
|
||||
endif()
|
||||
|
||||
if(USE_GTK3)
|
||||
# Disable USE_GTKGLEXT if using Gtk+3
|
||||
set(USE_GTKGLEXT OFF)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type." FORCE)
|
||||
endif()
|
||||
|
|
|
@ -339,6 +339,8 @@ List of supported parameters (passed as `-DPARAMETER=VALUE`):
|
|||
| ENABLE_DATA | bool | OFF | Use CelestiaContent submodule for data
|
||||
| ENABLE_GLES | bool | OFF | Use OpenGL ES 2.0 in rendering code
|
||||
| NATIVE_OSX_APP | bool | OFF | Support native OSX data paths
|
||||
| USE_GTKGLEXT | bool | ON | Use libgtkglext1 in GTK2 frontend
|
||||
| USE_GTK3 | bool | OFF | Use Gtk3 instead of Gtk2 in GTK2 frontend
|
||||
|
||||
Notes:
|
||||
\* /usr/local on Unix-like systems, c:\Program Files or c:\Program Files (x86)
|
||||
|
@ -356,6 +358,11 @@ On Windows systems two additonal options are supported:
|
|||
64-bit Celestia. To build 32-bit Celestia it should be omitted.
|
||||
- `CMAKE_TOOLCHAIN_FILE` - location of vcpkg.cmake if vcpkg is used.
|
||||
|
||||
Please note that not all options are compatible:
|
||||
- `USE_GTKGLEXT` is not compatible with `ENABLE_GLES` and `USE_GTK3` and will
|
||||
be disabled if any of this is set.
|
||||
- `ENABLE_GLES` is not compatible with `ENABLE_GLUT` and with `ENABLE_QT` if
|
||||
your `glut` or Qt5 installation don't support OpenGL ES.
|
||||
|
||||
Executable files
|
||||
----------------
|
||||
|
|
|
@ -42,7 +42,11 @@ if (NOT USE_GTKGLEXT)
|
|||
set(GTK_HEADERS ${GTK_HEADERS} gtkegl.h)
|
||||
endif()
|
||||
|
||||
pkg_check_modules(GTK2 gtk+-2.0 REQUIRED)
|
||||
if (USE_GTK3)
|
||||
pkg_check_modules(GTK gtk+-3.0 REQUIRED)
|
||||
else()
|
||||
pkg_check_modules(GTK gtk+-2.0 REQUIRED)
|
||||
endif()
|
||||
pkg_check_modules(CAIRO cairo)
|
||||
|
||||
if (ENABLE_GLES)
|
||||
|
@ -59,8 +63,8 @@ add_executable(celestia-gtk ${GTK_SOURCES})
|
|||
add_dependencies(celestia-gtk celestia)
|
||||
cotire(celestia-gtk)
|
||||
|
||||
target_include_directories(celestia-gtk PRIVATE ${GTK2_INCLUDE_DIRS})
|
||||
target_link_libraries(celestia-gtk celestia ${GTK2_LIBRARIES})
|
||||
target_include_directories(celestia-gtk PRIVATE ${GTK_INCLUDE_DIRS})
|
||||
target_link_libraries(celestia-gtk celestia ${GTK_LIBRARIES})
|
||||
|
||||
if (CAIRO_FOUND)
|
||||
target_include_directories(celestia-gtk PRIVATE ${CAIRO_INCLUDE_DIRS})
|
||||
|
|
|
@ -28,7 +28,11 @@
|
|||
/* Declarations: Callbacks */
|
||||
static gint glarea_idle(AppData* app);
|
||||
static gint glarea_configure(GtkWidget* widget, GdkEventConfigure*, AppData* app);
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
static gint glarea_expose(GtkWidget* widget, GdkEventExpose* event, AppData* app);
|
||||
#else
|
||||
static gint glarea_draw(GtkWidget*, cairo_t*, AppData* app);
|
||||
#endif
|
||||
static gint glarea_motion_notify(GtkWidget*, GdkEventMotion* event, AppData* app);
|
||||
static gint glarea_mouse_scroll(GtkWidget*, GdkEventScroll* event, AppData* app);
|
||||
static gint glarea_button_press(GtkWidget*, GdkEventButton* event, AppData* app);
|
||||
|
@ -44,8 +48,13 @@ static bool handleSpecialKey(int key, int state, bool down, AppData* app);
|
|||
/* ENTRY: Initialize/Bind all glArea Callbacks */
|
||||
void initGLCallbacks(AppData* app)
|
||||
{
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
g_signal_connect(G_OBJECT(app->glArea), "expose_event",
|
||||
G_CALLBACK(glarea_expose), app);
|
||||
#else
|
||||
g_signal_connect(G_OBJECT(app->glArea), "draw",
|
||||
G_CALLBACK(glarea_draw), app);
|
||||
#endif
|
||||
g_signal_connect(G_OBJECT(app->glArea), "configure_event",
|
||||
G_CALLBACK(glarea_configure), app);
|
||||
g_signal_connect(G_OBJECT(app->glArea), "button_press_event",
|
||||
|
@ -102,6 +111,7 @@ static gint glarea_configure(GtkWidget* widget, GdkEventConfigure*, AppData* app
|
|||
}
|
||||
|
||||
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
/* CALLBACK: GL Function for event "expose_event" */
|
||||
static gint glarea_expose(GtkWidget*, GdkEventExpose* event, AppData* app)
|
||||
{
|
||||
|
@ -112,6 +122,13 @@ static gint glarea_expose(GtkWidget*, GdkEventExpose* event, AppData* app)
|
|||
/* Redraw -- draw checks are made in function */
|
||||
return glDrawFrame(app);
|
||||
}
|
||||
#else
|
||||
/* CALLBACK: GL Function for event "draw" */
|
||||
static gint glarea_draw(GtkWidget*, cairo_t*, AppData* app)
|
||||
{
|
||||
return glDrawFrame(app);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* CALLBACK: GL Function for event "motion_notify_event" */
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
using namespace std;
|
||||
|
||||
/* Declarations */
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
static gboolean splashExpose(GtkWidget* win, GdkEventExpose *event, SplashData* ss);
|
||||
#endif
|
||||
|
||||
|
||||
/* OBJECT: Overrides ProgressNotifier to receive feedback from core */
|
||||
|
@ -58,7 +60,7 @@ SplashData* splashStart(AppData* app, gboolean showSplash)
|
|||
gtk_window_set_position(GTK_WINDOW(ss->splash), GTK_WIN_POS_CENTER);
|
||||
gtk_widget_set_app_paintable(ss->splash, TRUE);
|
||||
|
||||
#ifdef CAIRO
|
||||
#if defined(CAIRO) && GTK_MAJOR_VERSION == 2
|
||||
/* Colormap Magic */
|
||||
GdkScreen* screen = gtk_widget_get_screen(ss->splash);
|
||||
GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
|
||||
|
@ -93,9 +95,11 @@ SplashData* splashStart(AppData* app, gboolean showSplash)
|
|||
gtk_fixed_put(GTK_FIXED(gf), ss->label, 40, allocation.height / 2 - 40);
|
||||
gtk_widget_show(ss->label);
|
||||
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
g_signal_connect (ss->splash, "expose_event",
|
||||
G_CALLBACK (splashExpose),
|
||||
ss);
|
||||
#endif
|
||||
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
|
@ -133,7 +137,7 @@ void splashSetText(SplashData* ss, const char* text)
|
|||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
}
|
||||
|
||||
|
||||
#if GTK_MAJOR_VERSION == 2
|
||||
/* CALLBACK: Called when the splash screen is exposed */
|
||||
static gboolean splashExpose(GtkWidget* win, GdkEventExpose *event, SplashData* ss)
|
||||
{
|
||||
|
@ -190,3 +194,4 @@ static gboolean splashExpose(GtkWidget* win, GdkEventExpose *event, SplashData*
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue