[gtkmm] Application: Simplify the window handling slightly.



commit 1a66091de4fd39970b0cd74decdead656a563780
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Mar 3 12:19:05 2012 +0100

    Application: Simplify the window handling slightly.
    
    	* gtk/src/application.[hg|ccg]: run(): Show the window immediately
    	instead of doing it in a signal handler, because that bug has been
    	fixed in GTK+.

 ChangeLog               |    8 ++++++++
 gtk/src/application.ccg |   31 ++-----------------------------
 gtk/src/application.hg  |    4 ----
 3 files changed, 10 insertions(+), 33 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 49cd2a8..9a55912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-03-03  Murray Cumming  <murrayc murrayc com>
+
+	Application: Simplify the window handling slightly.
+
+	* gtk/src/application.[hg|ccg]: run(): Show the window immediately
+	instead of doing it in a signal handler, because that bug has been
+	fixed in GTK+.
+
 2012-03-02  Murray Cumming  <murrayc murrayc com>
 
 	Deprecate Gtk::Main in favor of Gtk::Application.
diff --git a/gtk/src/application.ccg b/gtk/src/application.ccg
index 6a76224..4769eb0 100644
--- a/gtk/src/application.ccg
+++ b/gtk/src/application.ccg
@@ -71,7 +71,6 @@ Application::Application(const Glib::ustring& application_id, Gio::ApplicationFl
   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
   Glib::ObjectBase(0),
   Gio::Application(Glib::ConstructParams(custom_class_init(), "application_id", application_id.c_str(), "flags", GApplicationFlags(flags), static_cast<char*>(0))),
-  m_main_window(0),
   m_argc(0),
   m_argv(0)
 {
@@ -82,7 +81,6 @@ Application::Application(int& argc, char**& argv, const Glib::ustring& applicati
   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
   Glib::ObjectBase(0),
   Gio::Application(Glib::ConstructParams(custom_class_init(), "application_id", application_id.c_str(), "flags", GApplicationFlags(flags), static_cast<char*>(0))),
-  m_main_window(0),
   m_argc(argc),
   m_argv(argv)
 {
@@ -99,14 +97,6 @@ Glib::RefPtr<Application> Application::create(int& argc, char**& argv, const Gli
   return Glib::RefPtr<Application>( new Application(argc, argv, application_id, flags) );
 }
 
-void Application::on_activate_showwindow()
-{
-  if(m_main_window)
-    m_main_window->show();
-  
-  m_main_window = 0; //We don't need to remember this anymore.
-}
-
 void Application::on_window_hide(Window* window)
 {
   //Tell GtkApplication to forget the window.
@@ -138,17 +128,9 @@ int Application::run(int argc, char** argv)
 int Application::run(Window& window, int argc, char** argv)
 {
   add_window(window);
-  
-  //Show the window when the application starts.
-  //We could just call show() now,
-  //but GApplication currently warns if we don't connect to the activate signal,
-  //which seems very C-centric. See https://bugzilla.gnome.org/show_bug.cgi?id=640042
-  m_main_window = &window;
-  signal_activate().connect(
-    sigc::mem_fun(*this, &Application::on_activate_showwindow));
+  window.show();
 
   const int result = Gio::Application::run(argc, argv);
-  init_gtkmm_internals(); //TODO: This is too late. We want to do this as soon as possible, but it can't be done before gtk_init(argc, argv).
   return result;
 }
 
@@ -158,17 +140,9 @@ int Application::run(Window& window)
   g_assert(m_argv);
 
   add_window(window);
-  
-  //Show the window when the application starts.
-  //We could just call show() now,
-  //but GApplication currently warns if we don't connect to the activate signal,
-  //which seems very C-centric. See https://bugzilla.gnome.org/show_bug.cgi?id=640042
-  m_main_window = &window;
-  signal_activate().connect(
-    sigc::mem_fun(*this, &Application::on_activate_showwindow));
+  window.show();
 
   const int result = Gio::Application::run(m_argc, m_argv);
-  init_gtkmm_internals();  //TODO: This is too late. We want to do this as soon as possible, but it can't be done before gtk_init(argc, argv).
   return result;
 }
 
@@ -178,7 +152,6 @@ int Application::run()
   g_assert(m_argv);
 
   const int result = Gio::Application::run(m_argc, m_argv);
-  init_gtkmm_internals();  //TODO: This is too late. We want to do this as soon as possible, but it can't be done before gtk_init(argc, argv).
   return result;
 }
 
diff --git a/gtk/src/application.hg b/gtk/src/application.hg
index c1bc608..338cf12 100644
--- a/gtk/src/application.hg
+++ b/gtk/src/application.hg
@@ -164,12 +164,8 @@ private:
    */
   const Glib::Class& custom_class_init();
   
-  void on_activate_showwindow();
   void on_window_hide(Window*);
   
-  ///We show the window in the activate signal handler.
-  Window* m_main_window;
-  
   //We need these to call g_application_run(), 
   //even if we have already called gtk_init().
   int m_argc;



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