- Use smart_ptr for tooltips into schedulable_state_widget. Closes task #3.

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@984 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-01 17:20:17 +00:00
parent ad774067e1
commit 6f2c9c3252
2 changed files with 16 additions and 7 deletions

View File

@ -22,6 +22,8 @@
#include "schedulable_state_widget.hh"
#include "smartp.tcc"
#include <glibmm/ustring.h>
#include <cassert>
@ -29,15 +31,16 @@
using namespace sgpem;
Gtk::Tooltips*
SchedulableStateWidget::_ttips = NULL;
memory::smart_ptr<Gtk::Tooltips>
SchedulableStateWidget::_global_ttips = NULL;
SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
: Glib::ObjectBase("sgpem_SchedulableStateWidget"), CairoWidget(), _color(1, 1, 1)
{
// Yes, we leak, but this will be up until the end of the app
if(!_ttips) _ttips = new Gtk::Tooltips();
if(!_global_ttips) _global_ttips = new Gtk::Tooltips();
_ttips = _global_ttips;
set_scaling_mode(scaling_to_w);
set_state(st);
@ -46,6 +49,9 @@ SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
SchedulableStateWidget::~SchedulableStateWidget()
{
_ttips->unset_tip(*this);
_ttips = memory::smart_ptr<Gtk::Tooltips>::null;
if(_global_ttips.alive_refs() == 1)
_global_ttips = memory::smart_ptr<Gtk::Tooltips>::null;
}
@ -68,7 +74,7 @@ SchedulableStateWidget::set_state(Schedulable::state new_state)
tip = _("Running");
break;
case Schedulable::state_blocked:
_color = Color(0, 0, 1); // Blue
_color = Color(1, 0, 0); // Red
tip = _("Blocked");
break;
case Schedulable::state_terminated:

View File

@ -27,7 +27,8 @@
#include "cairo_elements.hh"
#include "cairo_widget.hh"
#include "glibmm/refptr.h"
#include "smartp.tcc"
#include "gtkmm/tooltips.h"
namespace sgpem
@ -50,8 +51,10 @@ namespace sgpem
virtual void calc_widget_size(size_t& width, size_t& height) const;
private:
static memory::smart_ptr<Gtk::Tooltips> _global_ttips;
Color _color;
static Gtk::Tooltips* _ttips;
memory::smart_ptr<Gtk::Tooltips> _ttips;
};
} //~ namespace sgpem