[gtkmm-documentation] Use Gtk::Application::make_window_and_run()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Use Gtk::Application::make_window_and_run()
- Date: Fri, 23 Oct 2020 10:43:20 +0000 (UTC)
commit 47a36622d64e45fc89c7807d14004915a8f20bac
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Oct 23 12:40:16 2020 +0200
Use Gtk::Application::make_window_and_run()
and other necessary changes after recent changes in gtk and gtkmm.
examples/book/actionbar/main.cc | 4 +--
examples/book/aspectframe/main.cc | 4 +--
examples/book/assistant/main.cc | 4 +--
examples/book/base/base.cc | 17 ++++++++---
examples/book/box/main.cc | 6 ++--
examples/book/builder/basic/main.cc | 35 +++++++++++++++++-----
examples/book/builder/derived/main.cc | 34 ++++++++++++++++-----
examples/book/buttons/button/main.cc | 4 +--
examples/book/buttons/checkbutton/main.cc | 4 +--
examples/book/buttons/filechooserbutton/main.cc | 4 +--
examples/book/buttons/radiobutton/main.cc | 4 +--
examples/book/buttons/scalebutton/main.cc | 4 +--
examples/book/buttons/togglebutton/main.cc | 4 +--
examples/book/buttons/volumebutton/main.cc | 4 +--
examples/book/clipboard/ideal/main.cc | 4 +--
examples/book/clipboard/simple/main.cc | 4 +--
examples/book/combobox/complex/main.cc | 4 +--
examples/book/combobox/entry_complex/main.cc | 4 +--
examples/book/combobox/entry_text/main.cc | 4 +--
examples/book/combobox/text/main.cc | 4 +--
examples/book/custom/custom_container/main.cc | 4 +--
examples/book/custom/custom_widget/main.cc | 4 +--
examples/book/dialogs/aboutdialog/examplewindow.cc | 24 ---------------
examples/book/dialogs/aboutdialog/examplewindow.h | 1 -
examples/book/dialogs/aboutdialog/main.cc | 4 +--
examples/book/dialogs/colorchooserdialog/main.cc | 4 +--
examples/book/dialogs/filechooserdialog/main.cc | 4 +--
examples/book/dialogs/filechoosernative/main.cc | 4 +--
examples/book/dialogs/fontchooserdialog/main.cc | 4 +--
examples/book/dialogs/messagedialog/main.cc | 4 +--
examples/book/dialogs/simple/main.cc | 4 +--
examples/book/drag_and_drop/main.cc | 6 ++--
examples/book/drawingarea/arcs/main.cc | 23 +++++++++-----
examples/book/drawingarea/clock/main.cc | 23 +++++++++-----
examples/book/drawingarea/curve/main.cc | 23 +++++++++-----
examples/book/drawingarea/image/main.cc | 25 +++++++++++-----
examples/book/drawingarea/joins/main.cc | 23 +++++++++-----
examples/book/drawingarea/pango_text/main.cc | 23 +++++++++-----
examples/book/drawingarea/simple/main.cc | 23 +++++++++-----
examples/book/drawingarea/thin_lines/main.cc | 4 +--
examples/book/entry/completion/main.cc | 4 +--
examples/book/entry/icon/main.cc | 4 +--
examples/book/entry/progress/main.cc | 4 +--
examples/book/entry/simple/main.cc | 4 +--
examples/book/expander/main.cc | 4 +--
examples/book/flowbox/main.cc | 4 +--
examples/book/frame/main.cc | 4 +--
examples/book/grid/main.cc | 4 +--
examples/book/headerbar/main.cc | 5 +---
examples/book/helloworld/main.cc | 4 +--
examples/book/helloworld2/main.cc | 4 +--
examples/book/iconview/main.cc | 4 +--
examples/book/idle/main.cc | 3 +-
examples/book/infobar/main.cc | 3 +-
examples/book/keyboard_events/propagation/main.cc | 4 +--
examples/book/keyboard_events/simple/main.cc | 4 +--
examples/book/label/main.cc | 4 +--
examples/book/listbox/main.cc | 4 +--
examples/book/listmodel/main.cc | 4 +--
examples/book/menus/popup/main.cc | 4 +--
examples/book/menus_and_toolbars/examplewindow.cc | 2 +-
examples/book/menus_and_toolbars/main.cc | 6 ++--
examples/book/multithread/main.cc | 6 ++--
examples/book/notebook/main.cc | 4 +--
examples/book/paned/main.cc | 4 +--
examples/book/popover/main.cc | 4 +--
examples/book/printing/advanced/main.cc | 4 +--
examples/book/printing/simple/main.cc | 4 +--
examples/book/progressbar/main.cc | 4 +--
examples/book/range_widgets/main.cc | 4 +--
examples/book/recent_files/examplewindow.cc | 2 +-
examples/book/recent_files/main.cc | 4 +--
examples/book/revealer/main.cc | 5 +---
examples/book/scrolledwindow/main.cc | 4 +--
examples/book/searchbar/main.cc | 5 +---
examples/book/spinbutton/main.cc | 4 +--
examples/book/textview/main.cc | 4 +--
examples/book/timeout/main.cc | 3 +-
examples/book/toolbar/main.cc | 4 +--
examples/book/tooltips/main.cc | 4 +--
examples/book/treeview/combo_renderer/main.cc | 4 +--
examples/book/treeview/custom_treemodel/main.cc | 4 +--
examples/book/treeview/drag_and_drop/main.cc | 4 +--
examples/book/treeview/editable_cells/main.cc | 4 +--
examples/book/treeview/filter/main.cc | 4 +--
examples/book/treeview/filter_modify/main.cc | 4 +--
examples/book/treeview/list/main.cc | 4 +--
examples/book/treeview/listviewtext/main.cc | 4 +--
examples/book/treeview/modelsort/main.cc | 4 +--
examples/book/treeview/popup/main.cc | 4 +--
examples/book/treeview/tree/main.cc | 4 +--
examples/book/update_ui/main.cc | 4 +--
examples/others/arrow/arrow.cc | 3 +-
examples/others/calendar/calendar.cc | 4 +--
.../cellrenderercustom/cellrenderertoggle.cc | 5 +---
examples/others/cellrenderercustom/testpopup.cc | 5 +---
examples/others/dnd/main.cc | 3 +-
examples/others/exception/exceptiontest.cc | 29 ++++++++++--------
examples/others/idle/idle.cc | 4 +--
examples/others/statusbar/statusbar.cc | 4 +--
examples/others/tictactoe/ttt_test.cc | 26 +++++++++-------
examples/others/treemodelcustom/main.cc | 3 +-
examples/others/window/wheelbarrow.cc | 4 +--
103 files changed, 308 insertions(+), 380 deletions(-)
---
diff --git a/examples/book/actionbar/main.cc b/examples/book/actionbar/main.cc
index 958c829..f202c7f 100644
--- a/examples/book/actionbar/main.cc
+++ b/examples/book/actionbar/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.actionbar");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/aspectframe/main.cc b/examples/book/aspectframe/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/aspectframe/main.cc
+++ b/examples/book/aspectframe/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/assistant/main.cc b/examples/book/assistant/main.cc
index 65dcb23..baa03e1 100644
--- a/examples/book/assistant/main.cc
+++ b/examples/book/assistant/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/base/base.cc b/examples/book/base/base.cc
index 61c48d8..f2b149c 100644
--- a/examples/book/base/base.cc
+++ b/examples/book/base/base.cc
@@ -1,11 +1,20 @@
#include <gtkmm.h>
+class MyWindow : public Gtk::Window
+{
+public:
+ MyWindow();
+};
+
+MyWindow::MyWindow()
+{
+ set_title("Basic application");
+ set_default_size(200, 200);
+}
+
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.examples.base");
- Gtk::Window window;
- window.set_default_size(200, 200);
-
- return app->run(window, argc, argv);
+ return app->make_window_and_run<MyWindow>(argc, argv);
}
diff --git a/examples/book/box/main.cc b/examples/book/box/main.cc
index 1d6e195..9c7e4e2 100644
--- a/examples/book/box/main.cc
+++ b/examples/book/box/main.cc
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
#if GTK_APPLICATION_RECEIVES_COMMAND_LINE_ARGUMENTS
// The Gio::Application::Flags::HANDLES_COMMAND_LINE flag and the
// on_command_line() signal handler are not necessary. This program is simpler
- // without them, and with argc = 1 in the call to Gtk::Application::run().
+ // without them, and with argc = 1 in the call to Gtk::Application::make_window_and_run().
// They are included to show a program with Gio::Application::Flags::HANDLES_COMMAND_LINE.
// Gio::Application::Flags::NON_UNIQUE makes it possible to run several instances of
// this application simultaneously.
@@ -71,6 +71,6 @@ int main(int argc, char *argv[])
auto app = Gtk::Application::create("org.gtkmm.example", Gio::Application::Flags::NON_UNIQUE);
#endif
- ExampleWindow window(std::atoi(argv[1]));
- return app->run(window, argc1, argv); // Shows the window and returns when it is closed.
+ // Shows the window and returns when it is closed.
+ return app->make_window_and_run<ExampleWindow>(argc1, argv, std::atoi(argv[1]));
}
diff --git a/examples/book/builder/basic/main.cc b/examples/book/builder/basic/main.cc
index b840b42..ec782be 100644
--- a/examples/book/builder/basic/main.cc
+++ b/examples/book/builder/basic/main.cc
@@ -7,13 +7,21 @@ static
void on_button_clicked()
{
if(pDialog)
- pDialog->hide(); //hide() will cause main::run() to end.
+ pDialog->hide(); //hide() will cause Gtk::Application::run() to end.
}
-int main (int argc, char **argv)
+int main(int argc, char** argv)
{
auto app = Gtk::Application::create("org.gtkmm.example");
+ // The application must be registered when the builder adds widgets from
+ // the basic.glade file.
+ // Calling Gio::Application::register_application() explicitly is necessary
+ // in this example because the .glade file is loaded in the main() function.
+ // There are better ways. See other examples, such as examples/book/buildapp/,
+ // and examples/book/menus/ and examples/book/menus_and_toolbars/.
+ app->register_application();
+
//Load the GtkBuilder file and instantiate its widgets:
auto refBuilder = Gtk::Builder::create();
try
@@ -38,7 +46,9 @@ int main (int argc, char **argv)
//Get the GtkBuilder-instantiated Dialog:
pDialog = refBuilder->get_widget<Gtk::Dialog>("DialogBasic");
- if(pDialog)
+
+ int status = 1;
+ if (pDialog)
{
//Get the GtkBuilder-instantiated Button, and connect a signal handler:
auto pButton = refBuilder->get_widget<Gtk::Button>("quit_button");
@@ -47,10 +57,21 @@ int main (int argc, char **argv)
pButton->signal_clicked().connect( sigc::ptr_fun(on_button_clicked) );
}
- app->run(*pDialog, argc, argv);
- }
+ // All widgets must be deleted before app->run() returns.
+ // This is yet another reason why you should usually not use the builder
+ // in the main() function.
+ pDialog->signal_hide().connect([&refBuilder] ()
+ {
+ delete pDialog;
+ refBuilder.reset();
+ });
- delete pDialog;
+ // We can call add_window() before run() because we have registered the
+ // application. (run() registers the application, if it has not been done.)
+ app->add_window(*pDialog);
+ pDialog->show();
+ status = app->run(argc, argv);
+ }
- return 0;
+ return status;
}
diff --git a/examples/book/builder/derived/main.cc b/examples/book/builder/derived/main.cc
index a8f1970..317402e 100644
--- a/examples/book/builder/derived/main.cc
+++ b/examples/book/builder/derived/main.cc
@@ -21,7 +21,7 @@
// Not really used anywhere, but force an instance to be created.
DerivedButton* my_globally_accessible_button = nullptr;
-int main (int argc, char **argv)
+int main(int argc, char** argv)
{
bool show_icon = false;
bool is_glad = true;
@@ -44,6 +44,14 @@ int main (int argc, char **argv)
auto app = Gtk::Application::create("org.gtkmm.example");
+ // The application must be registered when the builder adds widgets from
+ // the derived.glade file.
+ // Calling Gio::Application::register_application() explicitly is necessary
+ // in this example because the .glade file is loaded in the main() function.
+ // There are better ways. See other examples, such as examples/book/buildapp/,
+ // and examples/book/menus/ and examples/book/menus_and_toolbars/.
+ app->register_application();
+
// Create a dummy instance before the call to refBuilder->add_from_file().
// This creation registers DerivedButton's class in the GType system.
my_globally_accessible_button = new DerivedButton();
@@ -76,13 +84,25 @@ int main (int argc, char **argv)
pDialog = Gtk::Builder::get_widget_derived<DerivedDialog>(refBuilder, "DialogDerived", is_glad);
else
pDialog = Gtk::Builder::get_widget_derived<DerivedDialog>(refBuilder, "DialogDerived");
- if(pDialog)
+
+ int status = 1;
+ if (pDialog)
{
- //Start:
- app->run(*pDialog, argc1, argv);
- }
+ // All widgets must be deleted before app->run() returns.
+ // This is yet another reason why you should usually not use the builder
+ // in the main() function.
+ pDialog->signal_hide().connect([pDialog, &refBuilder] ()
+ {
+ delete pDialog;
+ refBuilder.reset();
+ });
- delete pDialog;
+ // We can call add_window() before run() because we have registered the
+ // application. (run() registers the application, if it has not been done.)
+ app->add_window(*pDialog);
+ pDialog->show();
+ status = app->run(argc1, argv);
+ }
- return 0;
+ return status;
}
diff --git a/examples/book/buttons/button/main.cc b/examples/book/buttons/button/main.cc
index 0f8fa08..dd8e666 100644
--- a/examples/book/buttons/button/main.cc
+++ b/examples/book/buttons/button/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- Buttons buttons;
-
//Shows the window and returns when it is closed.
- return app->run(buttons, argc, argv);
+ return app->make_window_and_run<Buttons>(argc, argv);
}
diff --git a/examples/book/buttons/checkbutton/main.cc b/examples/book/buttons/checkbutton/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/buttons/checkbutton/main.cc
+++ b/examples/book/buttons/checkbutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/buttons/filechooserbutton/main.cc b/examples/book/buttons/filechooserbutton/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/buttons/filechooserbutton/main.cc
+++ b/examples/book/buttons/filechooserbutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/buttons/radiobutton/main.cc b/examples/book/buttons/radiobutton/main.cc
index 62bda28..be10908 100644
--- a/examples/book/buttons/radiobutton/main.cc
+++ b/examples/book/buttons/radiobutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- RadioButtons buttons;
-
//Shows the window and returns when it is closed.
- return app->run(buttons, argc, argv);
+ return app->make_window_and_run<RadioButtons>(argc, argv);
}
diff --git a/examples/book/buttons/scalebutton/main.cc b/examples/book/buttons/scalebutton/main.cc
index dfce2f4..5437c7f 100644
--- a/examples/book/buttons/scalebutton/main.cc
+++ b/examples/book/buttons/scalebutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow exampleWindow;
-
//Shows the window and returns when it is closed.
- return app->run(exampleWindow, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/buttons/togglebutton/main.cc b/examples/book/buttons/togglebutton/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/buttons/togglebutton/main.cc
+++ b/examples/book/buttons/togglebutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/buttons/volumebutton/main.cc b/examples/book/buttons/volumebutton/main.cc
index dfce2f4..5437c7f 100644
--- a/examples/book/buttons/volumebutton/main.cc
+++ b/examples/book/buttons/volumebutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow exampleWindow;
-
//Shows the window and returns when it is closed.
- return app->run(exampleWindow, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/clipboard/ideal/main.cc b/examples/book/clipboard/ideal/main.cc
index 2b01891..8397650 100644
--- a/examples/book/clipboard/ideal/main.cc
+++ b/examples/book/clipboard/ideal/main.cc
@@ -24,8 +24,6 @@ int main(int argc, char *argv[])
auto app = Gtk::Application::create(
"org.gtkmm.example", Gio::Application::Flags::NON_UNIQUE);
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/clipboard/simple/main.cc b/examples/book/clipboard/simple/main.cc
index 2b01891..8397650 100644
--- a/examples/book/clipboard/simple/main.cc
+++ b/examples/book/clipboard/simple/main.cc
@@ -24,8 +24,6 @@ int main(int argc, char *argv[])
auto app = Gtk::Application::create(
"org.gtkmm.example", Gio::Application::Flags::NON_UNIQUE);
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/combobox/complex/main.cc b/examples/book/combobox/complex/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/combobox/complex/main.cc
+++ b/examples/book/combobox/complex/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/combobox/entry_complex/main.cc b/examples/book/combobox/entry_complex/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/combobox/entry_complex/main.cc
+++ b/examples/book/combobox/entry_complex/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/combobox/entry_text/main.cc b/examples/book/combobox/entry_text/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/combobox/entry_text/main.cc
+++ b/examples/book/combobox/entry_text/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/combobox/text/main.cc b/examples/book/combobox/text/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/combobox/text/main.cc
+++ b/examples/book/combobox/text/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/custom/custom_container/main.cc b/examples/book/custom/custom_container/main.cc
index 55629a6..605a62b 100644
--- a/examples/book/custom/custom_container/main.cc
+++ b/examples/book/custom/custom_container/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/custom/custom_widget/main.cc b/examples/book/custom/custom_widget/main.cc
index 55629a6..605a62b 100644
--- a/examples/book/custom/custom_widget/main.cc
+++ b/examples/book/custom/custom_widget/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/aboutdialog/examplewindow.cc
b/examples/book/dialogs/aboutdialog/examplewindow.cc
index b69374a..408ff5b 100644
--- a/examples/book/dialogs/aboutdialog/examplewindow.cc
+++ b/examples/book/dialogs/aboutdialog/examplewindow.cc
@@ -61,9 +61,6 @@ ExampleWindow::ExampleWindow()
list_authors.push_back("AN Other");
m_Dialog.set_authors(list_authors);
- m_Dialog.signal_response().connect(
- sigc::mem_fun(*this, &ExampleWindow::on_about_dialog_response) );
-
m_Button.grab_focus();
}
@@ -71,27 +68,6 @@ ExampleWindow::~ExampleWindow()
{
}
-void ExampleWindow::on_about_dialog_response(int response_id)
-{
- std::cout << response_id
- << ", close=" << Gtk::ResponseType::CLOSE
- << ", cancel=" << Gtk::ResponseType::CANCEL
- << ", delete_event=" << Gtk::ResponseType::DELETE_EVENT
- << std::endl;
-
- switch (response_id)
- {
- case Gtk::ResponseType::CLOSE:
- case Gtk::ResponseType::CANCEL:
- case Gtk::ResponseType::DELETE_EVENT:
- m_Dialog.hide();
- break;
- default:
- std::cout << "Unexpected response!" << std::endl;
- break;
- }
-}
-
void ExampleWindow::on_button_clicked()
{
m_Dialog.show();
diff --git a/examples/book/dialogs/aboutdialog/examplewindow.h
b/examples/book/dialogs/aboutdialog/examplewindow.h
index 2faf4d2..020335b 100644
--- a/examples/book/dialogs/aboutdialog/examplewindow.h
+++ b/examples/book/dialogs/aboutdialog/examplewindow.h
@@ -28,7 +28,6 @@ public:
protected:
//Signal handlers:
void on_button_clicked();
- void on_about_dialog_response(int response_id);
//Child widgets:
Gtk::Box m_VBox;
diff --git a/examples/book/dialogs/aboutdialog/main.cc b/examples/book/dialogs/aboutdialog/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/aboutdialog/main.cc
+++ b/examples/book/dialogs/aboutdialog/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/colorchooserdialog/main.cc
b/examples/book/dialogs/colorchooserdialog/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/colorchooserdialog/main.cc
+++ b/examples/book/dialogs/colorchooserdialog/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/filechooserdialog/main.cc b/examples/book/dialogs/filechooserdialog/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/filechooserdialog/main.cc
+++ b/examples/book/dialogs/filechooserdialog/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/filechoosernative/main.cc b/examples/book/dialogs/filechoosernative/main.cc
index 629c67a..8487b2f 100644
--- a/examples/book/dialogs/filechoosernative/main.cc
+++ b/examples/book/dialogs/filechoosernative/main.cc
@@ -20,8 +20,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/fontchooserdialog/main.cc b/examples/book/dialogs/fontchooserdialog/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/fontchooserdialog/main.cc
+++ b/examples/book/dialogs/fontchooserdialog/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/messagedialog/main.cc b/examples/book/dialogs/messagedialog/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/messagedialog/main.cc
+++ b/examples/book/dialogs/messagedialog/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/dialogs/simple/main.cc b/examples/book/dialogs/simple/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/dialogs/simple/main.cc
+++ b/examples/book/dialogs/simple/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drag_and_drop/main.cc b/examples/book/drag_and_drop/main.cc
index f2fd645..a8e57d7 100644
--- a/examples/book/drag_and_drop/main.cc
+++ b/examples/book/drag_and_drop/main.cc
@@ -17,12 +17,10 @@
#include "dndwindow.h"
#include <gtkmm/application.h>
-int main (int argc, char *argv[])
+int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- DnDWindow dndWindow;
-
//Shows the window and returns when it is closed.
- return app->run(dndWindow, argc, argv);
+ return app->make_window_and_run<DnDWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/arcs/main.cc b/examples/book/drawingarea/arcs/main.cc
index be3741a..f0f7266 100644
--- a/examples/book/drawingarea/arcs/main.cc
+++ b/examples/book/drawingarea/arcs/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
+
+protected:
+ MyArea m_area;
+};
- Gtk::Window win;
- win.set_title("DrawingArea");
+ExampleWindow::ExampleWindow()
+{
+ set_title("DrawingArea");
+ set_child(m_area);
+}
- MyArea area;
- win.set_child(area);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/clock/main.cc b/examples/book/drawingarea/clock/main.cc
index 07b3255..97189eb 100644
--- a/examples/book/drawingarea/clock/main.cc
+++ b/examples/book/drawingarea/clock/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
+
+protected:
+ Clock m_clock;
+};
- Gtk::Window win;
- win.set_title("Cairomm Clock");
+ExampleWindow::ExampleWindow()
+{
+ set_title("Cairomm Clock");
+ set_child(m_clock);
+}
- Clock c;
- win.set_child(c);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/curve/main.cc b/examples/book/drawingarea/curve/main.cc
index be3741a..f0f7266 100644
--- a/examples/book/drawingarea/curve/main.cc
+++ b/examples/book/drawingarea/curve/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
+
+protected:
+ MyArea m_area;
+};
- Gtk::Window win;
- win.set_title("DrawingArea");
+ExampleWindow::ExampleWindow()
+{
+ set_title("DrawingArea");
+ set_child(m_area);
+}
- MyArea area;
- win.set_child(area);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/image/main.cc b/examples/book/drawingarea/image/main.cc
index e134b27..9617aca 100644
--- a/examples/book/drawingarea/image/main.cc
+++ b/examples/book/drawingarea/image/main.cc
@@ -18,16 +18,25 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
- Gtk::Window win;
- win.set_title("DrawingArea");
- win.set_default_size(300, 200);
+protected:
+ MyArea m_area;
+};
+
+ExampleWindow::ExampleWindow()
+{
+ set_title("DrawingArea");
+ set_default_size(300, 200);
+ set_child(m_area);
+}
- MyArea area;
- win.set_child(area);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/joins/main.cc b/examples/book/drawingarea/joins/main.cc
index be3741a..f0f7266 100644
--- a/examples/book/drawingarea/joins/main.cc
+++ b/examples/book/drawingarea/joins/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
+
+protected:
+ MyArea m_area;
+};
- Gtk::Window win;
- win.set_title("DrawingArea");
+ExampleWindow::ExampleWindow()
+{
+ set_title("DrawingArea");
+ set_child(m_area);
+}
- MyArea area;
- win.set_child(area);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/pango_text/main.cc b/examples/book/drawingarea/pango_text/main.cc
index 9fac47e..96b9b85 100644
--- a/examples/book/drawingarea/pango_text/main.cc
+++ b/examples/book/drawingarea/pango_text/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char* argv[])
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
- Gtk::Window window;
- window.set_title("Drawing text example");
+protected:
+ MyArea m_area;
+};
+
+ExampleWindow::ExampleWindow()
+{
+ set_title("Drawing text example");
+ set_child(m_area);
+}
- MyArea area;
- window.set_child(area);
+int main(int argc, char* argv[])
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/simple/main.cc b/examples/book/drawingarea/simple/main.cc
index be3741a..f0f7266 100644
--- a/examples/book/drawingarea/simple/main.cc
+++ b/examples/book/drawingarea/simple/main.cc
@@ -18,15 +18,24 @@
#include <gtkmm/application.h>
#include <gtkmm/window.h>
-int main(int argc, char** argv)
+class ExampleWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+public:
+ ExampleWindow();
+
+protected:
+ MyArea m_area;
+};
- Gtk::Window win;
- win.set_title("DrawingArea");
+ExampleWindow::ExampleWindow()
+{
+ set_title("DrawingArea");
+ set_child(m_area);
+}
- MyArea area;
- win.set_child(area);
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(win, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/drawingarea/thin_lines/main.cc b/examples/book/drawingarea/thin_lines/main.cc
index 9cb45d9..86c7a44 100644
--- a/examples/book/drawingarea/thin_lines/main.cc
+++ b/examples/book/drawingarea/thin_lines/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/entry/completion/main.cc b/examples/book/entry/completion/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/entry/completion/main.cc
+++ b/examples/book/entry/completion/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/entry/icon/main.cc b/examples/book/entry/icon/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/entry/icon/main.cc
+++ b/examples/book/entry/icon/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/entry/progress/main.cc b/examples/book/entry/progress/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/entry/progress/main.cc
+++ b/examples/book/entry/progress/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/entry/simple/main.cc b/examples/book/entry/simple/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/entry/simple/main.cc
+++ b/examples/book/entry/simple/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/expander/main.cc b/examples/book/expander/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/expander/main.cc
+++ b/examples/book/expander/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/flowbox/main.cc b/examples/book/flowbox/main.cc
index 32f003c..9787e8b 100644
--- a/examples/book/flowbox/main.cc
+++ b/examples/book/flowbox/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.flowbox");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/frame/main.cc b/examples/book/frame/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/frame/main.cc
+++ b/examples/book/frame/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/grid/main.cc b/examples/book/grid/main.cc
index 5557ad8..beccbce 100644
--- a/examples/book/grid/main.cc
+++ b/examples/book/grid/main.cc
@@ -22,8 +22,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/headerbar/main.cc b/examples/book/headerbar/main.cc
index 6ba8978..149000a 100644
--- a/examples/book/headerbar/main.cc
+++ b/examples/book/headerbar/main.cc
@@ -21,9 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.headerbar");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
-
diff --git a/examples/book/helloworld/main.cc b/examples/book/helloworld/main.cc
index 9e890ff..47a3421 100644
--- a/examples/book/helloworld/main.cc
+++ b/examples/book/helloworld/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- HelloWorld helloworld;
-
//Shows the window and returns when it is closed.
- return app->run(helloworld, argc, argv);
+ return app->make_window_and_run<HelloWorld>(argc, argv);
}
diff --git a/examples/book/helloworld2/main.cc b/examples/book/helloworld2/main.cc
index 9e890ff..47a3421 100644
--- a/examples/book/helloworld2/main.cc
+++ b/examples/book/helloworld2/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- HelloWorld helloworld;
-
//Shows the window and returns when it is closed.
- return app->run(helloworld, argc, argv);
+ return app->make_window_and_run<HelloWorld>(argc, argv);
}
diff --git a/examples/book/iconview/main.cc b/examples/book/iconview/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/iconview/main.cc
+++ b/examples/book/iconview/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/idle/main.cc b/examples/book/idle/main.cc
index cdb1234..ec8b1c9 100644
--- a/examples/book/idle/main.cc
+++ b/examples/book/idle/main.cc
@@ -21,6 +21,5 @@ int main (int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- IdleExample example;
- return app->run(example, argc, argv);
+ return app->make_window_and_run<IdleExample>(argc, argv);
}
diff --git a/examples/book/infobar/main.cc b/examples/book/infobar/main.cc
index ef643a0..89475cd 100644
--- a/examples/book/infobar/main.cc
+++ b/examples/book/infobar/main.cc
@@ -21,7 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/keyboard_events/propagation/main.cc
b/examples/book/keyboard_events/propagation/main.cc
index 50cdf57..451d4db 100644
--- a/examples/book/keyboard_events/propagation/main.cc
+++ b/examples/book/keyboard_events/propagation/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/keyboard_events/simple/main.cc b/examples/book/keyboard_events/simple/main.cc
index 50cdf57..451d4db 100644
--- a/examples/book/keyboard_events/simple/main.cc
+++ b/examples/book/keyboard_events/simple/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/label/main.cc b/examples/book/label/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/label/main.cc
+++ b/examples/book/label/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/listbox/main.cc b/examples/book/listbox/main.cc
index 73a94f8..d21723e 100644
--- a/examples/book/listbox/main.cc
+++ b/examples/book/listbox/main.cc
@@ -20,8 +20,6 @@ int main (int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/listmodel/main.cc b/examples/book/listmodel/main.cc
index 217edb1..8beb072 100644
--- a/examples/book/listmodel/main.cc
+++ b/examples/book/listmodel/main.cc
@@ -20,8 +20,6 @@ int main (int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/menus/popup/main.cc b/examples/book/menus/popup/main.cc
index 6eeaea6..28488b3 100644
--- a/examples/book/menus/popup/main.cc
+++ b/examples/book/menus/popup/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window(app);
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv, app);
}
diff --git a/examples/book/menus_and_toolbars/examplewindow.cc
b/examples/book/menus_and_toolbars/examplewindow.cc
index ac0ae53..6803848 100644
--- a/examples/book/menus_and_toolbars/examplewindow.cc
+++ b/examples/book/menus_and_toolbars/examplewindow.cc
@@ -153,7 +153,7 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_action_file_quit()
{
- hide(); //Closes the main window to stop the app->run().
+ hide(); //Closes the main window to stop the app->make_window_and_run().
}
void ExampleWindow::on_action_file_new()
diff --git a/examples/book/menus_and_toolbars/main.cc b/examples/book/menus_and_toolbars/main.cc
index 28516b3..80804cd 100644
--- a/examples/book/menus_and_toolbars/main.cc
+++ b/examples/book/menus_and_toolbars/main.cc
@@ -17,12 +17,10 @@
#include <gtkmm.h>
#include "examplewindow.h"
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window(app);
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv, app);
}
diff --git a/examples/book/multithread/main.cc b/examples/book/multithread/main.cc
index 73a94f8..0aa0ea0 100644
--- a/examples/book/multithread/main.cc
+++ b/examples/book/multithread/main.cc
@@ -16,12 +16,10 @@
#include "examplewindow.h"
#include <gtkmm/application.h>
-int main (int argc, char* argv[])
+int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/notebook/main.cc b/examples/book/notebook/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/notebook/main.cc
+++ b/examples/book/notebook/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/paned/main.cc b/examples/book/paned/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/paned/main.cc
+++ b/examples/book/paned/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/popover/main.cc b/examples/book/popover/main.cc
index afd7659..ce29c7a 100644
--- a/examples/book/popover/main.cc
+++ b/examples/book/popover/main.cc
@@ -21,9 +21,7 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.popovers");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/printing/advanced/main.cc b/examples/book/printing/advanced/main.cc
index cc7aeda..ca698eb 100644
--- a/examples/book/printing/advanced/main.cc
+++ b/examples/book/printing/advanced/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window(app);
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv, app);
}
diff --git a/examples/book/printing/simple/main.cc b/examples/book/printing/simple/main.cc
index cc7aeda..ca698eb 100644
--- a/examples/book/printing/simple/main.cc
+++ b/examples/book/printing/simple/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window(app);
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv, app);
}
diff --git a/examples/book/progressbar/main.cc b/examples/book/progressbar/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/progressbar/main.cc
+++ b/examples/book/progressbar/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/range_widgets/main.cc b/examples/book/range_widgets/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/range_widgets/main.cc
+++ b/examples/book/range_widgets/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/recent_files/examplewindow.cc b/examples/book/recent_files/examplewindow.cc
index 74600ad..9fdd8ac 100644
--- a/examples/book/recent_files/examplewindow.cc
+++ b/examples/book/recent_files/examplewindow.cc
@@ -142,7 +142,7 @@ void ExampleWindow::on_menu_file_new()
void ExampleWindow::on_menu_file_quit()
{
- hide(); //Closes the main window to stop the app->run().
+ hide(); //Closes the main window to stop the app->make_window_and_run().
}
void ExampleWindow::on_menu_file_files_dialog()
diff --git a/examples/book/recent_files/main.cc b/examples/book/recent_files/main.cc
index 6eeaea6..28488b3 100644
--- a/examples/book/recent_files/main.cc
+++ b/examples/book/recent_files/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window(app);
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv, app);
}
diff --git a/examples/book/revealer/main.cc b/examples/book/revealer/main.cc
index f3ded34..9884252 100644
--- a/examples/book/revealer/main.cc
+++ b/examples/book/revealer/main.cc
@@ -21,9 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.revealer");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
-
diff --git a/examples/book/scrolledwindow/main.cc b/examples/book/scrolledwindow/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/scrolledwindow/main.cc
+++ b/examples/book/scrolledwindow/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/searchbar/main.cc b/examples/book/searchbar/main.cc
index 0d7fa37..df6e848 100644
--- a/examples/book/searchbar/main.cc
+++ b/examples/book/searchbar/main.cc
@@ -21,9 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example.searchbar");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
-
diff --git a/examples/book/spinbutton/main.cc b/examples/book/spinbutton/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/spinbutton/main.cc
+++ b/examples/book/spinbutton/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/textview/main.cc b/examples/book/textview/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/textview/main.cc
+++ b/examples/book/textview/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/timeout/main.cc b/examples/book/timeout/main.cc
index 45fa4b6..81e1380 100644
--- a/examples/book/timeout/main.cc
+++ b/examples/book/timeout/main.cc
@@ -21,6 +21,5 @@ int main (int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- TimerExample example;
- return app->run(example, argc, argv);
+ return app->make_window_and_run<TimerExample>(argc, argv);
}
diff --git a/examples/book/toolbar/main.cc b/examples/book/toolbar/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/toolbar/main.cc
+++ b/examples/book/toolbar/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/tooltips/main.cc b/examples/book/tooltips/main.cc
index 5a44977..3d23aa7 100644
--- a/examples/book/tooltips/main.cc
+++ b/examples/book/tooltips/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/combo_renderer/main.cc b/examples/book/treeview/combo_renderer/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/combo_renderer/main.cc
+++ b/examples/book/treeview/combo_renderer/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/custom_treemodel/main.cc b/examples/book/treeview/custom_treemodel/main.cc
index e5c4d77..feb3840 100644
--- a/examples/book/treeview/custom_treemodel/main.cc
+++ b/examples/book/treeview/custom_treemodel/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
// Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/drag_and_drop/main.cc b/examples/book/treeview/drag_and_drop/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/drag_and_drop/main.cc
+++ b/examples/book/treeview/drag_and_drop/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/editable_cells/main.cc b/examples/book/treeview/editable_cells/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/editable_cells/main.cc
+++ b/examples/book/treeview/editable_cells/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/filter/main.cc b/examples/book/treeview/filter/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/filter/main.cc
+++ b/examples/book/treeview/filter/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/filter_modify/main.cc b/examples/book/treeview/filter_modify/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/filter_modify/main.cc
+++ b/examples/book/treeview/filter_modify/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/list/main.cc b/examples/book/treeview/list/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/list/main.cc
+++ b/examples/book/treeview/list/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/listviewtext/main.cc b/examples/book/treeview/listviewtext/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/listviewtext/main.cc
+++ b/examples/book/treeview/listviewtext/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/modelsort/main.cc b/examples/book/treeview/modelsort/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/modelsort/main.cc
+++ b/examples/book/treeview/modelsort/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/popup/main.cc b/examples/book/treeview/popup/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/popup/main.cc
+++ b/examples/book/treeview/popup/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/treeview/tree/main.cc b/examples/book/treeview/tree/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/treeview/tree/main.cc
+++ b/examples/book/treeview/tree/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/book/update_ui/main.cc b/examples/book/update_ui/main.cc
index 8a8594a..5437c7f 100644
--- a/examples/book/update_ui/main.cc
+++ b/examples/book/update_ui/main.cc
@@ -21,8 +21,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
-
//Shows the window and returns when it is closed.
- return app->run(window, argc, argv);
+ return app->make_window_and_run<ExampleWindow>(argc, argv);
}
diff --git a/examples/others/arrow/arrow.cc b/examples/others/arrow/arrow.cc
index 5a82eef..259e81d 100644
--- a/examples/others/arrow/arrow.cc
+++ b/examples/others/arrow/arrow.cc
@@ -85,9 +85,8 @@ AppWindow::~AppWindow()
int main (int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- AppWindow arrows;
- return app->run(arrows, argc, argv);
+ return app->make_window_and_run<AppWindow>(argc, argv);
}
/* example-end */
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index b80a5ea..f92fe85 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -288,7 +288,5 @@ Glib::DateTime CalendarExample::get_date() const
int main(int argc, char** argv)
{
auto app = Gtk::Application::create("org.gtkmm.example");
- CalendarExample calendar;
- return app->run(calendar, argc, argv);
+ return app->make_window_and_run<CalendarExample>(argc, argv);
}
-
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc
b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index c300946..c86a4be 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -293,8 +293,5 @@ int main(int argc, char** argv)
{
auto app = Gtk::Application::create("org.gtkmm.example");
- AppWindow window;
- app->run(window, argc, argv);
-
- return 0;
+ return app->make_window_and_run<AppWindow>(argc, argv);
}
diff --git a/examples/others/cellrenderercustom/testpopup.cc b/examples/others/cellrenderercustom/testpopup.cc
index cb2fb0f..62c72c1 100644
--- a/examples/others/cellrenderercustom/testpopup.cc
+++ b/examples/others/cellrenderercustom/testpopup.cc
@@ -108,9 +108,6 @@ int main(int argc, char** argv)
{
auto app = Gtk::Application::create("org.gtkmm.example");
- AppWindow window;
- app->run(window, argc, argv);
-
- return 0;
+ return app->make_window_and_run<AppWindow>(argc, argv);
}
diff --git a/examples/others/dnd/main.cc b/examples/others/dnd/main.cc
index a524bce..b5ee89b 100644
--- a/examples/others/dnd/main.cc
+++ b/examples/others/dnd/main.cc
@@ -21,6 +21,5 @@ int main (int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- DnDWindow dndWindow;
- return app->run(dndWindow, argc, argv); //Shows the window and returns when it is closed.
+ return app->make_window_and_run<DnDWindow>(argc, argv); //Shows the window and returns when it is closed.
}
diff --git a/examples/others/exception/exceptiontest.cc b/examples/others/exception/exceptiontest.cc
index 990ec8c..dc97d39 100644
--- a/examples/others/exception/exceptiontest.cc
+++ b/examples/others/exception/exceptiontest.cc
@@ -85,20 +85,19 @@ void handler2()
// if not handled it gets passed to next handler
}
-} // anonymous namespace
-
-
-int main(int argc, char** argv)
+class MyWindow : public Gtk::Window
{
- auto app = Gtk::Application::create("org.gtkmm.example");
-
+public:
+ MyWindow();
+};
- Gtk::Window window;
- window.set_title("Exception Handlers");
+MyWindow::MyWindow()
+{
+ set_title("Exception Handlers");
Gtk::Box *const box = new Gtk::Box(Gtk::Orientation::VERTICAL, 5);
box->set_margin(10);
- window.set_child(*Gtk::manage(box));
+ set_child(*Gtk::manage(box));
// New exception handlers are inserted at the front of the per-thread
// handler list. Thus, in this example handler2() is executed before
@@ -106,7 +105,6 @@ int main(int argc, char** argv)
sigc::connection conn_handler1 = Glib::add_exception_handler(&handler1);
sigc::connection conn_handler2 = Glib::add_exception_handler(&handler2);
-
Gtk::Button *const button1 = new MyButton("From virtual method");
box->append(*Gtk::manage(button1));
Gtk::Button *const button2 = new Gtk::Button("From signal handler");
@@ -125,7 +123,14 @@ int main(int argc, char** argv)
button4->signal_clicked().connect(&global_on_clicked_throw_std_exception);
button5->signal_clicked().connect(sigc::mem_fun(conn_handler1, &sigc::connection::disconnect));
button6->signal_clicked().connect(sigc::mem_fun(conn_handler2, &sigc::connection::disconnect));
-
- return app->run(window, argc, argv);
}
+} // anonymous namespace
+
+
+int main(int argc, char** argv)
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
+
+ return app->make_window_and_run<MyWindow>(argc, argv);
+}
diff --git a/examples/others/idle/idle.cc b/examples/others/idle/idle.cc
index 7d411eb..2935399 100644
--- a/examples/others/idle/idle.cc
+++ b/examples/others/idle/idle.cc
@@ -101,8 +101,6 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- IdleExample example;
-
- return app->run(example, argc, argv);
+ return app->make_window_and_run<IdleExample>(argc, argv);
}
diff --git a/examples/others/statusbar/statusbar.cc b/examples/others/statusbar/statusbar.cc
index 6a61e27..7aa8da7 100644
--- a/examples/others/statusbar/statusbar.cc
+++ b/examples/others/statusbar/statusbar.cc
@@ -62,8 +62,6 @@ int main (int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- StatusBarExample exampleWindow;
-
- return app->run(exampleWindow, argc, argv);
+ return app->make_window_and_run<StatusBarExample>(argc, argv);
}
diff --git a/examples/others/tictactoe/ttt_test.cc b/examples/others/tictactoe/ttt_test.cc
index f265936..cb7414a 100644
--- a/examples/others/tictactoe/ttt_test.cc
+++ b/examples/others/tictactoe/ttt_test.cc
@@ -2,7 +2,6 @@
#include <gtkmm/window.h>
#include <gtkmm/application.h>
-
void
win (TicTacToe *ttt)
{
@@ -10,19 +9,26 @@ win (TicTacToe *ttt)
ttt->clear();
}
+class MyWindow : public Gtk::Window
+{
+public:
+ MyWindow();
+};
-int
-main (int argc, char *argv[])
+MyWindow::MyWindow()
{
- auto app = Gtk::Application::create("org.gtkmm.example");
+ set_title("Tic-Tac-Toe");
auto ttt = Gtk::make_managed<TicTacToe>();
- ttt->tictactoe.connect( sigc::bind (sigc::ptr_fun(&win), ttt) );
-
- Gtk::Window window;
- window.set_title("Tic-Tac-Toe");
+ ttt->tictactoe.connect(sigc::bind (sigc::ptr_fun(&win), ttt));
ttt->set_margin(10);
- window.set_child(*ttt);
+ set_child(*ttt);
+}
+
+int
+main(int argc, char* argv[])
+{
+ auto app = Gtk::Application::create("org.gtkmm.example");
- return app->run(window, argc, argv);
+ return app->make_window_and_run<MyWindow>(argc, argv);
}
diff --git a/examples/others/treemodelcustom/main.cc b/examples/others/treemodelcustom/main.cc
index febddd9..c07faa3 100644
--- a/examples/others/treemodelcustom/main.cc
+++ b/examples/others/treemodelcustom/main.cc
@@ -21,6 +21,5 @@ int main(int argc, char *argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
- ExampleWindow window;
- return app->run(window, argc, argv); //Shows the window and returns when it is closed.
+ return app->make_window_and_run<ExampleWindow>(argc, argv); //Shows the window and returns when it is
closed.
}
diff --git a/examples/others/window/wheelbarrow.cc b/examples/others/window/wheelbarrow.cc
index 48edad0..bcc320a 100644
--- a/examples/others/window/wheelbarrow.cc
+++ b/examples/others/window/wheelbarrow.cc
@@ -193,7 +193,5 @@ int main(int argc, char** argv)
{
auto app = Gtk::Application::create("org.gtkmm.example");
-
- Wheelbarrow wheelbarrow;
- return app->run(wheelbarrow, argc, argv);
+ return app->make_window_and_run<Wheelbarrow>(argc, argv);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]