diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/clipboard.cpp | 12 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 81 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.h | 8 | ||||
| -rw-r--r-- | src/ui/dialog/xml-tree.cpp | 1 | ||||
| -rw-r--r-- | src/ui/previewholder.cpp | 2 |
5 files changed, 52 insertions, 52 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f2b9fb02a..72ddd90a9 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -332,6 +332,10 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const* use->setAttribute("style", style ); _root->appendChild(use); + // This min and max sets offsets, we don't have any so set to zero. + sp_repr_set_point(_clipnode, "min", Geom::Point(0,0)); + sp_repr_set_point(_clipnode, "max", Geom::Point(0,0)); + fit_canvas_to_drawing(_clipboardSPDoc); _setClipboardTargets(); } @@ -767,14 +771,6 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } } - // Copy symbols: We may want to be more clever... - // if (SP_IS_USE(item)) { - // SPObject *symbol = SP_USE(item)->child; - // if( symbol && SP_IS_SYMBOL(symbol) ) { - // _copyNode(symbol->getRepr(), _doc, _defs); - // } - // } - // recurse for (SPObject *o = item->children ; o != NULL ; o = o->next) { if (SP_IS_ITEM(o)) { diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 4eeb1b5f0..989375bbd 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -49,6 +49,7 @@ #include "inkscape.h" #include "sp-root.h" #include "sp-use.h" +#include "sp-defs.h" #include "sp-symbol.h" #ifdef WITH_LIBVISIO @@ -246,12 +247,19 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : key = SPItem::display_key_new(1); renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); + // This might need to be a global variable so setTargetDesktop can modify it + SPDefs *defs = currentDocument->getDefs(); + sigc::connection defsModifiedConn = (SP_OBJECT(defs))->connectModified( + sigc::mem_fun(*this, &SymbolsDialog::defsModified)); + instanceConns.push_back(defsModifiedConn); + get_symbols(); draw_symbols( currentDocument ); /* Defaults to current document */ - desktopChangeConn = + sigc::connection desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); + deskTrack.connect(GTK_WIDGET(gobj())); } @@ -304,6 +312,13 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*cont } +void SymbolsDialog::defsModified(SPObject *object, guint flags) +{ + if ( !symbolSets[symbolSet->get_active_text()] ) { + rebuild(); + } +} + void SymbolsDialog::iconChanged() { #if WITH_GTKMM_3_0 std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items(); @@ -484,10 +499,8 @@ void SymbolsDialog::get_symbols() { } GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) -{ - if (!r) { - return l; - } +{ + g_return_val_if_fail(r != NULL, l); // Stop multiple counting of same symbol if( SP_IS_USE(r) ) { @@ -559,32 +572,32 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { - - SymbolColumns* columns = getColumns(); - GSList* l = symbols_in_doc( symbolDocument ); for( ; l != NULL; l = l->next ) { - SPObject* symbol = SP_OBJECT(l->data); - if (!SP_IS_SYMBOL(symbol)) { - //std::cout << " Error: not symbol" << std::endl; - continue; + if (SP_IS_SYMBOL(symbol)) { + draw_symbol( symbol ); } + } +} - gchar const *id = symbol->getRepr()->attribute("id"); - gchar const *title = symbol->title(); // From title element - if( !title ) { - title = id; - } +void SymbolsDialog::draw_symbol( SPObject* symbol ) { + + SymbolColumns* columns = getColumns(); - Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbolDocument, &renderDrawing, key ); - if( pixbuf ) { + gchar const *id = symbol->getRepr()->attribute("id"); + gchar const *title = symbol->title(); // From title element + if( !title ) { + title = id; + } - Gtk::ListStore::iterator row = store->append(); - (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = Glib::ustring( title ); - (*row)[columns->symbol_image] = pixbuf; - } + Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbol ); + + if( pixbuf ) { + Gtk::ListStore::iterator row = store->append(); + (*row)[columns->symbol_id] = Glib::ustring( id ); + (*row)[columns->symbol_title] = Glib::ustring( title ); + (*row)[columns->symbol_image] = pixbuf; } delete columns; @@ -600,18 +613,8 @@ void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { * the temporary document is rendered. */ Glib::RefPtr<Gdk::Pixbuf> -SymbolsDialog::create_symbol_image(gchar const *symbol_id, - SPDocument *source, - Inkscape::Drawing* drawing, - unsigned /*visionkey*/) +SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) { - // Retrieve the symbol named 'symbol_id' from the source SVG document - SPObject const* symbol = source->getObjectById(symbol_id); - if (symbol == NULL) { - //std::cout << " Failed to find symbol: " << symbol_id << std::endl; - //return 0; - } - // Create a copy repr of the symbol with id="the_symbol" Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc(); Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc); @@ -628,10 +631,10 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, gchar const* style = repr->attribute("inkscape:symbol-style"); if( !style ) { // If no default style in <symbol>, look in documents. - if( source == currentDocument ) { - style = style_from_use( symbol_id, source ); + if( symbol->document == currentDocument ) { + style = style_from_use( symbol_id, symbol->document ); } else { - style = source->getReprRoot()->attribute("style"); + style = symbol->document->getReprRoot()->attribute("style"); } } // Last ditch effort to provide some default styling @@ -721,7 +724,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, scale = atof( previewScaleString.c_str() ); } - pixbuf = Glib::wrap(render_pixbuf(*drawing, scale, *dbox, psize)); + pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 08221bf22..b81f6981e 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -46,11 +46,13 @@ private: static SymbolColumns *getColumns(); void rebuild(); + void defsModified(SPObject *object, guint flags); void iconChanged(); void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); void draw_symbols( SPDocument* symbol_document ); + void draw_symbol( SPObject* symbol_document ); SPDocument* symbols_preview_doc(); GSList* symbols_in_doc_recursive(SPObject *r, GSList *l); @@ -60,9 +62,7 @@ private: gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr<Gdk::Pixbuf> - create_symbol_image(gchar const *symbol_name, - SPDocument *source, Inkscape::Drawing* drawing, - unsigned /*visionkey*/); + create_symbol_image(gchar const *symbol_name, SPObject *symbol); /* Keep track of all symbol template documents */ std::map<Glib::ustring, SPDocument*> symbolSets; @@ -85,8 +85,6 @@ private: Inkscape::Drawing renderDrawing; std::vector<sigc::connection> instanceConns; - sigc::connection desktopChangeConn; - }; } //namespace Dialogs diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 29dbc4b93..a537b7fca 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -986,6 +986,7 @@ void XmlTree::cmd_delete_node() g_assert(selected_repr != NULL); sp_repr_unparent(selected_repr); + reinterpret_cast<SPObject *>(current_desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, Q_("nodeAsInXMLinHistoryDialog|Delete node")); } diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index b5a1a29a8..38f6f353f 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -50,6 +50,8 @@ PreviewHolder::PreviewHolder() : _border(BORDER_NONE) { _scroller = manage(new Gtk::ScrolledWindow()); + ((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC); #if WITH_GTKMM_3_0 _insides = manage(new Gtk::Grid()); |
