[gtkmm] Tests: Use Gtk::Application instead of Gtk::Main.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Tests: Use Gtk::Application instead of Gtk::Main.
- Date: Sat, 3 Mar 2012 11:43:29 +0000 (UTC)
commit 1e3deca5104cf47207a2de933e5a3b35a7534a0b
Author: Murray Cumming <murrayc murrayc com>
Date: Sat Mar 3 12:19:52 2012 +0100
Tests: Use Gtk::Application instead of Gtk::Main.
* tests/: Use Gtk::Application because we have deprecated Gtk::Main.
ChangeLog | 6 ++++++
tests/child_widget/main.cc | 8 ++++----
tests/child_widget2/main.cc | 8 ++++----
tests/child_widget_managed/main.cc | 10 ++++++----
tests/delete_cpp_child/main.cc | 9 +++++----
tests/dialog/main.cc | 9 +++++----
tests/dialog_deletethis/main.cc | 9 ++++++---
tests/main_with_options/main.cc | 9 +++++----
tests/menu_destruction/main.cc | 8 ++++----
tests/property_notification/main.cc | 6 ++++--
tests/refcount_dialog/main.cc | 10 ++++++----
tests/scrolledwindow/main.cc | 5 +++--
tests/wrap_existing/main.cc | 4 +++-
13 files changed, 61 insertions(+), 40 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a55912..73e4152 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-03-03 Murray Cumming <murrayc murrayc com>
+ Tests: Use Gtk::Application instead of Gtk::Main.
+
+ * tests/: Use Gtk::Application because we have deprecated Gtk::Main.
+
+2012-03-03 Murray Cumming <murrayc murrayc com>
+
Application: Simplify the window handling slightly.
* gtk/src/application.[hg|ccg]: run(): Show the window immediately
diff --git a/tests/child_widget/main.cc b/tests/child_widget/main.cc
index f4dbea1..2ee60a2 100644
--- a/tests/child_widget/main.cc
+++ b/tests/child_widget/main.cc
@@ -21,10 +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.test");
TestWindow testWindow;
- kit.run(testWindow); //Shows the window and returns when it is closed.
-
- return 0;
+ return app->run(testWindow); //Shows the window and returns when it is closed.
}
diff --git a/tests/child_widget2/main.cc b/tests/child_widget2/main.cc
index c1a49f7..8d402e7 100644
--- a/tests/child_widget2/main.cc
+++ b/tests/child_widget2/main.cc
@@ -20,10 +20,10 @@ MyWindow::MyWindow() :
int main (int argc, char *argv[])
{
- Gtk::Main kit(argc, argv);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
MyWindow window;
- kit.run(window);
-
- return 0;
+ return app->run(window);
}
diff --git a/tests/child_widget_managed/main.cc b/tests/child_widget_managed/main.cc
index 8081822..b0c3255 100644
--- a/tests/child_widget_managed/main.cc
+++ b/tests/child_widget_managed/main.cc
@@ -45,8 +45,10 @@ ExampleWindow::~ExampleWindow()
int main(int argc, char* argv[])
{
- Gtk::Main kit(argc, argv);
- ExampleWindow window;
- kit.run(window);
- return 0;
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
+
+ ExampleWindow window;
+ return app->run(window);
}
diff --git a/tests/delete_cpp_child/main.cc b/tests/delete_cpp_child/main.cc
index 30eb81a..40a5b5f 100644
--- a/tests/delete_cpp_child/main.cc
+++ b/tests/delete_cpp_child/main.cc
@@ -50,8 +50,9 @@ void AppWindow::on_button_clicked()
int main(int argc, char *argv[])
{
- Gtk::Main kit(&argc, &argv);
- AppWindow app;
- Gtk::Main::run(app);
- return(0);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
+ AppWindow window;
+ return app->run(window);
}
diff --git a/tests/dialog/main.cc b/tests/dialog/main.cc
index c6cebb0..d719aeb 100644
--- a/tests/dialog/main.cc
+++ b/tests/dialog/main.cc
@@ -50,8 +50,9 @@ void AppWindow::on_button_clicked()
int main(int argc, char *argv[])
{
- Gtk::Main kit(&argc, &argv);
- AppWindow app;
- Gtk::Main::run(app);
- return(0);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
+ AppWindow window;
+ return app->run(window);
}
diff --git a/tests/dialog_deletethis/main.cc b/tests/dialog_deletethis/main.cc
index 95c7046..8c6c894 100644
--- a/tests/dialog_deletethis/main.cc
+++ b/tests/dialog_deletethis/main.cc
@@ -1,6 +1,8 @@
#include <gtkmm.h>
#include <iostream>
+Glib::RefPtr<Gtk::Application> app;
+
//This is _not_ a good example of coding with gtkmm.
class Dlg : public sigc::trackable
{
@@ -34,7 +36,7 @@ class Dlg : public sigc::trackable
void quit() {
delete this; //This is _not_ a good example of coding with gtkmm.
- Gtk::Main::quit();
+ app->quit();
}
private:
@@ -43,11 +45,12 @@ class Dlg : public sigc::trackable
int main (int argc, char **argv)
{
- Gtk::Main kit (argc, argv);
+ app = Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
new Dlg(); //Not a Gtk::Dialog - it creates one in its constructor.
- Gtk::Main::run();
+ return app->run();
}
diff --git a/tests/main_with_options/main.cc b/tests/main_with_options/main.cc
index b3885c1..03e5573 100644
--- a/tests/main_with_options/main.cc
+++ b/tests/main_with_options/main.cc
@@ -103,7 +103,9 @@ int main(int argc, char *argv[])
try
{
- Gtk::Main main_instance(argc, argv, context);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
//Here we can see the parsed values of our custom command-line arguments:
@@ -125,13 +127,12 @@ int main(int argc, char *argv[])
//Any standard GTK+ command-line arguments will have an effect on this window:
//Try --name="bobble" to change the window's title to "bobble", for instance.
Gtk::Window testWindow;
- main_instance.run(testWindow); //Shows the window and returns when it is closed.
+ return app->run(testWindow); //Shows the window and returns when it is closed.
}
catch(const Glib::Error& ex)
{
- std::cout << "Exception: " << ex.what() << std::endl;
+ std::cerr << "Exception: " << ex.what() << std::endl;
}
-
return 0;
}
diff --git a/tests/menu_destruction/main.cc b/tests/menu_destruction/main.cc
index 7f9431a..878bc8c 100644
--- a/tests/menu_destruction/main.cc
+++ b/tests/menu_destruction/main.cc
@@ -76,9 +76,9 @@ test_window::test_window()
int main(int argc, char *argv[])
{
- Gtk::Main main_runner(argc, argv);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
test_window foo;
- Gtk::Main::run(foo);
-
- return(0);
+ return app->run(foo);
}
diff --git a/tests/property_notification/main.cc b/tests/property_notification/main.cc
index a10e37d..97f792a 100644
--- a/tests/property_notification/main.cc
+++ b/tests/property_notification/main.cc
@@ -19,7 +19,9 @@ void on_property_name_changed()
int main (int argc, char **argv)
{
- Gtk::Main kit (argc, argv);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
Gtk::Window window;
@@ -35,5 +37,5 @@ int main (int argc, char **argv)
window.add(button);
- Gtk::Main::run(window);
+ return app->run(window);
}
diff --git a/tests/refcount_dialog/main.cc b/tests/refcount_dialog/main.cc
index f64444b..bca6ac9 100644
--- a/tests/refcount_dialog/main.cc
+++ b/tests/refcount_dialog/main.cc
@@ -33,6 +33,8 @@ MyWindow::MyWindow()
m_Button.signal_clicked().connect( sigc::mem_fun(*this, &MyWindow::on_button_clicked) );
m_Box.pack_start(m_Button);
add(m_Box);
+
+ show_all_children();
}
void MyWindow::on_button_clicked()
@@ -52,10 +54,10 @@ void MyWindow::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.test");
MyWindow win;
- win.show_all();
- kit.run(win);
- return 0;
+ return app->run(win);
}
diff --git a/tests/scrolledwindow/main.cc b/tests/scrolledwindow/main.cc
index 8149d72..2276493 100644
--- a/tests/scrolledwindow/main.cc
+++ b/tests/scrolledwindow/main.cc
@@ -58,8 +58,9 @@ protected:
int main ( int argc, char *argv[] ) {
- Gtk::Main main( argc, argv );
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
Instance instance;
-
}
diff --git a/tests/wrap_existing/main.cc b/tests/wrap_existing/main.cc
index e755ef6..95e4941 100644
--- a/tests/wrap_existing/main.cc
+++ b/tests/wrap_existing/main.cc
@@ -20,7 +20,9 @@ void on_object_qdata_destroyed(gpointer data)
int main(int argc, char**argv)
{
- Gtk::Main app(&argc, &argv);
+ Glib::RefPtr<Gtk::Application> app =
+ Gtk::Application::create(argc, argv,
+ "org.gtkmm.test");
Gtk::Dialog* pDialog = new Gtk::Dialog();
Gtk::Box* pBox = pDialog->get_content_area();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]