From 483cf2815d8d89a0335527adf7cc8f053ece1771 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 6 Jul 2006 11:26:23 +0000 Subject: [PATCH] - Pardon my italian, but "'affanculo" is the only thing that crosses my mind seeing what was the correct fix. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@738 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/main.cc | 2 +- src/parse_opts.cc | 16 ++++++++++------ src/start_gui.cc | 11 ++++++----- src/start_gui.hh | 4 +++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main.cc b/src/main.cc index 10c628f..7ba24e6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -53,6 +53,6 @@ main(int argc, char* argv[]) // Parses options and prepares vector with // filenames of documents to be opened parse_options(argc, argv); - + return 0; } diff --git a/src/parse_opts.cc b/src/parse_opts.cc index 792549e..9ec689d 100644 --- a/src/parse_opts.cc +++ b/src/parse_opts.cc @@ -93,7 +93,7 @@ parse_options(int argc, char** argv) try { // Parse options, initialising the Gtk::Main at the same time - Gtk::Main(argc, argv, context); + Gtk::Main main_loop(argc, argv, context); GlobalPreferences& prefs = GlobalPreferences::get_instance(); @@ -118,11 +118,15 @@ parse_options(int argc, char** argv) throw Glib::OptionError(Glib::OptionError::FAILED, _("The `No-GUI' option isn't active yet.")); // FIXME : to be written! - } else { - if(fnames.begin() != fnames.end()) - start_gui(*fnames.begin()); - else - start_gui(""); + } + else + { + Gtk::Window* main_window; + if(fnames.begin() != fnames.end()) + main_window = start_gui(*fnames.begin()); + else + main_window = start_gui(""); + main_loop.run(*main_window); } } // ~ try catch(Glib::OptionError e) diff --git a/src/start_gui.cc b/src/start_gui.cc index 0be8819..b5235b2 100644 --- a/src/start_gui.cc +++ b/src/start_gui.cc @@ -28,12 +28,11 @@ #include #include #include -#include #include #include -void +Gtk::Window* start_gui(const std::string& filename) { using namespace Gnome; @@ -54,19 +53,21 @@ start_gui(const std::string& filename) // Glade::Xml::get_widget_derived -- better --) MenuItem* file_quit = NULL; refXml->get_widget("MenuItem.File.Quit", file_quit); - file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit)); + assert(file_quit != NULL); + file_quit->signal_activate().connect(sigc::ptr_fun(&Main::quit)); // About dialog MenuItem* help_about = NULL; refXml->get_widget("MenuItem.Help.About", help_about); + assert(help_about != NULL); AboutDialog* about_dialog = NULL; refXml->get_widget("AboutDialog", about_dialog); + assert(about_dialog != NULL); help_about->signal_activate().connect(sigc::mem_fun(*about_dialog, &Window::show)); // FIXME: Here open filename if != "" main_window->show_all_children(); - - Main::run(*main_window); + return main_window; } diff --git a/src/start_gui.hh b/src/start_gui.hh index bdaaaf4..ec3bd10 100644 --- a/src/start_gui.hh +++ b/src/start_gui.hh @@ -23,12 +23,14 @@ #include "config.h" +#include + #include /** \brief This function initialize and starts the whole GUI */ -void SG_DLLEXPORT start_gui(const std::string& filename); +Gtk::Window* start_gui(const std::string& filename); #endif