/**
* @file
* Symbols dialog.
*/
/* Authors:
* Copyright (C) 2012 Tavmjong Bah
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <iostream>
#include <algorithm>
#include <locale>
#include <functional>
#include <sstream>
#include <gtkmm/buttonbox.h>
#if WITH_GTKMM_3_0
# include <gtkmm/togglebutton.h>
#else
#endif
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/iconview.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treemodelcolumn.h>
#include <gtkmm/clipboard.h>
#include <glibmm/stringutils.h>
#include "path-prefix.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/clipboard.h"
#include "ui/icon-names.h"
#include "symbols.h"
#include "selection.h"
#include "desktop.h"
#include "document.h"
#include "inkscape.h"
#include "sp-root.h"
#include "sp-use.h"
#include "sp-defs.h"
#include "sp-symbol.h"
#ifdef WITH_LIBVISIO
#include <libvisio/libvisio.h>
// TODO: Drop this check when librevenge is widespread.
#if WITH_LIBVISIO01
#include <librevenge-stream/librevenge-stream.h>
using librevenge::RVNGFileStream;
using librevenge::RVNGStringVector;
#else
#include <libwpd-stream/libwpd-stream.h>
typedef WPXFileStream RVNGFileStream;
#endif
#endif
#include "verbs.h"
#include "helper/action-context.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
{
public:
SymbolColumns() {
}
};
{
return columns;
}
/**
* Constructor
*/
iconView(0),
currentDesktop(0),
deskTrack(),
currentDocument(0),
previewDocument(0),
{
/******************** Table *************************/
#if WITH_GTKMM_3_0
#else
#endif
// panel is a cloked Gtk::VBox
/******************** Symbol Sets *************************/
#if WITH_GTKMM_3_0
#else
#endif
#if WITH_GTKMM_3_0
symbolSet->set_hexpand();
#else
#endif
++row;
/********************* Icon View **************************/
//iconView->set_text_column( columns->symbol_id );
// Giving the iconview a small minimum size will help users understand
// What the dialog does.
#if WITH_GTKMM_3_0
scroller->set_hexpand();
scroller->set_vexpand();
#else
#endif
++row;
/******************** Tools *******************************/
//tools->set_layout( Gtk::BUTTONBOX_END );
#if WITH_GTKMM_3_0
scroller->set_hexpand();
#else
#endif
addSymbol->set_focus_on_click( false );
removeSymbol->set_focus_on_click( false );
// Pack size (controls display area)
button->set_focus_on_click( false );
button->set_focus_on_click( false );
fitSymbol->set_focus_on_click( false );
fitSymbol->set_active( true );
// Render size (scales symbols within display area)
scale_factor = 0; // Default 1:1 * pack_size/pack_size default
zoomOut->set_focus_on_click( false );
zoomOut->set_sensitive( false );
zoomIn->set_focus_on_click( false );
zoomIn->set_sensitive( false );
++row;
/**********************************************************/
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
sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified));
get_symbols();
}
{
for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) {
it->disconnect();
}
}
{
return *new SymbolsDialog();
}
if(pack_size < 4) {
pack_size++;
rebuild();
}
}
if(pack_size > 0) {
pack_size--;
rebuild();
}
}
if(scale_factor < 4) {
scale_factor++;
rebuild();
}
}
if(scale_factor > -8) {
scale_factor--;
rebuild();
}
}
if( fitSymbol->get_active() ) {
zoomIn->set_sensitive( false );
zoomOut->set_sensitive( false );
} else {
zoomIn->set_sensitive( true);
zoomOut->set_sensitive( true );
}
if( !symbolDocument ) {
// Symbol must be from Current Document (this method of
// checking should be language independent).
addSymbol->set_sensitive( true );
removeSymbol->set_sensitive( true );
} else {
addSymbol->set_sensitive( false );
removeSymbol->set_sensitive( false );
}
}
SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop) );
}
SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop ) );
}
void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/)
{
#if WITH_GTKMM_3_0
#else
#endif
//std::cout << " iconArray empty: huh? " << std::endl;
} else {
}
}
{
rebuild();
}
}
iconView->unselect_all();
}
}
{
rebuild();
}
/* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */
if( !symbolDocument ) {
// Symbol must be from Current Document (this method of checking should be language independent).
return currentDocument;
}
return symbolDocument;
}
#if WITH_GTKMM_3_0
#else
#endif
}
}
if( symbol ) {
if( symbolDocument == currentDocument ) {
// Select the symbol on the canvas so it can be manipulated
}
// Find style for use in <use>
// First look for default style stored in <symbol>
if( !style ) {
// If no default style in <symbol>, look in documents.
if( symbolDocument == currentDocument ) {
} else {
}
}
}
}
#ifdef WITH_LIBVISIO
// Read Visio stencil files
return NULL;
}
#if WITH_LIBVISIO01
#else
#endif
return NULL;
}
return NULL;
}
tmpSVGOutput += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
tmpSVGOutput += "<svg\n";
tmpSVGOutput += " xmlns=\"http://www.w3.org/2000/svg\"\n";
tmpSVGOutput += " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
tmpSVGOutput += " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n";
tmpSVGOutput += " version=\"1.1\"\n";
tmpSVGOutput += " style=\"fill:none;stroke:#000000;stroke-width:2\">\n";
tmpSVGOutput += " <title>";
tmpSVGOutput += filename;
tmpSVGOutput += "</title>\n";
tmpSVGOutput += " <defs>\n";
// Create a string we can use for the symbol id (libvisio doesn't give us a name)
// std::cout << filename << " |" << sanitized << "|" << std::endl;
// Each "symbol" is in it's own SVG file, we wrap with <symbol> and merge into one file.
ss << i;
tmpSVGOutput += " <symbol id=\"";
tmpSVGOutput += "_";
tmpSVGOutput += "\">\n";
// std::cout << line << std::endl;
tmpSVGOutput += line;
tmpSVGOutput += "\n";
}
}
tmpSVGOutput += " </symbol>\n";
}
tmpSVGOutput += " </defs>\n";
tmpSVGOutput += "</svg>\n";
}
#endif
/* Hunts preference directories for symbol files */
// \TODO optimize this
}
if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
}
if( dir ) {
#ifdef WITH_LIBVISIO
if( symbol_doc ) {
}
}
#endif
// Try to read all remaining files as SVG
if( !symbol_doc ) {
if( symbol_doc ) {
// A user provided file may not have a title
} else {
title = _("Unnamed Symbols");
}
}
}
}
}
g_dir_close( dir );
}
}
}
{
g_return_val_if_fail(r != NULL, l);
// Stop multiple counting of same symbol
if ( dynamic_cast<SPUse *>(r) ) {
return l;
}
if ( dynamic_cast<SPSymbol *>(r) ) {
l = g_slist_prepend (l, r);
}
l = symbols_in_doc_recursive( child, l );
}
return l;
}
l = g_slist_reverse( l );
return l;
}
{
if ( dynamic_cast<SPUse *>(r) ) {
l = g_slist_prepend (l, r);
}
l = use_in_doc_recursive( child, l );
}
return l;
}
return l;
}
// Returns style from first <use> element found that references id.
// This is a last ditch effort to find a style.
if ( use ) {
if( href ) {
break;
}
}
}
}
return style;
}
if (symbol) {
add_symbol( symbol );
}
}
}
if( !title ) {
}
if( pixbuf ) {
(*row)[columns->symbol_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) ));
}
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.
*/
{
// Create a copy repr of the symbol with id="the_symbol"
// Replace old "the_symbol" in previewDocument by new.
if (symbol_old) {
symbol_old->deleteObject(false);
}
// First look for default style stored in <symbol>
if( !style ) {
// If no default style in <symbol>, look in documents.
} else {
}
}
// Last ditch effort to provide some default styling
// This is for display in Symbols dialog only
// BUG: Symbols don't work if defined outside of <defs>. Causes Inkscape
// crash when trying to read in such a file.
//defsrepr->appendChild(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.
// Make sure we have symbol in previewDocument
// 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();
if (dbox) {
/* Scale symbols to fit */
if( fitSymbol->get_active() )
else
}
return pixbuf;
}
/*
* Return empty doc to render symbols in.
* Symbols are by default not rendered so a <use> element is
* provided.
*/
{
// BUG: <symbol> must be inside <defs>
"<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>";
}
{
if (this->currentDesktop != desktop) {
this->currentDesktop = desktop;
// 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 :