6
* Copyright (C) 2006-2008 Authors
8
* Released under GNU GPL, read the file 'COPYING' for more information
12
#include "ui/widget/imagetoggler.h"
14
#include <gtkmm/icontheme.h>
16
#include "widgets/icon.h"
22
ImageToggler::ImageToggler( char const* on, char const* off) :
23
Glib::ObjectBase(typeid(ImageToggler)),
24
Gtk::CellRendererPixbuf(),
27
_property_active(*this, "active", false),
28
_property_activatable(*this, "activatable", true),
29
_property_pixbuf_on(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)),
30
_property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0))
32
property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
33
int phys = sp_icon_get_phys_size((int)Inkscape::ICON_SIZE_DECORATION);
34
Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
36
if (icon_theme->has_icon(_pixOnName)) {
37
_property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0);
40
if (icon_theme->has_icon(_pixOffName)) {
41
_property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0);
44
property_pixbuf() = _property_pixbuf_off.get_value();
48
ImageToggler::get_size_vfunc( Gtk::Widget& widget,
49
const Gdk::Rectangle* cell_area,
55
Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
58
*width += (*width) >> 1;
61
*height += (*height) >> 1;
67
ImageToggler::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
69
const Gdk::Rectangle& background_area,
70
const Gdk::Rectangle& cell_area,
71
const Gdk::Rectangle& expose_area,
72
Gtk::CellRendererState flags )
74
property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off;
75
Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
79
ImageToggler::activate_vfunc(GdkEvent* event,
80
Gtk::Widget& /*widget*/,
81
const Glib::ustring& path,
82
const Gdk::Rectangle& /*background_area*/,
83
const Gdk::Rectangle& /*cell_area*/,
84
Gtk::CellRendererState /*flags*/)
86
_signal_pre_toggle.emit(event);
87
_signal_toggled.emit(path);
95
} // namespace Inkscape
100
c-file-style:"stroustrup"
101
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :