FindGTK2: Add tests for components and targets in gtk and gtkmm modules

This commit is contained in:
Daniele E. Domenichelli 2013-08-06 11:33:59 +02:00 committed by Brad King
parent 95fc47aa49
commit 7efef02df2
48 changed files with 1031 additions and 0 deletions

View File

@ -1070,6 +1070,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif()
endif()
find_package(GTK2 QUIET)
if(GTK2_FOUND)
add_subdirectory(FindGTK2)
endif()
add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/ExternalProject"

View File

@ -0,0 +1,317 @@
find_package(GTK2 COMPONENTS gtk glade gtkmm glademm QUIET)
# Test GTK2 components
if(GTK2_GTK_FOUND)
add_test(GTK2Components.gtk ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gtk"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Components/gtk"
${build_generator_args}
--build-target gtk-all-libs
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Components/gtk"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(GTK2_GTKMM_FOUND)
add_test(GTK2Components.gtkmm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gtkmm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Components/gtkmm"
${build_generator_args}
--build-target gtkmm-all-libs
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Components/gtkmm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
# Test GTK2 targets
if(TARGET GTK2::glib)
add_test(GTK2Targets.glib ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/glib"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/glib"
${build_generator_args}
--build-project glib
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/glib"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gobject)
add_test(GTK2Targets.gobject ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gobject"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gobject"
${build_generator_args}
--build-project gobject
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gobject"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gio)
add_test(GTK2Targets.gio ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gio"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gio"
${build_generator_args}
--build-project gio
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gio"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gmodule)
add_test(GTK2Targets.gmodule ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gmodule"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gmodule"
${build_generator_args}
--build-project gmodule
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gmodule"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gthread)
add_test(GTK2Targets.gthread ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gthread"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gthread"
${build_generator_args}
--build-project gthread
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gthread"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::atk)
add_test(GTK2Targets.atk ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/atk"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/atk"
${build_generator_args}
--build-project atk
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/atk"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gdk_pixbuf)
add_test(GTK2Targets.gdk_pixbuf ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gdk_pixbuf"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gdk_pixbuf"
${build_generator_args}
--build-project gdk_pixbuf
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gdk_pixbuf"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::cairo)
add_test(GTK2Targets.cairo ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/cairo"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/cairo"
${build_generator_args}
--build-project cairo
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/cairo"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::pango)
add_test(GTK2Targets.pango ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/pango"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pango"
${build_generator_args}
--build-project pango
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pango"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::pangocairo)
add_test(GTK2Targets.pangocairo ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/pangocairo"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangocairo"
${build_generator_args}
--build-project pangocairo
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangocairo"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::pangoxft)
add_test(GTK2Targets.pangoxft ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/pangoxft"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangoxft"
${build_generator_args}
--build-project pangoxft
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangoxft"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::pangoft2)
add_test(GTK2Targets.pangoft2 ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/pangoft2"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangoft2"
${build_generator_args}
--build-project pangoft2
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangoft2"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gdk)
add_test(GTK2Targets.gdk ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gdk"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gdk"
${build_generator_args}
--build-project gdk
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gdk"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gtk)
add_test(GTK2Targets.gtk ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gtk"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gtk"
${build_generator_args}
--build-project gtk
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gtk"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::sigc++)
add_test(GTK2Targets.sigc++ ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/sigc++"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/sigc++"
${build_generator_args}
--build-project sigc++
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/sigc++"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::glibmm)
add_test(GTK2Targets.glibmm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/glibmm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/glibmm"
${build_generator_args}
--build-project glibmm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/glibmm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::giomm)
add_test(GTK2Targets.giomm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/giomm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/giomm"
${build_generator_args}
--build-project giomm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/giomm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::atkmm)
add_test(GTK2Targets.atkmm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/atkmm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/atkmm"
${build_generator_args}
--build-project atkmm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/atkmm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::cairomm)
add_test(GTK2Targets.cairomm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/cairomm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/cairomm"
${build_generator_args}
--build-project cairomm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/cairomm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::pangomm)
add_test(GTK2Targets.pangomm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/pangomm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangomm"
${build_generator_args}
--build-project pangomm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/pangomm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gdkmm)
add_test(GTK2Targets.gdkmm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gdkmm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/GTK2Targets/gdkmm"
${build_generator_args}
--build-project gdkmm
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/GTK2Targets/gdkmm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()
if(TARGET GTK2::gtkmm)
add_test(GTK2Targets.gtkmm ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindGTK2/gtkmm"
"${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gtkmm"
${build_generator_args}
--build-target gtkmm-target
--build-exe-dir "${CMake_BINARY_DIR}/Tests/FindGTK2/GTK2Targets/gtkmm"
--force-new-ctest-process
--test-command ${CMAKE_CTEST_COMMAND} -V
)
endif()

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(atk C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(atk WIN32 main.c)
target_link_libraries(atk GTK2::atk)

View File

@ -0,0 +1,7 @@
#include <atk/atk.h>
int main(int argc, char *argv[])
{
const gchar *name = atk_get_toolkit_name();
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(atkmm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(atkmm WIN32 main.cpp)
target_link_libraries(atkmm GTK2::atkmm)

View File

@ -0,0 +1,8 @@
#include <atkmm.h>
#include <atkmm/init.h>
int main(int argc, char *argv[])
{
Atk::init();
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(cairo C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(cairo WIN32 main.c)
target_link_libraries(cairo GTK2::cairo)

View File

@ -0,0 +1,52 @@
/* Taken from http://cairographics.org/samples/ */
#include <cairo.h>
#include <math.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
char *filename;
if (argc != 2)
{
fprintf (stderr, "Usage: %s OUTPUT_FILENAME\n", argv[0]);
return 1;
}
filename = argv[1];
double xc = 128.0;
double yc = 128.0;
double radius = 100.0;
double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0); /* in radians */
cairo_surface_t *im = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xc * 2, yc * 2);
cairo_t *cr = cairo_create(im);
cairo_set_line_width (cr, 10.0);
cairo_arc (cr, xc, yc, radius, angle1, angle2);
cairo_stroke (cr);
/* draw helping lines */
cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
cairo_set_line_width (cr, 6.0);
cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI);
cairo_fill (cr);
cairo_arc (cr, xc, yc, radius, angle1, angle1);
cairo_line_to (cr, xc, yc);
cairo_arc (cr, xc, yc, radius, angle2, angle2);
cairo_line_to (cr, xc, yc);
cairo_stroke (cr);
cairo_status_t status = cairo_surface_write_to_png (im, filename);
cairo_surface_destroy (im);
if (status != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "Could not save png to '%s'\n", filename);
}
cairo_destroy(cr);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(cairomm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(cairomm WIN32 main.cpp)
target_link_libraries(cairomm GTK2::cairomm)

View File

@ -0,0 +1,62 @@
// Taken from http://cgit.freedesktop.org/cairomm/plain/examples/surfaces/image-surface.cc
/* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris,
* et. al.
*/
#if defined(_MSC_VER)
#define _USE_MATH_DEFINES
#endif
#include <string>
#include <iostream>
#include <cairommconfig.h>
#include <cairomm/context.h>
#include <cairomm/surface.h>
#include <cmath>
int main()
{
Cairo::RefPtr<Cairo::ImageSurface> surface =
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->save(); // save the state of the context
cr->set_source_rgb(0.86, 0.85, 0.47);
cr->paint(); // fill image with the color
cr->restore(); // color is back to black now
cr->save();
// draw a border around the image
cr->set_line_width(20.0); // make the line wider
cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height());
cr->stroke();
cr->set_source_rgba(0.0, 0.0, 0.0, 0.7);
// draw a circle in the center of the image
cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0,
surface->get_height() / 4.0, 0.0, 2.0 * M_PI);
cr->stroke();
// draw a diagonal line
cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0);
cr->line_to(surface->get_width() * 3.0 / 4.0, surface->get_height() * 3.0 / 4.0);
cr->stroke();
cr->restore();
#ifdef CAIRO_HAS_PNG_FUNCTIONS
std::string filename = "image.png";
surface->write_to_png(filename);
std::cout << "Wrote png file \"" << filename << "\"" << std::endl;
#else
std::cout << "You must compile cairo with PNG support for this example to work."
<< std::endl;
#endif
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gdk C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gdk WIN32 main.c)
target_link_libraries(gdk GTK2::gdk)

View File

@ -0,0 +1,7 @@
#include <gdk/gdk.h>
int main(int argc, char *argv[])
{
gdk_init(argc, argv);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gdk_pixbuf C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gdk_pixbuf WIN32 main.c)
target_link_libraries(gdk_pixbuf GTK2::gdk_pixbuf)

View File

@ -0,0 +1,10 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
int main(int argc, char *argv[])
{
const char *version = gdk_pixbuf_version;
const guint major = gdk_pixbuf_major_version;
const guint minor = gdk_pixbuf_minor_version;
const guint micro = gdk_pixbuf_micro_version;
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gdkmm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gdkmm WIN32 main.cpp)
target_link_libraries(gdkmm GTK2::gdkmm)

View File

@ -0,0 +1,7 @@
#include <gdkmm.h>
int main(int argc, char *argv[])
{
Gdk::Color red = Gdk::Color("red");
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gio C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gio WIN32 main.c)
target_link_libraries(gio GTK2::gio)

View File

@ -0,0 +1,8 @@
#include <gio/gio.h>
int main(int argc, char *argv[])
{
GFile *file = g_file_new_for_path("path");
g_object_unref(file);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(giomm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(giomm WIN32 main.cpp)
target_link_libraries(giomm GTK2::giomm)

View File

@ -0,0 +1,7 @@
#include <giomm.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gio::File> f = Gio::File::create_for_path("path");
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(glib C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(glib WIN32 main.c)
target_link_libraries(glib GTK2::glib)

View File

@ -0,0 +1,11 @@
#include <glib.h>
int main(int argc, char *argv[])
{
if (!g_file_test("file", G_FILE_TEST_EXISTS)) {
g_print("File not found. \n");
} else {
g_print("File found. \n");
}
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(glibmm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(glibmm WIN32 main.cpp)
target_link_libraries(glibmm GTK2::glibmm)

View File

@ -0,0 +1,7 @@
#include <glibmm/init.h>
int main(int, char**)
{
Glib::init();
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gmodule C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gmodule WIN32 main.c)
target_link_libraries(gmodule GTK2::gmodule)

View File

@ -0,0 +1,7 @@
#include <gmodule.h>
int main(int argc, char *argv[])
{
gboolean b = g_module_supported();
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gobject C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gobject WIN32 main.c)
target_link_libraries(gobject GTK2::gobject)

View File

@ -0,0 +1,72 @@
/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html */
#include <glib-object.h>
#define MAMAN_TYPE_BAR (maman_bar_get_type ())
#define MAMAN_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_BAR, MamanBar))
#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_BAR))
#define MAMAN_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE_BAR, MamanBarClass))
#define MAMAN_IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAMAN_TYPE_BAR))
#define MAMAN_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAMAN_TYPE_BAR, MamanBarClass))
typedef struct _MamanBar MamanBar;
typedef struct _MamanBarClass MamanBarClass;
struct _MamanBar
{
GObject parent_instance;
/* instance members */
};
struct _MamanBarClass
{
GObjectClass parent_class;
/* class members */
};
/* will create maman_bar_get_type and set maman_bar_parent_class */
G_DEFINE_TYPE (MamanBar, maman_bar, G_TYPE_OBJECT);
static GObject *
maman_bar_constructor (GType gtype,
guint n_properties,
GObjectConstructParam *properties)
{
GObject *obj;
{
/* Always chain up to the parent constructor */
obj = G_OBJECT_CLASS (maman_bar_parent_class)->constructor (gtype, n_properties, properties);
}
/* update the object state depending on constructor properties */
return obj;
}
static void
maman_bar_class_init (MamanBarClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->constructor = maman_bar_constructor;
}
static void
maman_bar_init (MamanBar *self)
{
/* initialize the object */
}
int
main(int argc, char *argv[])
{
MamanBar *bar = g_object_new (MAMAN_TYPE_BAR, NULL);
g_object_unref(bar);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(gthread C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gthread WIN32 main.c)
target_link_libraries(gthread GTK2::gthread)

View File

@ -0,0 +1,7 @@
#include <glib.h>
int main(int argc, char *argv[])
{
g_thread_init(NULL);
return 0;
}

View File

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 2.8)
project(gtk C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gtk WIN32 main.c)
target_link_libraries(gtk GTK2::gtk)
add_executable(gtk-all-libs WIN32 main.c)
target_link_libraries(gtk-all-libs ${GTK2_LIBRARIES})
target_include_directories(gtk-all-libs PRIVATE ${GTK2_INCLUDE_DIRS})

15
Tests/FindGTK2/gtk/main.c Normal file
View File

@ -0,0 +1,15 @@
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_main ();
return 0;
}

View File

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 2.8)
project(gtkmm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(gtkmm-target WIN32 main.cpp helloworld.cpp helloworld.h)
target_link_libraries(gtkmm-target GTK2::gtkmm)
add_executable(gtkmm-all-libs WIN32 main.cpp helloworld.cpp helloworld.h)
target_link_libraries(gtkmm-all-libs ${GTK2_LIBRARIES})
target_include_directories(gtkmm-all-libs PRIVATE ${GTK2_INCLUDE_DIRS})

View File

@ -0,0 +1,29 @@
#include "helloworld.h"
#include <iostream>
HelloWorld::HelloWorld()
: m_button("Hello World") // creates a new button with label "Hello World".
{
// Sets the border width of the window.
set_border_width(10);
// When the button receives the "clicked" signal, it will call the
// on_button_clicked() method defined below.
m_button.signal_clicked().connect(sigc::mem_fun(*this,
&HelloWorld::on_button_clicked));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}

View File

@ -0,0 +1,20 @@
#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
#define GTKMM_EXAMPLE_HELLOWORLD_H
#include <gtkmm.h>
class HelloWorld : public Gtk::Window
{
public:
HelloWorld();
virtual ~HelloWorld();
protected:
//Signal handlers:
void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
};
#endif // GTKMM_EXAMPLE_HELLOWORLD_H

View File

@ -0,0 +1,13 @@
#include <gtkmm.h>
#include "helloworld.h"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
HelloWorld helloworld;
//Shows the window and returns when it is closed.
Gtk::Main::run(helloworld);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(pango C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(pango WIN32 main.c)
target_link_libraries(pango GTK2::pango)

View File

@ -0,0 +1,7 @@
#include <pango/pango.h>
int main(int argc, char *argv[])
{
gboolean ret = pango_color_parse(NULL, "#ffffff");
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(pangocairo C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(pangocairo WIN32 main.c)
target_link_libraries(pangocairo GTK2::pangocairo m)

View File

@ -0,0 +1,72 @@
/* Taken from https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html */
#include <math.h>
#include <pango/pangocairo.h>
static void
draw_text (cairo_t *cr)
{
#define RADIUS 150
#define N_WORDS 10
#define FONT "Sans Bold 27"
PangoLayout *layout;
PangoFontDescription *desc;
int i;
/* Center coordinates on the middle of the region we are drawing
*/
cairo_translate (cr, RADIUS, RADIUS);
/* Create a PangoLayout, set the font and text */
layout = pango_cairo_create_layout (cr);
pango_layout_set_text (layout, "Text", -1);
desc = pango_font_description_from_string (FONT);
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
/* Draw the layout N_WORDS times in a circle */
for (i = 0; i < N_WORDS; i++)
{
int width, height;
double angle = (360. * i) / N_WORDS;
double red;
cairo_save (cr);
/* Gradient from red at angle == 60 to blue at angle == 240 */
red = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
cairo_set_source_rgb (cr, red, 0, 1.0 - red);
cairo_rotate (cr, angle * G_PI / 180.);
/* Inform Pango to re-layout the text with the new transformation */
pango_cairo_update_layout (cr, layout);
pango_layout_get_size (layout, &width, &height);
cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
pango_cairo_show_layout (cr, layout);
cairo_restore (cr);
}
/* free the layout object */
g_object_unref (layout);
}
int main (int argc, char **argv)
{
cairo_t *cr;
char *filename;
cairo_status_t status;
cairo_surface_t *surface;
if (argc != 2)
{
g_printerr ("Usage: cairosimple OUTPUT_FILENAME\n");
return 1;
}
filename = argv[1];
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
2 * RADIUS, 2 * RADIUS);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_paint (cr);
draw_text (cr);
cairo_destroy (cr);
status = cairo_surface_write_to_png (surface, filename);
cairo_surface_destroy (surface);
if (status != CAIRO_STATUS_SUCCESS)
{
g_printerr ("Could not save png to '%s'\n", filename);
return 1;
}
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(pangoft2 C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(pangoft2 WIN32 main.c)
target_link_libraries(pangoft2 GTK2::pangoft2)

View File

@ -0,0 +1,8 @@
#include <pango/pangoft2.h>
int main(int argc, char *argv[])
{
PangoFontMap* pfm = pango_ft2_font_map_new();
g_object_unref(pfm);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(pangomm CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(pangomm WIN32 main.cpp)
target_link_libraries(pangomm GTK2::pangomm)

View File

@ -0,0 +1,8 @@
#include <pangomm.h>
#include <pangomm/init.h>
int main(int argc, char *argv[])
{
Pango::init();
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(pangoxft C)
find_package(GTK2 COMPONENTS gtk REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(pangoxft WIN32 main.c)
target_link_libraries(pangoxft GTK2::pangoxft)

View File

@ -0,0 +1,7 @@
#include <pango/pangoxft.h>
int main(int argc, char *argv[])
{
pango_xft_get_context(NULL, 0);
return 0;
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
project(sigc++ CXX)
find_package(GTK2 COMPONENTS gtk gtkmm REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(sigc++ WIN32 main.cpp)
target_link_libraries(sigc++ GTK2::sigc++)

View File

@ -0,0 +1,30 @@
// Taken from https://developer.gnome.org/libsigc++-tutorial/stable/ch02.html
#include <sigc++/sigc++.h>
#include <iostream>
class AlienDetector
{
public:
AlienDetector() {}
void run() {}
sigc::signal<void> signal_detected;
};
void warn_people()
{
std::cout << "There are aliens in the carpark!" << std::endl;
}
int main()
{
AlienDetector mydetector;
mydetector.signal_detected.connect( sigc::ptr_fun(warn_people) );
mydetector.run();
return 0;
}