layers-panel.cpp revision 17eb9e57e1550f744916bf486947162aa523bdda
/*
* A simple panel for layers
*
* Authors:
* Jon A. Cruz
*
* Copyright (C) 2006 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtkstock.h>
#include "inkscape.h"
#include "layers-panel.h"
#include "layer-manager.h"
#include "layer-fns.h"
#include "verbs.h"
#include "document.h"
#include "desktop.h"
#include "sp-object.h"
#include "sp-item.h"
#include "prefs-utils.h"
#include "svg/css-ostringstream.h"
#include "desktop-style.h"
//#define DUMP_LAYERS 1
namespace Inkscape {
namespace UI {
namespace Dialogs {
{
return *new LayersPanel();
}
enum {
COL_VISIBLE = 1,
};
enum {
BUTTON_NEW = 0,
// BUTTON_DUPLICATE,
};
public:
_pixOnName(on),
_property_active(*this, "active", false),
_property_activatable(*this, "activatable", true),
{
if ( thingie ) {
}
delete thingie;
}
if ( thingie ) {
}
delete thingie;
}
}
{
return _signal_toggled;
}
{
return _signal_pre_toggle;
}
// virtual Glib::PropertyProxy_Base _property_renderable(); //override
protected:
int* x_offset,
int* y_offset,
int* width,
int* height ) const
{
if ( width ) {
}
if ( height ) {
}
}
{
Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags );
}
{
return false;
}
private:
};
class LayersPanel::InternalUIBounce
{
public:
int _actionCode;
};
static gboolean layers_panel_activated( GtkObject */*object*/, GdkEvent * /*event*/, gpointer data )
{
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 ) {
gtk_widget_show( child );
set = true;
}
if ( desktop ) {
if ( verb ) {
gtk_widget_show( child );
set = true;
}
}
}
}
}
}
Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id )
{
GtkWidget* iconWidget = 0;
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)) );
} else {
menulist.push_back( Gtk::Menu_Helpers::MenuElem( label, sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), id)) );
}
}
{
if ( _desktop ) {
if ( verb ) {
if ( action ) {
// } else {
// g_message("no action");
}
// } else {
// g_message("no verb for %u", code);
}
// } else {
// g_message("no active desktop");
}
}
// SP_VERB_LAYER_NEXT,
// SP_VERB_LAYER_PREV,
{
if ( !_pending ) {
_pending = new InternalUIBounce();
}
}
bool LayersPanel::_executeAction()
{
// Make sure selected layer hasn't changed since the action was triggered
if ( _pending
&& (
)
)
) {
// SPObject* target = _pending->_target;
switch ( val ) {
case BUTTON_NEW:
{
}
break;
case BUTTON_RENAME:
{
}
break;
case BUTTON_TOP:
{
}
break;
case BUTTON_BOTTOM:
{
}
break;
case BUTTON_UP:
{
}
break;
case BUTTON_DOWN:
{
}
break;
case BUTTON_DELETE:
{
}
break;
}
delete _pending;
_pending = 0;
}
return false;
}
{
public:
{
}
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;
}
}
} else {
_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;
}
void LayersPanel::_layersChanged()
{
// g_message("_layersChanged()");
if ( root ) {
#if DUMP_LAYERS
#endif // 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
#endif // DUMP_LAYERS
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
}
}
}
}
}
{
if ( iter ) {
}
return obj;
}
{
// TODO hunt down the possible API abuse in getting NULL
if ( _desktop->currentRoot() ) {
if ( inTree ) {
}
} else {
}
}
}
void LayersPanel::_checkTreeSelection()
{
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 ( _toggleEvent ) {
_toggleEvent = 0;
}
// Make a copy so we can keep it around.
}
}
{
if ( item ) {
switch ( targetCol ) {
case COL_VISIBLE:
{
item->updateRepr();
}
break;
case COL_LOCKED:
{
item->updateRepr();
}
break;
}
}
}
{
// TODO - fix to a better is-popup function
{
int x2 = 0;
int y2 = 0;
if ( _tree.get_path_at_pos( x, y,
}
}
}
}
void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& /*path*/, Gtk::TreeModel::iterator const& iter )
{
if ( row ) {
if ( obj ) {
}
}
}
}
bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*model*/, Gtk::TreeModel::Path const & /*path*/, bool currentlySelected )
{
bool val = true;
if ( !currentlySelected && _toggleEvent )
{
if ( event ) {
// (keep these checks separate, so we know when to call gdk_event_free()
)
{
// Ooooh! It's a magic one
val = false;
}
}
}
}
return val;
}
/**
* Constructor
*/
LayersPanel::LayersPanel() :
_maxNestDepth(20),
_mgr(0),
_desktop(0),
_model(0),
_pending(0),
_toggleEvent(0)
{
_tree.set_headers_visible(false);
eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) );
eyeRenderer->property_activatable() = true;
if ( col ) {
}
renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) );
renderer->property_activatable() = true;
if ( col ) {
}
_selectedConnection = _tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) );
_tree.get_selection()->set_select_function( sigc::mem_fun(*this, &LayersPanel::_rowSelectFunction) );
_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 = manage( new Gtk::Button("Dup") );
// btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) );
// _buttonsRow.add( *btn );
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 ) );
}
// -------------------------------------------------------
(*it)->set_sensitive( false );
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
(*it)->set_sensitive( false );
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
(*it)->set_sensitive( false );
}
g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this );
// restorePanelPrefs();
}
{
if ( _model )
{
delete _model;
}
if ( _toggleEvent )
{
_toggleEvent = 0;
}
}
{
if ( _mgr ) {
_mgr = 0;
}
if ( _desktop ) {
_desktop = 0;
}
_desktop = getDesktop();
if ( _desktop ) {
//setLabel( _desktop->doc()->name );
if ( _mgr ) {
_layerChangedConnection = _mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
_layerUpdatedConnection = _mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );
}
}
}
/*
GSList const *layers=sp_document_get_resource_list( _desktop->doc(), "layer" );
g_message( "layers list starts at %p", layers );
for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
SPObject *layer=static_cast<SPObject *>(iter->data);
g_message(" {%s} [%s]", layer->id, layer->label() );
}
*/
}
} //namespace Dialogs
} //namespace UI
} //namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :