layers-panel.cpp revision e4aaa36123a7d9c9d44938e44d751d3a5d816d76
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop * A simple panel for layers
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop * Jon A. Cruz
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop * Copyright (C) 2006 Jon A. Cruz
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop * Released under GNU GPL, read the file 'COPYING' for more information
d3af895e39575a428183b753c2870086ec224e38nicholasbishop//#define DUMP_LAYERS 1
d16763fbe2a4e6b778d417469a8f047e86ffab91nicholasbishop// BUTTON_DUPLICATE,
d16763fbe2a4e6b778d417469a8f047e86ffab91nicholasbishopclass ImageToggler : public Gtk::CellRendererPixbuf {
d16763fbe2a4e6b778d417469a8f047e86ffab91nicholasbishop ImageToggler( char const* on, char const* off) :
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop _property_activatable(*this, "activatable", true),
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop _property_pixbuf_on(*this, "pixbuf_on", Glib::RefPtr<Gdk::Pixbuf>(0)),
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop _property_pixbuf_off(*this, "pixbuf_off", Glib::RefPtr<Gdk::Pixbuf>(0))
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
c9f29ccf73d68064b0e869847ce640bd27b94b82nicholasbishop Gtk::Widget* thingie = sp_icon_get_icon(_pixOnName.c_str(), Inkscape::ICON_SIZE_DECORATION);
delete thingie;
if ( thingie ) {
delete thingie;
return _signal_toggled;
Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
int _actionCode;
if ( data )
return FALSE;
void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback )
bool set = false;
if ( iconName ) {
set = true;
if ( desktop ) {
if ( verb ) {
set = true;
Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id )
const char* label = 0;
if ( iconName ) {
if ( desktop ) {
if ( verb ) {
if ( action ) {
if ( iconWidget ) {
if ( wrapped ) {
menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem( label, *wrapped, sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), id)) );
menulist.push_back( Gtk::Menu_Helpers::MenuElem( label, sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), id)) );
if ( _desktop ) {
if ( verb ) {
if ( action ) {
if ( !_pending ) {
if ( _pending
switch ( val ) {
case BUTTON_NEW:
case BUTTON_RENAME:
case BUTTON_TOP:
case BUTTON_BOTTOM:
case BUTTON_UP:
case BUTTON_DOWN:
case BUTTON_DELETE:
delete _pending;
_pending = 0;
virtual ~ModelColumns() {}
_store->foreach( sigc::bind<SPObject*>(sigc::mem_fun(*this, &LayersPanel::_checkForUpdated), layer) );
bool LayersPanel::_checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer)
bool stopGoing = false;
stopGoing = true;
return stopGoing;
_store->foreach( sigc::bind<SPObject*>(sigc::mem_fun(*this, &LayersPanel::_checkForSelected), layer) );
bool LayersPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer)
bool stopGoing = false;
stopGoing = true;
return stopGoing;
if ( root ) {
#if DUMP_LAYERS
void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level )
for ( unsigned int i = 0; i < counter; i++ ) {
if ( child ) {
#if DUMP_LAYERS
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
if ( iter ) {
return obj;
if ( inTree ) {
// TODO - move these to a function in layer-manager.cpp
// TODO - move these to a function in layer-manager.cpp
bool sensitive = false;
bool sensitiveNonTop = false;
bool sensitiveNonBottom = false;
sensitive = true;
if ( inTree ) {
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
if ( item ) {
switch ( targetCol ) {
case COL_VISIBLE:
case COL_LOCKED:
int x2 = 0;
int y2 = 0;
void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter )
if ( row ) {
if ( obj ) {
_mgr(0),
_desktop(0),
_model(0),
_pending(0)
eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) );
if ( col ) {
renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) );
if ( col ) {
_tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) );
_tree.get_model()->signal_row_changed().connect( sigc::mem_fun(*this, &LayersPanel::_handleRowChange) );
_tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
// btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RENAME, 0, "Rename", (int)BUTTON_RENAME ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_NEW, 0, "New", (int)BUTTON_NEW ) );
_watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up", (int)BUTTON_UP ) );
_watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Down", (int)BUTTON_DOWN ) );
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this );
if ( _model )
delete _model;
if ( _mgr ) {
_mgr = 0;
if ( _desktop ) {
_desktop = 0;
if ( _desktop ) {
if ( _mgr ) {
_layerChangedConnection = _mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
_layerUpdatedConnection = _mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );