Skip to content

Commit

Permalink
Added GTK+3 GUI.
Browse files Browse the repository at this point in the history
We'll keep the GTK+2 plugin for older machines, but GTK+3 gives us a more
modern look, Wayland support, etc.
  • Loading branch information
icculus committed Nov 3, 2018
1 parent 6f6178e commit 7cd4215
Show file tree
Hide file tree
Showing 5 changed files with 933 additions and 6 deletions.
49 changes: 43 additions & 6 deletions CMakeLists.txt
Expand Up @@ -5,6 +5,8 @@
# This file written by Ryan C. Gordon.


# !!! FIXME: modernize this file.


# The "BINARY SIZE +=" comments note about how much bulk, in kilobytes, a
# given option adds to the binary on x86 Linux (built with gcc 3.3.6
Expand Down Expand Up @@ -501,26 +503,61 @@ IF(NOT BEOS)
IF(NOT MACOSX)
FIND_PACKAGE(GTK2 COMPONENTS gtk)
IF(NOT GTK2_FOUND)
MESSAGE(STATUS "Can't find GTK+v2 headers/libraries. Can't build GTK+ GUI.")
MESSAGE(STATUS "Can't find GTK+v2 headers/libraries. Can't build GTK+-2.0 GUI.")
ELSE(NOT GTK2_FOUND)
# In order to reduce the GTK2 library dependencies at link time, we only link against 'gtk-x11-2.0'.
# This is more portable, as the dynamic linker/loader will take care of the other library dependencies at run time.
SET(LIBGTK_LINK_FLAGS "-lgtk-x11-2.0")
SET(LIBGTK2_LINK_FLAGS "-lgtk-x11-2.0")
OPTION(MOJOSETUP_GUI_GTKPLUS2 "Enable GTK+ 2.0 GUI" TRUE)
IF(MOJOSETUP_GUI_GTKPLUS2)
ADD_DEFINITIONS(-DSUPPORT_GUI_GTKPLUS2=1)
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
OPTION(MOJOSETUP_GUI_GTKPLUS2_STATIC "Statically link GTK+ GUI" FALSE)
OPTION(MOJOSETUP_GUI_GTKPLUS2_STATIC "Statically link GTK+ 2.0 GUI" FALSE)
IF(MOJOSETUP_GUI_GTKPLUS2_STATIC)
INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
ADD_DEFINITIONS(-DGUI_STATIC_LINK_GTKPLUS2=1)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_gtkplus2.c)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${LIBGTK_LINK_FLAGS})
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${LIBGTK2_LINK_FLAGS})
ELSE(MOJOSETUP_GUI_GTKPLUS2_STATIC)
MOJOSETUP_ADD_LIBRARY(mojosetupgui_gtkplus2 gui_gtkplus2.c)
TARGET_LINK_LIBRARIES(mojosetupgui_gtkplus2 ${LIBGTK_LINK_FLAGS})
TARGET_LINK_LIBRARIES(mojosetupgui_gtkplus2 ${LIBGTK2_LINK_FLAGS})
TARGET_INCLUDE_DIRECTORIES(mojosetupgui_gtkplus2 PUBLIC ${GTK2_INCLUDE_DIRS})
ENDIF(MOJOSETUP_GUI_GTKPLUS2_STATIC)
ENDIF(MOJOSETUP_GUI_GTKPLUS2)
ENDIF(NOT GTK2_FOUND)

FIND_PACKAGE(PkgConfig)
IF(NOT PkgConfig_FOUND)
MESSAGE(STATUS "Can't find pkgconfig. Can't build GTK+-3.0 GUI.")
ELSE(NOT PkgConfig_FOUND)
PKG_CHECK_MODULES(GTK3 gtk+-3.0)
IF(NOT GTK3_FOUND)
MESSAGE(STATUS "Can't find GTK+v3 headers/libraries. Can't build GTK+-3.0 GUI.")
ELSE(NOT GTK3_FOUND)
# In order to reduce the GTK3 library dependencies at link time, we only link against 'gtk-3.0'.
# This is more portable, as the dynamic linker/loader will take care of the other library dependencies at run time.
SET(LIBGTK3_LINK_FLAGS "-lgtk-3")
OPTION(MOJOSETUP_GUI_GTKPLUS3 "Enable GTK+ 3.0 GUI" TRUE)
IF(MOJOSETUP_GUI_GTKPLUS3)
ADD_DEFINITIONS(-DSUPPORT_GUI_GTKPLUS3=1)
OPTION(MOJOSETUP_GUI_GTKPLUS3_STATIC "Statically link GTK+ 3.0 GUI" FALSE)
IF(MOJOSETUP_GUI_GTKPLUS3_STATIC)
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
ADD_DEFINITIONS(-DGUI_STATIC_LINK_GTKPLUS3=1)
SET(OPTIONAL_SRCS ${OPTIONAL_SRCS} gui_gtkplus3.c)
SET(OPTIONAL_LIBS ${OPTIONAL_LIBS} ${LIBGTK3_LINK_FLAGS})
ELSE(MOJOSETUP_GUI_GTKPLUS3_STATIC)
MOJOSETUP_ADD_LIBRARY(mojosetupgui_gtkplus3 gui_gtkplus3.c)
TARGET_LINK_LIBRARIES(mojosetupgui_gtkplus3 ${LIBGTK3_LINK_FLAGS})
TARGET_INCLUDE_DIRECTORIES(mojosetupgui_gtkplus3 PUBLIC ${GTK3_INCLUDE_DIRS})
ENDIF(MOJOSETUP_GUI_GTKPLUS3_STATIC)
ENDIF(MOJOSETUP_GUI_GTKPLUS3)
ENDIF(NOT GTK3_FOUND)
ENDIF(NOT PkgConfig_FOUND)

IF(MOJOSETUP_GUI_GTKPLUS2_STATIC AND MOJOSETUP_GUI_GTKPLUS3_STATIC)
MESSAGE(FATAL_ERROR "You can't statically link both GTK+2 and GTK+3 support.")
ENDIF(MOJOSETUP_GUI_GTKPLUS2_STATIC AND MOJOSETUP_GUI_GTKPLUS3_STATIC)

ENDIF(NOT MACOSX)
ENDIF(NOT BEOS)
ENDIF(UNIX)
Expand Down
2 changes: 2 additions & 0 deletions examples/build-example.sh
Expand Up @@ -141,6 +141,8 @@ cmake \
-DMOJOSETUP_ARCHIVE_TAR_GZ=FALSE \
-DMOJOSETUP_GUI_GTKPLUS2=$FALSEIFMINIMAL \
-DMOJOSETUP_GUI_GTKPLUS2_STATIC=FALSE \
-DMOJOSETUP_GUI_GTKPLUS3=$FALSEIFMINIMAL \
-DMOJOSETUP_GUI_GTKPLUS3_STATIC=FALSE \
-DMOJOSETUP_GUI_NCURSES=$FALSEIFMINIMAL \
-DMOJOSETUP_GUI_NCURSES_STATIC=FALSE \
-DMOJOSETUP_GUI_STDIO=TRUE \
Expand Down
3 changes: 3 additions & 0 deletions gui.c
Expand Up @@ -31,6 +31,9 @@ static const MojoGuiEntryPoint staticGui[] =
#if GUI_STATIC_LINK_COCOA
MojoGuiPlugin_cocoa,
#endif
#if GUI_STATIC_LINK_GTKPLUS3
MojoGuiPlugin_gtkplus3,
#endif
#if GUI_STATIC_LINK_GTKPLUS2
MojoGuiPlugin_gtkplus2,
#endif
Expand Down
1 change: 1 addition & 0 deletions gui.h
Expand Up @@ -287,6 +287,7 @@ const MojoGui *MOJOGUI_ENTRY_POINT(int rev, const MojoSetupEntryPoints *e) \
const MojoGui *MojoGuiPlugin_stdio(int rev, const MojoSetupEntryPoints *e);
const MojoGui *MojoGuiPlugin_ncurses(int rev, const MojoSetupEntryPoints *e);
const MojoGui *MojoGuiPlugin_gtkplus2(int rev, const MojoSetupEntryPoints *e);
const MojoGui *MojoGuiPlugin_gtkplus3(int rev, const MojoSetupEntryPoints *e);
const MojoGui *MojoGuiPlugin_www(int rev, const MojoSetupEntryPoints *e);
const MojoGui *MojoGuiPlugin_cocoa(int rev, const MojoSetupEntryPoints *e);

Expand Down

0 comments on commit 7cd4215

Please sign in to comment.