- 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:
parent
ad774067e1
commit
6f2c9c3252
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "schedulable_state_widget.hh"
|
#include "schedulable_state_widget.hh"
|
||||||
|
|
||||||
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -29,15 +31,16 @@
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
|
|
||||||
Gtk::Tooltips*
|
memory::smart_ptr<Gtk::Tooltips>
|
||||||
SchedulableStateWidget::_ttips = NULL;
|
SchedulableStateWidget::_global_ttips = NULL;
|
||||||
|
|
||||||
|
|
||||||
SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
|
SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
|
||||||
: Glib::ObjectBase("sgpem_SchedulableStateWidget"), CairoWidget(), _color(1, 1, 1)
|
: Glib::ObjectBase("sgpem_SchedulableStateWidget"), CairoWidget(), _color(1, 1, 1)
|
||||||
{
|
{
|
||||||
// Yes, we leak, but this will be up until the end of the app
|
// 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_scaling_mode(scaling_to_w);
|
||||||
set_state(st);
|
set_state(st);
|
||||||
|
@ -46,6 +49,9 @@ SchedulableStateWidget::SchedulableStateWidget(Schedulable::state st)
|
||||||
SchedulableStateWidget::~SchedulableStateWidget()
|
SchedulableStateWidget::~SchedulableStateWidget()
|
||||||
{
|
{
|
||||||
_ttips->unset_tip(*this);
|
_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");
|
tip = _("Running");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
_color = Color(0, 0, 1); // Blue
|
_color = Color(1, 0, 0); // Red
|
||||||
tip = _("Blocked");
|
tip = _("Blocked");
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
#include "cairo_elements.hh"
|
#include "cairo_elements.hh"
|
||||||
#include "cairo_widget.hh"
|
#include "cairo_widget.hh"
|
||||||
|
|
||||||
#include "glibmm/refptr.h"
|
#include "smartp.tcc"
|
||||||
|
|
||||||
#include "gtkmm/tooltips.h"
|
#include "gtkmm/tooltips.h"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
|
@ -50,8 +51,10 @@ namespace sgpem
|
||||||
virtual void calc_widget_size(size_t& width, size_t& height) const;
|
virtual void calc_widget_size(size_t& width, size_t& height) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static memory::smart_ptr<Gtk::Tooltips> _global_ttips;
|
||||||
|
|
||||||
Color _color;
|
Color _color;
|
||||||
static Gtk::Tooltips* _ttips;
|
memory::smart_ptr<Gtk::Tooltips> _ttips;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
Loading…
Reference in New Issue