[gtkmm-documentation] Use Gtk::Application instead of Gtk::Main.



commit a0b46b739fc69e7cae0beedeaf1ed659c790028c
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Mar 3 12:33:07 2012 +0100

    Use Gtk::Application instead of Gtk::Main.
    
    * examples/: Use Gtk::Application instead of Gtk::Main, which will
    probably be deprecated.

 ChangeLog                                          |    7 +++++++
 examples/book/alignment/main.cc                    |    9 ++++-----
 examples/book/aspectframe/main.cc                  |    9 ++++-----
 examples/book/assistant/main.cc                    |    9 ++++-----
 examples/book/box/main.cc                          |    8 +++-----
 examples/book/builder/basic/main.cc                |    4 ++--
 examples/book/builder/derived/main.cc              |    4 ++--
 examples/book/buttonbox/main.cc                    |    9 ++++-----
 examples/book/buttons/button/main.cc               |    9 ++++-----
 examples/book/buttons/checkbutton/main.cc          |    9 ++++-----
 examples/book/buttons/filechooserbutton/main.cc    |    9 ++++-----
 examples/book/buttons/radiobutton/main.cc          |    9 ++++-----
 examples/book/buttons/togglebutton/main.cc         |    9 ++++-----
 examples/book/clipboard/ideal/main.cc              |    9 ++++-----
 examples/book/clipboard/simple/main.cc             |    9 ++++-----
 examples/book/combobox/complex/main.cc             |    9 ++++-----
 examples/book/combobox/entry_complex/main.cc       |    9 ++++-----
 examples/book/combobox/entry_text/main.cc          |    9 ++++-----
 examples/book/combobox/text/main.cc                |    9 ++++-----
 examples/book/custom/custom_container/main.cc      |    9 ++++-----
 examples/book/custom/custom_widget/main.cc         |    9 ++++-----
 examples/book/dialogs/aboutdialog/main.cc          |    9 ++++-----
 examples/book/dialogs/colorchooserdialog/main.cc   |    9 ++++-----
 examples/book/dialogs/filechooserdialog/main.cc    |    9 ++++-----
 examples/book/dialogs/fontchooserdialog/main.cc    |    9 ++++-----
 examples/book/dialogs/messagedialog/main.cc        |    9 ++++-----
 examples/book/dialogs/simple/main.cc               |    9 ++++-----
 examples/book/drag_and_drop/main.cc                |    9 ++++-----
 examples/book/drawingarea/arcs/main.cc             |    8 +++-----
 examples/book/drawingarea/clock/main.cc            |    8 +++-----
 examples/book/drawingarea/curve/main.cc            |    8 +++-----
 examples/book/drawingarea/image/main.cc            |    8 +++-----
 examples/book/drawingarea/joins/main.cc            |    8 +++-----
 examples/book/drawingarea/pango_text/main.cc       |    8 +++-----
 examples/book/drawingarea/simple/main.cc           |    8 +++-----
 examples/book/drawingarea/thin_lines/main.cc       |    9 ++++-----
 examples/book/entry/completion/main.cc             |    9 ++++-----
 examples/book/entry/icon/main.cc                   |    9 ++++-----
 examples/book/entry/progress/main.cc               |    9 ++++-----
 examples/book/entry/simple/main.cc                 |    9 ++++-----
 examples/book/eventbox/main.cc                     |    9 ++++-----
 examples/book/expander/main.cc                     |    9 ++++-----
 examples/book/frame/main.cc                        |    9 ++++-----
 examples/book/grid/main.cc                         |    9 ++++-----
 examples/book/helloworld/main.cc                   |    9 ++++-----
 examples/book/helloworld2/main.cc                  |    9 ++++-----
 examples/book/iconview/main.cc                     |    8 +++-----
 examples/book/idle/main.cc                         |    8 +++-----
 examples/book/infobar/main.cc                      |    8 +++-----
 examples/book/input/main.cc                        |   11 ++++++-----
 examples/book/keyboard_events/propagation/main.cc  |    8 +++-----
 examples/book/keyboard_events/simple/main.cc       |    8 +++-----
 examples/book/label/main.cc                        |    9 ++++-----
 examples/book/menus/main_menu/examplewindow.cc     |    2 +-
 examples/book/menus/main_menu/main.cc              |    9 ++++-----
 examples/book/menus/popup/main.cc                  |    9 ++++-----
 examples/book/menus_and_toolbars/examplewindow.cc  |    2 +-
 examples/book/menus_and_toolbars/main.cc           |    7 +++----
 examples/book/notebook/main.cc                     |    9 ++++-----
 examples/book/paned/main.cc                        |    9 ++++-----
 examples/book/printing/advanced/main.cc            |    9 ++++-----
 examples/book/printing/simple/main.cc              |    9 ++++-----
 examples/book/progressbar/main.cc                  |    9 ++++-----
 examples/book/range_widgets/main.cc                |    9 ++++-----
 examples/book/recent_files/examplewindow.cc        |    2 +-
 examples/book/recent_files/main.cc                 |    9 ++++-----
 examples/book/scrolledwindow/main.cc               |    9 ++++-----
 examples/book/socket/plug.cc                       |    7 ++++---
 examples/book/socket/socket.cc                     |    4 ++--
 examples/book/spinbutton/main.cc                   |    9 ++++-----
 examples/book/statusicon/main.cc                   |    6 ++----
 examples/book/textview/main.cc                     |    9 ++++-----
 examples/book/timeout/main.cc                      |    8 +++-----
 examples/book/toolbar/main.cc                      |    9 ++++-----
 examples/book/toolpalette/main.cc                  |    9 ++++-----
 examples/book/tooltips/main.cc                     |    9 ++++-----
 examples/book/treeview/combo_renderer/main.cc      |    9 ++++-----
 examples/book/treeview/drag_and_drop/main.cc       |    9 ++++-----
 examples/book/treeview/editable_cells/main.cc      |    9 ++++-----
 examples/book/treeview/filter/main.cc              |    9 ++++-----
 examples/book/treeview/filter_modify/main.cc       |    9 ++++-----
 examples/book/treeview/list/main.cc                |    9 ++++-----
 examples/book/treeview/listviewtext/main.cc        |    9 ++++-----
 examples/book/treeview/modelsort/main.cc           |    9 ++++-----
 examples/book/treeview/popup/main.cc               |    9 ++++-----
 examples/book/treeview/tree/main.cc                |    9 ++++-----
 examples/book/update_ui/examplewindow.cc           |    4 ++--
 examples/book/update_ui/main.cc                    |    9 ++++-----
 examples/others/arrow/arrow.cc                     |    7 +++----
 examples/others/arrow/direction.cc                 |    7 +++----
 examples/others/calendar/calendar.cc               |   13 +++++++++----
 .../cellrenderercustom/cellrenderertoggle.cc       |    4 ++--
 examples/others/cellrenderercustom/testpopup.cc    |    4 ++--
 examples/others/dnd/dndwindow.cc                   |    2 +-
 examples/others/dnd/main.cc                        |    8 +++-----
 examples/others/exception/exceptiontest.cc         |    9 ++++-----
 examples/others/idle/idle.cc                       |   11 +++++------
 examples/others/statusbar/statusbar.cc             |    7 +++----
 examples/others/stock/stock.cc                     |    8 +++-----
 examples/others/tictactoe/ttt_test.cc              |    8 +++-----
 examples/others/treemodelcustom/main.cc            |    8 +++-----
 examples/others/window/wheelbarrow.cc              |    9 ++++-----
 102 files changed, 371 insertions(+), 464 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fcea0a7..8da59ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-03  Murray Cumming  <murrayc murrayc com>
+
+	Use Gtk::Application instead of Gtk::Main.
+
+	* examples/: Use Gtk::Application instead of Gtk::Main, which will
+	probably be deprecated.
+
 2012-03-02  Murray Cumming  <murrayc murrayc com>
 
 	Use ColorChooserDialog instead of deprecated ColorSelectionDialog.
diff --git a/examples/book/alignment/main.cc b/examples/book/alignment/main.cc
index 4620054..3c36987 100644
--- a/examples/book/alignment/main.cc
+++ b/examples/book/alignment/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/aspectframe/main.cc b/examples/book/aspectframe/main.cc
index 4620054..3c36987 100644
--- a/examples/book/aspectframe/main.cc
+++ b/examples/book/aspectframe/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/assistant/main.cc b/examples/book/assistant/main.cc
index 6d800d0..a46a3c0 100644
--- a/examples/book/assistant/main.cc
+++ b/examples/book/assistant/main.cc
@@ -15,15 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  // Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  // Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/box/main.cc b/examples/book/box/main.cc
index a9c4344..3df5894 100644
--- a/examples/book/box/main.cc
+++ b/examples/book/box/main.cc
@@ -17,7 +17,7 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <iostream>
 #include <cstdlib>
 
@@ -25,7 +25,7 @@ using std::atoi;
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main main_instance(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   if(argc != 2)
   {
@@ -34,7 +34,5 @@ int main(int argc, char *argv[])
   }
 
   ExampleWindow window( atoi(argv[1]) );
-  Gtk::Main::run(window); //Shows the window and returns when it is closed.
-
-  return 0;
+  return app->run(window); //Shows the window and returns when it is closed.
 }
diff --git a/examples/book/builder/basic/main.cc b/examples/book/builder/basic/main.cc
index 05346a6..5514bd8 100644
--- a/examples/book/builder/basic/main.cc
+++ b/examples/book/builder/basic/main.cc
@@ -12,7 +12,7 @@ void on_button_clicked()
 
 int main (int argc, char **argv)
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   //Load the GtkBuilder file and instantiate its widgets:
   Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
@@ -48,7 +48,7 @@ int main (int argc, char **argv)
       pButton->signal_clicked().connect( sigc::ptr_fun(on_button_clicked) );
     }
 
-    kit.run(*pDialog);
+    app->run(*pDialog);
   }
 
   delete pDialog;
diff --git a/examples/book/builder/derived/main.cc b/examples/book/builder/derived/main.cc
index 112ff81..332f190 100644
--- a/examples/book/builder/derived/main.cc
+++ b/examples/book/builder/derived/main.cc
@@ -21,7 +21,7 @@
 
 int main (int argc, char **argv)
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   //Load the Glade file and instiate its widgets:
   Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
@@ -51,7 +51,7 @@ int main (int argc, char **argv)
   if(pDialog)
   {
     //Start:
-    kit.run(*pDialog);
+    app->run(*pDialog);
   }
 
   delete pDialog;
diff --git a/examples/book/buttonbox/main.cc b/examples/book/buttonbox/main.cc
index 4620054..3c36987 100644
--- a/examples/book/buttonbox/main.cc
+++ b/examples/book/buttonbox/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/buttons/button/main.cc b/examples/book/buttons/button/main.cc
index 04683fb..7da9c83 100644
--- a/examples/book/buttons/button/main.cc
+++ b/examples/book/buttons/button/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "buttons.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   Buttons buttons;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(buttons);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(buttons);
 }
diff --git a/examples/book/buttons/checkbutton/main.cc b/examples/book/buttons/checkbutton/main.cc
index 4620054..3c36987 100644
--- a/examples/book/buttons/checkbutton/main.cc
+++ b/examples/book/buttons/checkbutton/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/buttons/filechooserbutton/main.cc b/examples/book/buttons/filechooserbutton/main.cc
index 4620054..3c36987 100644
--- a/examples/book/buttons/filechooserbutton/main.cc
+++ b/examples/book/buttons/filechooserbutton/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/buttons/radiobutton/main.cc b/examples/book/buttons/radiobutton/main.cc
index 2a8a582..d1a52d4 100644
--- a/examples/book/buttons/radiobutton/main.cc
+++ b/examples/book/buttons/radiobutton/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "radiobuttons.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   RadioButtons buttons;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(buttons);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(buttons);
 }
diff --git a/examples/book/buttons/togglebutton/main.cc b/examples/book/buttons/togglebutton/main.cc
index 4620054..3c36987 100644
--- a/examples/book/buttons/togglebutton/main.cc
+++ b/examples/book/buttons/togglebutton/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/clipboard/ideal/main.cc b/examples/book/clipboard/ideal/main.cc
index 4620054..3c36987 100644
--- a/examples/book/clipboard/ideal/main.cc
+++ b/examples/book/clipboard/ideal/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/clipboard/simple/main.cc b/examples/book/clipboard/simple/main.cc
index 4620054..3c36987 100644
--- a/examples/book/clipboard/simple/main.cc
+++ b/examples/book/clipboard/simple/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/combobox/complex/main.cc b/examples/book/combobox/complex/main.cc
index 4620054..3c36987 100644
--- a/examples/book/combobox/complex/main.cc
+++ b/examples/book/combobox/complex/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/combobox/entry_complex/main.cc b/examples/book/combobox/entry_complex/main.cc
index 4620054..3c36987 100644
--- a/examples/book/combobox/entry_complex/main.cc
+++ b/examples/book/combobox/entry_complex/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/combobox/entry_text/main.cc b/examples/book/combobox/entry_text/main.cc
index 4620054..3c36987 100644
--- a/examples/book/combobox/entry_text/main.cc
+++ b/examples/book/combobox/entry_text/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/combobox/text/main.cc b/examples/book/combobox/text/main.cc
index 4620054..3c36987 100644
--- a/examples/book/combobox/text/main.cc
+++ b/examples/book/combobox/text/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/custom/custom_container/main.cc b/examples/book/custom/custom_container/main.cc
index aae8917..834048b 100644
--- a/examples/book/custom/custom_container/main.cc
+++ b/examples/book/custom/custom_container/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/custom/custom_widget/main.cc b/examples/book/custom/custom_widget/main.cc
index aae8917..834048b 100644
--- a/examples/book/custom/custom_widget/main.cc
+++ b/examples/book/custom/custom_widget/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/aboutdialog/main.cc b/examples/book/dialogs/aboutdialog/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/aboutdialog/main.cc
+++ b/examples/book/dialogs/aboutdialog/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/colorchooserdialog/main.cc b/examples/book/dialogs/colorchooserdialog/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/colorchooserdialog/main.cc
+++ b/examples/book/dialogs/colorchooserdialog/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/filechooserdialog/main.cc b/examples/book/dialogs/filechooserdialog/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/filechooserdialog/main.cc
+++ b/examples/book/dialogs/filechooserdialog/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/fontchooserdialog/main.cc b/examples/book/dialogs/fontchooserdialog/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/fontchooserdialog/main.cc
+++ b/examples/book/dialogs/fontchooserdialog/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/messagedialog/main.cc b/examples/book/dialogs/messagedialog/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/messagedialog/main.cc
+++ b/examples/book/dialogs/messagedialog/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/dialogs/simple/main.cc b/examples/book/dialogs/simple/main.cc
index 4620054..3c36987 100644
--- a/examples/book/dialogs/simple/main.cc
+++ b/examples/book/dialogs/simple/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/drag_and_drop/main.cc b/examples/book/drag_and_drop/main.cc
index de2fc65..856c051 100644
--- a/examples/book/drag_and_drop/main.cc
+++ b/examples/book/drag_and_drop/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "dndwindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   DnDWindow dndWindow;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(dndWindow);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(dndWindow);
 }
diff --git a/examples/book/drawingarea/arcs/main.cc b/examples/book/drawingarea/arcs/main.cc
index fddf5ce..238a2af 100644
--- a/examples/book/drawingarea/arcs/main.cc
+++ b/examples/book/drawingarea/arcs/main.cc
@@ -17,12 +17,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-   Gtk::Main kit(argc, argv);
+   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
    Gtk::Window win;
    win.set_title("DrawingArea");
@@ -31,7 +31,5 @@ int main(int argc, char** argv)
    win.add(area);
    area.show();
 
-   Gtk::Main::run(win);
-
-   return 0;
+   return app->run(win);
 }
diff --git a/examples/book/drawingarea/clock/main.cc b/examples/book/drawingarea/clock/main.cc
index bc56126..944ecab 100644
--- a/examples/book/drawingarea/clock/main.cc
+++ b/examples/book/drawingarea/clock/main.cc
@@ -17,12 +17,12 @@
  */
 
 #include "clock.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-   Gtk::Main kit(argc, argv);
+   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
    Gtk::Window win;
    win.set_title("Cairomm Clock");
@@ -31,7 +31,5 @@ int main(int argc, char** argv)
    win.add(c);
    c.show();
 
-   Gtk::Main::run(win);
-
-   return 0;
+   return app->run(win);
 }
diff --git a/examples/book/drawingarea/curve/main.cc b/examples/book/drawingarea/curve/main.cc
index fddf5ce..238a2af 100644
--- a/examples/book/drawingarea/curve/main.cc
+++ b/examples/book/drawingarea/curve/main.cc
@@ -17,12 +17,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-   Gtk::Main kit(argc, argv);
+   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
    Gtk::Window win;
    win.set_title("DrawingArea");
@@ -31,7 +31,5 @@ int main(int argc, char** argv)
    win.add(area);
    area.show();
 
-   Gtk::Main::run(win);
-
-   return 0;
+   return app->run(win);
 }
diff --git a/examples/book/drawingarea/image/main.cc b/examples/book/drawingarea/image/main.cc
index 74ae86d..6f6f351 100644
--- a/examples/book/drawingarea/image/main.cc
+++ b/examples/book/drawingarea/image/main.cc
@@ -15,12 +15,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   Gtk::Window win;
   win.set_title("DrawingArea");
@@ -30,7 +30,5 @@ int main(int argc, char** argv)
   win.add(area);
   area.show();
 
-  Gtk::Main::run(win);
-
-  return 0;
+  return app->run(win);
 }
diff --git a/examples/book/drawingarea/joins/main.cc b/examples/book/drawingarea/joins/main.cc
index fddf5ce..238a2af 100644
--- a/examples/book/drawingarea/joins/main.cc
+++ b/examples/book/drawingarea/joins/main.cc
@@ -17,12 +17,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-   Gtk::Main kit(argc, argv);
+   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
    Gtk::Window win;
    win.set_title("DrawingArea");
@@ -31,7 +31,5 @@ int main(int argc, char** argv)
    win.add(area);
    area.show();
 
-   Gtk::Main::run(win);
-
-   return 0;
+   return app->run(win);
 }
diff --git a/examples/book/drawingarea/pango_text/main.cc b/examples/book/drawingarea/pango_text/main.cc
index f775cb6..bf0fa53 100644
--- a/examples/book/drawingarea/pango_text/main.cc
+++ b/examples/book/drawingarea/pango_text/main.cc
@@ -15,12 +15,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char* argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   Gtk::Window window;
   window.set_title("Drawing text example");
@@ -29,7 +29,5 @@ int main(int argc, char* argv[])
   window.add(area);
   area.show();
 
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/book/drawingarea/simple/main.cc b/examples/book/drawingarea/simple/main.cc
index fddf5ce..238a2af 100644
--- a/examples/book/drawingarea/simple/main.cc
+++ b/examples/book/drawingarea/simple/main.cc
@@ -17,12 +17,12 @@
  */
 
 #include "myarea.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 int main(int argc, char** argv)
 {
-   Gtk::Main kit(argc, argv);
+   Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
    Gtk::Window win;
    win.set_title("DrawingArea");
@@ -31,7 +31,5 @@ int main(int argc, char** argv)
    win.add(area);
    area.show();
 
-   Gtk::Main::run(win);
-
-   return 0;
+   return app->run(win);
 }
diff --git a/examples/book/drawingarea/thin_lines/main.cc b/examples/book/drawingarea/thin_lines/main.cc
index f8a538c..3852815 100644
--- a/examples/book/drawingarea/thin_lines/main.cc
+++ b/examples/book/drawingarea/thin_lines/main.cc
@@ -15,15 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char* argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/entry/completion/main.cc b/examples/book/entry/completion/main.cc
index 4620054..3c36987 100644
--- a/examples/book/entry/completion/main.cc
+++ b/examples/book/entry/completion/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/entry/icon/main.cc b/examples/book/entry/icon/main.cc
index 4620054..3c36987 100644
--- a/examples/book/entry/icon/main.cc
+++ b/examples/book/entry/icon/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/entry/progress/main.cc b/examples/book/entry/progress/main.cc
index 4620054..3c36987 100644
--- a/examples/book/entry/progress/main.cc
+++ b/examples/book/entry/progress/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/entry/simple/main.cc b/examples/book/entry/simple/main.cc
index 4620054..3c36987 100644
--- a/examples/book/entry/simple/main.cc
+++ b/examples/book/entry/simple/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/eventbox/main.cc b/examples/book/eventbox/main.cc
index 4620054..3c36987 100644
--- a/examples/book/eventbox/main.cc
+++ b/examples/book/eventbox/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/expander/main.cc b/examples/book/expander/main.cc
index 4620054..3c36987 100644
--- a/examples/book/expander/main.cc
+++ b/examples/book/expander/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/frame/main.cc b/examples/book/frame/main.cc
index 4620054..3c36987 100644
--- a/examples/book/frame/main.cc
+++ b/examples/book/frame/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/grid/main.cc b/examples/book/grid/main.cc
index 385aec8..2822057 100644
--- a/examples/book/grid/main.cc
+++ b/examples/book/grid/main.cc
@@ -16,15 +16,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  // Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  // Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/helloworld/main.cc b/examples/book/helloworld/main.cc
index 181c850..7dfc6e7 100644
--- a/examples/book/helloworld/main.cc
+++ b/examples/book/helloworld/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "helloworld.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   HelloWorld helloworld;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(helloworld);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(helloworld);
 }
diff --git a/examples/book/helloworld2/main.cc b/examples/book/helloworld2/main.cc
index 181c850..7dfc6e7 100644
--- a/examples/book/helloworld2/main.cc
+++ b/examples/book/helloworld2/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "helloworld.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   HelloWorld helloworld;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(helloworld);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(helloworld);
 }
diff --git a/examples/book/iconview/main.cc b/examples/book/iconview/main.cc
index 13ad846..3c36987 100644
--- a/examples/book/iconview/main.cc
+++ b/examples/book/iconview/main.cc
@@ -17,16 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
 
   //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/book/idle/main.cc b/examples/book/idle/main.cc
index d40637f..6f60ec5 100644
--- a/examples/book/idle/main.cc
+++ b/examples/book/idle/main.cc
@@ -17,14 +17,12 @@
  */
 
 #include "idleexample.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main app(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   IdleExample example;
-  Gtk::Main::run(example);
-
-  return 0;
+  return app->run(example);
 }
diff --git a/examples/book/infobar/main.cc b/examples/book/infobar/main.cc
index fe6e705..6d68ea5 100644
--- a/examples/book/infobar/main.cc
+++ b/examples/book/infobar/main.cc
@@ -15,15 +15,13 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
   //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/book/input/main.cc b/examples/book/input/main.cc
index ad76f35..f22ebea 100644
--- a/examples/book/input/main.cc
+++ b/examples/book/input/main.cc
@@ -1,5 +1,5 @@
 #include <build/config.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <glibmm/main.h>
 #include <glibmm/iochannel.h>
 #include <fcntl.h>
@@ -11,6 +11,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+Glib::RefPtr<Gtk::Application> app;
+
 int read_fd;
 Glib::RefPtr<Glib::IOChannel> iochannel;
 
@@ -37,7 +39,7 @@ bool MyCallback(Glib::IOCondition io_condition)
    iochannel->read_line(buf);
    std::cout << buf;
    if (buf == "Q\n")
-       Gtk::Main::quit ();
+     app->quit();
 
   }
   return true;
@@ -46,8 +48,7 @@ bool MyCallback(Glib::IOCondition io_condition)
 
 int main(int argc, char *argv[])
 {
-  // the usual Gtk::Main object
-  Gtk::Main app(argc, argv);
+  app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   if (access("testfifo", F_OK) == -1) {
     // fifo doesn't exit - create it
@@ -76,7 +77,7 @@ int main(int argc, char *argv[])
   iochannel = Glib::IOChannel::create_from_fd(read_fd);
 
   // and last but not least - run the application main loop
-  app.run();
+  app->run();
 
   // now remove the temporary fifo
   if(unlink("testfifo"))
diff --git a/examples/book/keyboard_events/propagation/main.cc b/examples/book/keyboard_events/propagation/main.cc
index a352431..08ec0bb 100644
--- a/examples/book/keyboard_events/propagation/main.cc
+++ b/examples/book/keyboard_events/propagation/main.cc
@@ -15,16 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
 
   //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/book/keyboard_events/simple/main.cc b/examples/book/keyboard_events/simple/main.cc
index a352431..08ec0bb 100644
--- a/examples/book/keyboard_events/simple/main.cc
+++ b/examples/book/keyboard_events/simple/main.cc
@@ -15,16 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
 
   //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/book/label/main.cc b/examples/book/label/main.cc
index 4620054..3c36987 100644
--- a/examples/book/label/main.cc
+++ b/examples/book/label/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/menus/main_menu/examplewindow.cc b/examples/book/menus/main_menu/examplewindow.cc
index 1e0ff39..bc2b40e 100644
--- a/examples/book/menus/main_menu/examplewindow.cc
+++ b/examples/book/menus/main_menu/examplewindow.cc
@@ -141,7 +141,7 @@ ExampleWindow::~ExampleWindow()
 
 void ExampleWindow::on_menu_file_quit()
 {
-  hide(); //Closes the main window to stop the Gtk::Main::run().
+  hide(); //Closes the main window to stop the app->run().
 }
 
 void ExampleWindow::on_menu_file_new_generic()
diff --git a/examples/book/menus/main_menu/main.cc b/examples/book/menus/main_menu/main.cc
index 4620054..3c36987 100644
--- a/examples/book/menus/main_menu/main.cc
+++ b/examples/book/menus/main_menu/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/menus/popup/main.cc b/examples/book/menus/popup/main.cc
index 4620054..3c36987 100644
--- a/examples/book/menus/popup/main.cc
+++ b/examples/book/menus/popup/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/menus_and_toolbars/examplewindow.cc b/examples/book/menus_and_toolbars/examplewindow.cc
index 6b389de..e4c0388 100644
--- a/examples/book/menus_and_toolbars/examplewindow.cc
+++ b/examples/book/menus_and_toolbars/examplewindow.cc
@@ -112,7 +112,7 @@ ExampleWindow::~ExampleWindow()
 
 void ExampleWindow::on_action_file_quit()
 {
-  hide(); //Closes the main window to stop the Gtk::Main::run().
+  hide(); //Closes the main window to stop the app->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 7f01036..c277339 100644
--- a/examples/book/menus_and_toolbars/main.cc
+++ b/examples/book/menus_and_toolbars/main.cc
@@ -21,11 +21,10 @@
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/notebook/main.cc b/examples/book/notebook/main.cc
index 4620054..3c36987 100644
--- a/examples/book/notebook/main.cc
+++ b/examples/book/notebook/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/paned/main.cc b/examples/book/paned/main.cc
index 4620054..3c36987 100644
--- a/examples/book/paned/main.cc
+++ b/examples/book/paned/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/printing/advanced/main.cc b/examples/book/printing/advanced/main.cc
index 465f220..f6a7ced 100644
--- a/examples/book/printing/advanced/main.cc
+++ b/examples/book/printing/advanced/main.cc
@@ -15,15 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/printing/simple/main.cc b/examples/book/printing/simple/main.cc
index 465f220..f6a7ced 100644
--- a/examples/book/printing/simple/main.cc
+++ b/examples/book/printing/simple/main.cc
@@ -15,15 +15,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/progressbar/main.cc b/examples/book/progressbar/main.cc
index 4620054..3c36987 100644
--- a/examples/book/progressbar/main.cc
+++ b/examples/book/progressbar/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/range_widgets/main.cc b/examples/book/range_widgets/main.cc
index 4620054..3c36987 100644
--- a/examples/book/range_widgets/main.cc
+++ b/examples/book/range_widgets/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/recent_files/examplewindow.cc b/examples/book/recent_files/examplewindow.cc
index 8633058..5eed162 100644
--- a/examples/book/recent_files/examplewindow.cc
+++ b/examples/book/recent_files/examplewindow.cc
@@ -108,7 +108,7 @@ void ExampleWindow::on_menu_file_new()
 
 void ExampleWindow::on_menu_file_quit()
 {
-  hide(); //Closes the main window to stop the Gtk::Main::run().
+  hide(); //Closes the main window to stop the app->run().
 }
 
 void ExampleWindow::on_menu_file_recent_files_item()
diff --git a/examples/book/recent_files/main.cc b/examples/book/recent_files/main.cc
index 4620054..3c36987 100644
--- a/examples/book/recent_files/main.cc
+++ b/examples/book/recent_files/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/scrolledwindow/main.cc b/examples/book/scrolledwindow/main.cc
index 4620054..3c36987 100644
--- a/examples/book/scrolledwindow/main.cc
+++ b/examples/book/scrolledwindow/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/socket/plug.cc b/examples/book/socket/plug.cc
index be3750d..67823f7 100644
--- a/examples/book/socket/plug.cc
+++ b/examples/book/socket/plug.cc
@@ -23,7 +23,7 @@ class MyPlug : public Gtk::Plug
     set_size_request(150, 100);
     add(m_label);
     signal_embedded().connect(sigc::ptr_fun(on_embed));
-    show_all();
+    show_all_children();
   }
 
   private:
@@ -33,15 +33,16 @@ class MyPlug : public Gtk::Plug
 
 int main(int argc, char** argv)
 {
-  Gtk::Main app(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
   MyPlug plug;
+  plug.show();
 
   ofstream out(id_filename);
   out << plug.get_id();
   out.close();
   cout << "The window ID is: " << plug.get_id() << endl;
 
-  app.run(plug);
+  app->run(plug);
 
   // remove the ID file when the program exits
   g_remove(id_filename);
diff --git a/examples/book/socket/socket.cc b/examples/book/socket/socket.cc
index b0a0370..1c43dca 100644
--- a/examples/book/socket/socket.cc
+++ b/examples/book/socket/socket.cc
@@ -50,8 +50,8 @@ class MySocketWindow : public Gtk::Window
 
 int main(int argc, char** argv)
 {
-  Gtk::Main app(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
   MySocketWindow win;
-  app.run(win);
+  app->run(win);
   return 0;
 }
diff --git a/examples/book/spinbutton/main.cc b/examples/book/spinbutton/main.cc
index 4620054..3c36987 100644
--- a/examples/book/spinbutton/main.cc
+++ b/examples/book/spinbutton/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/statusicon/main.cc b/examples/book/statusicon/main.cc
index 03f663d..74dcf23 100644
--- a/examples/book/statusicon/main.cc
+++ b/examples/book/statusicon/main.cc
@@ -20,7 +20,7 @@
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   //Use your own icon in real life.
   Glib::RefPtr<Gtk::StatusIcon> status_icon =
@@ -33,7 +33,5 @@ int main(int argc, char *argv[])
   Gtk::Window window;
   window.set_title("gtkmm StatusIcon example.");
   window.set_default_size(300, 300);
-  Gtk::Main::run(window); //Shows the window and returns when it is closed.
-
-  return 0;
+  return app->run(window); //Shows the window and returns when it is closed.
 }
diff --git a/examples/book/textview/main.cc b/examples/book/textview/main.cc
index 4620054..3c36987 100644
--- a/examples/book/textview/main.cc
+++ b/examples/book/textview/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/timeout/main.cc b/examples/book/timeout/main.cc
index 8b01b99..be36913 100644
--- a/examples/book/timeout/main.cc
+++ b/examples/book/timeout/main.cc
@@ -17,14 +17,12 @@
  */
 
 #include "timerexample.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main app(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   TimerExample example;
-  Gtk::Main::run(example);
-
-  return 0;
+  return app->run(example);
 }
diff --git a/examples/book/toolbar/main.cc b/examples/book/toolbar/main.cc
index 4620054..3c36987 100644
--- a/examples/book/toolbar/main.cc
+++ b/examples/book/toolbar/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/toolpalette/main.cc b/examples/book/toolpalette/main.cc
index fe1f52e..46eba18 100644
--- a/examples/book/toolpalette/main.cc
+++ b/examples/book/toolpalette/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/tooltips/main.cc b/examples/book/tooltips/main.cc
index 0ebc818..8c2e7a7 100644
--- a/examples/book/tooltips/main.cc
+++ b/examples/book/tooltips/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/combo_renderer/main.cc b/examples/book/treeview/combo_renderer/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/combo_renderer/main.cc
+++ b/examples/book/treeview/combo_renderer/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/drag_and_drop/main.cc b/examples/book/treeview/drag_and_drop/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/drag_and_drop/main.cc
+++ b/examples/book/treeview/drag_and_drop/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/editable_cells/main.cc b/examples/book/treeview/editable_cells/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/editable_cells/main.cc
+++ b/examples/book/treeview/editable_cells/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/filter/main.cc b/examples/book/treeview/filter/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/filter/main.cc
+++ b/examples/book/treeview/filter/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/filter_modify/main.cc b/examples/book/treeview/filter_modify/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/filter_modify/main.cc
+++ b/examples/book/treeview/filter_modify/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/list/main.cc b/examples/book/treeview/list/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/list/main.cc
+++ b/examples/book/treeview/list/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/listviewtext/main.cc b/examples/book/treeview/listviewtext/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/listviewtext/main.cc
+++ b/examples/book/treeview/listviewtext/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/modelsort/main.cc b/examples/book/treeview/modelsort/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/modelsort/main.cc
+++ b/examples/book/treeview/modelsort/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/popup/main.cc b/examples/book/treeview/popup/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/popup/main.cc
+++ b/examples/book/treeview/popup/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/treeview/tree/main.cc b/examples/book/treeview/tree/main.cc
index 4620054..3c36987 100644
--- a/examples/book/treeview/tree/main.cc
+++ b/examples/book/treeview/tree/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/book/update_ui/examplewindow.cc b/examples/book/update_ui/examplewindow.cc
index 84fede2..8cc5077 100644
--- a/examples/book/update_ui/examplewindow.cc
+++ b/examples/book/update_ui/examplewindow.cc
@@ -69,8 +69,8 @@ void ExampleWindow::on_button_start()
 
      // Allow GTK+ to perform all updates for us. Without this, the progress bar
      // will appear to do nothing and then suddenly fill completely.
-     while(Gtk::Main::instance()->events_pending())
-         Gtk::Main::instance()->iteration();
+     while(Gtk::Main::events_pending())
+         Gtk::Main::iteration();
   }
 }
 
diff --git a/examples/book/update_ui/main.cc b/examples/book/update_ui/main.cc
index 4620054..3c36987 100644
--- a/examples/book/update_ui/main.cc
+++ b/examples/book/update_ui/main.cc
@@ -17,15 +17,14 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  //Shows the window and returns when it is closed.
-  Gtk::Main::run(window);
 
-  return 0;
+  //Shows the window and returns when it is closed.
+  return app->run(window);
 }
diff --git a/examples/others/arrow/arrow.cc b/examples/others/arrow/arrow.cc
index 71eff9d..85b2c3d 100644
--- a/examples/others/arrow/arrow.cc
+++ b/examples/others/arrow/arrow.cc
@@ -2,7 +2,7 @@
 #include <gtkmm/arrow.h>
 #include <gtkmm/button.h>
 #include <gtkmm/window.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 class ArrowButton : public Gtk::Button
 {
@@ -67,9 +67,8 @@ AppWindow::~AppWindow()
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   AppWindow arrows;
-  Gtk::Main::run(arrows);
-  return 0;
+  return app->run(arrows);
 }
diff --git a/examples/others/arrow/direction.cc b/examples/others/arrow/direction.cc
index 2d4a64b..22e82fe 100644
--- a/examples/others/arrow/direction.cc
+++ b/examples/others/arrow/direction.cc
@@ -4,7 +4,7 @@
 #include <gtkmm/grid.h>
 #include <gtkmm/button.h>
 #include <gtkmm/window.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 class ArrowButton : public Gtk::Button
 {
@@ -74,11 +74,10 @@ AppWindow::~AppWindow()
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main myapp(&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
   AppWindow arrows;
 
-  Gtk::Main::run(arrows);
-  return 0;
+  return app->run(arrows);
 }
 
 /* example-end */
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index ca359ca..cde92a5 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -43,6 +43,7 @@ public:
 
 protected:
   void on_font_button_font_set();
+  void on_button_close();
  
   Gtk::CheckButton* flag_checkboxes_[5];
   bool settings_[5];
@@ -124,6 +125,10 @@ void CalendarExample::on_font_button_font_set()
   }
 }
 
+void CalendarExample::on_button_close()
+{
+  hide();
+}
 
 CalendarExample::CalendarExample()
 {
@@ -232,7 +237,8 @@ CalendarExample::CalendarExample()
   bbox->set_layout(Gtk::BUTTONBOX_END);
 
   Gtk::Button* button = Gtk::manage(new Gtk::Button("Close"));
-  button->signal_clicked().connect(&Gtk::Main::quit);
+  button->signal_clicked().connect(
+    sigc::mem_fun(*this, &CalendarExample::on_button_close));
   bbox->add(*button);
   button->set_can_default();
   button->grab_default();
@@ -252,9 +258,8 @@ Glib::Date CalendarExample::get_date() const
 
 int main(int argc, char** argv)
 {
-  Gtk::Main myapp(&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
   CalendarExample calendar;
-  Gtk::Main::run(calendar);
-  return 0;
+  return app->run(calendar);
 }
 
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index 4a22047..ee5cc72 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -287,10 +287,10 @@ void AppWindow::on_cell_toggled(const Glib::ustring& path_string)
 
 int main(int argc, char** argv)
 {
-  Gtk::Main main_instance (&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   AppWindow window;
-  Gtk::Main::run(window);
+  app->run(window);
 
   return 0;
 }
diff --git a/examples/others/cellrenderercustom/testpopup.cc b/examples/others/cellrenderercustom/testpopup.cc
index eb37094..ad811be 100644
--- a/examples/others/cellrenderercustom/testpopup.cc
+++ b/examples/others/cellrenderercustom/testpopup.cc
@@ -110,10 +110,10 @@ void AppWindow::on_cell_edited(const Glib::ustring& path, const Glib::ustring& n
 
 int main(int argc, char** argv)
 {
-  Gtk::Main main_instance (&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   AppWindow window;
-  Gtk::Main::run(window);
+  app->run(window);
 
   return 0;
 }
diff --git a/examples/others/dnd/dndwindow.cc b/examples/others/dnd/dndwindow.cc
index 8f4691a..eaa4dfb 100644
--- a/examples/others/dnd/dndwindow.cc
+++ b/examples/others/dnd/dndwindow.cc
@@ -18,7 +18,7 @@
 
 #include "dndwindow.h"
 #include "dnd_images.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <iostream>
 
 DnDWindow::DnDWindow()
diff --git a/examples/others/dnd/main.cc b/examples/others/dnd/main.cc
index 6007d14..4946dd8 100644
--- a/examples/others/dnd/main.cc
+++ b/examples/others/dnd/main.cc
@@ -17,14 +17,12 @@
  */
 
 #include "dndwindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   DnDWindow dndWindow;
-  Gtk::Main::run(dndWindow); //Shows the window and returns when it is closed.
-
-  return 0;
+  return app->run(dndWindow); //Shows the window and returns when it is closed.
 }
diff --git a/examples/others/exception/exceptiontest.cc b/examples/others/exception/exceptiontest.cc
index 317ec17..49adb7a 100644
--- a/examples/others/exception/exceptiontest.cc
+++ b/examples/others/exception/exceptiontest.cc
@@ -3,7 +3,7 @@
 #include <gtkmm/box.h>
 #include <glibmm/convert.h>
 #include <glibmm/exceptionhandler.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 #include <gtkmm/button.h>
 
@@ -92,7 +92,8 @@ void handler2()
 
 int main(int argc, char** argv)
 {
-  Gtk::Main main_instance (&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
+
 
   Gtk::Window window;
   window.set_title("Exception Handlers");
@@ -129,8 +130,6 @@ int main(int argc, char** argv)
 
 
   window.show_all_children();
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
 
diff --git a/examples/others/idle/idle.cc b/examples/others/idle/idle.cc
index 5dd3297..baa1d1b 100644
--- a/examples/others/idle/idle.cc
+++ b/examples/others/idle/idle.cc
@@ -8,7 +8,7 @@
 #include <gtkmm/button.h>
 #include <gtkmm/label.h>
 #include <gtkmm/progressbar.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 #include <glibmm/main.h>
 
@@ -60,7 +60,7 @@ IdleExample::IdleExample() :
   // set border and display all
   set_border_width(5);
   add(*vbox);
-  show_all();
+  show_all_children();
 
   // formatting drive c in timeout callback ;-)
   Glib::signal_timeout().connect(sigc::mem_fun(*this, &IdleExample::timer_callback), 50);
@@ -95,13 +95,12 @@ bool IdleExample::idle_callback()
   return (fraction < 1.0);
 }
 
-int main (int argc, char *argv[])
+int main(int argc, char *argv[])
 {
-  Gtk::Main app(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   IdleExample example;
 
-  Gtk::Main::run(example);
-  return 0;
+  return app->run(example);
 }
 
diff --git a/examples/others/statusbar/statusbar.cc b/examples/others/statusbar/statusbar.cc
index eddc71e..f5cc729 100644
--- a/examples/others/statusbar/statusbar.cc
+++ b/examples/others/statusbar/statusbar.cc
@@ -1,6 +1,6 @@
 #include <gtkmm/box.h>
 #include <gtkmm/button.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 #include <gtkmm/statusbar.h>
 
@@ -59,11 +59,10 @@ StatusBarExample::push_item(unsigned int context_id)
 
 int main (int argc, char *argv[])
 {
-  Gtk::Main myapp(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   StatusBarExample exampleWindow;
 
-  Gtk::Main::run(exampleWindow);
-  return 0;
+  return app->run(exampleWindow);
 }
 
diff --git a/examples/others/stock/stock.cc b/examples/others/stock/stock.cc
index f94f82e..90b490b 100644
--- a/examples/others/stock/stock.cc
+++ b/examples/others/stock/stock.cc
@@ -8,7 +8,7 @@
 #include <gtkmm/stock.h>
 #include <gtkmm/toolbutton.h>
 #include <gtkmm/separatortoolitem.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 #include <cstdio>
 //#include <glib.h>
@@ -137,10 +137,8 @@ void MainWindowClass::quit_pressed_cb()
 
 int main(gint argc, gchar **argv)
 {
-    Gtk::Main kit(argc, argv);
+    Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
     MainWindowClass main_window;
   
-    Gtk::Main::run(main_window);
-
-    return 0;
+    return app->run(main_window);
 }
diff --git a/examples/others/tictactoe/ttt_test.cc b/examples/others/tictactoe/ttt_test.cc
index ff197ab..4dceaa0 100644
--- a/examples/others/tictactoe/ttt_test.cc
+++ b/examples/others/tictactoe/ttt_test.cc
@@ -1,6 +1,6 @@
 #include "tictactoe.h"
 #include <gtkmm/window.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 
 void
@@ -14,7 +14,7 @@ win (TicTacToe *ttt)
 int
 main (int argc, char *argv[])
 {
-  Gtk::Main m(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   TicTacToe* ttt = manage( new TicTacToe );
   ttt->tictactoe.connect( sigc::bind (sigc::ptr_fun(&win), ttt) );
@@ -25,7 +25,5 @@ main (int argc, char *argv[])
   window.add(*ttt);
   window.show_all_children();
 
-  Gtk::Main::run(window);
-
-  return 0;
+  return app->run(window);
 }
diff --git a/examples/others/treemodelcustom/main.cc b/examples/others/treemodelcustom/main.cc
index 3bfdcd5..5ed68e1 100644
--- a/examples/others/treemodelcustom/main.cc
+++ b/examples/others/treemodelcustom/main.cc
@@ -17,14 +17,12 @@
  */
 
 #include "examplewindow.h"
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 
 int main(int argc, char *argv[])
 {
-  Gtk::Main kit(argc, argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
   ExampleWindow window;
-  Gtk::Main::run(window); //Shows the window and returns when it is closed.
-
-  return 0;
+  return app->run(window); //Shows the window and returns when it is closed.
 }
diff --git a/examples/others/window/wheelbarrow.cc b/examples/others/window/wheelbarrow.cc
index 8c063ba..f61ef12 100644
--- a/examples/others/window/wheelbarrow.cc
+++ b/examples/others/window/wheelbarrow.cc
@@ -4,7 +4,7 @@
 
 #include <gdkmm.h>
 #include <gtkmm/image.h>
-#include <gtkmm/main.h>
+#include <gtkmm/application.h>
 #include <gtkmm/window.h>
 
 
@@ -191,10 +191,9 @@ bool Wheelbarrow::on_button_press_event(GdkEventButton* event)
 
 int main(int argc, char** argv)
 {
-  Gtk::Main myapp (&argc, &argv);
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
 
-  Wheelbarrow wheelbarrow;
-  Gtk::Main::run(wheelbarrow);
 
-  return 0;
+  Wheelbarrow wheelbarrow;
+  return app->run(wheelbarrow);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]