Created
May 18, 2016 22:31
-
-
Save engelmarkus/2f27fe62550c56311e28539286948e17 to your computer and use it in GitHub Desktop.
Creating a window with gtkmm 3 and a glade description.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ -std=c++14 -o gtkmm-example gtkmm-example.cpp `pkg-config --cflags --libs gtkmm-3.0` | |
#include <memory> | |
#include <gtkmm.h> | |
class MainWindow : public Gtk::ApplicationWindow { | |
public: | |
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder) | |
: Gtk::ApplicationWindow(obj) | |
, builder{builder} | |
{ | |
} | |
virtual ~MainWindow() = default; | |
private: | |
Glib::RefPtr<Gtk::Builder> builder; | |
}; | |
int main(int argc, char* argv[]) { | |
auto app = Gtk::Application::create(argc, argv, "de.engelmarkus.example"); | |
auto builder = Gtk::Builder::create(); | |
builder->add_from_string( | |
"<interface>" | |
" <object class='GtkApplicationWindow' id='MainWindow'>" | |
" <property name='title'>The MainWindow</property>" | |
" </object>" | |
"</interface>" | |
); | |
MainWindow* wnd = nullptr; | |
builder->get_widget_derived("MainWindow", wnd); | |
auto r = app->run(*wnd); | |
delete wnd; | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment