cephtool: join GUI thread before shutting down

Join GUI thread before shutting down.

Move open_icon function.

Delete unused get_widgets function.

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
This commit is contained in:
Colin Patrick McCabe 2010-10-28 14:52:33 -07:00
parent c883903561
commit c13183e7db
2 changed files with 32 additions and 23 deletions

View File

@ -131,6 +131,7 @@ public:
{
shutting_down = true;
g.gui_cond.Signal();
this->join();
}
private:
@ -189,24 +190,6 @@ GuiMonitor::~GuiMonitor()
delete guiMonitorAboutDialog;
}
bool GuiMonitor::open_icon(Glib::RefPtr<Gdk::Pixbuf> &icon, const std::string &path)
{
try {
icon = Gdk::Pixbuf::create_from_file(path);
}
catch (const Gdk::PixbufError& e) {
cerr << "Problem making graphic from " << path << "; error code: " <<
e.code() << std::endl;
return false;
}
catch (const Glib::FileError& e) {
cerr << "Problem open " << path << std::endl;
return false;
}
return true;
}
bool GuiMonitor::init()
{
assert(!thread);
@ -251,6 +234,33 @@ void GuiMonitor::run_main_loop(Gtk::Main &kit)
kit.run(*guiMonitorWindow);
}
void GuiMonitor::thread_shutdown()
{
if (!thread)
return;
thread->shutdown();
delete thread;
thread = NULL;
}
bool GuiMonitor::open_icon(Glib::RefPtr<Gdk::Pixbuf> &icon, const std::string &path)
{
try {
icon = Gdk::Pixbuf::create_from_file(path);
}
catch (const Gdk::PixbufError& e) {
cerr << "Problem making graphic from " << path << "; error code: " <<
e.code() << std::endl;
return false;
}
catch (const Glib::FileError& e) {
cerr << "Problem open " << path << std::endl;
return false;
}
return true;
}
// Connects signals to the GUI elements such that they respond to events.
void GuiMonitor::connect_signals()
{
@ -824,8 +834,7 @@ void GuiMonitor::check_status()
// Handler for quitting the GUI via the "x" button on the window.
bool GuiMonitor::quit_gui(GdkEventAny *event)
{
if (thread)
thread->shutdown();
thread_shutdown();
guiMonitorWindow->hide();
return true;
}
@ -833,14 +842,14 @@ bool GuiMonitor::quit_gui(GdkEventAny *event)
// Handler for quitting the GUI via the menu option.
void GuiMonitor::gui_monitor_quit()
{
if (thread)
thread->shutdown();
thread_shutdown();
guiMonitorWindow->hide();
}
// Called when the main window is closed. Ends the program.
bool GuiMonitor::quit_signal_handler()
{
thread_shutdown();
Gtk::Main::quit();
return false; // never executed
}

View File

@ -169,6 +169,7 @@ public:
bool init();
void run_main_loop(Gtk::Main &kit);
void thread_shutdown();
void check_status();
@ -176,7 +177,6 @@ private:
/*
* Private Functions
*/
void get_widgets(Glib::RefPtr<Gtk::Builder> builder_object);
bool open_icon(Glib::RefPtr<Gdk::Pixbuf> &icon, const std::string &path);
void connect_signals();
void link_elements();