symbols.cpp revision dc8f4c8f5b21b98069c1d0bac90876c8ac3d5824
/**
* @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 <gtkmm/buttonbox.h>
#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 "path-prefix.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/clipboard.h"
#include "symbols.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "document.h"
#include "inkscape.h"
#include "sp-root.h"
#include "sp-use.h"
#include "sp-symbol.h"
#include "verbs.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
{
public:
SymbolColumns() {
}
};
{
return columns;
}
/**
* Constructor
*/
iconView(0),
previewScale(0),
previewSize(0),
currentDesktop(0),
deskTrack(),
currentDocument(0),
previewDocument(0),
{
/******************** Table *************************/
// Replace by Grid for GTK 3.0
// panel is a cloked Gtk::VBox
/******************** Symbol Sets *************************/
#if WITH_GTKMM_2_24
#else
#endif
++row;
/********************* Icon View **************************/
//iconView->set_text_column( columns->symbol_id );
++row;
/******************** Preview Scale ***********************/
for( int i = 0; scales[i]; ++i ) {
#if WITH_GTKMM_2_24
#else
#endif
}
++row;
/******************** Preview Size ************************/
for( int i = 0; sizes[i]; ++i ) {
#if WITH_GTKMM_2_24
#else
#endif
}
++row;
/**********************************************************/
renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY ));
get_symbols();
}
{
for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) {
it->disconnect();
}
}
{
return *new SymbolsDialog();
}
void SymbolsDialog::rebuild() {
if( !symbolDocument ) {
// Symbol must be from Current Document (this method of
// checking should be language independent).
}
}
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 {
}
}
void SymbolsDialog::iconChanged() {
#if WITH_GTKMM_3_0
#else
#endif
//std::cout << " iconArray empty: huh? " << std::endl;
} else {
/* 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).
}
if( symbol ) {
// 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 {
}
}
}
}
}
/* Hunts preference directories for symbol files */
void SymbolsDialog::get_symbols() {
}
}
if( dir ) {
if( symbol_doc ) {
#if WITH_GTKMM_2_24
#else
#endif
}
}
}
g_dir_close( dir );
}
}
}
{
// Stop multiple counting of same symbol
if( SP_IS_USE(r) ) {
return l;
}
if( SP_IS_SYMBOL(r) ) {
l = g_slist_prepend (l, r);
}
l = symbols_in_doc_recursive( child, l );
}
return l;
}
return l;
}
{
if( SP_IS_USE(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( href ) {
break;
}
}
}
}
return style;
}
if (!SP_IS_SYMBOL(symbol)) {
//std::cout << " Error: not symbol" << std::endl;
continue;
}
if( !title ) {
}
if( 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.
*/
unsigned /*visionkey*/)
{
// Retrieve the symbol named 'symbol_id' from the source SVG document
//std::cout << " Failed to find symbol: " << symbol_id << std::endl;
//return 0;
}
// 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.
if( source == currentDocument ) {
} else {
}
}
// Last ditch effort to provide some default styling
// This is for display in Symbols dialog only
if( style ) {
}
// 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(symbol_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
// if( object_temp == NULL || !SP_IS_ITEM(object_temp) ) {
// //std::cout << " previewDocument broken?" << std::endl;
// //return 0;
// }
/* Update to renderable state */
//std::cout << " Key: " << key << std::endl;
// FIX ME
//Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
// Find object's bbox in document.
// Note symbols can have own viewport... ignore for now.
//Geom::OptRect dbox = item->geometricBounds();
if (!dbox) {
//std::cout << " No dbox" << std::endl;
return pixbuf;
}
if (!pixbuf) {
/* Scale symbols to fit */
double scale = 1.0;
if( width == 0.0 ) {
width = 1.0;
}
if( height == 0.0 ) {
height = 1.0;
}
switch (previewScaleRow) {
case 0:
/* Fit */
break;
case 1:
/* Fit width */
break;
case 2:
/* Fit height */
break;
default:
}
}
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