[gtkmm] Gtk::Application: Remove create() method with argc, argv arguments
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::Application: Remove create() method with argc, argv arguments
- Date: Fri, 10 Feb 2017 17:51:10 +0000 (UTC)
commit d0f03c7d3ff7c0e718b094bd60d3fb19fb6c13fd
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Fri Feb 10 18:47:50 2017 +0100
Gtk::Application: Remove create() method with argc,argv arguments
* gtk/src/application.[ccg|hg]: Remove the constructor and create() method
that take argc and argv arguments. They are unnecessary now that gtk_init()
does not use argc,argv.
* demos/gtk-demo/main.cc:
* tests/*/main.cc: Move argc,argv from create() to run().
https://mail.gnome.org/archives/gtkmm-list/2017-February/msg00000.html
demos/gtk-demo/main.cc | 7 +---
gtk/src/application.ccg | 30 ++++------------
gtk/src/application.hg | 68 -----------------------------------
tests/builder/main.cc | 8 ++--
tests/child_widget/main.cc | 7 +---
tests/child_widget2/main.cc | 5 +--
tests/child_widget_managed/main.cc | 5 +--
tests/delete_cpp_child/main.cc | 5 +--
tests/dialog/main.cc | 5 +--
tests/dialog_deletethis/main.cc | 4 +-
tests/main_with_options/main.cc | 7 +---
tests/menu_destruction/main.cc | 5 +--
tests/property_notification/main.cc | 5 +--
tests/refcount_dialog/main.cc | 5 +--
tests/scrolledwindow/main.cc | 9 +++--
tests/wrap_existing/main.cc | 7 ++--
16 files changed, 42 insertions(+), 140 deletions(-)
---
diff --git a/demos/gtk-demo/main.cc b/demos/gtk-demo/main.cc
index e54c059..39d938e 100644
--- a/demos/gtk-demo/main.cc
+++ b/demos/gtk-demo/main.cc
@@ -1,5 +1,3 @@
-/* $Id$ */
-
/* main.cc
*
* Copyright (C) 2001-2002 The gtkmm Development Team
@@ -24,10 +22,9 @@
int main (int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
DemoWindow window;
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/gtk/src/application.ccg b/gtk/src/application.ccg
index 2af7342..54b3c45 100644
--- a/gtk/src/application.ccg
+++ b/gtk/src/application.ccg
@@ -93,23 +93,12 @@ Application::Application(const Glib::ustring& application_id, Gio::ApplicationFl
// Mark this class as non-derived to allow C++ vfuncs to be skipped.
//Note that GApplication complains about "" but allows nullptr, so we avoid passing "".
Glib::ObjectBase(nullptr),
- Gio::Application(Glib::ConstructParams(custom_class_init(), "application_id", (application_id.empty() ?
nullptr : application_id.c_str()), "flags", GApplicationFlags(flags), nullptr)),
- m_argc(0),
- m_argv(nullptr)
-{
- gtk_init();
- set_cxx_locale_to_c_locale();
-}
-
-Application::Application(int& argc, char**& argv, const Glib::ustring& application_id, Gio::ApplicationFlags
flags)
-:
- // Mark this class as non-derived to allow C++ vfuncs to be skipped.
- //Note that GApplication complains about "" but allows nullptr, so we avoid passing "".
- Glib::ObjectBase(nullptr),
- Gio::Application(Glib::ConstructParams(custom_class_init(), "application_id", (application_id.empty() ?
nullptr : application_id.c_str()), "flags", GApplicationFlags(flags), nullptr)),
- m_argc(argc),
- m_argv(argv)
+ Gio::Application(Glib::ConstructParams(custom_class_init(), "application_id", (application_id.empty() ?
nullptr : application_id.c_str()), "flags", GApplicationFlags(flags), nullptr))
{
+ // gtk_init() is called by the 'startup' default signal handler when g_application_run() is called.
+ // It's also called here, to make it possible for users of gtkmm to create
+ // a window and other widgets before calling run().
+ // See https://bugzilla.gnome.org/show_bug.cgi?id=639925
gtk_init();
set_cxx_locale_to_c_locale();
}
@@ -119,11 +108,6 @@ Glib::RefPtr<Application> Application::create(const Glib::ustring& application_i
return Glib::RefPtr<Application>( new Application(application_id, flags) );
}
-Glib::RefPtr<Application> Application::create(int& argc, char**& argv, const Glib::ustring& application_id,
Gio::ApplicationFlags flags)
-{
- return Glib::RefPtr<Application>( new Application(argc, argv, application_id, flags) );
-}
-
void Application::on_window_hide(Window* window)
{
//Tell GtkApplication to forget the window.
@@ -177,13 +161,13 @@ int Application::run(Window& window)
sigc::mem_fun(*this, &Application::on_activate_add_and_show_main_window),
&window));
- const auto result = Gio::Application::run(m_argc, m_argv);
+ const auto result = Gio::Application::run(0, nullptr);
return result;
}
int Application::run()
{
- const auto result = Gio::Application::run(m_argc, m_argv);
+ const auto result = Gio::Application::run(0, nullptr);
return result;
}
diff --git a/gtk/src/application.hg b/gtk/src/application.hg
index c6afbc1..1b19adf 100644
--- a/gtk/src/application.hg
+++ b/gtk/src/application.hg
@@ -121,37 +121,6 @@ protected:
_IGNORE(gtk_application_window_new)
- //This constructor does not correspond to anything in the C API.
- //We added it so we can choose to always initialize gtkmm as early as possible.
- //See https://bugzilla.gnome.org/show_bug.cgi?id=639925
- /** Creates a new Application instance.
- *
- * This initializes gtkmm (and the GObject type system) for you, parsing the
- * standard GTK+ command line arguments.
- * The global locale is set as specified by Glib::set_init_to_users_preferred_locale().
- *
- * You could instead use the constructor that takes no command line arguments
- * and later supply the command line arguments to run().
- *
- * Note that all GTK+ functionality that is available via command line arguments
- * can instead be achieved by setting suitable environment variables
- * such as G_DEBUG.
- *
- * If non-empty, the application ID must be valid. See Gio::Application::id_is_valid().
- *
- * If no application ID is given then some features (most notably application
- * uniqueness) will be disabled. A null application ID is only allowed with
- * gtkmm 3.6 or later.
- *
- * @param argc The parameter received by your main() function.
- * @param argv The parameter received by your main() function.
- * @param application_id A valid application ID.
- * @param flags The application flags.
- *
- * @newin{3,4}
- */
- explicit Application(int& argc, char**& argv, const Glib::ustring& application_id = Glib::ustring(),
Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
-
public:
/** Creates a new Application instance.
@@ -172,34 +141,6 @@ public:
*/
static Glib::RefPtr<Application> create(const Glib::ustring& application_id = Glib::ustring(),
Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
- /** Creates a new Application instance.
- *
- * This initializes gtkmm (and the GObject type system) for you, parsing the
- * standard GTK+ command line arguments.
- * The global locale is set as specified by Glib::set_init_to_users_preferred_locale().
- *
- * You could instead use the constructor that takes no command line arguments
- * and later supply the command line arguments to run().
- *
- * Note that all GTK+ functionality that is available via command line arguments
- * can instead be achieved by setting suitable environment variables
- * such as G_DEBUG.
- *
- * If non-empty, the application ID must be valid. See Gio::Application::id_is_valid().
- *
- * If no application ID is given then some features (most notably application
- * uniqueness) will be disabled. A null application ID is only allowed with
- * gtkmm 3.6 or later.
- *
- * @param argc The parameter received by your main() function.
- * @param argv The parameter received by your main() function.
- * @param application_id A valid application ID.
- *
- * @param flags The application flags.
- * @newin{3,4}
- */
- static Glib::RefPtr<Application> create(int& argc, char**& argv, const Glib::ustring& application_id =
Glib::ustring(), Gio::ApplicationFlags flags = Gio::APPLICATION_FLAGS_NONE);
-
#m4 _CONVERSION(`GList*',`std::vector<Window*>',`Glib::ListHandler<Window*>::list_to_vector($3,
Glib::OWNERSHIP_NONE)')
_WRAP_METHOD(std::vector<Window*> get_windows(), gtk_application_get_windows)
@@ -268,8 +209,6 @@ public:
*/
int run(Window& window, int argc, char** argv);
- //TODO: If argc and argv are necessary at all, document the need to call that constructor first.
- //See https://bugzilla.gnome.org/show_bug.cgi?id=639925#c4
/** Starts the application.
*
* The default implementation of this virtual function will simply run
@@ -289,8 +228,6 @@ public:
*/
int run(Window& window);
- //TODO: If argc and argv are necessary at all, document the need to call that constructor first.
- //See https://bugzilla.gnome.org/show_bug.cgi?id=639925#c4
/** Starts the application.
*
* The default implementation of this virtual function will simply run
@@ -383,11 +320,6 @@ private:
void on_activate_add_and_show_main_window(Window* window);
void on_window_hide(Window* window);
-
- //We need these to call g_application_run(),
- //even if we have already called gtk_init().
- int m_argc;
- char** m_argv;
};
} // namespace Gtk
diff --git a/tests/builder/main.cc b/tests/builder/main.cc
index 961cfa2..7ff695b 100644
--- a/tests/builder/main.cc
+++ b/tests/builder/main.cc
@@ -150,7 +150,7 @@ int main(int argc, char* argv[])
argc1 = 1; // Don't give the command line arguments to Gtk::Application.
}
- Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc1, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create_from_string(gladefile);
@@ -166,15 +166,15 @@ int main(int argc, char* argv[])
const GObject* const derived_button = (GObject*)main_win->get_derived_button()->gobj();
const GObject* const standard_button = (GObject*)main_win->get_standard_button()->gobj();
- std::cout << "Before app->run(*main_win)" << std::endl
+ std::cout << "Before app->run(*main_win, argc1, argv)" << std::endl
<< " ref_count(MainWindow)=" << window->ref_count << std::endl
<< " ref_count(DerivedButton)=" << derived_button->ref_count << std::endl
<< " ref_count(Gtk::Button)=" << standard_button->ref_count << std::endl
<< " ref_count(orphaned_button)=" << orphaned_button->ref_count << std::endl;
- const int result = app->run(*main_win);
+ const int result = app->run(*main_win, argc1, argv);
- std::cout << "After app->run(*main_win)" << std::endl
+ std::cout << "After app->run(*main_win, argc1, argv)" << std::endl
<< " ref_count(MainWindow)=" << window->ref_count << std::endl
<< " ref_count(DerivedButton)=" << derived_button->ref_count << std::endl
<< " ref_count(Gtk::Button)=" << standard_button->ref_count << std::endl
diff --git a/tests/child_widget/main.cc b/tests/child_widget/main.cc
index c36de4e..03c9b32 100644
--- a/tests/child_widget/main.cc
+++ b/tests/child_widget/main.cc
@@ -1,5 +1,3 @@
-//$Id$ -*- c++ -*-
-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
@@ -21,9 +19,8 @@
int main(int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
TestWindow testWindow;
- return app->run(testWindow); //Shows the window and returns when it is closed.
+ return app->run(testWindow, argc, argv); //Shows the window and returns when it is closed.
}
diff --git a/tests/child_widget2/main.cc b/tests/child_widget2/main.cc
index d678ea2..768a59a 100644
--- a/tests/child_widget2/main.cc
+++ b/tests/child_widget2/main.cc
@@ -19,9 +19,8 @@ MyWindow::MyWindow() :
int main (int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
MyWindow window;
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/tests/child_widget_managed/main.cc b/tests/child_widget_managed/main.cc
index cf5ecd5..037aa45 100644
--- a/tests/child_widget_managed/main.cc
+++ b/tests/child_widget_managed/main.cc
@@ -43,9 +43,8 @@ ExampleWindow::~ExampleWindow()
int main(int argc, char* argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
ExampleWindow window;
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/tests/delete_cpp_child/main.cc b/tests/delete_cpp_child/main.cc
index dc7daf2..bafae55 100644
--- a/tests/delete_cpp_child/main.cc
+++ b/tests/delete_cpp_child/main.cc
@@ -48,8 +48,7 @@ void AppWindow::on_button_clicked()
int main(int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
AppWindow window;
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/tests/dialog/main.cc b/tests/dialog/main.cc
index 4ece208..137abd9 100644
--- a/tests/dialog/main.cc
+++ b/tests/dialog/main.cc
@@ -48,8 +48,7 @@ void AppWindow::on_button_clicked()
int main(int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
AppWindow window;
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/tests/dialog_deletethis/main.cc b/tests/dialog_deletethis/main.cc
index 99fce4c..30fbe14 100644
--- a/tests/dialog_deletethis/main.cc
+++ b/tests/dialog_deletethis/main.cc
@@ -44,12 +44,12 @@ class Dlg : public sigc::trackable
int main (int argc, char **argv)
{
- app = Gtk::Application::create(argc, argv);
+ app = Gtk::Application::create();
new Dlg(); //Not a Gtk::Dialog - it creates one in its constructor.
app->hold();
- return app->run();
+ return app->run(argc, argv);
}
diff --git a/tests/main_with_options/main.cc b/tests/main_with_options/main.cc
index 530466f..ac8e209 100644
--- a/tests/main_with_options/main.cc
+++ b/tests/main_with_options/main.cc
@@ -1,5 +1,3 @@
-//$Id$ -*- c++ -*-
-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
@@ -103,8 +101,7 @@ int main(int argc, char *argv[])
try
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
//Here we can see the parsed values of our custom command-line arguments:
@@ -126,7 +123,7 @@ 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;
- return app->run(testWindow); //Shows the window and returns when it is closed.
+ return app->run(testWindow, argc, argv); //Shows the window and returns when it is closed.
}
catch(const Glib::Error& ex)
{
diff --git a/tests/menu_destruction/main.cc b/tests/menu_destruction/main.cc
index 4b1df72..41bc5ba 100644
--- a/tests/menu_destruction/main.cc
+++ b/tests/menu_destruction/main.cc
@@ -76,8 +76,7 @@ test_window::test_window()
int main(int argc, char *argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
test_window foo;
- return app->run(foo);
+ return app->run(foo, argc, argv);
}
diff --git a/tests/property_notification/main.cc b/tests/property_notification/main.cc
index 1b4988b..afde633 100644
--- a/tests/property_notification/main.cc
+++ b/tests/property_notification/main.cc
@@ -19,8 +19,7 @@ void on_property_name_changed()
int main (int argc, char **argv)
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
Gtk::Window window;
@@ -36,5 +35,5 @@ int main (int argc, char **argv)
window.add(button);
- return app->run(window);
+ return app->run(window, argc, argv);
}
diff --git a/tests/refcount_dialog/main.cc b/tests/refcount_dialog/main.cc
index f821f45..1d0c3d8 100644
--- a/tests/refcount_dialog/main.cc
+++ b/tests/refcount_dialog/main.cc
@@ -52,9 +52,8 @@ void MyWindow::on_button_clicked()
int main(int argc, char* argv[])
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
MyWindow win;
- return app->run(win);
+ return app->run(win, argc, argv);
}
diff --git a/tests/scrolledwindow/main.cc b/tests/scrolledwindow/main.cc
index 61b16df..1428d0c 100644
--- a/tests/scrolledwindow/main.cc
+++ b/tests/scrolledwindow/main.cc
@@ -55,10 +55,11 @@ protected:
DerivedScrolledWindow m_ScrolledWindow;
};
-int main ( int argc, char *argv[] ) {
-
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+int main (int /* argc */, char** /* argv */)
+{
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
Instance instance;
+
+ return 0;
}
diff --git a/tests/wrap_existing/main.cc b/tests/wrap_existing/main.cc
index 5167291..21c34b9 100644
--- a/tests/wrap_existing/main.cc
+++ b/tests/wrap_existing/main.cc
@@ -18,10 +18,9 @@ void on_object_qdata_destroyed(gpointer data)
g_warning("on_object_qdata_destroyed(): c instance=%p", (void*)data);
}
-int main(int argc, char**argv)
+int main (int /* argc */, char** /* argv */)
{
- Glib::RefPtr<Gtk::Application> app =
- Gtk::Application::create(argc, argv);
+ Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
Gtk::Dialog* pDialog = new Gtk::Dialog();
Gtk::Box* pBox = pDialog->get_content_area();
@@ -36,4 +35,6 @@ int main(int argc, char**argv)
delete pDialog;
g_warning("after delete");
+
+ return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]