Skip to content

Commit

Permalink
These changes introduce Gtk3 support into the highgui module.
Browse files Browse the repository at this point in the history
A new option WITH_GTK3 has been added to the cmake configure system to enable compilation under Gtk version 3.The flag HAVE_GTK3 is also introduced to select the new Gtk3 code in the source files. (Gtk2 is disbled when Gtk3 is selected).

window_gtk.cpp has been modified to remove obsolete (and deleted from libgtk 3) and introduce new Gtk3 code in its place when compiled for Gtk3.

To compile for Gtk2, disable WITH_GTK3 in cmake. To build for Gtk3 both WITH_GTK and WITH_GTK3 must be selected.
  • Loading branch information
Exocoder committed Oct 2, 2013
1 parent 97fc1e1 commit 81d6842
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_GSTREAMER_1_X "Include Gstreamer 1.x support" OFF)
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_GTK3 "Include GTK3 support" ON IF (UNIX AND WITH_GTK AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF IF (MSVC OR X86 OR X86_64) )
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
OCV_OPTION(WITH_JPEG "Include JPEG support" ON)
Expand Down Expand Up @@ -603,6 +604,7 @@ else()
endif()
else()
status(" GTK+ 2.x:" HAVE_GTK THEN "YES (ver ${ALIASOF_gtk+-2.0_VERSION})" ELSE NO)
status(" GTK+ 3.x:" HAVE_GTK3 THEN "YES (ver ${ALIASOF_gtk+-3.0_VERSION})" ELSE NO)
status(" GThread :" HAVE_GTHREAD THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})" ELSE NO)
status(" GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${ALIASOF_gtkglext-1.0_VERSION})" ELSE NO)
endif()
Expand Down
8 changes: 6 additions & 2 deletions cmake/OpenCVFindLibsGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ if(WITH_QT)
endif()

# --- GTK ---
ocv_clear_vars(HAVE_GTK HAVE_GTHREAD HAVE_GTKGLEXT)
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
if(WITH_GTK3)
CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
else()
CHECK_MODULE(gtk+-2.0 HAVE_GTK)
endif()
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
if(WITH_OPENGL)
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
Expand Down
3 changes: 3 additions & 0 deletions cmake/templates/cvconfig.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
/* GTK+ 2.x toolkit */
#cmakedefine HAVE_GTK

/* GTK+ 3.x toolkit */
#cmakedefine HAVE_GTK3

/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1

Expand Down
2 changes: 1 addition & 1 deletion modules/highgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ elseif(HAVE_QT)
endif()
elseif(HAVE_WIN32UI)
list(APPEND highgui_srcs src/window_w32.cpp)
elseif(HAVE_GTK)
elseif(HAVE_GTK OR HAVE_GTK3)
list(APPEND highgui_srcs src/window_gtk.cpp)
elseif(HAVE_CARBON)
list(APPEND highgui_srcs src/window_carbon.cpp)
Expand Down
11 changes: 11 additions & 0 deletions modules/highgui/src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
cvSetModeWindow_W32(name,prop_value);
#elif defined (HAVE_GTK)
cvSetModeWindow_GTK(name,prop_value);
#elif defined (HAVE_GTK3)
cvSetModeWindow_GTK(name,prop_value);
#elif defined (HAVE_CARBON)
cvSetModeWindow_CARBON(name,prop_value);
#elif defined (HAVE_COCOA)
Expand Down Expand Up @@ -100,6 +102,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetModeWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetModeWindow_GTK(name);
#elif defined (HAVE_GTK3)
return cvGetModeWindow_GTK(name);
#elif defined (HAVE_CARBON)
return cvGetModeWindow_CARBON(name);
#elif defined (HAVE_COCOA)
Expand All @@ -117,6 +121,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetPropWindowAutoSize_W32(name);
#elif defined (HAVE_GTK)
return cvGetPropWindowAutoSize_GTK(name);
#elif defined (HAVE_GTK3)
return cvGetPropWindowAutoSize_GTK(name);
#else
return -1;
#endif
Expand All @@ -130,6 +136,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetRatioWindow_W32(name);
#elif defined (HAVE_GTK)
return cvGetRatioWindow_GTK(name);
#elif defined (HAVE_GTK3)
return cvGetRatioWindow_GTK(name);
#else
return -1;
#endif
Expand All @@ -143,6 +151,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetOpenGlProp_W32(name);
#elif defined (HAVE_GTK)
return cvGetOpenGlProp_GTK(name);
#elif defined (HAVE_GTK3)
return cvGetOpenGlProp_GTK(name);
#else
return -1;
#endif
Expand Down Expand Up @@ -472,6 +482,7 @@ int cv::createButton(const String&, ButtonCallback, void*, int , bool )

#if defined(HAVE_WIN32UI) // see window_w32.cpp
#elif defined (HAVE_GTK) // see window_gtk.cpp
#elif defined (HAVE_GTK3) // see window_gtk.cpp
#elif defined (HAVE_COCOA) // see window_carbon.cpp
#elif defined (HAVE_CARBON)
#elif defined (HAVE_QT) //YV see window_QT.cpp
Expand Down
Loading

0 comments on commit 81d6842

Please sign in to comment.