summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6290dbd)
raw | patch | inline | side by side (parent: 6290dbd)
author | joncruz <joncruz@users.sourceforge.net> | |
Thu, 18 May 2006 09:47:35 +0000 (09:47 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Thu, 18 May 2006 09:47:35 +0000 (09:47 +0000) |
ChangeLog | patch | blob | history | |
src/dialogs/layers-panel.cpp | patch | blob | history | |
src/dialogs/layers-panel.h | patch | blob | history | |
src/layer-manager.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 1e07cedc968209b63ee5c13a970393ace078e919..5bf5721a563bf554dde0951a1e2f43181f1bb7c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-18 Jon A. Cruz <jon@joncruz.org>
+ * src/layer-manager.cpp, src/dialogs/layers-panel.h,
+ src/dialogs/layers-panel.cpp:
+ Next round of layer dialog updates.
+
2006-05-17 Kees Cook <kees@outflux.net>
* src/dialogs/rdf.cpp: corrected localization on array, added comments.
* src/ui/widget/licensor.cpp: Localized the license name.
index 4d13d37a258ffe840a9740e726f6ea8a9e7acadb..707ba1880377da5b37a53d9d8f8fe9f38daa110b 100644 (file)
#include "layers-panel.h"
#include "layer-manager.h"
+#include "layer-fns.h"
+
#include "verbs.h"
#include "helper/action.h"
enum {
BUTTON_NEW = 0,
+ BUTTON_RENAME,
BUTTON_TOP,
BUTTON_BOTTOM,
BUTTON_UP,
}
}
+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 ) {
+ iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName );
+ }
+
+ if ( desktop ) {
+ Verb *verb = Verb::get( code );
+ if ( verb ) {
+ SPAction *action = verb->get_action(desktop);
+ if ( !iconWidget && action && action->image ) {
+ iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image );
+ }
+
+ if ( action ) {
+ label = action->name;
+ }
+ }
+ }
+
+ if ( !label && fallback ) {
+ label = fallback;
+ }
+
+ Gtk::Widget* wrapped = 0;
+ if ( iconWidget ) {
+ wrapped = manage(Glib::wrap(iconWidget));
+ wrapped->show();
+ }
+
+
+
+ Gtk::Menu::MenuList& menulist = _popupMenu.items();
+
+ 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)) );
+ }
+ return menulist.back();
+}
+
void LayersPanel::_fireAction( unsigned int code )
{
if ( _desktop ) {
_fireAction( SP_VERB_LAYER_NEW );
}
break;
+ case BUTTON_RENAME:
+ {
+ _fireAction( SP_VERB_LAYER_RENAME );
+ }
+ break;
case BUTTON_TOP:
{
_fireAction( SP_VERB_LAYER_TO_TOP );
void LayersPanel::_checkTreeSelection()
{
bool sensitive = false;
+ bool sensitiveNonTop = false;
+ bool sensitiveNonBottom = false;
if ( _tree.get_selection()->count_selected_rows() > 0 ) {
sensitive = true;
SPObject* inTree = _selectedLayer();
if ( inTree ) {
+
+ sensitiveNonTop = (Inkscape::next_layer(inTree->parent, inTree) != 0);
+ sensitiveNonBottom = (Inkscape::previous_layer(inTree->parent, inTree) != 0);
+
SPObject* curr = _desktop->currentLayer();
if ( curr != inTree ) {
_layerChangedConnection.block();
sensitive = false;
}
- for ( std::vector<Gtk::Button*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) {
+ for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) {
(*it)->set_sensitive( sensitive );
}
+ for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
+ (*it)->set_sensitive( sensitiveNonTop );
+ }
+ for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
+ (*it)->set_sensitive( sensitiveNonBottom );
+ }
}
void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
}
}
+void LayersPanel::_handleButtonEvent(GdkEventButton* evt)
+{
+ if ( (evt->type == GDK_BUTTON_PRESS) && (evt->button == 3) ) {
+
+
+ {
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn* col = 0;
+ int x = static_cast<int>(evt->x);
+ int y = static_cast<int>(evt->y);
+ int x2 = 0;
+ int y2 = 0;
+ if ( _tree.get_path_at_pos( x, y,
+ path, col,
+ x2, y2 ) ) {
+ _checkTreeSelection();
+ _popupMenu.popup(evt->button, evt->time);
+ }
+ }
+
+ }
+}
+
+void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter )
+{
+ Gtk::TreeModel::Row row = *iter;
+ if ( row ) {
+ SPObject* obj = row[_model->_colObject];
+ if ( obj ) {
+ gchar const* oldLabel = obj->label();
+ Glib::ustring tmp = row[_model->_colLabel];
+ if ( oldLabel && oldLabel[0] && !tmp.empty() && (tmp != oldLabel) ) {
+ obj->setLabel(tmp.c_str());
+ }
+ }
+ }
+}
/**
* Constructor
_tree.set_model( _store );
int visibleColNum = _tree.append_column("vis", _model->_colVisible) - 1;
int lockedColNum = _tree.append_column("lock", _model->_colLocked) - 1;
- int nameColNum = _tree.append_column("Name", _model->_colLabel) - 1;
+ int nameColNum = _tree.append_column_editable("Name", _model->_colLabel) - 1;
_tree.set_expander_column( *_tree.get_column(nameColNum) );
_tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_checkTreeSelection) );
- _getContents()->pack_start(_tree, Gtk::PACK_EXPAND_WIDGET);
-
+ _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) );
+ _scroller.add( _tree );
+ _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
+ _getContents()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET );
_getContents()->pack_end(_buttonsRow, Gtk::PACK_SHRINK);
SPDesktop* targetDesktop = SP_ACTIVE_DESKTOP;
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, GTK_STOCK_GOTO_TOP, "Top" );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
- _watching.push_back( btn );
+ _watchingNonTop.push_back( btn );
_buttonsRow.pack_start( *btn );
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up" );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
- _watching.push_back( btn );
+ _watchingNonTop.push_back( btn );
_buttonsRow.pack_start( *btn );
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Dn" );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
- _watching.push_back( btn );
+ _watchingNonBottom.push_back( btn );
_buttonsRow.pack_start( *btn );
btn = manage( new Gtk::Button() );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, "Btm" );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
- _watching.push_back( btn );
+ _watchingNonBottom.push_back( btn );
_buttonsRow.pack_start( *btn );
// btn = manage( new Gtk::Button("Dup") );
_buttonsRow.pack_start( *btn );
- for ( std::vector<Gtk::Button*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) {
+
+
+ // -------------------------------------------------------
+ {
+ _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 ) );
+
+ _popupMenu.items().push_back( Gtk::Menu_Helpers::SeparatorElem() );
+
+ _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 ) );
+
+ _popupMenu.show_all_children();
+ }
+ // -------------------------------------------------------
+
+
+
+ for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) {
+ (*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 );
}
index 366abfa987c35ed5d887bf85d6c84dbd70246f50..ba135e20202522cca24e07ea93dc85c3dfc25f28 100644 (file)
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/tooltips.h>
+#include <gtkmm/scrolledwindow.h>
#include "ui/widget/panel.h"
//#include "ui/previewholder.h"
void _styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback );
void _fireAction( unsigned int code );
+ Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
void _toggled( Glib::ustring const& str, int targetCol );
+ void _handleButtonEvent(GdkEventButton* evt);
+ void _handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter );
+
void _checkTreeSelection();
void _takeAction( int val );
SPDesktop* _desktop;
ModelColumns* _model;
Glib::RefPtr<Gtk::TreeStore> _store;
- std::vector<Gtk::Button*> _watching;
+ std::vector<Gtk::Widget*> _watching;
+ std::vector<Gtk::Widget*> _watchingNonTop;
+ std::vector<Gtk::Widget*> _watchingNonBottom;
Gtk::Tooltips _tips;
Gtk::TreeView _tree;
Gtk::HBox _buttonsRow;
+ Gtk::ScrolledWindow _scroller;
+ Gtk::Menu _popupMenu;
};
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index 090c967146312f2e7b342e370341f5b08131f4b3..c2999f6c80c4bc2ea925ee65a12f0239fb7f0775 100644 (file)
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
LayerManager::LayerManager(SPDesktop *desktop)
: _desktop(desktop), _document(NULL)
{
- sigc::slot<void> base = sigc::mem_fun(*this, &LayerManager::_rebuild);
- sigc::slot<void, SPObject *> slot = sigc::hide<0>(base);
- _layer_connection = desktop->connectCurrentLayerChanged(slot);
+// _layer_connection = desktop->connectCurrentLayerChanged( sigc::hide<0>( sigc::mem_fun(*this, &LayerManager::_rebuild) ) );
sigc::bound_mem_functor1<void, Inkscape::LayerManager, SPDocument*> first = sigc::mem_fun(*this, &LayerManager::_setDocument);