symbols.cpp revision d952ff41b31f89d65e80205020ab8302a517db1c
359a38ce40498397028473d956691915ed3e849atavmjong-free/**
359a38ce40498397028473d956691915ed3e849atavmjong-free * @file
359a38ce40498397028473d956691915ed3e849atavmjong-free * Symbols dialog.
359a38ce40498397028473d956691915ed3e849atavmjong-free */
359a38ce40498397028473d956691915ed3e849atavmjong-free/* Authors:
359a38ce40498397028473d956691915ed3e849atavmjong-free * Copyright (C) 2012 Tavmjong Bah
359a38ce40498397028473d956691915ed3e849atavmjong-free *
359a38ce40498397028473d956691915ed3e849atavmjong-free * Released under GNU GPL, read the file 'COPYING' for more information
359a38ce40498397028473d956691915ed3e849atavmjong-free */
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#ifdef HAVE_CONFIG_H
359a38ce40498397028473d956691915ed3e849atavmjong-free# include "config.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <iostream>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <algorithm>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <locale>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <functional>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <sstream>
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
3fad3df12ae2d320c12871d471eb0faf5f187cbdAlex Valavanis#include <glibmm/threads.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/buttonbox.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/label.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#if WITH_GTKMM_3_0
359a38ce40498397028473d956691915ed3e849atavmjong-free# include <gtkmm/togglebutton.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free# include <gtkmm/grid.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#else
359a38ce40498397028473d956691915ed3e849atavmjong-free# include <gtkmm/table.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/scrolledwindow.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/comboboxtext.h>
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free#include <gtkmm/iconview.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/liststore.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/treemodelcolumn.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <gtkmm/clipboard.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <glibmm/stringutils.h>
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White#include <glibmm/markup.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <glibmm/i18n.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "path-prefix.h"
d1561c248f49dc3508ae9e6557fc0d371928e394Markus Engel#include "io/sys.h"
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "ui/cache/svg_preview_cache.h"
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free#include "ui/clipboard.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "ui/icon-names.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "symbols.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "selection.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "desktop.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "desktop-handles.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "document.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "inkscape.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "sp-root.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "sp-use.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "sp-defs.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "sp-symbol.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "widgets/icon.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#ifdef WITH_LIBVISIO
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <libvisio/libvisio.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#include <libwpd-stream/libwpd-stream.h>
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "verbs.h"
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free#include "helper/action.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free#include "helper/action-context.h"
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White#include "xml/repr.h"
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freenamespace Inkscape {
359a38ce40498397028473d956691915ed3e849atavmjong-freenamespace UI {
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freenamespace Dialog {
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free// See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-freeclass SymbolColumns : public Gtk::TreeModel::ColumnRecord
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free{
a3c27728560e19f7c710399f838dadeedac39249tavmjong-freepublic:
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free Gtk::TreeModelColumn<Glib::ustring> symbol_id;
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free Gtk::TreeModelColumn<Glib::ustring> symbol_title;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > symbol_image;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free SymbolColumns() {
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free add(symbol_id);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free add(symbol_title);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free add(symbol_image);
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin }
c652591f8105502bfed1dcd3d7207681932a7515Kris De Gussem};
aa9235c966804d9b8f8daa083a2d123d9d47d2bbMarc Jeanmougin
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-freeSymbolColumns* SymbolsDialog::getColumns()
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free{
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free SymbolColumns* columns = new SymbolColumns();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free return columns;
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free}
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free/**
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free * Constructor
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free */
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-freeSymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS),
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free store(Gtk::ListStore::create(*getColumns())),
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free iconView(0),
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free currentDesktop(0),
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free deskTrack(),
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free currentDocument(0),
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free previewDocument(0),
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free instanceConns()
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free{
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free /******************** Table *************************/
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#if WITH_GTKMM_3_0
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free Gtk::Grid *table = new Gtk::Grid();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#else
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free Gtk::Table *table = new Gtk::Table(2, 4, false);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#endif
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // panel is a cloked Gtk::VBox
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free guint row = 0;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free /******************** Symbol Sets *************************/
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: "));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#if WITH_GTKMM_3_0
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free table->attach(*Gtk::manage(labelSet),0,row,1,1);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#else
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#endif
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free symbolSet = new Gtk::ComboBoxText(); // Fill in later
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free symbolSet->append(_("Current Document"));
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free symbolSet->set_active_text(_("Current Document"));
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#if WITH_GTKMM_3_0
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free symbolSet->set_hexpand();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free table->attach(*Gtk::manage(symbolSet),1,row,1,1);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#else
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#endif
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::connection connSet = symbolSet->signal_changed().connect(
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::mem_fun(*this, &SymbolsDialog::rebuild));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free instanceConns.push_back(connSet);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free ++row;
359a38ce40498397028473d956691915ed3e849atavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free /********************* Icon View **************************/
359a38ce40498397028473d956691915ed3e849atavmjong-free SymbolColumns* columns = getColumns();
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free iconView = new Gtk::IconView(static_cast<Glib::RefPtr<Gtk::TreeModel> >(store));
359a38ce40498397028473d956691915ed3e849atavmjong-free //iconView->set_text_column( columns->symbol_id );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free iconView->set_tooltip_column( 1 );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free iconView->set_pixbuf_column( columns->symbol_image );
359a38ce40498397028473d956691915ed3e849atavmjong-free // Giving the iconview a small minimum size will help users understand
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // What the dialog does.
359a38ce40498397028473d956691915ed3e849atavmjong-free iconView->set_size_request( 100, 200 );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free std::vector< Gtk::TargetEntry > targets;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste"));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free iconView->signal_drag_data_get().connect(
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::connection connIconChanged;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free connIconChanged = iconView->signal_selection_changed().connect(
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::mem_fun(*this, &SymbolsDialog::iconChanged));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free instanceConns.push_back(connIconChanged);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow();
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free scroller->add(*Gtk::manage(iconView));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free#if WITH_GTKMM_3_0
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free scroller->set_hexpand();
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free scroller->set_vexpand();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free table->attach(*Gtk::manage(scroller),0,row,2,1);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free#else
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free#endif
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free ++row;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free /******************** Tools *******************************/
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free Gtk::Button* button;
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::HBox* tools = new Gtk::HBox();
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free //tools->set_layout( Gtk::BUTTONBOX_END );
359a38ce40498397028473d956691915ed3e849atavmjong-free#if WITH_GTKMM_3_0
359a38ce40498397028473d956691915ed3e849atavmjong-free scroller->set_hexpand();
359a38ce40498397028473d956691915ed3e849atavmjong-free table->attach(*Gtk::manage(tools),0,row,2,1);
359a38ce40498397028473d956691915ed3e849atavmjong-free#else
359a38ce40498397028473d956691915ed3e849atavmjong-free table->attach(*Gtk::manage(tools),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL);
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol = Gtk::manage(new Gtk::Button());
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol->add(*Gtk::manage(Glib::wrap(
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-add")))) );
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol->set_tooltip_text(_("Add Symbol from the current document."));
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White addSymbol->set_relief( Gtk::RELIEF_NONE );
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol->set_focus_on_click( false );
3eb97a45889abb73fa05c413b45785ea682f07c5Jon A. Cruz addSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol));
359a38ce40498397028473d956691915ed3e849atavmjong-free tools->pack_start(* addSymbol, Gtk::PACK_SHRINK);
359a38ce40498397028473d956691915ed3e849atavmjong-free
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White removeSymbol = Gtk::manage(new Gtk::Button());
359a38ce40498397028473d956691915ed3e849atavmjong-free removeSymbol->add(*Gtk::manage(Glib::wrap(
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-remove")))) );
359a38ce40498397028473d956691915ed3e849atavmjong-free removeSymbol->set_tooltip_text(_("Remove Symbol from the current document."));
359a38ce40498397028473d956691915ed3e849atavmjong-free removeSymbol->set_relief( Gtk::RELIEF_NONE );
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free removeSymbol->set_focus_on_click( false );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free removeSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol));
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free tools->pack_start(* removeSymbol, Gtk::PACK_SHRINK);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin Gtk::Label* spacer = Gtk::manage(new Gtk::Label(""));
c652591f8105502bfed1dcd3d7207681932a7515Kris De Gussem tools->pack_start(* Gtk::manage(spacer));
aa9235c966804d9b8f8daa083a2d123d9d47d2bbMarc Jeanmougin
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // Pack size (controls display area)
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free pack_size = 2; // Default 32px
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button = Gtk::manage(new Gtk::Button());
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->add(*Gtk::manage(Glib::wrap(
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-more")))) );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_tooltip_text(_("Display more icons in row."));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_relief( Gtk::RELIEF_NONE );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_focus_on_click( false );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tools->pack_start(* button, Gtk::PACK_SHRINK);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free button = Gtk::manage(new Gtk::Button());
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->add(*Gtk::manage(Glib::wrap(
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("pack-less")))) );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_tooltip_text(_("Display fewer icons in row."));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_relief( Gtk::RELIEF_NONE );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->set_focus_on_click( false );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packless));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tools->pack_start(* button, Gtk::PACK_SHRINK);
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // Toggle scale to fit on/off
359a38ce40498397028473d956691915ed3e849atavmjong-free fitSymbol = Gtk::manage(new Gtk::ToggleButton());
359a38ce40498397028473d956691915ed3e849atavmjong-free fitSymbol->add(*Gtk::manage(Glib::wrap(
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-fit")))) );
359a38ce40498397028473d956691915ed3e849atavmjong-free fitSymbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space."));
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free fitSymbol->set_relief( Gtk::RELIEF_NONE );
359a38ce40498397028473d956691915ed3e849atavmjong-free fitSymbol->set_focus_on_click( false );
359a38ce40498397028473d956691915ed3e849atavmjong-free fitSymbol->set_active( true );
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free fitSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild));
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free tools->pack_start(* fitSymbol, Gtk::PACK_SHRINK);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free // Render size (scales symbols within display area)
359a38ce40498397028473d956691915ed3e849atavmjong-free scale_factor = 0; // Default 1:1 * pack_size/pack_size default
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomOut = Gtk::manage(new Gtk::Button());
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomOut->add(*Gtk::manage(Glib::wrap(
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-smaller")))) );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomOut->set_tooltip_text(_("Make symbols smaller by zooming out."));
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomOut->set_relief( Gtk::RELIEF_NONE );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomOut->set_focus_on_click( false );
3eb97a45889abb73fa05c413b45785ea682f07c5Jon A. Cruz zoomOut->set_sensitive( false );
3eb97a45889abb73fa05c413b45785ea682f07c5Jon A. Cruz zoomOut->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout));
359a38ce40498397028473d956691915ed3e849atavmjong-free tools->pack_start(* zoomOut, Gtk::PACK_SHRINK);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn = Gtk::manage(new Gtk::Button());
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->add(*Gtk::manage(Glib::wrap(
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-bigger")))) );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->set_tooltip_text(_("Make symbols bigger by zooming in."));
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->set_relief( Gtk::RELIEF_NONE );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->set_focus_on_click( false );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->set_sensitive( false );
359a38ce40498397028473d956691915ed3e849atavmjong-free zoomIn->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin));
359a38ce40498397028473d956691915ed3e849atavmjong-free tools->pack_start(* zoomIn, Gtk::PACK_SHRINK);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free ++row;
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free /**********************************************************/
3eb97a45889abb73fa05c413b45785ea682f07c5Jon A. Cruz currentDesktop = inkscape_active_desktop();
3eb97a45889abb73fa05c413b45785ea682f07c5Jon A. Cruz currentDocument = sp_desktop_document(currentDesktop);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free previewDocument = symbols_preview_doc(); /* Template to render symbols in */
359a38ce40498397028473d956691915ed3e849atavmjong-free previewDocument->ensureUpToDate(); /* Necessary? */
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free key = SPItem::display_key_new(1);
359a38ce40498397028473d956691915ed3e849atavmjong-free renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY ));
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free // This might need to be a global variable so setTargetDesktop can modify it
359a38ce40498397028473d956691915ed3e849atavmjong-free SPDefs *defs = currentDocument->getDefs();
359a38ce40498397028473d956691915ed3e849atavmjong-free sigc::connection defsModifiedConn = (SP_OBJECT(defs))->connectModified(
359a38ce40498397028473d956691915ed3e849atavmjong-free sigc::mem_fun(*this, &SymbolsDialog::defsModified));
359a38ce40498397028473d956691915ed3e849atavmjong-free instanceConns.push_back(defsModifiedConn);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free sigc::connection selectionChangedConn = currentDesktop->selection->connectChanged(
359a38ce40498397028473d956691915ed3e849atavmjong-free sigc::mem_fun(*this, &SymbolsDialog::selectionChanged));
f9110b2951479b0cf4a92c4242825b18bf636e42tavmjong-free instanceConns.push_back(selectionChangedConn);
f9110b2951479b0cf4a92c4242825b18bf636e42tavmjong-free
f9110b2951479b0cf4a92c4242825b18bf636e42tavmjong-free sigc::connection documentReplacedConn = currentDesktop->connectDocumentReplaced(
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free sigc::mem_fun(*this, &SymbolsDialog::documentReplaced));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free instanceConns.push_back(documentReplacedConn);
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free get_symbols();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free add_symbols( currentDocument ); /* Defaults to current document */
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sigc::connection desktopChangeConn =
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free instanceConns.push_back( desktopChangeConn );
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free deskTrack.connect(GTK_WIDGET(gobj()));
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free}
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-freeSymbolsDialog::~SymbolsDialog()
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free{
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) {
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free it->disconnect();
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free }
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free instanceConns.clear();
f9110b2951479b0cf4a92c4242825b18bf636e42tavmjong-free deskTrack.disconnect();
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free}
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-freeSymbolsDialog& SymbolsDialog::getInstance()
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free{
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free return *new SymbolsDialog();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::packless() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if(pack_size < 4) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free pack_size++;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free rebuild();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::packmore() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if(pack_size > 0) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free pack_size--;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free rebuild();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::zoomin() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if(scale_factor < 4) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free scale_factor++;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free rebuild();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::zoomout() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if(scale_factor > -8) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free scale_factor--;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free rebuild();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::rebuild() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if( fitSymbol->get_active() ) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free zoomIn->set_sensitive( false );
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free zoomOut->set_sensitive( false );
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free } else {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free zoomIn->set_sensitive( true);
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White zoomOut->set_sensitive( true );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White }
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free store->clear();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free Glib::ustring symbolSetString = symbolSet->get_active_text();
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free SPDocument* symbolDocument = symbolSets[symbolSetString];
359a38ce40498397028473d956691915ed3e849atavmjong-free if( !symbolDocument ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free // Symbol must be from Current Document (this method of
359a38ce40498397028473d956691915ed3e849atavmjong-free // checking should be language independent).
359a38ce40498397028473d956691915ed3e849atavmjong-free symbolDocument = currentDocument;
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol->set_sensitive( true );
359a38ce40498397028473d956691915ed3e849atavmjong-free removeSymbol->set_sensitive( true );
359a38ce40498397028473d956691915ed3e849atavmjong-free } else {
359a38ce40498397028473d956691915ed3e849atavmjong-free addSymbol->set_sensitive( false );
359a38ce40498397028473d956691915ed3e849atavmjong-free removeSymbol->set_sensitive( false );
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free add_symbols( symbolDocument );
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::insertSymbol() {
359a38ce40498397028473d956691915ed3e849atavmjong-free Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL );
359a38ce40498397028473d956691915ed3e849atavmjong-free SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop) );
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_action_perform (action, NULL);
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::revertSymbol() {
359a38ce40498397028473d956691915ed3e849atavmjong-free Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL );
359a38ce40498397028473d956691915ed3e849atavmjong-free SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop ) );
359a38ce40498397028473d956691915ed3e849atavmjong-free sp_action_perform (action, NULL);
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/)
359a38ce40498397028473d956691915ed3e849atavmjong-free{
359a38ce40498397028473d956691915ed3e849atavmjong-free#if WITH_GTKMM_3_0
359a38ce40498397028473d956691915ed3e849atavmjong-free std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
359a38ce40498397028473d956691915ed3e849atavmjong-free#else
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items();
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free if( iconArray.empty() ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free //std::cout << " iconArray empty: huh? " << std::endl;
359a38ce40498397028473d956691915ed3e849atavmjong-free } else {
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::TreeModel::Path const & path = *iconArray.begin();
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::ListStore::iterator row = store->get_iter(path);
359a38ce40498397028473d956691915ed3e849atavmjong-free Glib::ustring symbol_id = (*row)[getColumns()->symbol_id];
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE );
359a38ce40498397028473d956691915ed3e849atavmjong-free gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() );
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/)
359a38ce40498397028473d956691915ed3e849atavmjong-free{
359a38ce40498397028473d956691915ed3e849atavmjong-free if ( !symbolSets[symbolSet->get_active_text()] ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free rebuild();
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::selectionChanged(Inkscape::Selection *selection) {
359a38ce40498397028473d956691915ed3e849atavmjong-free Glib::ustring symbol_id = selectedSymbolId();
359a38ce40498397028473d956691915ed3e849atavmjong-free SPDocument* symbolDocument = selectedSymbols();
359a38ce40498397028473d956691915ed3e849atavmjong-free SPObject* symbol = symbolDocument->getObjectById(symbol_id);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free if(symbol && !selection->includes(symbol)) {
359a38ce40498397028473d956691915ed3e849atavmjong-free iconView->unselect_all();
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document)
359a38ce40498397028473d956691915ed3e849atavmjong-free{
359a38ce40498397028473d956691915ed3e849atavmjong-free currentDesktop = desktop;
359a38ce40498397028473d956691915ed3e849atavmjong-free currentDocument = document;
359a38ce40498397028473d956691915ed3e849atavmjong-free rebuild();
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freeSPDocument* SymbolsDialog::selectedSymbols() {
359a38ce40498397028473d956691915ed3e849atavmjong-free /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */
359a38ce40498397028473d956691915ed3e849atavmjong-free Glib::ustring symbolSetString = symbolSet->get_active_text();
359a38ce40498397028473d956691915ed3e849atavmjong-free
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff SPDocument* symbolDocument = symbolSets[symbolSetString];
359a38ce40498397028473d956691915ed3e849atavmjong-free if( !symbolDocument ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free // Symbol must be from Current Document (this method of checking should be language independent).
add38d633bbf8ef881bdb908735ea27385c554b8Matthew Petroff return currentDocument;
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free return symbolDocument;
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freeGlib::ustring SymbolsDialog::selectedSymbolId() {
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#if WITH_GTKMM_3_0
359a38ce40498397028473d956691915ed3e849atavmjong-free std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
359a38ce40498397028473d956691915ed3e849atavmjong-free#else
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items();
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff if( !iconArray.empty() ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::TreeModel::Path const & path = *iconArray.begin();
359a38ce40498397028473d956691915ed3e849atavmjong-free Gtk::ListStore::iterator row = store->get_iter(path);
add38d633bbf8ef881bdb908735ea27385c554b8Matthew Petroff return (*row)[getColumns()->symbol_id];
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free return Glib::ustring("");
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-freevoid SymbolsDialog::iconChanged() {
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free Glib::ustring symbol_id = selectedSymbolId();
359a38ce40498397028473d956691915ed3e849atavmjong-free SPDocument* symbolDocument = selectedSymbols();
359a38ce40498397028473d956691915ed3e849atavmjong-free SPObject* symbol = symbolDocument->getObjectById(symbol_id);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free if( symbol ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free if( symbolDocument == currentDocument ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free // Select the symbol on the canvas so it can be manipulated
359a38ce40498397028473d956691915ed3e849atavmjong-free currentDesktop->selection->set( symbol, false );
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free // Find style for use in <use>
359a38ce40498397028473d956691915ed3e849atavmjong-free // First look for default style stored in <symbol>
359a38ce40498397028473d956691915ed3e849atavmjong-free gchar const* style = symbol->getAttribute("inkscape:symbol-style");
359a38ce40498397028473d956691915ed3e849atavmjong-free if( !style ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free // If no default style in <symbol>, look in documents.
359a38ce40498397028473d956691915ed3e849atavmjong-free if( symbolDocument == currentDocument ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free style = style_from_use( symbol_id.c_str(), currentDocument );
359a38ce40498397028473d956691915ed3e849atavmjong-free } else {
359a38ce40498397028473d956691915ed3e849atavmjong-free style = symbolDocument->getReprRoot()->attribute("style");
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free ClipboardManager *cm = ClipboardManager::get();
359a38ce40498397028473d956691915ed3e849atavmjong-free cm->copySymbol(symbol->getRepr(), style);
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free}
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free#ifdef WITH_LIBVISIO
359a38ce40498397028473d956691915ed3e849atavmjong-free// Read Visio stencil files
359a38ce40498397028473d956691915ed3e849atavmjong-freeSPDocument* read_vss( gchar* fullname, gchar* filename ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free WPXFileStream input(fullname);
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free if (!libvisio::VisioDocument::isSupported(&input)) {
359a38ce40498397028473d956691915ed3e849atavmjong-free return NULL;
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White libvisio::VSDStringVector output;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free if (!libvisio::VisioDocument::generateSVGStencils(&input, output)) {
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free return NULL;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free }
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free if (output.empty()) {
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free return NULL;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free }
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free Glib::ustring tmpSVGOutput;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += "<svg\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += " xmlns=\"http://www.w3.org/2000/svg\"\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n";
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free tmpSVGOutput += " version=\"1.1\"\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += " style=\"fill:none;stroke:#000000;stroke-width:2\">\n";
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += " <title>";
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free tmpSVGOutput += filename;
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free tmpSVGOutput += "</title>\n";
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free tmpSVGOutput += " <defs>\n";
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // Create a string we can use for the symbol id (libvisio doesn't give us a name)
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free std::string sanitized( filename );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sanitized.erase( sanitized.find_last_of(".vss")-3 );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free sanitized.erase( std::remove_if( sanitized.begin(), sanitized.end(), ispunct ), sanitized.end() );
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free std::replace( sanitized.begin(), sanitized.end(), ' ', '_' );
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // std::cout << filename << " |" << sanitized << "|" << std::endl;
a3c27728560e19f7c710399f838dadeedac39249tavmjong-free
214a2dca4418a9937d7142e42ed91fdfdb86ae16tavmjong-free // Each "symbol" is in it's own SVG file, we wrap with <symbol> and merge into one file.
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free for (unsigned i=0; i<output.size(); ++i) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free std::stringstream ss;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free ss << i;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += " <symbol id=\"";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += sanitized;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += "_";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += ss.str();
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += "\">\n";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free std::istringstream iss( output[i].cstr() );
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free std::string line;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free while( std::getline( iss, line ) ) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free // std::cout << line << std::endl;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free if( line.find( "svg:svg" ) == std::string::npos ) {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += line;
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += "\n";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += " </symbol>\n";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free }
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += " </defs>\n";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free tmpSVGOutput += "</svg>\n";
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free return SPDocument::createNewDocFromMem( tmpSVGOutput.c_str(), strlen( tmpSVGOutput.c_str()), 0 );
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free}
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free#endif
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free/* Hunts preference directories for symbol files */
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-freevoid SymbolsDialog::get_symbols() {
438035e1fbba64c0adf12fc08de1b34afd3c9374tavmjong-free
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White std::list<Glib::ustring> directories;
359a38ce40498397028473d956691915ed3e849atavmjong-free
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White directories.push_back( INKSCAPE_SYMBOLSDIR );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White }
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White directories.push_back( profile_path("symbols") );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White }
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White std::list<Glib::ustring>::iterator it;
769a6887551cf7ff7bce4b48d3ac303cbea69507Liam P. White for( it = directories.begin(); it != directories.end(); ++it ) {
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White GError *err = 0;
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White GDir *dir = g_dir_open( (*it).c_str(), 0, &err );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White if( dir ) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White gchar *filename = 0;
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White gchar *fullname = g_build_filename((*it).c_str(), filename, NULL);
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR )
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White Glib::ustring fn( filename );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 );
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White SPDocument* symbol_doc = NULL;
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White#ifdef WITH_LIBVISIO
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White if( tag.compare( "vss" ) == 0 ) {
652485ad88d2a42f827c7e355220efeb3b2e37afLiam P. White
359a38ce40498397028473d956691915ed3e849atavmjong-free symbol_doc = read_vss( fullname, filename );
359a38ce40498397028473d956691915ed3e849atavmjong-free if( symbol_doc ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free symbolSets[Glib::ustring(filename)]= symbol_doc;
359a38ce40498397028473d956691915ed3e849atavmjong-free symbolSet->append(filename);
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free }
359a38ce40498397028473d956691915ed3e849atavmjong-free#endif
359a38ce40498397028473d956691915ed3e849atavmjong-free // Try to read all remaining files as SVG
359a38ce40498397028473d956691915ed3e849atavmjong-free if( !symbol_doc ) {
359a38ce40498397028473d956691915ed3e849atavmjong-free
359a38ce40498397028473d956691915ed3e849atavmjong-free symbol_doc = SPDocument::createNewDoc( fullname, FALSE );
359a38ce40498397028473d956691915ed3e849atavmjong-free if( symbol_doc ) {
const gchar *title = symbol_doc->getRoot()->title();
// A user provided file may not have a title
if( title != NULL ) {
title = g_dpgettext2(NULL, "Symbol", title); // Translate
} else {
title = _("Unnamed Symbols");
}
symbolSets[Glib::ustring(title)] = symbol_doc;
symbolSet->append(title);
}
}
}
g_free( fullname );
}
g_dir_close( dir );
}
}
}
GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
{
g_return_val_if_fail(r != NULL, l);
// Stop multiple counting of same symbol
if( SP_IS_USE(r) ) {
return l;
}
if( SP_IS_SYMBOL(r) ) {
l = g_slist_prepend (l, r);
}
for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
l = symbols_in_doc_recursive( child, l );
}
return l;
}
GSList* SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) {
GSList *l = NULL;
l = symbols_in_doc_recursive (symbolDocument->getRoot(), l );
l = g_slist_reverse( l );
return l;
}
GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l)
{
if( SP_IS_USE(r) ) {
l = g_slist_prepend (l, r);
}
for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
l = use_in_doc_recursive( child, l );
}
return l;
}
GSList* SymbolsDialog::use_in_doc( SPDocument* useDocument ) {
GSList *l = NULL;
l = use_in_doc_recursive (useDocument->getRoot(), l );
return l;
}
// Returns style from first <use> element found that references id.
// This is a last ditch effort to find a style.
gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* document) {
gchar const* style = 0;
GSList* l = use_in_doc( document );
for( ; l != NULL; l = l->next ) {
SPObject* use = SP_OBJECT(l->data);
if( SP_IS_USE( use ) ) {
gchar const *href = use->getRepr()->attribute("xlink:href");
if( href ) {
Glib::ustring href2(href);
Glib::ustring id2(id);
id2 = "#" + id2;
if( !href2.compare(id2) ) {
style = use->getRepr()->attribute("style");
break;
}
}
}
}
return style;
}
void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) {
GSList* l = symbols_in_doc( symbolDocument );
for( ; l != NULL; l = l->next ) {
SPObject* symbol = SP_OBJECT(l->data);
if (SP_IS_SYMBOL(symbol)) {
add_symbol( symbol );
}
}
}
void SymbolsDialog::add_symbol( SPObject* symbol ) {
SymbolColumns* columns = getColumns();
gchar const *id = symbol->getRepr()->attribute("id");
gchar const *title = symbol->title(); // From title element
if( !title ) {
title = id;
}
Glib::RefPtr<Gdk::Pixbuf> pixbuf = draw_symbol( symbol );
if( pixbuf ) {
Gtk::ListStore::iterator row = store->append();
(*row)[columns->symbol_id] = Glib::ustring( id );
(*row)[columns->symbol_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) ));
(*row)[columns->symbol_image] = pixbuf;
}
delete columns;
}
/*
* Returns image of symbol.
*
* Symbols normally are not visible. They must be referenced by a
* <use> element. A temporary document is created with a dummy
* <symbol> element and a <use> element that references the symbol
* element. Each real symbol is swapped in for the dummy symbol and
* the temporary document is rendered.
*/
Glib::RefPtr<Gdk::Pixbuf>
SymbolsDialog::draw_symbol(SPObject *symbol)
{
// 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);
repr->setAttribute("id", "the_symbol");
// Replace old "the_symbol" in previewDocument by new.
Inkscape::XML::Node *root = previewDocument->getReprRoot();
SPObject *symbol_old = previewDocument->getObjectById("the_symbol");
if (symbol_old) {
symbol_old->deleteObject(false);
}
// First look for default style stored in <symbol>
gchar const* style = repr->attribute("inkscape:symbol-style");
if( !style ) {
// If no default style in <symbol>, look in documents.
if( symbol->document == currentDocument ) {
gchar const *id = symbol->getRepr()->attribute("id");
style = style_from_use( id, symbol->document );
} else {
style = symbol->document->getReprRoot()->attribute("style");
}
}
// Last ditch effort to provide some default styling
if( !style ) style = "fill:#bbbbbb;stroke:#808080";
// This is for display in Symbols dialog only
if( style ) repr->setAttribute( "style", style );
// BUG: Symbols don't work if defined outside of <defs>. Causes Inkscape
// crash when trying to read in such a file.
root->appendChild(repr);
//defsrepr->appendChild(repr);
Inkscape::GC::release(repr);
// Uncomment this to get the previewDocument documents saved (useful for debugging)
// FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w");
// sp_repr_save_stream(previewDocument->getReprDoc(), fp);
// fclose (fp);
// Make sure previewDocument is up-to-date.
previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
previewDocument->ensureUpToDate();
// Make sure we have symbol in previewDocument
SPObject *object_temp = previewDocument->getObjectById( "the_use" );
previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
previewDocument->ensureUpToDate();
SPItem *item = SP_ITEM(object_temp);
unsigned psize = SYMBOL_ICON_SIZES[pack_size];
Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL);
// We could use cache here, but it doesn't really work with the structure
// of this user interface and we've already cached the pixbuf in the gtklist
// Find object's bbox in document.
// Note symbols can have own viewport... ignore for now.
//Geom::OptRect dbox = item->geometricBounds();
Geom::OptRect dbox = item->documentVisualBounds();
if (dbox) {
/* Scale symbols to fit */
double scale = 1.0;
double width = dbox->width();
double height = dbox->height();
if( width == 0.0 ) width = 1.0;
if( height == 0.0 ) height = 1.0;
if( fitSymbol->get_active() )
scale = psize / std::max(width, height);
else
scale = pow( 2.0, scale_factor/2.0 ) * psize / 32.0;
pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize));
}
return pixbuf;
}
/*
* Return empty doc to render symbols in.
* Symbols are by default not rendered so a <use> element is
* provided.
*/
SPDocument* SymbolsDialog::symbols_preview_doc()
{
// BUG: <symbol> must be inside <defs>
gchar const *buffer =
"<svg xmlns=\"http://www.w3.org/2000/svg\""
" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\""
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\""
" xmlns:xlink=\"http://www.w3.org/1999/xlink\">"
" <defs id=\"defs\">"
" <symbol id=\"the_symbol\"/>"
" </defs>"
" <use id=\"the_use\" xlink:href=\"#the_symbol\"/>"
"</svg>";
return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE );
}
void SymbolsDialog::setTargetDesktop(SPDesktop *desktop)
{
if (this->currentDesktop != desktop) {
this->currentDesktop = desktop;
if( !symbolSets[symbolSet->get_active_text()] ) {
// Symbol set is from Current document, update
rebuild();
}
}
}
} //namespace Dialogs
} //namespace UI
} //namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-basic-offset:2
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 :