From f97fa61ab37fbc15e00078e640f1ac3eeb0eb4cd Mon Sep 17 00:00:00 2001 From: Tom Schoonjans Date: Thu, 19 Dec 2019 13:03:31 +0000 Subject: [PATCH] Add code to test runtime --- test/hello-world-gtk.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ test/hello-world-gtk.h | 22 +++++++++++++++++ test/main-gtk.cpp | 13 ++++++++++ 3 files changed, 86 insertions(+) create mode 100644 test/hello-world-gtk.cpp create mode 100644 test/hello-world-gtk.h create mode 100644 test/main-gtk.cpp diff --git a/test/hello-world-gtk.cpp b/test/hello-world-gtk.cpp new file mode 100644 index 00000000..dbef97b7 --- /dev/null +++ b/test/hello-world-gtk.cpp @@ -0,0 +1,51 @@ +#include "hello-world-gtk2.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +HelloWorld::HelloWorld() +: m_button("Hello World") // creates a new button with label "Hello World". +{ + + GType json_node_type = json_node_get_type(); + GType peas_type = peas_extension_get_type(); + GType soup_type = soup_message_get_type(); + + xmlpp::Document doc; + + Gsv::init(); + Glib::RefPtr language_manager = + Gsv::LanguageManager::create(); + std::vector langs = language_manager->get_language_ids (); + std::cout << "number of languages found: " << langs.size () << std::endl; + + + // 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; +} diff --git a/test/hello-world-gtk.h b/test/hello-world-gtk.h new file mode 100644 index 00000000..5aa2dc92 --- /dev/null +++ b/test/hello-world-gtk.h @@ -0,0 +1,22 @@ +#ifndef GTKMM_EXAMPLE_HELLOWORLD_H +#define GTKMM_EXAMPLE_HELLOWORLD_H + +#include +#include + +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 diff --git a/test/main-gtk.cpp b/test/main-gtk.cpp new file mode 100644 index 00000000..36d3c4b9 --- /dev/null +++ b/test/main-gtk.cpp @@ -0,0 +1,13 @@ +#include "hello-world-gtk2.h" +#include + +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; +}