diff options
Diffstat (limited to 'src')
259 files changed, 5464 insertions, 3285 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8925e24f..fa54940db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -239,6 +239,7 @@ set(inkscape_SRC knotholder.cpp layer-fns.cpp layer-manager.cpp + layer-model.cpp line-geometry.cpp line-snapper.cpp lpe-tool-context.cpp @@ -398,6 +399,7 @@ set(inkscape_SRC knotholder.h layer-fns.h layer-manager.h + layer-model.h line-geometry.h line-snapper.h lpe-tool-context.h @@ -407,7 +409,6 @@ set(inkscape_SRC marker.h measure-context.h media.h - memeq.h menus-skeleton.h mesh-context.h message-context.h diff --git a/src/Makefile_insert b/src/Makefile_insert index 440757e5c..17dbce005 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -21,6 +21,7 @@ ink_common_sources += \ color-profile.cpp color-profile.h \ color-profile-cms-fns.h \ color-rgba.h \ + colorspace.h \ common-context.cpp common-context.h \ composite-undo-stack-observer.cpp \ composite-undo-stack-observer.h \ @@ -92,6 +93,7 @@ ink_common_sources += \ knot-holder-entity.h knot-holder-entity.cpp \ layer-fns.cpp layer-fns.h \ layer-manager.cpp layer-manager.h \ + layer-model.cpp layer-model.h \ line-geometry.cpp line-geometry.h \ line-snapper.cpp line-snapper.h \ lpe-tool-context.cpp lpe-tool-context.h \ diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 13b75db98..ade624365 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -279,13 +279,13 @@ gint SPArcContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-arc"); ret = TRUE; } @@ -318,7 +318,7 @@ gint SPArcContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index c009dc699..6d1a3dde4 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -374,47 +374,47 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; case GDK_KEY_bracketright: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_KEY_bracketleft: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_KEY_parenright: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_KEY_parenleft: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_KEY_braceright: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_KEY_braceleft: - persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT); + persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT(event)); DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; @@ -422,7 +422,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { /* TODO: what is this??? case GDK_O: - if (MOD__CTRL && MOD__SHIFT) { + if (MOD__CTRL(event) && MOD__SHIFT(event)) { Box3D::create_canvas_point(persp3d_get_VP(document()->getCurrentPersp3D(), Proj::W).affine(), 6, 0xff00ff00); } @@ -432,7 +432,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_selection_to_guides(desktop); ret = true; } @@ -440,7 +440,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_p: case GDK_KEY_P: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { if (document->getCurrentPersp3D()) { persp3d_print_debugging_info (document->getCurrentPersp3D()); } @@ -450,12 +450,11 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-box3d"); ret = TRUE; } - - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { persp3d_toggle_VPs(selection->perspList(), Proj::X); this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically? ret = true; @@ -464,7 +463,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_y: case GDK_KEY_Y: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { persp3d_toggle_VPs(selection->perspList(), Proj::Y); this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically? ret = true; @@ -473,7 +472,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { persp3d_toggle_VPs(selection->perspList(), Proj::Z); this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically? ret = true; @@ -502,7 +501,7 @@ gint Box3DContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/colorspace.h b/src/colorspace.h new file mode 100644 index 000000000..9b7af55e5 --- /dev/null +++ b/src/colorspace.h @@ -0,0 +1,52 @@ +#ifndef SEEN_COLOR_SPACE_H +#define SEEN_COLOR_SPACE_H + +/* + * Authors: + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2013 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + +#if HAVE_STDINT_H +# include <stdint.h> +#endif + +#include <vector> +#include <string> + + +namespace Inkscape +{ + +class ColorProfile; + +} // namespace Inkscape + +namespace colorspace +{ + +class Component +{ +public: + Component(); + Component(std::string const &name, std::string const &tip, guint scale); + + std::string name; + std::string tip; + guint scale; +}; + +std::vector<Component> getColorSpaceInfo( uint32_t space ); + +std::vector<Component> getColorSpaceInfo( Inkscape::ColorProfile *prof ); + +} // namespace colorspace + +#endif // SEEN_COLOR_SPACE_H diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 40132ec58..c632f9033 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -501,7 +501,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill || SP_IS_FLOWTSPAN(parent) || SP_IS_FLOWLINE(parent)); // 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary - + + // cppcheck-suppress comparisonOfBoolWithInt if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) { return QUERY_STYLE_MULTIPLE_DIFFERENT; // different types of paint } diff --git a/src/desktop.cpp b/src/desktop.cpp index d999c780e..029e58c59 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -53,15 +53,16 @@ #include "display/sp-canvas-util.h" #include "document.h" #include "event-log.h" +#include "helper/action-context.h" #include "helper/units.h" #include "interface.h" #include "inkscape-private.h" #include "layer-fns.h" #include "layer-manager.h" +#include "layer-model.h" #include "macros.h" #include "message-context.h" #include "message-stack.h" -#include "object-hierarchy.h" #include "preferences.h" #include "resource-manager.h" #include "select-context.h" @@ -70,6 +71,7 @@ #include "sp-item-group.h" #include "sp-namedview.h" #include "sp-root.h" +#include "sp-defs.h" #include "widgets/desktop-widget.h" #include "xml/repr.h" #include "helper/action.h" //sp_action_perform @@ -94,6 +96,7 @@ SPDesktop::SPDesktop() : _dlg_mgr( 0 ), namedview( 0 ), canvas( 0 ), + layers( 0 ), selection( 0 ), event_context( 0 ), layer_manager( 0 ), @@ -124,7 +127,6 @@ SPDesktop::SPDesktop() : gr_point_type( POINT_LG_BEGIN ), gr_point_i( 0 ), gr_fill_or_stroke( Inkscape::FOR_FILL ), - _layer_hierarchy( 0 ), _reconstruction_old_layer_id(), // an id attribute is not allowed to be the empty string _display_mode(Inkscape::RENDERMODE_NORMAL), _display_color_mode(Inkscape::COLORMODE_NORMAL), @@ -139,8 +141,12 @@ SPDesktop::SPDesktop() : { _d2w.setIdentity(); _w2d.setIdentity(); - - selection = Inkscape::GC::release( new Inkscape::Selection(this) ); + + layers = new Inkscape::LayerModel(); + layers->_layer_activated_signal.connect(sigc::bind(sigc::ptr_fun(_layer_activated), this)); + layers->_layer_deactivated_signal.connect(sigc::bind(sigc::ptr_fun(_layer_deactivated), this)); + layers->_layer_changed_signal.connect(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this)); + selection = Inkscape::GC::release( new Inkscape::Selection(layers, this) ); } void @@ -169,6 +175,9 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid dkey = SPItem::display_key_new(1); + /* Connect display key to layer model */ + layers->setDisplayKey(dkey); + /* Connect document */ setDocument (document); @@ -367,10 +376,7 @@ void SPDesktop::destroy() event_context = 0; } - if (_layer_hierarchy) { - delete _layer_hierarchy; -// _layer_hierarchy = NULL; //this should be here, but commented to find other bug somewhere else. - } + delete layers; if (layer_manager) { delete layer_manager; @@ -491,131 +497,45 @@ void SPDesktop::displayColorModeToggle() { } } -/** - * Returns current root (=bottom) layer. - */ +// Pass-through LayerModel functions SPObject *SPDesktop::currentRoot() const { - return _layer_hierarchy ? _layer_hierarchy->top() : NULL; + return layers->currentRoot(); } -/** - * Returns current top layer. - */ SPObject *SPDesktop::currentLayer() const { - return _layer_hierarchy ? _layer_hierarchy->bottom() : NULL; + return layers->currentLayer(); } -/** - * Sets the current layer of the desktop. - * - * Make \a object the top layer. - */ -void SPDesktop::setCurrentLayer(SPObject *object) { - g_return_if_fail(SP_IS_GROUP(object)); - g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); - // printf("Set Layer to ID: %s\n", object->getId()); - _layer_hierarchy->setBottom(object); -} - -void SPDesktop::toggleHideAllLayers(bool hide) { - - for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { - SP_ITEM(obj)->setHidden(hide); - } +void SPDesktop::setCurrentLayer(SPObject *object) +{ + layers->setCurrentLayer(object); } -void SPDesktop::toggleLockAllLayers(bool lock) { - - for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { - SP_ITEM(obj)->setLocked(lock); - } +void SPDesktop::toggleLayerSolo(SPObject *object) +{ + layers->toggleLayerSolo(object); } -void SPDesktop::toggleLockOtherLayers(SPObject *object) { - g_return_if_fail(SP_IS_GROUP(object)); - g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); - - bool othersLocked = false; - std::vector<SPObject*> layers; - for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { - // Dont lock any ancestors, since that would in turn lock the layer as well - if (!obj->isAncestorOf(object)) { - layers.push_back(obj); - othersLocked |= !SP_ITEM(obj)->isLocked(); - } - } - for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { - if (!obj->isAncestorOf(object)) { - layers.push_back(obj); - othersLocked |= !SP_ITEM(obj)->isLocked(); - } - } - - SPItem *item = SP_ITEM(object); - if ( item->isLocked() ) { - item->setLocked(false); - } - - for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) { - SP_ITEM(*it)->setLocked(othersLocked); - } +void SPDesktop::toggleHideAllLayers(bool hide) +{ + layers->toggleHideAllLayers(hide); } - -void SPDesktop::toggleLayerSolo(SPObject *object) { - g_return_if_fail(SP_IS_GROUP(object)); - g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); - - bool othersShowing = false; - std::vector<SPObject*> layers; - for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { - // Don't hide ancestors, since that would in turn hide the layer as well - if (!obj->isAncestorOf(object)) { - layers.push_back(obj); - othersShowing |= !SP_ITEM(obj)->isHidden(); - } - } - for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { - if (!obj->isAncestorOf(object)) { - layers.push_back(obj); - othersShowing |= !SP_ITEM(obj)->isHidden(); - } - } - - - SPItem *item = SP_ITEM(object); - if ( item->isHidden() ) { - item->setHidden(false); - } - - for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) { - SP_ITEM(*it)->setHidden(othersShowing); - } +void SPDesktop::toggleLockAllLayers(bool lock) +{ + layers->toggleLockAllLayers(lock); } -/** - * Return layer that contains \a object. - */ -SPObject *SPDesktop::layerForObject(SPObject *object) { - g_return_val_if_fail(object != NULL, NULL); - - SPObject *root=currentRoot(); - object = object->parent; - while ( object && object != root && !isLayer(object) ) { - object = object->parent; - } - return object; +void SPDesktop::toggleLockOtherLayers(SPObject *object) +{ + layers->toggleLockOtherLayers(object); } -/** - * True if object is a layer. - */ -bool SPDesktop::isLayer(SPObject *object) const { - return ( SP_IS_GROUP(object) - && ( SP_GROUP(object)->effectiveLayerMode(this->dkey) - == SPGroup::LAYER ) ); +bool SPDesktop::isLayer(SPObject *object) const +{ + return layers->isLayer(object); } /** @@ -1607,15 +1527,7 @@ SPDesktop::setDocument (SPDocument *doc) this->doc()->getRoot()->invoke_hide(dkey); } - if (_layer_hierarchy) { - _layer_hierarchy->clear(); - delete _layer_hierarchy; - } - _layer_hierarchy = new Inkscape::ObjectHierarchy(NULL); - _layer_hierarchy->connectAdded(sigc::bind(sigc::ptr_fun(_layer_activated), this)); - _layer_hierarchy->connectRemoved(sigc::bind(sigc::ptr_fun(_layer_deactivated), this)); - _layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this)); - _layer_hierarchy->setTop(doc->getRoot()); + layers->setDocument(doc); // remove old EventLog if it exists (see also: bug #1071082) if (event_log) { @@ -1723,9 +1635,9 @@ _onSelectionChanged */ SPItem *item=selection->singleItem(); if (item) { - SPObject *layer=desktop->layerForObject(item); + SPObject *layer=desktop->layers->layerForObject(item); if ( layer && layer != desktop->currentLayer() ) { - desktop->setCurrentLayer(layer); + desktop->layers->setCurrentLayer(layer); } } } @@ -1770,9 +1682,9 @@ _layer_hierarchy_changed(SPObject */*top*/, SPObject *bottom, /// Called when document is starting to be rebuilt. static void _reconstruction_start(SPDesktop * desktop) { - // printf("Desktop, starting reconstruction\n"); + g_debug("Desktop, starting reconstruction\n"); desktop->_reconstruction_old_layer_id = desktop->currentLayer()->getId() ? desktop->currentLayer()->getId() : ""; - desktop->_layer_hierarchy->setBottom(desktop->currentRoot()); + desktop->layers->reset(); /* GSList const * selection_objs = desktop->selection->list(); @@ -1782,22 +1694,22 @@ static void _reconstruction_start(SPDesktop * desktop) */ desktop->selection->clear(); - // printf("Desktop, starting reconstruction end\n"); + g_debug("Desktop, starting reconstruction end\n"); } /// Called when document rebuild is finished. static void _reconstruction_finish(SPDesktop * desktop) { - // printf("Desktop, finishing reconstruction\n"); + g_debug("Desktop, finishing reconstruction\n"); if ( !desktop->_reconstruction_old_layer_id.empty() ) { SPObject * newLayer = desktop->namedview->document->getObjectById(desktop->_reconstruction_old_layer_id); if (newLayer != NULL) { - desktop->setCurrentLayer(newLayer); + desktop->layers->setCurrentLayer(newLayer); } desktop->_reconstruction_old_layer_id.clear(); - // printf("Desktop, finishing reconstruction end\n"); } + g_debug("Desktop, finishing reconstruction end\n"); } /** @@ -1963,7 +1875,7 @@ SPDesktop::show_dialogs() if (visible) { Inkscape::Verb *verb = Inkscape::Verb::get(verbId); if (verb) { - SPAction *action = verb->get_action(this); + SPAction *action = verb->get_action(Inkscape::ActionContext(this)); if (action) { sp_action_perform(action, NULL); } diff --git a/src/desktop.h b/src/desktop.h index bf1e19904..d971b5bb2 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -62,9 +62,9 @@ typedef struct _GdkEventWindowState GdkEventWindowState; namespace Inkscape { struct Application; + class LayerModel; class MessageContext; class Selection; - class ObjectHierarchy; class LayerManager; class EventLog; namespace UI { @@ -125,6 +125,7 @@ public: Inkscape::UI::Dialog::DialogManager *_dlg_mgr; SPNamedView *namedview; SPCanvas *canvas; + Inkscape::LayerModel *layers; /// current selection; will never generally be NULL Inkscape::Selection *selection; SPEventContext *event_context; @@ -170,8 +171,6 @@ public: guint gr_point_i; Inkscape::PaintTarget gr_fill_or_stroke; - - Inkscape::ObjectHierarchy *_layer_hierarchy; Glib::ustring _reconstruction_old_layer_id; sigc::signal<void, sp_verb_t> _tool_changed; @@ -264,17 +263,16 @@ public: void set_active (bool new_active); - // TODO look into making these return a more specific subclass: + // Could make all callers use this->layers instead of passing calls through? SPObject *currentRoot() const; SPObject *currentLayer() const; - void setCurrentLayer(SPObject *object); void toggleLayerSolo(SPObject *object); void toggleHideAllLayers(bool hide); void toggleLockAllLayers(bool lock); void toggleLockOtherLayers(SPObject *object); - SPObject *layerForObject(SPObject *object); bool isLayer(SPObject *object) const; + bool isWithinViewport(SPItem *item) const; bool itemIsHidden(SPItem const *item) const; diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp index 1fb823bf0..4fbf26f94 100644 --- a/src/dialogs/dialog-events.cpp +++ b/src/dialogs/dialog-events.cpp @@ -15,6 +15,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/entry.h> #include <gtkmm/window.h> #include <gdk/gdkkeysyms.h> @@ -112,7 +116,7 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data) case GDK_KEY_w: case GDK_KEY_W: // close dialog - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { /* this code sends a delete_event to the dialog, * instead of just destroying it, so that the diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 170684328..1eadd3fd2 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -17,6 +17,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 88da22835..ee5ad0945 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -17,6 +17,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index eeba94d7c..f0965c460 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -114,7 +114,8 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D Geom::Affine trans = item->ctm(); - Geom::OptRect filter_area = filter_effect_area(item->itemBounds()); +// Geom::OptRect filter_area = filter_effect_area(item->itemBounds()); // disabled, already done in visualBounds + Geom::OptRect filter_area = item->itemBounds(); // see LP Bug 1188336 if (!filter_area) return 1; FilterUnits units(_filter_units, _primitive_units); @@ -221,7 +222,8 @@ void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item Geom::OptIntRect Filter::compute_drawbox(Inkscape::DrawingItem const *item, Geom::OptRect const &item_bbox) { - Geom::OptRect enlarged = filter_effect_area(item_bbox); +// Geom::OptRect enlarged = filter_effect_area(item_bbox); // disabled, already done in visualBounds + Geom::OptRect enlarged = item_bbox; // see LP Bug 1188336 if (enlarged) { *enlarged *= item->ctm(); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 9d4049512..9adb96642 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1095,8 +1095,8 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac SPCanvasItem *point_item = NULL; // cater for incomplete item implementations int has_point; - if (child->visible && SP_CANVAS_ITEM_GET_CLASS (child)->point) { - dist = sp_canvas_item_invoke_point (child, p, &point_item); + if (child->visible && SP_CANVAS_ITEM_GET_CLASS(child)->point) { + dist = sp_canvas_item_invoke_point(child, p, &point_item); has_point = TRUE; } else { has_point = FALSE; diff --git a/src/document.cpp b/src/document.cpp index e58f581b5..c4bdf7bbd 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -625,6 +625,11 @@ Geom::Point SPDocument::getDimensions() const return Geom::Point(getWidth(), getHeight()); } +Geom::OptRect SPDocument::preferredBounds() const +{ + return Geom::OptRect( Geom::Point(0, 0), getDimensions() ); +} + /** * Given a Geom::Rect that may, for example, correspond to the bbox of an object, * this function fits the canvas to that rect by resizing the canvas diff --git a/src/document.h b/src/document.h index 606a83be8..d49067250 100644 --- a/src/document.h +++ b/src/document.h @@ -228,6 +228,7 @@ public: gdouble getWidth() const; gdouble getHeight() const; Geom::Point getDimensions() const; + Geom::OptRect preferredBounds() const; void setWidth(gdouble width, const SPUnit *unit); void setHeight(gdouble height, const SPUnit *unit); void requestModified(); diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp index 71cd49dae..04e5ab33e 100644 --- a/src/doxygen-main.cpp +++ b/src/doxygen-main.cpp @@ -303,7 +303,7 @@ namespace XML {} * SPGuide [\ref sp-guide.cpp, \ref sp-guide.h, \ref satisfied-guide-cns.cpp, \ref sp-guide-attachment.h, \ref sp-guide-constraint.h] * * [\ref help.cpp] [\ref inkscape.cpp] [\ref inkscape-stock.cpp] - * [\ref interface.cpp, \ref memeq.h] [\ref main.cpp, \ref winmain.cpp] + * [\ref interface.cpp] [\ref main.cpp, \ref winmain.cpp] * [\ref menus-skeleton.h, \ref preferences-skeleton.h] * [\ref select-toolbar.cpp] [\ref shortcuts.cpp] * [\ref sp-cursor.cpp] [\ref text-edit.cpp] [\ref toolbox.cpp] diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 244a16c91..bb2468b98 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -205,7 +205,7 @@ gint SPDrawContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { ret = TRUE; } break; diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index d88281982..1f10dffa7 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -348,7 +348,7 @@ gint SPDropperContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { ret = TRUE; } break; diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 233c27f10..894fa91b5 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -851,7 +851,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { switch (get_group0_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_KP_Up: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { dc->angle += 5.0; if (dc->angle > 90.0) dc->angle = 90.0; @@ -861,7 +861,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Down: case GDK_KEY_KP_Down: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { dc->angle -= 5.0; if (dc->angle < -90.0) dc->angle = -90.0; @@ -871,7 +871,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Right: case GDK_KEY_KP_Right: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { dc->width += 0.01; if (dc->width > 1.0) dc->width = 1.0; @@ -881,7 +881,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Left: case GDK_KEY_KP_Left: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { dc->width -= 0.01; if (dc->width < 0.01) dc->width = 0.01; @@ -903,7 +903,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-calligraphy"); ret = TRUE; } @@ -917,7 +917,7 @@ gint SPDynaDrawContext::root_handler(GdkEvent* event) { break; case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__CTRL_ONLY && dc->is_drawing) { + if (MOD__CTRL_ONLY(event) && dc->is_drawing) { // if drawing, cancel, otherwise pass it up for undo calligraphic_cancel (dc); ret = TRUE; @@ -997,10 +997,10 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract) if (unionize) { sp_desktop_selection(desktop)->add(dc->repr); - sp_selected_path_union_skip_undo(desktop); + sp_selected_path_union_skip_undo(sp_desktop_selection(desktop), desktop); } else if (subtract) { sp_desktop_selection(desktop)->add(dc->repr); - sp_selected_path_diff_skip_undo(desktop); + sp_selected_path_diff_skip_undo(sp_desktop_selection(desktop), desktop); } else { if (dc->keep_selected) { sp_desktop_selection(desktop)->set(dc->repr); diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index d84f6cfaa..63737da61 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -539,7 +539,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { switch (get_group0_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_KP_Up: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->angle += 5.0; if (this->angle > 90.0) { @@ -553,7 +553,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_Down: case GDK_KEY_KP_Down: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->angle -= 5.0; if (this->angle < -90.0) { @@ -567,7 +567,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_Right: case GDK_KEY_KP_Right: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->width += 0.01; if (this->width > 1.0) { @@ -581,7 +581,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_Left: case GDK_KEY_KP_Left: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->width -= 0.01; if (this->width < 0.01) { @@ -609,7 +609,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-eraser"); ret = TRUE; } @@ -627,7 +627,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__CTRL_ONLY && this->is_drawing) { + if (MOD__CTRL_ONLY(event) && this->is_drawing) { // if drawing, cancel, otherwise pass it up for undo eraser_cancel (this); ret = TRUE; @@ -750,7 +750,7 @@ set_to_accumulated(SPEraserContext *dc) selection->set(item); selection->add(dup); - sp_selected_path_diff_skip_undo(desktop); + sp_selected_path_diff_skip_undo(selection, desktop); workDone = true; // TODO set this only if something was cut. if ( !selection->isEmpty() ) { diff --git a/src/event-context.cpp b/src/event-context.cpp index 622936fdb..edf34b923 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -18,6 +18,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include "shortcuts.h" #include "file.h" #include "event-context.h" @@ -614,21 +618,12 @@ gint SPEventContext::root_handler(GdkEvent* event) { ret = sp_shortcut_invoke(shortcut, desktop); break; - case GDK_KEY_D: - case GDK_KEY_d: - if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { - sp_toggle_dropper(desktop); - ret = TRUE; - } - break; - case GDK_KEY_Q: case GDK_KEY_q: if (desktop->quick_zoomed()) { ret = TRUE; } - - if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { + if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { desktop->zoom_quick(true); ret = TRUE; } @@ -638,7 +633,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_w: case GDK_KEY_F4: /* Close view */ - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { sp_ui_close_view(NULL); ret = TRUE; } @@ -647,7 +642,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_Left: // Ctrl Left case GDK_KEY_KP_Left: case GDK_KEY_KP_4: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -660,7 +655,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_Up: // Ctrl Up case GDK_KEY_KP_Up: case GDK_KEY_KP_8: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -673,7 +668,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_Right: // Ctrl Right case GDK_KEY_KP_Right: case GDK_KEY_KP_6: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -686,7 +681,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_Down: // Ctrl Down case GDK_KEY_KP_Down: case GDK_KEY_KP_2: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop))); @@ -697,7 +692,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { break; case GDK_KEY_F10: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_event_root_menu_popup(desktop, NULL, event); ret = TRUE; } @@ -717,7 +712,7 @@ gint SPEventContext::root_handler(GdkEvent* event) { case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->zoom_grab_focus(); ret = TRUE; } @@ -1196,11 +1191,11 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, gchar const *alt_tip) { guint keyval = get_group0_keyval(&event->key); - bool ctrl = ctrl_tip && (MOD__CTRL || (keyval == GDK_KEY_Control_L) || (keyval + bool ctrl = ctrl_tip && (MOD__CTRL(event) || (keyval == GDK_KEY_Control_L) || (keyval == GDK_KEY_Control_R)); - bool shift = shift_tip && (MOD__SHIFT || (keyval == GDK_KEY_Shift_L) || (keyval + bool shift = shift_tip && (MOD__SHIFT(event) || (keyval == GDK_KEY_Shift_L) || (keyval == GDK_KEY_Shift_R)); - bool alt = alt_tip && (MOD__ALT || (keyval == GDK_KEY_Alt_L) || (keyval + bool alt = alt_tip && (MOD__ALT(event) || (keyval == GDK_KEY_Alt_L) || (keyval == GDK_KEY_Alt_R) || (keyval == GDK_KEY_Meta_L) || (keyval == GDK_KEY_Meta_R)); gchar *tip = g_strdup_printf("%s%s%s%s%s", (ctrl ? ctrl_tip : ""), (ctrl diff --git a/src/event-log.h b/src/event-log.h index cabc3ae9a..78f0ae5d1 100644 --- a/src/event-log.h +++ b/src/event-log.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_EVENT_LOG_H #define INKSCAPE_EVENT_LOG_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/treestore.h> #include <glibmm/refptr.h> #include <gtkmm/treeselection.h> diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp index 8ee7bd12f..c0bc19d90 100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@ -18,6 +18,8 @@ #include "application-interface.h" #include <string.h> #include "dbus-init.h" +#include "file.h" +#include "inkscape.h" G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT) @@ -37,13 +39,32 @@ application_interface_class_init (ApplicationInterfaceClass *klass) } static void -application_interface_init (ApplicationInterface *object) +application_interface_init (ApplicationInterface *app_interface) { dbus_g_error_domain_register (INKSCAPE_ERROR, NULL, INKSCAPE_TYPE_ERROR); } +static bool +ensure_desktop_valid(GError **error) +{ + if (!inkscape_use_gui()) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires a GUI"); + return false; + } + return true; +} + +static bool +ensure_desktop_not_present(GError **error) +{ + if (inkscape_use_gui()) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Application interface action requires non-GUI (command line) mode"); + return false; + } + return true; +} ApplicationInterface * application_interface_new (void) @@ -94,27 +115,28 @@ GType inkscape_error_get_type(void) ****************************************************************************/ gchar* -application_interface_desktop_new (ApplicationInterface *object, +application_interface_desktop_new (ApplicationInterface *app_interface, GError **error) { - return (gchar*)Inkscape::Extension::Dbus::init_desktop(); + g_return_val_if_fail(ensure_desktop_valid(error), NULL); + return (gchar*)Inkscape::Extension::Dbus::init_desktop(); } gchar** -application_interface_get_desktop_list (ApplicationInterface *object) +application_interface_get_desktop_list (ApplicationInterface *app_interface) { return NULL; } gchar* -application_interface_get_active_desktop (ApplicationInterface *object, +application_interface_get_active_desktop (ApplicationInterface *app_interface, GError **error) { return NULL; } gboolean -application_interface_set_active_desktop (ApplicationInterface *object, +application_interface_set_active_desktop (ApplicationInterface *app_interface, gchar* document_name, GError **error) { @@ -122,15 +144,16 @@ application_interface_set_active_desktop (ApplicationInterface *object, } gboolean -application_interface_desktop_close_all (ApplicationInterface *object, +application_interface_desktop_close_all (ApplicationInterface *app_interface, GError **error) { return TRUE; } gboolean -application_interface_exit (ApplicationInterface *object, GError **error) +application_interface_exit (ApplicationInterface *app_interface, GError **error) { + sp_file_exit(); return TRUE; } @@ -138,20 +161,32 @@ application_interface_exit (ApplicationInterface *object, GError **error) DOCUMENT FUNCTIONS ****************************************************************************/ -gchar* application_interface_document_new (ApplicationInterface *object, +gchar* application_interface_document_new (ApplicationInterface *app_interface, GError **error) { - return (gchar*)Inkscape::Extension::Dbus::init_document(); + g_return_val_if_fail(ensure_desktop_not_present(error), NULL); + return (gchar*)Inkscape::Extension::Dbus::init_document(); +} + +gchar* +application_interface_get_active_document(ApplicationInterface *app_interface, + GError **error) +{ + gchar *result = (gchar*)Inkscape::Extension::Dbus::init_active_document(); + if (!result) { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "No active document"); + } + return result; } gchar** -application_interface_get_document_list (ApplicationInterface *object) +application_interface_get_document_list (ApplicationInterface *app_interface) { return NULL; } gboolean -application_interface_document_close_all (ApplicationInterface *object, +application_interface_document_close_all (ApplicationInterface *app_interface, GError **error) { return TRUE; diff --git a/src/extension/dbus/application-interface.h b/src/extension/dbus/application-interface.h index 88219a6b0..c108402cb 100644 --- a/src/extension/dbus/application-interface.h +++ b/src/extension/dbus/application-interface.h @@ -67,41 +67,45 @@ GType inkscape_error_get_type (void); ****************************************************************************/ gchar* -application_interface_desktop_new (ApplicationInterface *object, +application_interface_desktop_new (ApplicationInterface *app_interface, GError **error); gchar** -application_interface_get_desktop_list (ApplicationInterface *object); +application_interface_get_desktop_list (ApplicationInterface *app_interface); gchar* -application_interface_get_active_desktop (ApplicationInterface *object, +application_interface_get_active_desktop (ApplicationInterface *app_interface, GError **error); gboolean -application_interface_set_active_desktop (ApplicationInterface *object, +application_interface_set_active_desktop (ApplicationInterface *app_interface, gchar* document_name, GError **error); gboolean -application_interface_desktop_close_all (ApplicationInterface *object, +application_interface_desktop_close_all (ApplicationInterface *app_interface, GError **error); gboolean -application_interface_exit (ApplicationInterface *object, GError **error); +application_interface_exit (ApplicationInterface *app_interface, GError **error); /**************************************************************************** DOCUMENT FUNCTIONS ****************************************************************************/ gchar* -application_interface_document_new (ApplicationInterface *object, +application_interface_document_new (ApplicationInterface *app_interface, GError **error); +gchar* +application_interface_get_active_document(ApplicationInterface *app_interface, + GError **error); + gchar** -application_interface_get_document_list (ApplicationInterface *object); +application_interface_get_document_list (ApplicationInterface *app_interface); gboolean -application_interface_document_close_all (ApplicationInterface *object, +application_interface_document_close_all (ApplicationInterface *app_interface, GError **error); diff --git a/src/extension/dbus/application-interface.xml b/src/extension/dbus/application-interface.xml index ee2c4837b..1553971cc 100644 --- a/src/extension/dbus/application-interface.xml +++ b/src/extension/dbus/application-interface.xml @@ -32,7 +32,7 @@ </arg> <doc:doc> <doc:description> - <doc:para>Create a new document interface and return it's location.</doc:para> + <doc:para>Create a new document interface and return its location. Only call this when Inkscape is running in GUI mode.</doc:para> </doc:description> </doc:doc> </method> @@ -45,21 +45,21 @@ </arg> <doc:doc> <doc:description> - <doc:para>List all the interfaces that it is possible to connect to.</doc:para> + <doc:para>List all the interfaces that it is possible to connect to. TODO: not implemented.</doc:para> </doc:description> </doc:doc> </method> <method name="desktop_close_all"> <doc:doc> <doc:description> - <doc:para>Close all document interfaces without saving.</doc:para> + <doc:para>Close all document interfaces without saving. TODO: not implemented.</doc:para> </doc:description> </doc:doc> </method> <method name="exit"> <doc:doc> <doc:description> - <doc:para>Exit Inkscape without saving. Fairly straightforward. </doc:para> + <doc:para>Exit Inkscape without saving. Fairly straightforward.</doc:para> </doc:description> </doc:doc> </method> @@ -76,6 +76,21 @@ <doc:description> <doc:para>Originally, there were going to be two interfaces. A desktop and a document. Desktops would be used when the user wanted to see the result of their code and documents would be used when less overhead was desired. Unfortunately as more and more of the code can to rely on the desktop and it's associated support code (including selections and verbs) the document interface was looking more and more limited. Ultimately I decided to just go with the desktop interface since I didn't have a compelling reason for keeping the other one and having two similar interfaces could be very confusing. The desktop interface inherited the document name because I believe it's more familiar to people.</doc:para> <doc:para>Perhaps it would be best to have an option as to whether or not to create a window and fail with a good error message when they call a function that requires one. Or have a second interface for different use cases but have it be completely different, rather than a subset of the first if there are use cases that support it.</doc:para> + <doc:para>UPDATE: 3rd July 2013, Eric Greveson: After having done some initial work to attempt to decouple Inkscape "verbs" from desktops, it is now possible to run a limited subset of actions in command-line mode (with a selection model and document, but no desktop). I believe that the "single document interface" approach, with some functions that may require a GUI, is the better path, and so document interfaces without a desktop are now possible. Most functions still require the desktop to work, though, with the notable exception of selection methods and Boolean operations.</doc:para> + <doc:para>As a result, this function should ONLY be called when using Inkscape in command-line mode. Use "desktop_new" instead if running in GUI mode.</doc:para> + </doc:description> + </doc:doc> + </method> + <method name="get_active_document"> + <arg type="s" name="document_name" direction="out" > + <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/> + <doc:doc> + <doc:summary>This string can be used to connect to the current active document.</doc:summary> + </doc:doc> + </arg> + <doc:doc> + <doc:description> + <doc:para>Get the location of the current active document (e.g. when running in console mode, when desktops are not available).</doc:para> </doc:description> </doc:doc> </method> diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp index 9ff6897e5..19b48e10d 100644 --- a/src/extension/dbus/dbus-init.cpp +++ b/src/extension/dbus/dbus-init.cpp @@ -36,7 +36,14 @@ #include <sstream> - +namespace +{ + // This stores the bus name to use for this app instance. By default, it + // will be set to org.inkscape. However, users may provide other names by + // setting command-line parameters when starting Inkscape, so that more + // than one instance of Inkscape may be used by external scripts. + gchar *instance_bus_name = NULL; +} namespace Inkscape { namespace Extension { @@ -78,10 +85,53 @@ dbus_register_object (DBusGConnection *connection, return object; } +/* + * PRIVATE register a document interface for the document in the given ActionContext, if none exists. + * Return the DBus path to the interface (something like /org/inkscape/document_0). + * Note that while a DocumentInterface could be used either for a document with no desktop, or a + * document with a desktop, this function is only used for creating interfaces in the former case. + * Desktop-associated DocumentInterfaces are named /org/inkscape/desktop_0, etc. + * FIXME: This state of affairs probably needs tidying up at some point in the future. + */ +static gchar * +dbus_register_document(Inkscape::ActionContext const & target) +{ + SPDocument *doc = target.getDocument(); + g_assert(doc != NULL); + + // Document name is not suitable for DBus name, as it might contain invalid chars + std::string name("/org/inkscape/document_"); + std::stringstream ss; + ss << doc->serial(); + name.append(ss.str()); + + DBusGConnection *connection = dbus_get_connection(); + DBusGProxy *proxy = dbus_get_proxy(connection); + + // Has the document already been registered? + if (!dbus_g_connection_lookup_g_object(connection, name.c_str())) { + // No - register it + DocumentInterface *doc_interface = (DocumentInterface*) dbus_register_object (connection, + proxy, + TYPE_DOCUMENT_INTERFACE, + &dbus_glib_document_interface_object_info, + name.c_str()); + + // Set the document info for this interface + doc_interface->target = target; + } + return strdup(name.c_str()); +} + /* Initialize a Dbus service */ void init (void) { + if (instance_bus_name == NULL) { + // Set the bus name to the default + instance_bus_name = strdup("org.inkscape"); + } + guint result; GError *error = NULL; DBusGConnection *connection; @@ -89,7 +139,7 @@ init (void) connection = dbus_get_connection(); proxy = dbus_get_proxy(connection); org_freedesktop_DBus_request_name (proxy, - "org.inkscape", + instance_bus_name, DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error); //create interface for application dbus_register_object (connection, @@ -97,37 +147,36 @@ init (void) TYPE_APPLICATION_INTERFACE, &dbus_glib_application_interface_object_info, DBUS_APPLICATION_INTERFACE_PATH); -} //init +} gchar * -init_document (void) { - DBusGConnection *connection; - DBusGProxy *proxy; - SPDocument *doc; - - doc = SPDocument::createNewDoc(NULL, 1, TRUE); - - std::string name("/org/inkscape/"); - name.append(doc->getName()); - std::replace(name.begin(), name.end(), ' ', '_'); +init_document (void) +{ + // This is for command-line use only + g_assert(!inkscape_use_gui()); - connection = dbus_get_connection(); - proxy = dbus_get_proxy(connection); + // Create a blank document and get its selection model etc in an ActionContext + SPDocument *doc = SPDocument::createNewDoc(NULL, 1, TRUE); + inkscape_add_document(doc); + return dbus_register_document(inkscape_action_context_for_document(doc)); +} - dbus_register_object (connection, - proxy, - TYPE_DOCUMENT_INTERFACE, - &dbus_glib_document_interface_object_info, - name.c_str()); - return strdup(name.c_str()); -} //init_document +gchar * +init_active_document() +{ + SPDocument *doc = inkscape_active_document(); + if (!doc) { + return NULL; + } + + return dbus_register_document(inkscape_active_action_context()); +} gchar * dbus_init_desktop_interface (SPDesktop * dt) { DBusGConnection *connection; DBusGProxy *proxy; - DocumentInterface *obj; std::string name("/org/inkscape/desktop_"); std::stringstream out; @@ -139,12 +188,12 @@ dbus_init_desktop_interface (SPDesktop * dt) connection = dbus_get_connection(); proxy = dbus_get_proxy(connection); - obj = (DocumentInterface*) dbus_register_object (connection, + DocumentInterface *doc_interface = (DocumentInterface*) dbus_register_object (connection, proxy, TYPE_DOCUMENT_INTERFACE, &dbus_glib_document_interface_object_info, name.c_str()); - obj->desk = dt; - obj->updates = TRUE; - dt->dbus_document_interface=obj; + doc_interface->target = Inkscape::ActionContext(dt); + doc_interface->updates = TRUE; + dt->dbus_document_interface=doc_interface; return strdup(name.c_str()); } @@ -159,8 +208,21 @@ init_desktop (void) { out << dt->dkey; name.append(out.str()); return strdup(name.c_str()); -} //init_desktop +} +void +dbus_set_bus_name(gchar * bus_name) +{ + g_assert(bus_name != NULL); + g_assert(instance_bus_name == NULL); + instance_bus_name = strdup(bus_name); +} +gchar * +dbus_get_bus_name() +{ + g_assert(instance_bus_name != NULL); + return instance_bus_name; +} } } } /* namespace Inkscape::Extension::Dbus */ diff --git a/src/extension/dbus/dbus-init.h b/src/extension/dbus/dbus-init.h index 025011f28..7862ad3c3 100644 --- a/src/extension/dbus/dbus-init.h +++ b/src/extension/dbus/dbus-init.h @@ -10,8 +10,7 @@ #ifndef INKSCAPE_EXTENSION_DBUS_INIT_H__ #define INKSCAPE_EXTENSION_DBUS_INIT_H__ -#include "desktop.h" - +class SPDesktop; namespace Inkscape { namespace Extension { @@ -23,10 +22,22 @@ void init (void); gchar * init_document (void); +gchar * init_active_document (); + gchar * init_desktop (void); gchar * dbus_init_desktop_interface (SPDesktop * dt); +/** Set the bus name to use. Default is "org.inkscape". + This function should only be called once, before init(), if a non-default + bus name is required. */ +void dbus_set_bus_name(gchar * bus_name); + +/** Get the bus name for this instance. Default is "org.inkscape". + This function should only be called after init(). + The returned gchar * is owned by this module and should not be freed. */ +gchar * dbus_get_bus_name(); + } } } /* namespace Dbus, Extension, Inkscape */ #endif /* INKSCAPE_EXTENSION_DBUS_INIT_H__ */ diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 56d1dfdbd..3cb03646a 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -20,6 +20,7 @@ #include "application-interface.h" #include <string.h> #include <dbus/dbus-glib.h> +#include "desktop.h" #include "desktop-handles.h" //sp_desktop_document() #include "desktop-style.h" //sp_desktop_get_style #include "display/canvas-text.h" //text @@ -30,8 +31,10 @@ #include "extension/system.h" //IO #include "file.h" //IO #include "helper/action.h" //sp_action_perform +#include "helper/action-context.h" #include "inkscape.h" //inkscape_find_desktop_by_dkey, activate desktops #include "layer-fns.h" //LPOS_BELOW +#include "layer-model.h" #include "live_effects/parameter/text.h" //text #include "print.h" //IO #include "selection-chemistry.h"// lots of selection functions @@ -91,12 +94,12 @@ * place to adjust things. */ Inkscape::XML::Node * -get_repr_by_name (SPDesktop *desk, gchar *name, GError **error) +get_repr_by_name (SPDocument *doc, gchar *name, GError **error) { /* ALTERNATIVE (is this faster if only repr is needed?) Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name); */ - SPObject * obj = sp_desktop_document(desk)->getObjectById(name); + SPObject * obj = doc->getObjectById(name); if (!obj) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); @@ -109,9 +112,9 @@ get_repr_by_name (SPDesktop *desk, gchar *name, GError **error) * See comment for get_repr_by_name, above. */ SPObject * -get_object_by_name (SPDesktop *desk, gchar *name, GError **error) +get_object_by_name (SPDocument *doc, gchar *name, GError **error) { - SPObject * obj = sp_desktop_document(desk)->getObjectById(name); + SPObject * obj = doc->getObjectById(name); if (!obj) { g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); @@ -183,12 +186,11 @@ selection_get_center_y (Inkscape::Selection *sel){ * they might see the selection box flicker if used in a loop. */ const GSList * -selection_swap(SPDesktop *desk, gchar *name, GError **error) +selection_swap(Inkscape::Selection *sel, gchar *name, GError **error) { - Inkscape::Selection *sel = sp_desktop_selection(desk); const GSList *oldsel = g_slist_copy((GSList *)sel->list()); - sel->set(get_object_by_name(desk, name, error)); + sel->set(get_object_by_name(sel->layers()->getDocument(), name, error)); return oldsel; } @@ -196,9 +198,8 @@ selection_swap(SPDesktop *desk, gchar *name, GError **error) * See selection_swap, above */ void -selection_restore(SPDesktop *desk, const GSList * oldsel) +selection_restore(Inkscape::Selection *sel, const GSList * oldsel) { - Inkscape::Selection *sel = sp_desktop_selection(desk); sel->setList(oldsel); } @@ -206,9 +207,8 @@ selection_restore(SPDesktop *desk, const GSList * oldsel) * Shortcut for creating a Node. */ Inkscape::XML::Node * -dbus_create_node (SPDesktop *desk, const gchar *type) +dbus_create_node (SPDocument *doc, const gchar *type) { - SPDocument * doc = sp_desktop_document (desk); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); return xml_doc->createElement(type); @@ -221,10 +221,12 @@ dbus_create_node (SPDesktop *desk, const gchar *type) * There is probably a better way to do this (use the shape tools default styles) * but I'm not sure how. */ -gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc) +gchar *finish_create_shape (DocumentInterface *doc_interface, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc) { - SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE); - + SPCSSAttr *style = NULL; + if (doc_interface->target.getDesktop()) { + style = sp_desktop_get_style(doc_interface->target.getDesktop(), TRUE); + } if (style) { Glib::ustring str; sp_repr_css_write_string(style, str); @@ -234,13 +236,11 @@ gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inks newNode->setAttribute("style", "fill:#0000ff;fill-opacity:1;stroke:#c900b9;stroke-width:0;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none", TRUE); } - object->desk->currentLayer()->appendChildRepr(newNode); - object->desk->currentLayer()->updateRepr(); + doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode); + doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr(); - if (object->updates) { - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc); - //} else { - //document_interface_pause_updates(object, error); + if (doc_interface->updates) { + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), 0, (gchar *)desc); } return strdup(newNode->attribute("id")); @@ -255,31 +255,40 @@ gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inks * document_interface_call_verb is similar but is called by the user. */ gboolean -dbus_call_verb (DocumentInterface *object, int verbid, GError **error) +dbus_call_verb (DocumentInterface *doc_interface, int verbid, GError **error) { - SPDesktop *desk2 = object->desk; - desktop_ensure_active (desk2); - - if ( desk2 ) { - Inkscape::Verb *verb = Inkscape::Verb::get( verbid ); - if ( verb ) { - SPAction *action = verb->get_action(desk2); - if ( action ) { - //if (!object->updates) - //document_interface_pause_updates (object, error); - sp_action_perform( action, NULL ); - if (object->updates) - Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); - //if (!object->updates) - //document_interface_pause_updates (object, error); - return TRUE; - } + SPDesktop *desk = doc_interface->target.getDesktop(); + if ( desk ) { + desktop_ensure_active (desk); + } + Inkscape::Verb *verb = Inkscape::Verb::get( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(doc_interface->target); + if ( action ) { + sp_action_perform( action, NULL ); + if (doc_interface->updates) + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), verb->get_code(), g_strdup(verb->get_tip())); + return TRUE; } } g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb failed to execute"); return FALSE; } +/* + * Check that the desktop is not NULL. If it is NULL, set the error to a useful message. + */ +bool +ensure_desktop_valid(SPDesktop* desk, GError **error) +{ + if (desk) { + return true; + } + + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Document interface action requires a GUI"); + return false; +} + /**************************************************************************** DOCUMENT INTERFACE CLASS STUFF ****************************************************************************/ @@ -310,9 +319,9 @@ document_interface_class_init (DocumentInterfaceClass *klass) } static void -document_interface_init (DocumentInterface *object) +document_interface_init (DocumentInterface *doc_interface) { - object->desk = NULL; + doc_interface->target = Inkscape::ActionContext(); } @@ -328,28 +337,28 @@ document_interface_new (void) MISC FUNCTIONS ****************************************************************************/ -gboolean document_interface_delete_all(DocumentInterface *object, GError ** /*error*/) +gboolean document_interface_delete_all(DocumentInterface *doc_interface, GError ** /*error*/) { - sp_edit_clear_all(object->desk); + sp_edit_clear_all(doc_interface->target.getSelection()); return TRUE; } gboolean -document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError **error) -{ - SPDesktop *desk2 = object->desk; - desktop_ensure_active (object->desk); - if ( desk2 ) { - Inkscape::Verb *verb = Inkscape::Verb::getbyid( verbid ); - if ( verb ) { - SPAction *action = verb->get_action(desk2); - if ( action ) { - sp_action_perform( action, NULL ); - if (object->updates) { - Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); - } - return TRUE; +document_interface_call_verb (DocumentInterface *doc_interface, gchar *verbid, GError **error) +{ + SPDesktop *desk = doc_interface->target.getDesktop(); + if ( desk ) { + desktop_ensure_active (desk); + } + Inkscape::Verb *verb = Inkscape::Verb::getbyid( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(doc_interface->target); + if ( action ) { + sp_action_perform( action, NULL ); + if (doc_interface->updates) { + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), verb->get_code(), g_strdup(verb->get_tip())); } + return TRUE; } } g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb '%s' failed to execute or was not found.", verbid); @@ -362,39 +371,39 @@ document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError * ****************************************************************************/ gchar* -document_interface_rectangle (DocumentInterface *object, int x, int y, +document_interface_rectangle (DocumentInterface *doc_interface, int x, int y, int width, int height, GError **error) { - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:rect"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:rect"); sp_repr_set_int(newNode, "x", x); //could also use newNode->setAttribute() sp_repr_set_int(newNode, "y", y); sp_repr_set_int(newNode, "width", width); sp_repr_set_int(newNode, "height", height); - return finish_create_shape (object, error, newNode, (gchar *)"create rectangle"); + return finish_create_shape (doc_interface, error, newNode, (gchar *)"create rectangle"); } gchar* -document_interface_ellipse_center (DocumentInterface *object, int cx, int cy, +document_interface_ellipse_center (DocumentInterface *doc_interface, int cx, int cy, int rx, int ry, GError **error) { - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("sodipodi:type", "arc"); sp_repr_set_int(newNode, "sodipodi:cx", cx); sp_repr_set_int(newNode, "sodipodi:cy", cy); sp_repr_set_int(newNode, "sodipodi:rx", rx); sp_repr_set_int(newNode, "sodipodi:ry", ry); - return finish_create_shape (object, error, newNode, (gchar *)"create circle"); + return finish_create_shape (doc_interface, error, newNode, (gchar *)"create circle"); } gchar* -document_interface_polygon (DocumentInterface *object, int cx, int cy, +document_interface_polygon (DocumentInterface *doc_interface, int cx, int cy, int radius, int rotation, int sides, GError **error) { gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0); - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("inkscape:flatsided", "true"); newNode->setAttribute("sodipodi:type", "star"); sp_repr_set_int(newNode, "sodipodi:cx", cx); @@ -407,15 +416,15 @@ document_interface_polygon (DocumentInterface *object, int cx, int cy, sp_repr_set_svg_double(newNode, "sodipodi:arg2", rot); sp_repr_set_svg_double(newNode, "inkscape:rounded", 0); - return finish_create_shape (object, error, newNode, (gchar *)"create polygon"); + return finish_create_shape (doc_interface, error, newNode, (gchar *)"create polygon"); } gchar* -document_interface_star (DocumentInterface *object, int cx, int cy, +document_interface_star (DocumentInterface *doc_interface, int cx, int cy, int r1, int r2, int sides, gdouble rounded, gdouble arg1, gdouble arg2, GError **error) { - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("inkscape:flatsided", "false"); newNode->setAttribute("sodipodi:type", "star"); sp_repr_set_int(newNode, "sodipodi:cx", cx); @@ -428,35 +437,35 @@ document_interface_star (DocumentInterface *object, int cx, int cy, sp_repr_set_svg_double(newNode, "sodipodi:arg2", arg2); sp_repr_set_svg_double(newNode, "inkscape:rounded", rounded); - return finish_create_shape (object, error, newNode, (gchar *)"create star"); + return finish_create_shape (doc_interface, error, newNode, (gchar *)"create star"); } gchar* -document_interface_ellipse (DocumentInterface *object, int x, int y, +document_interface_ellipse (DocumentInterface *doc_interface, int x, int y, int width, int height, GError **error) { int rx = width/2; int ry = height/2; - return document_interface_ellipse_center (object, x+rx, y+ry, rx, ry, error); + return document_interface_ellipse_center (doc_interface, x+rx, y+ry, rx, ry, error); } gchar* -document_interface_line (DocumentInterface *object, int x, int y, +document_interface_line (DocumentInterface *doc_interface, int x, int y, int x2, int y2, GError **error) { - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); std::stringstream out; // Not sure why this works. out << "m " << x << "," << y << " " << x2 - x << "," << y2 - y; newNode->setAttribute("d", out.str().c_str()); - return finish_create_shape (object, error, newNode, (gchar *)"create line"); + return finish_create_shape (doc_interface, error, newNode, (gchar *)"create line"); } gchar* -document_interface_spiral (DocumentInterface *object, int cx, int cy, +document_interface_spiral (DocumentInterface *doc_interface, int cx, int cy, int r, int revolutions, GError **error) { - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("sodipodi:type", "spiral"); sp_repr_set_int(newNode, "sodipodi:cx", cx); sp_repr_set_int(newNode, "sodipodi:cy", cy); @@ -465,7 +474,7 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy, sp_repr_set_int(newNode, "sodipodi:t0", 0); sp_repr_set_int(newNode, "sodipodi:argument", 0); sp_repr_set_int(newNode, "sodipodi:expansion", 1); - gchar * retval = finish_create_shape (object, error, newNode, (gchar *)"create spiral"); + gchar * retval = finish_create_shape (doc_interface, error, newNode, (gchar *)"create spiral"); //Makes sure there is no fill for spirals by default. gchar* newString = g_strconcat(newNode->attribute("style"), ";fill:none", NULL); newNode->setAttribute("style", newString); @@ -474,57 +483,55 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy, } gchar* -document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error) +document_interface_text (DocumentInterface *doc_interface, int x, int y, gchar *text, GError **error) { - Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text"); + Inkscape::XML::Node *text_node = dbus_create_node(doc_interface->target.getDocument(), "svg:text"); sp_repr_set_int(text_node, "x", x); sp_repr_set_int(text_node, "y", y); //just a workaround so i can get an spitem from the name - gchar *name = finish_create_shape (object, error, text_node, (gchar *)"create text"); + gchar *name = finish_create_shape (doc_interface, error, text_node, (gchar *)"create text"); - SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); sp_te_set_repr_text_multiline(text_obj, text); return name; } gchar * -document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error) +document_interface_image (DocumentInterface *doc_interface, int x, int y, gchar *filename, GError **error) { gchar * uri = g_filename_to_uri (filename, FALSE, error); if (!uri) return FALSE; - Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:image"); + Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:image"); sp_repr_set_int(newNode, "x", x); sp_repr_set_int(newNode, "y", y); newNode->setAttribute("xlink:href", uri); - object->desk->currentLayer()->appendChildRepr(newNode); - object->desk->currentLayer()->updateRepr(); + doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode); + doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr(); - if (object->updates) - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, "Imported bitmap."); + if (doc_interface->updates) + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), 0, "Imported bitmap."); //g_free(uri); return strdup(newNode->attribute("id")); } -gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** /*error*/) +gchar *document_interface_node(DocumentInterface *doc_interface, gchar *type, GError ** /*error*/) { - SPDocument * doc = sp_desktop_document (object->desk); + SPDocument * doc = doc_interface->target.getDocument(); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *newNode = xml_doc->createElement(type); - object->desk->currentLayer()->appendChildRepr(newNode); - object->desk->currentLayer()->updateRepr(); + doc_interface->target.getSelection()->layers()->currentLayer()->appendChildRepr(newNode); + doc_interface->target.getSelection()->layers()->currentLayer()->updateRepr(); - if (object->updates) { - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node"); - //} else { - //document_interface_pause_updates(object, error); + if (doc_interface->updates) { + Inkscape::DocumentUndo::done(doc, 0, (gchar *)"created empty node"); } return strdup(newNode->attribute("id")); @@ -534,53 +541,59 @@ gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** ENVIRONMENT FUNCTIONS ****************************************************************************/ gdouble -document_interface_document_get_width (DocumentInterface *object) +document_interface_document_get_width (DocumentInterface *doc_interface) { - return sp_desktop_document(object->desk)->getWidth(); + return doc_interface->target.getDocument()->getWidth(); } gdouble -document_interface_document_get_height (DocumentInterface *object) +document_interface_document_get_height (DocumentInterface *doc_interface) { - return sp_desktop_document(object->desk)->getHeight(); + return doc_interface->target.getDocument()->getHeight(); } -gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/) +gchar *document_interface_document_get_css(DocumentInterface *doc_interface, GError ** error) { - SPCSSAttr *current = (object->desk)->current; + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), NULL); + SPCSSAttr *current = desk->current; Glib::ustring str; sp_repr_css_write_string(current, str); return (str.empty() ? NULL : g_strdup (str.c_str())); } -gboolean document_interface_document_merge_css(DocumentInterface *object, - gchar *stylestring, GError ** /*error*/) +gboolean document_interface_document_merge_css(DocumentInterface *doc_interface, + gchar *stylestring, GError ** error) { + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); SPCSSAttr * style = sp_repr_css_attr_new(); sp_repr_css_attr_add_from_string(style, stylestring); - sp_desktop_set_style(object->desk, style); + sp_desktop_set_style(desk, style); return TRUE; } -gboolean document_interface_document_set_css(DocumentInterface *object, - gchar *stylestring, GError ** /*error*/) +gboolean document_interface_document_set_css(DocumentInterface *doc_interface, + gchar *stylestring, GError ** error) { + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); SPCSSAttr * style = sp_repr_css_attr_new(); sp_repr_css_attr_add_from_string (style, stylestring); //Memory leak? - object->desk->current = style; + desk->current = style; return TRUE; } gboolean -document_interface_document_resize_to_fit_selection (DocumentInterface *object, +document_interface_document_resize_to_fit_selection (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_FIT_CANVAS_TO_SELECTION, error); + return dbus_call_verb (doc_interface, SP_VERB_FIT_CANVAS_TO_SELECTION, error); } gboolean -document_interface_document_set_display_area (DocumentInterface *object, +document_interface_document_set_display_area (DocumentInterface *doc_interface, double x0, double y0, double x1, @@ -588,19 +601,25 @@ document_interface_document_set_display_area (DocumentInterface *object, double border, GError **error) { - object->desk->set_display_area (x0, + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); + desk->set_display_area (x0, y0, x1, y1, border, false); - return TRUE; + return TRUE; } GArray * -document_interface_document_get_display_area (DocumentInterface *object) +document_interface_document_get_display_area (DocumentInterface *doc_interface) { - Geom::Rect const d = object->desk->get_display_area(); + SPDesktop *desk = doc_interface->target.getDesktop(); + if (!desk) { + return NULL; + } + Geom::Rect const d = desk->get_display_area(); GArray * dArr = g_array_new (TRUE, TRUE, sizeof(double)); @@ -622,10 +641,10 @@ document_interface_document_get_display_area (DocumentInterface *object) ****************************************************************************/ gboolean -document_interface_set_attribute (DocumentInterface *object, char *shape, +document_interface_set_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, char *newval, GError **error) { - Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error); + Inkscape::XML::Node *newNode = get_repr_by_name(doc_interface->target.getDocument(), shape, error); /* ALTERNATIVE (is this faster?) Inkscape::XML::Node *newnode = sp_repr_lookup_name((doc->root)->repr, name); @@ -641,11 +660,11 @@ document_interface_set_attribute (DocumentInterface *object, char *shape, } gboolean -document_interface_set_int_attribute (DocumentInterface *object, +document_interface_set_int_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, int newval, GError **error) { - Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error); + Inkscape::XML::Node *newNode = get_repr_by_name (doc_interface->target.getDocument(), shape, error); if (!newNode) return FALSE; @@ -655,11 +674,11 @@ document_interface_set_int_attribute (DocumentInterface *object, gboolean -document_interface_set_double_attribute (DocumentInterface *object, +document_interface_set_double_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, double newval, GError **error) { - Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error); + Inkscape::XML::Node *newNode = get_repr_by_name (doc_interface->target.getDocument(), shape, error); if (!dbus_check_string (attribute, error, "New value string was empty.")) return FALSE; @@ -671,10 +690,10 @@ document_interface_set_double_attribute (DocumentInterface *object, } gchar * -document_interface_get_attribute (DocumentInterface *object, char *shape, +document_interface_get_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, GError **error) { - Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error); + Inkscape::XML::Node *newNode = get_repr_by_name(doc_interface->target.getDocument(), shape, error); if (!dbus_check_string (attribute, error, "Attribute name empty.")) return NULL; @@ -685,47 +704,47 @@ document_interface_get_attribute (DocumentInterface *object, char *shape, } gboolean -document_interface_move (DocumentInterface *object, gchar *name, gdouble x, +document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error) { - const GSList *oldsel = selection_swap(object->desk, name, error); + const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error); if (!oldsel) return FALSE; - sp_selection_move (object->desk, x, 0 - y); - selection_restore(object->desk, oldsel); + sp_selection_move (doc_interface->target.getSelection(), x, 0 - y); + selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; } gboolean -document_interface_move_to (DocumentInterface *object, gchar *name, gdouble x, +document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error) { - const GSList *oldsel = selection_swap(object->desk, name, error); + const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), name, error); if (!oldsel) return FALSE; - Inkscape::Selection * sel = sp_desktop_selection(object->desk); - sp_selection_move (object->desk, x - selection_get_center_x(sel), + Inkscape::Selection * sel = doc_interface->target.getSelection(); + sp_selection_move (doc_interface->target.getSelection(), x - selection_get_center_x(sel), 0 - (y - selection_get_center_y(sel))); - selection_restore(object->desk, oldsel); + selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; } gboolean -document_interface_object_to_path (DocumentInterface *object, +document_interface_object_to_path (DocumentInterface *doc_interface, char *shape, GError **error) { - const GSList *oldsel = selection_swap(object->desk, shape, error); + const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); if (!oldsel) return FALSE; - dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); - selection_restore(object->desk, oldsel); + dbus_call_verb (doc_interface, SP_VERB_OBJECT_TO_CURVE, error); + selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; } gchar * -document_interface_get_path (DocumentInterface *object, char *pathname, GError **error) +document_interface_get_path (DocumentInterface *doc_interface, char *pathname, GError **error) { - Inkscape::XML::Node *node = get_repr_by_name(object->desk, pathname, error); + Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), pathname, error); if (!node) return NULL; @@ -739,30 +758,30 @@ document_interface_get_path (DocumentInterface *object, char *pathname, GError * } gboolean -document_interface_transform (DocumentInterface *object, gchar *shape, +document_interface_transform (DocumentInterface *doc_interface, gchar *shape, gchar *transformstr, GError **error) { //FIXME: This should merge transformations. gchar trans[] = "transform"; - document_interface_set_attribute (object, shape, trans, transformstr, error); + document_interface_set_attribute (doc_interface, shape, trans, transformstr, error); return TRUE; } gchar * -document_interface_get_css (DocumentInterface *object, gchar *shape, +document_interface_get_css (DocumentInterface *doc_interface, gchar *shape, GError **error) { gchar style[] = "style"; - return document_interface_get_attribute (object, shape, style, error); + return document_interface_get_attribute (doc_interface, shape, style, error); } gboolean -document_interface_modify_css (DocumentInterface *object, gchar *shape, +document_interface_modify_css (DocumentInterface *doc_interface, gchar *shape, gchar *cssattrb, gchar *newval, GError **error) { // Doesn't like non-variable strings for some reason. gchar style[] = "style"; - Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error); + Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), shape, error); if (!dbus_check_string (cssattrb, error, "Attribute string empty.")) return FALSE; @@ -778,12 +797,12 @@ document_interface_modify_css (DocumentInterface *object, gchar *shape, } gboolean -document_interface_merge_css (DocumentInterface *object, gchar *shape, +document_interface_merge_css (DocumentInterface *doc_interface, gchar *shape, gchar *stylestring, GError **error) { gchar style[] = "style"; - Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error); + Inkscape::XML::Node *node = get_repr_by_name(doc_interface->target.getDocument(), shape, error); if (!dbus_check_string (stylestring, error, "Style string empty.")) return FALSE; @@ -804,7 +823,7 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape, } gboolean -document_interface_set_color (DocumentInterface *object, gchar *shape, +document_interface_set_color (DocumentInterface *doc_interface, gchar *shape, int r, int g, int b, gboolean fill, GError **error) { gchar style[15]; @@ -820,29 +839,29 @@ document_interface_set_color (DocumentInterface *object, gchar *shape, snprintf(style, 15, "stroke:#%.2x%.2x%.2x", r, g, b); if (strcmp(shape, "document") == 0) - return document_interface_document_merge_css (object, style, error); + return document_interface_document_merge_css (doc_interface, style, error); - return document_interface_merge_css (object, shape, style, error); + return document_interface_merge_css (doc_interface, shape, style, error); } gboolean -document_interface_move_to_layer (DocumentInterface *object, gchar *shape, +document_interface_move_to_layer (DocumentInterface *doc_interface, gchar *shape, gchar *layerstr, GError **error) { - const GSList *oldsel = selection_swap(object->desk, shape, error); + const GSList *oldsel = selection_swap(doc_interface->target.getSelection(), shape, error); if (!oldsel) return FALSE; - document_interface_selection_move_to_layer(object, layerstr, error); - selection_restore(object->desk, oldsel); + document_interface_selection_move_to_layer(doc_interface, layerstr, error); + selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; } -GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/, gchar * /*shape*/) +GArray *document_interface_get_node_coordinates(DocumentInterface * /*doc_interface*/, gchar * /*shape*/) { //FIXME: Needs lot's of work. /* - Inkscape::XML::Node *shapenode = get_repr_by_name (object->desk, shape, error); + Inkscape::XML::Node *shapenode = get_repr_by_name (doc_interface->target.getDocument(), shape, error); if (shapenode == NULL || shapenode->attribute("d") == NULL) { return FALSE; } @@ -857,10 +876,10 @@ GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/, gboolean -document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error) +document_interface_set_text (DocumentInterface *doc_interface, gchar *name, gchar *text, GError **error) { - SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); //TODO verify object type if (!text_obj) return FALSE; @@ -872,12 +891,12 @@ document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text gboolean -document_interface_text_apply_style (DocumentInterface *object, gchar *name, +document_interface_text_apply_style (DocumentInterface *doc_interface, gchar *name, int start_pos, int end_pos, gchar *style, gchar *styleval, GError **error) { - SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error); + SPItem* text_obj=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); //void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPCSSAttr const *css) //TODO verify object type @@ -904,34 +923,40 @@ document_interface_text_apply_style (DocumentInterface *object, gchar *name, ****************************************************************************/ gboolean -document_interface_save (DocumentInterface *object, GError **error) +document_interface_save (DocumentInterface *doc_interface, GError **error) { - SPDocument * doc = sp_desktop_document(object->desk); + SPDocument * doc = doc_interface->target.getDocument(); printf("1: %s\n2: %s\n3: %s\n", doc->getURI(), doc->getBase(), doc->getName()); if (doc->getURI()) - return document_interface_save_as (object, doc->getURI(), error); + return document_interface_save_as (doc_interface, doc->getURI(), error); return FALSE; } -gboolean document_interface_load(DocumentInterface *object, +gboolean document_interface_load(DocumentInterface *doc_interface, gchar *filename, GError ** /*error*/) { - desktop_ensure_active(object->desk); + SPDesktop *desk = doc_interface->target.getDesktop(); + if (desk) { + desktop_ensure_active(desk); + } const Glib::ustring file(filename); sp_file_open(file, NULL, TRUE, TRUE); - if (object->updates) { - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File"); + if (doc_interface->updates) { + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_FILE_OPEN, "Opened File"); } return TRUE; } gchar * -document_interface_import (DocumentInterface *object, +document_interface_import (DocumentInterface *doc_interface, gchar *filename, GError **error) { - desktop_ensure_active (object->desk); + SPDesktop *desk = doc_interface->target.getDesktop(); + if (desk) { + desktop_ensure_active(desk); + } const Glib::ustring file(filename); - SPDocument * doc = sp_desktop_document(object->desk); + SPDocument * doc = doc_interface->target.getDocument(); SPObject *new_obj = NULL; new_obj = file_import(doc, file, NULL); @@ -939,10 +964,11 @@ document_interface_import (DocumentInterface *object, } gboolean -document_interface_save_as (DocumentInterface *object, +document_interface_save_as (DocumentInterface *doc_interface, const gchar *filename, GError **error) { - SPDocument * doc = sp_desktop_document(object->desk); + // FIXME: Isn't there a verb we can use for this instead? + SPDocument * doc = doc_interface->target.getDocument(); #ifdef WITH_GNOME_VFS const Glib::ustring file(filename); return file_save_remote(doc, file, NULL, TRUE, TRUE); @@ -955,18 +981,16 @@ document_interface_save_as (DocumentInterface *object, Inkscape::Extension::save(NULL, doc, filename, false, false, true, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS); } catch (...) { - //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + // FIXME: catch ... is not usually a great idea, why is it needed here? return false; } - //SP_ACTIVE_DESKTOP->event_log->rememberFileSave(); - //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, "Document saved."); return true; } -gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError ** /*error*/) +gboolean document_interface_mark_as_unmodified(DocumentInterface *doc_interface, GError ** /*error*/) { - SPDocument * doc = sp_desktop_document(object->desk); + SPDocument * doc = doc_interface->target.getDocument(); if (doc) { doc->modified_since_save = FALSE; } @@ -975,9 +999,9 @@ gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError /* gboolean -document_interface_print_to_file (DocumentInterface *object, GError **error) +document_interface_print_to_file (DocumentInterface *doc_interface, GError **error) { - SPDocument * doc = sp_desktop_document(object->desk); + SPDocument * doc = doc_interface->target.getDocument(); sp_print_document_to_file (doc, g_strdup("/home/soren/test.pdf")); return TRUE; @@ -988,27 +1012,27 @@ document_interface_print_to_file (DocumentInterface *object, GError **error) ****************************************************************************/ gboolean -document_interface_close (DocumentInterface *object, GError **error) +document_interface_close (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_FILE_CLOSE_VIEW, error); + return dbus_call_verb (doc_interface, SP_VERB_FILE_CLOSE_VIEW, error); } gboolean -document_interface_exit (DocumentInterface *object, GError **error) +document_interface_exit (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_FILE_QUIT, error); + return dbus_call_verb (doc_interface, SP_VERB_FILE_QUIT, error); } gboolean -document_interface_undo (DocumentInterface *object, GError **error) +document_interface_undo (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_EDIT_UNDO, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_UNDO, error); } gboolean -document_interface_redo (DocumentInterface *object, GError **error) +document_interface_redo (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_EDIT_REDO, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_REDO, error); } @@ -1020,48 +1044,46 @@ document_interface_redo (DocumentInterface *object, GError **error) Need to make sure it plays well with verbs because they are used so much. ****************************************************************************/ -void document_interface_pause_updates(DocumentInterface *object, GError ** /*error*/) +void document_interface_pause_updates(DocumentInterface *doc_interface, GError ** error) { - object->updates = FALSE; - object->desk->canvas->drawing_disabled = 1; - //object->desk->canvas->need_redraw = 0; - //object->desk->canvas->need_repick = 0; - //sp_desktop_document(object->desk)->root->uflags = FALSE; - //sp_desktop_document(object->desk)->root->mflags = FALSE; + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_if_fail(ensure_desktop_valid(desk, error)); + doc_interface->updates = FALSE; + desk->canvas->drawing_disabled = 1; } -void document_interface_resume_updates(DocumentInterface *object, GError ** /*error*/) +void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error) { - object->updates = TRUE; - object->desk->canvas->drawing_disabled = 0; - //object->desk->canvas->need_redraw = 1; - //object->desk->canvas->need_repick = 1; - //sp_desktop_document(object->desk)->root->uflags = TRUE; - //sp_desktop_document(object->desk)->root->mflags = TRUE; - //sp_desktop_document(object->desk)->_updateDocument(); + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_if_fail(ensure_desktop_valid(desk, error)); + doc_interface->updates = TRUE; + desk->canvas->drawing_disabled = 0; //FIXME: use better verb than rect. - Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); + Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions"); } -void document_interface_update(DocumentInterface *object, GError ** /*error*/) +void document_interface_update(DocumentInterface *doc_interface, GError ** error) { - sp_desktop_document(object->desk)->getRoot()->uflags = TRUE; - sp_desktop_document(object->desk)->getRoot()->mflags = TRUE; - object->desk->enableInteraction(); - sp_desktop_document(object->desk)->_updateDocument(); - object->desk->disableInteraction(); - sp_desktop_document(object->desk)->getRoot()->uflags = FALSE; - sp_desktop_document(object->desk)->getRoot()->mflags = FALSE; - //Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_if_fail(ensure_desktop_valid(desk, error)); + SPDocument *doc = doc_interface->target.getDocument(); + doc->getRoot()->uflags = TRUE; + doc->getRoot()->mflags = TRUE; + desk->enableInteraction(); + doc->_updateDocument(); + desk->disableInteraction(); + doc->getRoot()->uflags = FALSE; + doc->getRoot()->mflags = FALSE; + //Inkscape::DocumentUndo::done(doc, SP_VERB_CONTEXT_RECT, "Multiple actions"); } /**************************************************************************** SELECTION FUNCTIONS FIXME: use call_verb where appropriate (once update system is tested.) ****************************************************************************/ -gboolean document_interface_selection_get(DocumentInterface *object, char ***out, GError ** /*error*/) +gboolean document_interface_selection_get(DocumentInterface *doc_interface, char ***out, GError ** /*error*/) { - Inkscape::Selection * sel = sp_desktop_selection(object->desk); + Inkscape::Selection * sel = doc_interface->target.getSelection(); GSList const *oldsel = sel->list(); int size = g_slist_length((GSList *) oldsel); @@ -1079,85 +1101,82 @@ gboolean document_interface_selection_get(DocumentInterface *object, char ***out } gboolean -document_interface_selection_add (DocumentInterface *object, char *name, GError **error) +document_interface_selection_add (DocumentInterface *doc_interface, char *name, GError **error) { - SPObject * obj = get_object_by_name(object->desk, name, error); + SPObject * obj = get_object_by_name(doc_interface->target.getDocument(), name, error); if (!obj) return FALSE; - Inkscape::Selection *selection = sp_desktop_selection(object->desk); + Inkscape::Selection *selection = doc_interface->target.getSelection(); selection->add(obj); return TRUE; } gboolean -document_interface_selection_add_list (DocumentInterface *object, +document_interface_selection_add_list (DocumentInterface *doc_interface, char **names, GError **error) { int i; for (i=0;names[i] != NULL;i++) { - document_interface_selection_add(object, names[i], error); + document_interface_selection_add(doc_interface, names[i], error); } return TRUE; } -gboolean document_interface_selection_set(DocumentInterface *object, char *name, GError ** /*error*/) +gboolean document_interface_selection_set(DocumentInterface *doc_interface, char *name, GError ** /*error*/) { - SPDocument * doc = sp_desktop_document(object->desk); - Inkscape::Selection *selection = sp_desktop_selection(object->desk); + SPDocument * doc = doc_interface->target.getDocument(); + Inkscape::Selection *selection = doc_interface->target.getSelection(); selection->set(doc->getObjectById(name)); return TRUE; } gboolean -document_interface_selection_set_list (DocumentInterface *object, +document_interface_selection_set_list (DocumentInterface *doc_interface, gchar **names, GError **error) { - sp_desktop_selection(object->desk)->clear(); + doc_interface->target.getSelection()->clear(); int i; for (i=0;names[i] != NULL;i++) { - document_interface_selection_add(object, names[i], error); + document_interface_selection_add(doc_interface, names[i], error); } return TRUE; } -gboolean document_interface_selection_rotate(DocumentInterface *object, int angle, GError ** /*error*/) +gboolean document_interface_selection_rotate(DocumentInterface *doc_interface, int angle, GError ** /*error*/) { - Inkscape::Selection *selection = sp_desktop_selection(object->desk); + Inkscape::Selection *selection = doc_interface->target.getSelection(); sp_selection_rotate(selection, angle); return TRUE; } gboolean -document_interface_selection_delete (DocumentInterface *object, GError **error) +document_interface_selection_delete (DocumentInterface *doc_interface, GError **error) { - //sp_selection_delete (object->desk); - return dbus_call_verb (object, SP_VERB_EDIT_DELETE, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_DELETE, error); } -gboolean document_interface_selection_clear(DocumentInterface *object, GError ** /*error*/) +gboolean document_interface_selection_clear(DocumentInterface *doc_interface, GError ** /*error*/) { - sp_desktop_selection(object->desk)->clear(); + doc_interface->target.getSelection()->clear(); return TRUE; } gboolean -document_interface_select_all (DocumentInterface *object, GError **error) +document_interface_select_all (DocumentInterface *doc_interface, GError **error) { - //sp_edit_select_all (object->desk); - return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_SELECT_ALL, error); } gboolean -document_interface_select_all_in_all_layers(DocumentInterface *object, +document_interface_select_all_in_all_layers(DocumentInterface *doc_interface, GError **error) { - //sp_edit_select_all_in_all_layers (object->desk); - return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error); } -gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /*x*/, int /*y*/, +gboolean document_interface_selection_box(DocumentInterface * /*doc_interface*/, int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, gboolean /*replace*/, GError ** /*error*/) { @@ -1166,63 +1185,49 @@ gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /* } gboolean -document_interface_selection_invert (DocumentInterface *object, GError **error) +document_interface_selection_invert (DocumentInterface *doc_interface, GError **error) { - //sp_edit_invert (object->desk); - return dbus_call_verb (object, SP_VERB_EDIT_INVERT, error); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_INVERT, error); } gboolean -document_interface_selection_group (DocumentInterface *object, GError **error) +document_interface_selection_group (DocumentInterface *doc_interface, GError **error) { - //sp_selection_group (object->desk); - return dbus_call_verb (object, SP_VERB_SELECTION_GROUP, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_GROUP, error); } gboolean -document_interface_selection_ungroup (DocumentInterface *object, GError **error) +document_interface_selection_ungroup (DocumentInterface *doc_interface, GError **error) { - //sp_selection_ungroup (object->desk); - return dbus_call_verb (object, SP_VERB_SELECTION_UNGROUP, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_UNGROUP, error); } gboolean -document_interface_selection_cut (DocumentInterface *object, GError **error) +document_interface_selection_cut (DocumentInterface *doc_interface, GError **error) { - //desktop_ensure_active (object->desk); - //sp_selection_cut (object->desk); - return dbus_call_verb (object, SP_VERB_EDIT_CUT, error); + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_CUT, error); } gboolean -document_interface_selection_copy (DocumentInterface *object, GError **error) +document_interface_selection_copy (DocumentInterface *doc_interface, GError **error) { - //desktop_ensure_active (object->desk); - //sp_selection_copy (); - return dbus_call_verb (object, SP_VERB_EDIT_COPY, error); -} -/* -gboolean -document_interface_selection_paste (DocumentInterface *object, GError **error) -{ - desktop_ensure_active (object->desk); - if (!object->updates) - document_interface_pause_updates (object, error); - sp_selection_paste (object->desk, TRUE); - if (!object->updates) - document_interface_pause_updates (object, error); - return TRUE; - //return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error); + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_COPY, error); } -*/ + gboolean -document_interface_selection_paste (DocumentInterface *object, GError **error) +document_interface_selection_paste (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error); + SPDesktop *desk = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); + return dbus_call_verb (doc_interface, SP_VERB_EDIT_PASTE, error); } -gboolean document_interface_selection_scale(DocumentInterface *object, gdouble grow, GError ** /*error*/) +gboolean document_interface_selection_scale(DocumentInterface *doc_interface, gdouble grow, GError ** /*error*/) { - Inkscape::Selection *selection = sp_desktop_selection(object->desk); + Inkscape::Selection *selection = doc_interface->target.getSelection(); if (!selection) { return FALSE; @@ -1231,15 +1236,15 @@ gboolean document_interface_selection_scale(DocumentInterface *object, gdouble g return TRUE; } -gboolean document_interface_selection_move(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/) +gboolean document_interface_selection_move(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/) { - sp_selection_move(object->desk, x, 0 - y); //switching coordinate systems. + sp_selection_move(doc_interface->target.getSelection(), x, 0 - y); //switching coordinate systems. return TRUE; } -gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/) +gboolean document_interface_selection_move_to(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/) { - Inkscape::Selection * sel = sp_desktop_selection(object->desk); + Inkscape::Selection * sel = doc_interface->target.getSelection(); Geom::OptRect sel_bbox = sel->visualBounds(); if (sel_bbox) { @@ -1253,18 +1258,19 @@ gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble // This needs to use lower level cut_impl and paste_impl (messy) // See the built-in sp_selection_to_next_layer and duplicate. gboolean -document_interface_selection_move_to_layer (DocumentInterface *object, +document_interface_selection_move_to_layer (DocumentInterface *doc_interface, gchar *layerstr, GError **error) { - SPDesktop * dt = object->desk; + SPDesktop *dt = doc_interface->target.getDesktop(); + g_return_val_if_fail(ensure_desktop_valid(dt, error), FALSE); - Inkscape::Selection *selection = sp_desktop_selection(dt); + Inkscape::Selection *selection = doc_interface->target.getSelection(); // check if something is selected if (selection->isEmpty()) return FALSE; - SPObject *next = get_object_by_name(object->desk, layerstr, error); + SPObject *next = get_object_by_name(doc_interface->target.getDocument(), layerstr, error); if (!next) return FALSE; @@ -1273,7 +1279,7 @@ document_interface_selection_move_to_layer (DocumentInterface *object, sp_selection_cut(dt); - dt->setCurrentLayer(next); + doc_interface->target.getSelection()->layers()->setCurrentLayer(next); sp_selection_paste(dt, TRUE); } @@ -1281,9 +1287,9 @@ document_interface_selection_move_to_layer (DocumentInterface *object, } GArray * -document_interface_selection_get_center (DocumentInterface *object) +document_interface_selection_get_center (DocumentInterface *doc_interface) { - Inkscape::Selection * sel = sp_desktop_selection(object->desk); + Inkscape::Selection * sel = doc_interface->target.getSelection(); if (sel) { @@ -1300,52 +1306,46 @@ document_interface_selection_get_center (DocumentInterface *object) } gboolean -document_interface_selection_to_path (DocumentInterface *object, GError **error) +document_interface_selection_to_path (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); + return dbus_call_verb (doc_interface, SP_VERB_OBJECT_TO_CURVE, error); } -gchar * -document_interface_selection_combine (DocumentInterface *object, gchar *cmd, +gboolean +document_interface_selection_combine (DocumentInterface *doc_interface, gchar *cmd, char ***newpaths, GError **error) { if (strcmp(cmd, "union") == 0) - dbus_call_verb (object, SP_VERB_SELECTION_UNION, error); + dbus_call_verb (doc_interface, SP_VERB_SELECTION_UNION, error); else if (strcmp(cmd, "intersection") == 0) - dbus_call_verb (object, SP_VERB_SELECTION_INTERSECT, error); + dbus_call_verb (doc_interface, SP_VERB_SELECTION_INTERSECT, error); else if (strcmp(cmd, "difference") == 0) - dbus_call_verb (object, SP_VERB_SELECTION_DIFF, error); + dbus_call_verb (doc_interface, SP_VERB_SELECTION_DIFF, error); else if (strcmp(cmd, "exclusion") == 0) - dbus_call_verb (object, SP_VERB_SELECTION_SYMDIFF, error); - else - return NULL; - - if (sp_desktop_selection(object->desk)->singleRepr() != NULL) - return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id")); - return NULL; -} - -gboolean -document_interface_selection_divide (DocumentInterface *object, char ***out, GError **error) -{ - dbus_call_verb (object, SP_VERB_SELECTION_CUT, error); + dbus_call_verb (doc_interface, SP_VERB_SELECTION_SYMDIFF, error); + else if (strcmp(cmd, "division") == 0) + dbus_call_verb (doc_interface, SP_VERB_SELECTION_CUT, error); + else { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Operation command not recognised"); + return FALSE; + } - return document_interface_selection_get (object, out, error); + return document_interface_selection_get (doc_interface, newpaths, error); } gboolean -document_interface_selection_change_level (DocumentInterface *object, gchar *cmd, +document_interface_selection_change_level (DocumentInterface *doc_interface, gchar *cmd, GError **error) { if (strcmp(cmd, "raise") == 0) - return dbus_call_verb (object, SP_VERB_SELECTION_RAISE, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_RAISE, error); if (strcmp(cmd, "lower") == 0) - return dbus_call_verb (object, SP_VERB_SELECTION_LOWER, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_LOWER, error); if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) - return dbus_call_verb (object, SP_VERB_SELECTION_TO_FRONT, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_TO_FRONT, error); if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) - return dbus_call_verb (object, SP_VERB_SELECTION_TO_BACK, error); + return dbus_call_verb (doc_interface, SP_VERB_SELECTION_TO_BACK, error); return TRUE; } @@ -1353,58 +1353,58 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd LAYER FUNCTIONS ****************************************************************************/ -gchar *document_interface_layer_new(DocumentInterface *object, GError ** /*error*/) +gchar *document_interface_layer_new(DocumentInterface *doc_interface, GError ** /*error*/) { - SPDesktop * dt = object->desk; - SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW); - dt->setCurrentLayer(new_layer); + Inkscape::LayerModel * layers = doc_interface->target.getSelection()->layers(); + SPObject *new_layer = Inkscape::create_layer(layers->currentRoot(), layers->currentLayer(), Inkscape::LPOS_BELOW); + layers->setCurrentLayer(new_layer); return g_strdup(get_name_from_object(new_layer)); } gboolean -document_interface_layer_set (DocumentInterface *object, +document_interface_layer_set (DocumentInterface *doc_interface, gchar *layerstr, GError **error) { - SPObject * obj = get_object_by_name (object->desk, layerstr, error); + SPObject * obj = get_object_by_name (doc_interface->target.getDocument(), layerstr, error); if (!obj) return FALSE; - object->desk->setCurrentLayer (obj); + doc_interface->target.getSelection()->layers()->setCurrentLayer (obj); return TRUE; } -gchar **document_interface_layer_get_all(DocumentInterface * /*object*/) +gchar **document_interface_layer_get_all(DocumentInterface * /*doc_interface*/) { //FIXME: implement. return NULL; } gboolean -document_interface_layer_change_level (DocumentInterface *object, +document_interface_layer_change_level (DocumentInterface *doc_interface, gchar *cmd, GError **error) { if (strcmp(cmd, "raise") == 0) - return dbus_call_verb (object, SP_VERB_LAYER_RAISE, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_RAISE, error); if (strcmp(cmd, "lower") == 0) - return dbus_call_verb (object, SP_VERB_LAYER_LOWER, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_LOWER, error); if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) - return dbus_call_verb (object, SP_VERB_LAYER_TO_TOP, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_TO_TOP, error); if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) - return dbus_call_verb (object, SP_VERB_LAYER_TO_BOTTOM, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_TO_BOTTOM, error); return TRUE; } gboolean -document_interface_layer_next (DocumentInterface *object, GError **error) +document_interface_layer_next (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_LAYER_NEXT, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_NEXT, error); } gboolean -document_interface_layer_previous (DocumentInterface *object, GError **error) +document_interface_layer_previous (DocumentInterface *doc_interface, GError **error) { - return dbus_call_verb (object, SP_VERB_LAYER_PREV, error); + return dbus_call_verb (doc_interface, SP_VERB_LAYER_PREV, error); } @@ -1414,7 +1414,6 @@ document_interface_layer_previous (DocumentInterface *object, GError **error) DocumentInterface *fugly; gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) { - //DocumentInterface *obj; if (!item) return TRUE; g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId()); return TRUE; @@ -1424,9 +1423,9 @@ gboolean dbus_send_ping (SPDesktop* desk, SPItem *item) gboolean -document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error) +document_interface_get_children (DocumentInterface *doc_interface, char *name, char ***out, GError **error) { - SPItem* parent=(SPItem* )get_object_by_name(object->desk, name, error); + SPItem* parent=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); GSList const *children = parent->childList(false); @@ -1447,9 +1446,9 @@ document_interface_get_children (DocumentInterface *object, char *name, char ** gchar* -document_interface_get_parent (DocumentInterface *object, char *name, GError **error) +document_interface_get_parent (DocumentInterface *doc_interface, char *name, GError **error) { - SPItem* node=(SPItem* )get_object_by_name(object->desk, name, error); + SPItem* node=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); SPObject* parent=node->parent; @@ -1460,8 +1459,8 @@ document_interface_get_parent (DocumentInterface *object, char *name, GError ** #if 0 //just pseudo code gboolean -document_interface_get_xpath (DocumentInterface *object, char *xpath_expression, char ***out, GError **error){ - SPDocument * doc = sp_desktop_document (object->desk); +document_interface_get_xpath (DocumentInterface *doc_interface, char *xpath_expression, char ***out, GError **error){ + SPDocument * doc = doc_interface->target.getDocument(); Inkscape::XML::Document *repr = doc->getReprDoc(); xmlXPathObjectPtr xpathObj; diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 5fcbb919b..27460de52 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -30,9 +30,10 @@ #undef DBUS_MESSAGE_TYPE_ERROR #undef DBUS_MESSAGE_TYPE_SIGNAL -#include "desktop.h" +#include "helper/action-context.h" -#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document" +class SPDesktop; +class SPItem; #define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ()) #define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface)) @@ -47,8 +48,8 @@ typedef struct _DocumentInterface DocumentInterface; typedef struct _DocumentInterfaceClass DocumentInterfaceClass; struct _DocumentInterface { - GObject parent; - SPDesktop *desk; + GObject parent; + Inkscape::ActionContext target; ///< stores information about which document, selection, desktop etc this interface is linked to gboolean updates; }; @@ -67,10 +68,10 @@ struct DBUSPoint { ****************************************************************************/ gboolean -document_interface_delete_all (DocumentInterface *object, GError **error); +document_interface_delete_all (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_call_verb (DocumentInterface *object, +document_interface_call_verb (DocumentInterface *doc_interface, gchar *verbid, GError **error); /**************************************************************************** @@ -78,48 +79,48 @@ document_interface_call_verb (DocumentInterface *object, ****************************************************************************/ gchar* -document_interface_rectangle (DocumentInterface *object, int x, int y, +document_interface_rectangle (DocumentInterface *doc_interface, int x, int y, int width, int height, GError **error); gchar* -document_interface_ellipse (DocumentInterface *object, int x, int y, +document_interface_ellipse (DocumentInterface *doc_interface, int x, int y, int width, int height, GError **error); gchar* -document_interface_polygon (DocumentInterface *object, int cx, int cy, +document_interface_polygon (DocumentInterface *doc_interface, int cx, int cy, int radius, int rotation, int sides, GError **error); gchar* -document_interface_star (DocumentInterface *object, int cx, int cy, +document_interface_star (DocumentInterface *doc_interface, int cx, int cy, int r1, int r2, int sides, gdouble rounded, gdouble arg1, gdouble arg2, GError **error); gchar* -document_interface_spiral (DocumentInterface *object, int cx, int cy, +document_interface_spiral (DocumentInterface *doc_interface, int cx, int cy, int r, int revolutions, GError **error); gchar* -document_interface_line (DocumentInterface *object, int x, int y, +document_interface_line (DocumentInterface *doc_interface, int x, int y, int x2, int y2, GError **error); gchar* -document_interface_text (DocumentInterface *object, int x, int y, +document_interface_text (DocumentInterface *doc_interface, int x, int y, gchar *text, GError **error); gboolean -document_interface_set_text (DocumentInterface *object, gchar *name, +document_interface_set_text (DocumentInterface *doc_interface, gchar *name, gchar *text, GError **error); gboolean -document_interface_text_apply_style (DocumentInterface *object, gchar *name, +document_interface_text_apply_style (DocumentInterface *doc_interface, gchar *name, int start_pos, int end_pos, gchar *style, gchar *styleval, GError **error); gchar * -document_interface_image (DocumentInterface *object, int x, int y, +document_interface_image (DocumentInterface *doc_interface, int x, int y, gchar *filename, GError **error); gchar* -document_interface_node (DocumentInterface *object, gchar *svgtype, +document_interface_node (DocumentInterface *doc_interface, gchar *svgtype, GError **error); @@ -127,27 +128,27 @@ document_interface_node (DocumentInterface *object, gchar *svgtype, ENVIORNMENT FUNCTIONS ****************************************************************************/ gdouble -document_interface_document_get_width (DocumentInterface *object); +document_interface_document_get_width (DocumentInterface *doc_interface); gdouble -document_interface_document_get_height (DocumentInterface *object); +document_interface_document_get_height (DocumentInterface *doc_interface); gchar * -document_interface_document_get_css (DocumentInterface *object, GError **error); +document_interface_document_get_css (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_document_merge_css (DocumentInterface *object, +document_interface_document_merge_css (DocumentInterface *doc_interface, gchar *stylestring, GError **error); gboolean -document_interface_document_set_css (DocumentInterface *object, +document_interface_document_set_css (DocumentInterface *doc_interface, gchar *stylestring, GError **error); gboolean -document_interface_document_resize_to_fit_selection (DocumentInterface *object, +document_interface_document_resize_to_fit_selection (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_document_set_display_area (DocumentInterface *object, +document_interface_document_set_display_area (DocumentInterface *doc_interface, double x0, double y0, double x1, @@ -155,95 +156,95 @@ document_interface_document_set_display_area (DocumentInterface *object, double border, GError **error); GArray * -document_interface_document_get_display_area (DocumentInterface *object); +document_interface_document_get_display_area (DocumentInterface *doc_interface); /**************************************************************************** OBJECT FUNCTIONS ****************************************************************************/ gboolean -document_interface_set_attribute (DocumentInterface *object, +document_interface_set_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, char *newval, GError **error); gboolean -document_interface_set_int_attribute (DocumentInterface *object, +document_interface_set_int_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, int newval, GError **error); gboolean -document_interface_set_double_attribute (DocumentInterface *object, +document_interface_set_double_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, double newval, GError **error); gchar * -document_interface_get_attribute (DocumentInterface *object, +document_interface_get_attribute (DocumentInterface *doc_interface, char *shape, char *attribute, GError **error); gboolean -document_interface_move (DocumentInterface *object, gchar *name, +document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error); gboolean -document_interface_move_to (DocumentInterface *object, gchar *name, +document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdouble x, gdouble y, GError **error); gboolean -document_interface_object_to_path (DocumentInterface *object, +document_interface_object_to_path (DocumentInterface *doc_interface, char *shape, GError **error); gchar * -document_interface_get_path (DocumentInterface *object, +document_interface_get_path (DocumentInterface *doc_interface, char *pathname, GError **error); gboolean -document_interface_transform (DocumentInterface *object, gchar *shape, +document_interface_transform (DocumentInterface *doc_interface, gchar *shape, gchar *transformstr, GError **error); gchar * -document_interface_get_css (DocumentInterface *object, gchar *shape, +document_interface_get_css (DocumentInterface *doc_interface, gchar *shape, GError **error); gboolean -document_interface_modify_css (DocumentInterface *object, gchar *shape, +document_interface_modify_css (DocumentInterface *doc_interface, gchar *shape, gchar *cssattrb, gchar *newval, GError **error); gboolean -document_interface_merge_css (DocumentInterface *object, gchar *shape, +document_interface_merge_css (DocumentInterface *doc_interface, gchar *shape, gchar *stylestring, GError **error); gboolean -document_interface_set_color (DocumentInterface *object, gchar *shape, +document_interface_set_color (DocumentInterface *doc_interface, gchar *shape, int r, int g, int b, gboolean fill, GError **error); gboolean -document_interface_move_to_layer (DocumentInterface *object, gchar *shape, +document_interface_move_to_layer (DocumentInterface *doc_interface, gchar *shape, gchar *layerstr, GError **error); GArray * -document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape); +document_interface_get_node_coordinates (DocumentInterface *doc_interface, gchar *shape); /**************************************************************************** FILE I/O FUNCTIONS ****************************************************************************/ gboolean -document_interface_save (DocumentInterface *object, GError **error); +document_interface_save (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_load (DocumentInterface *object, +document_interface_load (DocumentInterface *doc_interface, gchar *filename, GError **error); gboolean -document_interface_save_as (DocumentInterface *object, +document_interface_save_as (DocumentInterface *doc_interface, const gchar *filename, GError **error); gboolean -document_interface_mark_as_unmodified (DocumentInterface *object, GError **error); +document_interface_mark_as_unmodified (DocumentInterface *doc_interface, GError **error); /* gboolean -document_interface_print_to_file (DocumentInterface *object, GError **error); +document_interface_print_to_file (DocumentInterface *doc_interface, GError **error); */ /**************************************************************************** @@ -251,125 +252,120 @@ document_interface_print_to_file (DocumentInterface *object, GError **error); ****************************************************************************/ gboolean -document_interface_close (DocumentInterface *object, GError **error); +document_interface_close (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_exit (DocumentInterface *object, GError **error); +document_interface_exit (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_undo (DocumentInterface *object, GError **error); +document_interface_undo (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_redo (DocumentInterface *object, GError **error); +document_interface_redo (DocumentInterface *doc_interface, GError **error); /**************************************************************************** UPDATE FUNCTIONS ****************************************************************************/ void -document_interface_pause_updates (DocumentInterface *object, GError **error); +document_interface_pause_updates (DocumentInterface *doc_interface, GError **error); void -document_interface_resume_updates (DocumentInterface *object, GError **error); +document_interface_resume_updates (DocumentInterface *doc_interface, GError **error); void -document_interface_update (DocumentInterface *object, GError **error); +document_interface_update (DocumentInterface *doc_interface, GError **error); /**************************************************************************** SELECTION FUNCTIONS ****************************************************************************/ gboolean -document_interface_selection_get (DocumentInterface *object, char ***out, GError **error); +document_interface_selection_get (DocumentInterface *doc_interface, char ***out, GError **error); gboolean -document_interface_selection_add (DocumentInterface *object, +document_interface_selection_add (DocumentInterface *doc_interface, char *name, GError **error); gboolean -document_interface_selection_add_list (DocumentInterface *object, +document_interface_selection_add_list (DocumentInterface *doc_interface, char **names, GError **error); gboolean -document_interface_selection_set (DocumentInterface *object, +document_interface_selection_set (DocumentInterface *doc_interface, char *name, GError **error); gboolean -document_interface_selection_set_list (DocumentInterface *object, +document_interface_selection_set_list (DocumentInterface *doc_interface, gchar **names, GError **error); gboolean -document_interface_selection_rotate (DocumentInterface *object, +document_interface_selection_rotate (DocumentInterface *doc_interface, int angle, GError **error); gboolean -document_interface_selection_delete(DocumentInterface *object, GError **error); +document_interface_selection_delete(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_clear(DocumentInterface *object, GError **error); +document_interface_selection_clear(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_select_all(DocumentInterface *object, GError **error); +document_interface_select_all(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_select_all_in_all_layers(DocumentInterface *object, +document_interface_select_all_in_all_layers(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_box (DocumentInterface *object, int x, int y, +document_interface_selection_box (DocumentInterface *doc_interface, int x, int y, int x2, int y2, gboolean replace, GError **error); gboolean -document_interface_selection_invert (DocumentInterface *object, GError **error); +document_interface_selection_invert (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_group(DocumentInterface *object, GError **error); +document_interface_selection_group(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_ungroup(DocumentInterface *object, GError **error); +document_interface_selection_ungroup(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_cut(DocumentInterface *object, GError **error); +document_interface_selection_cut(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_copy(DocumentInterface *object, GError **error); +document_interface_selection_copy(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_paste(DocumentInterface *object, GError **error); +document_interface_selection_paste(DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_scale (DocumentInterface *object, +document_interface_selection_scale (DocumentInterface *doc_interface, gdouble grow, GError **error); gboolean -document_interface_selection_move (DocumentInterface *object, gdouble x, +document_interface_selection_move (DocumentInterface *doc_interface, gdouble x, gdouble y, GError **error); gboolean -document_interface_selection_move_to (DocumentInterface *object, gdouble x, +document_interface_selection_move_to (DocumentInterface *doc_interface, gdouble x, gdouble y, GError **error); gboolean -document_interface_selection_move_to_layer (DocumentInterface *object, +document_interface_selection_move_to_layer (DocumentInterface *doc_interface, gchar *layerstr, GError **error); GArray * -document_interface_selection_get_center (DocumentInterface *object); +document_interface_selection_get_center (DocumentInterface *doc_interface); gboolean -document_interface_selection_to_path (DocumentInterface *object, GError **error); - -gchar * -document_interface_selection_combine (DocumentInterface *object, gchar *cmd, - GError **error); +document_interface_selection_to_path (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_selection_divide (DocumentInterface *object, - char ***out, GError **error); - +document_interface_selection_combine (DocumentInterface *doc_interface, gchar *cmd, char ***newpaths, + GError **error); gboolean -document_interface_selection_change_level (DocumentInterface *object, gchar *cmd, +document_interface_selection_change_level (DocumentInterface *doc_interface, gchar *cmd, GError **error); /**************************************************************************** @@ -377,24 +373,24 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd ****************************************************************************/ gchar * -document_interface_layer_new (DocumentInterface *object, GError **error); +document_interface_layer_new (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_layer_set (DocumentInterface *object, +document_interface_layer_set (DocumentInterface *doc_interface, gchar *layerstr, GError **error); gchar ** -document_interface_layer_get_all (DocumentInterface *object); +document_interface_layer_get_all (DocumentInterface *doc_interface); gboolean -document_interface_layer_change_level (DocumentInterface *object, +document_interface_layer_change_level (DocumentInterface *doc_interface, gchar *cmd, GError **error); gboolean -document_interface_layer_next (DocumentInterface *object, GError **error); +document_interface_layer_next (DocumentInterface *doc_interface, GError **error); gboolean -document_interface_layer_previous (DocumentInterface *object, GError **error); +document_interface_layer_previous (DocumentInterface *doc_interface, GError **error); @@ -410,13 +406,13 @@ extern DocumentInterface *fugly; gboolean dbus_send_ping (SPDesktop* desk, SPItem *item); gboolean -document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error); +document_interface_get_children (DocumentInterface *doc_interface, char *name, char ***out, GError **error); gchar* -document_interface_get_parent (DocumentInterface *object, char *name, GError **error); +document_interface_get_parent (DocumentInterface *doc_interface, char *name, GError **error); gchar* -document_interface_import (DocumentInterface *object, +document_interface_import (DocumentInterface *doc_interface, gchar *filename, GError **error); G_END_DECLS diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index aeacfae44..7481c0893 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -21,7 +21,7 @@ <node name="/org/inkscape/document" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd" > - +c <interface name="org.inkscape.document"> <!-- MISC FUNCTIONS --> @@ -1348,36 +1348,20 @@ <doc:summary>Type of combination.</doc:summary> </doc:doc> </arg> - <arg type="s" name="newpath" direction="out" > - <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/> + <arg type="as" name="newpaths" direction="out" > <doc:doc> - <doc:summary>The new path created, if there is one. NULL otherwise.</doc:summary> + <doc:summary>List of the ids of resulting paths after applying the operation.</doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para>Will erase all objects in the selection and replace with a single aggregate path.</doc:para> <doc:para>There are 5 types that can be passed in:</doc:para> - <doc:para>Union: The new shape is all of the other shapes put together, even if they don't overlap (paths can have multiple non-contiguous areas.)</doc:para> - <doc:para>Intersection: The new shape is composed of the area where ALL the objects in the selection overlap. If there is no area where all shapes overlap the new shape will be empty.</doc:para> - <doc:para>Difference: The area of the second shape is subtracted from the first, only works with two objects.</doc:para> - <doc:para>Exclusion: The new shape is the area(s) where none of the objects in the selection overlaped. Only works with two objects.</doc:para> - <doc:para>Division: the first object is split into multiple segments by the second object. Only works with two objects and if multiple paths result they are grouped and the group id is returned.</doc:para> - </doc:description> - </doc:doc> - </method> - - <method name="selection_divide"> - <arg type="as" name="pieces" direction="out" > - <!-- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/> --> - <doc:doc> - <doc:summary>List of the ids of resulting paths.</doc:summary> - </doc:doc> - </arg> - <doc:doc> - <doc:description> - <doc:para>Returns the result of cutting the bottom object by all other intersecting paths.</doc:para> - <doc:para>This may make many seperate layers.</doc:para> + <doc:para>'union': The new shape is all of the other shapes put together, even if they don't overlap (paths can have multiple non-contiguous areas.)</doc:para> + <doc:para>'intersection': The new shape is composed of the area where ALL the objects in the selection overlap. If there is no area where all shapes overlap the new shape will be empty.</doc:para> + <doc:para>'difference': The area of the second shape is subtracted from the first, only works with two objects.</doc:para> + <doc:para>'exclusion': The new shape is the area(s) where none of the objects in the selection overlaped. Only works with two objects.</doc:para> + <doc:para>'division': the first object is split into multiple segments by the second object. Only works with two objects.</doc:para> </doc:description> </doc:doc> </method> diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c index 7a33d4f38..c7e453593 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c @@ -96,7 +96,9 @@ inkscape_desktop_init_dbus () GError *error; DBusGProxy *proxy; +#if !GLIB_CHECK_VERSION(2,36,0) g_type_init (); +#endif error = NULL; connection = dbus_g_bus_get (DBUS_BUS_SESSION, @@ -686,23 +688,13 @@ inkscape_selection_to_path (DocumentInterface *doc, GError **error) } //static -char * -inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error) -{ - char * OUT_newpath; - DBusGProxy *proxy = doc->proxy; - org_inkscape_document_selection_combine (proxy, IN_type, &OUT_newpath, error); - return OUT_newpath; -} - -//static char ** -inkscape_selection_divide (DocumentInterface *doc, GError **error) +inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error) { - char ** OUT_pieces; + char ** OUT_newpaths; DBusGProxy *proxy = doc->proxy; - org_inkscape_document_selection_divide (proxy, &OUT_pieces, error); - return OUT_pieces; + org_inkscape_document_selection_combine (proxy, IN_type, &OUT_newpaths, error); + return OUT_newpaths; } //static diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h index 684f1b142..20830bd65 100644 --- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h +++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h @@ -8,8 +8,6 @@ //#include <dbus/dbus-glib-bindings.h> //#include <dbus/dbus-glib-lowlevel.h> - -#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document" #define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ()) #define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface)) @@ -304,12 +302,8 @@ gboolean inkscape_selection_to_path (DocumentInterface *doc, GError **error); //static -char * -inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error); - -//static char ** -inkscape_selection_divide (DocumentInterface *doc, GError **error); +inkscape_selection_combine (DocumentInterface *doc, const char * IN_type, GError **error); //static gboolean diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 1df8002ad..dcccf3d7d 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -359,22 +359,22 @@ Effect::set_pref_dialog (PrefDialog * prefdialog) } SPAction * -Effect::EffectVerb::make_action (Inkscape::UI::View::View * view) +Effect::EffectVerb::make_action (Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform, static_cast<void *>(this)); + return make_action_helper(context, &perform, static_cast<void *>(this)); } /** \brief Decode the verb code and take appropriate action */ void Effect::EffectVerb::perform( SPAction *action, void * data ) { + g_return_if_fail(ensure_desktop_valid(action)); Inkscape::UI::View::View * current_view = sp_action_get_view(action); -// SPDocument * current_document = current_view->doc; + Effect::EffectVerb * ev = reinterpret_cast<Effect::EffectVerb *>(data); Effect * effect = ev->_effect; if (effect == NULL) return; - if (current_view == NULL) return; if (ev->_showPrefs) { effect->prefs(current_view); diff --git a/src/extension/effect.h b/src/extension/effect.h index 193b90a97..a14cc6e7d 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -58,7 +58,7 @@ class Effect : public Extension { /** \brief Name with elipses if that makes sense */ gchar * _elip_name; protected: - virtual SPAction * make_action (Inkscape::UI::View::View * view); + virtual SPAction * make_action (Inkscape::ActionContext const & context); public: /** \brief Use the Verb initializer with the same parameters. */ EffectVerb(gchar const * id, diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 4058fd787..d4b5fd187 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -10,6 +10,14 @@ #include <config.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include "gtkmm/messagedialog.h" #include "execution-env.h" diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index f9cf70960..d63ec7485 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -19,6 +19,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/frame.h> @@ -421,16 +425,31 @@ gchar const *Extension::get_param_string(gchar const *name, SPDocument const *do } const gchar * -Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const { - Parameter* param = get_param(name); + Parameter const *param = get_param(name); return param->get_enum(doc, node); } +/** + * This is useful to find out, if a given string \c value is selectable in a ComboBox named \cname. + * + * @param name The name of the enum parameter to get. + * @param doc The document to look in for document specific parameters. + * @param node The node to look in for a specific parameter. + * @return true if value exists, false if not + */ +bool +Extension::get_param_enum_contains(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) const +{ + Parameter const *param = get_param(name); + return param->get_enum_contains(value, doc, node); +} + gchar const * -Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node) +Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node) const { - Parameter* param = get_param(name); + Parameter const*param = get_param(name); return param->get_optiongroup(doc, node); } @@ -504,9 +523,9 @@ Extension::get_param_float (const gchar * name, const SPDocument * doc, const In found parameter. */ guint32 -Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const { - Parameter* param = get_param(name); + Parameter const *param = get_param(name); return param->get_color(doc, node); } @@ -597,6 +616,13 @@ Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocu return param->set_optiongroup(value, doc, node); } +gchar const * +Extension::set_param_enum(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) +{ + Parameter * param = get_param(name); + return param->set_enum(value, doc, node); +} + /** \return The passed in value diff --git a/src/extension/extension.h b/src/extension/extension.h index b6b4c51ed..079276936 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -234,15 +234,20 @@ public: guint32 get_param_color (const gchar * name, const SPDocument * doc = NULL, - const Inkscape::XML::Node * node = NULL); + const Inkscape::XML::Node * node = NULL) const; const gchar * get_param_enum (const gchar * name, const SPDocument * doc = NULL, - const Inkscape::XML::Node * node = NULL); + const Inkscape::XML::Node * node = NULL) const; gchar const *get_param_optiongroup( gchar const * name, SPDocument const * doc = 0, - Inkscape::XML::Node const * node = 0); + Inkscape::XML::Node const * node = 0) const; + + bool get_param_enum_contains(gchar const * name, + gchar const * value, + SPDocument * doc = 0x0, + Inkscape::XML::Node * node = 0x0) const; bool set_param_bool (const gchar * name, bool value, @@ -269,6 +274,11 @@ public: SPDocument * doc = 0, Inkscape::XML::Node * node = 0); + gchar const * set_param_enum (gchar const * name, + gchar const * value, + SPDocument * doc = 0x0, + Inkscape::XML::Node * node = 0x0); + guint32 set_param_color (const gchar * name, guint32 color, SPDocument * doc = NULL, diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 69ce982d0..f0fd3711b 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -19,6 +19,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/messagedialog.h> #include <gtkmm/main.h> #include <gtkmm/scrolledwindow.h> diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 728c38dea..0d47240d4 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -8,6 +8,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <libintl.h> #include <gtkmm/box.h> diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 8f1e07211..a3d2fd6e5 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -17,6 +17,7 @@ #include "document.h" #include "selection.h" #include "helper/action.h" +#include "helper/action-context.h" #include "preferences.h" #include "path-chemistry.h" #include "sp-item.h" @@ -99,10 +100,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View /* Doing an inset here folks */ offset *= -1.0; prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px"); - sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL); + sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(Inkscape::ActionContext(desktop)), NULL); } else if (offset > 0.0) { prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px"); - sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL); + sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(Inkscape::ActionContext(desktop)), NULL); } selection->clear(); diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 983c9dfb5..5ce9a21f3 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -66,7 +66,7 @@ bool CairoEpsOutput::check (Inkscape::Extension::Extension * /*module*/) static bool ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, - bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false) + bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px, bool eps = false) { doc->ensureUpToDate(); @@ -104,7 +104,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l bool ret = ctx->setPsTarget(filename); if(ret) { /* Render document */ - ret = renderer->setupDocument(ctx, doc, pageBoundingBox, 0., base); + ret = renderer->setupDocument(ctx, doc, pageBoundingBox, bleedmargin_px, base); if (ret) { renderer->renderItem(ctx, base); ret = ctx->finish(); @@ -174,6 +174,11 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con bool new_areaDrawing = !new_areaPage; + float bleedmargin_px = 0.; + try { + bleedmargin_px = ext->get_param_float("bleed"); + } catch(...) {} + const gchar *new_exportId = NULL; try { new_exportId = mod->get_param_string("exportId"); @@ -183,7 +188,11 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con { gchar * final_name; final_name = g_strdup_printf("> %s", filename); - ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage); + ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, + new_textToLaTeX, new_blurToBitmap, + new_bitmapResolution, new_exportId, + new_areaDrawing, new_areaPage, + bleedmargin_px); g_free(final_name); if (!ret) @@ -254,6 +263,11 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co bool new_areaDrawing = !new_areaPage; + float bleedmargin_px = 0.; + try { + bleedmargin_px = ext->get_param_float("bleed"); + } catch(...) {} + const gchar *new_exportId = NULL; try { new_exportId = mod->get_param_string("exportId"); @@ -263,7 +277,11 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co { gchar * final_name; final_name = g_strdup_printf("> %s", filename); - ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage, true); + ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, + new_textToLaTeX, new_blurToBitmap, + new_bitmapResolution, new_exportId, + new_areaDrawing, new_areaPage, + bleedmargin_px, true); g_free(final_name); if (!ret) @@ -322,6 +340,7 @@ CairoPsOutput::init (void) "<_option value=\"page\">" N_("Use document's page size") "</_option>" "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" "</param>" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.ps</extension>\n" @@ -362,6 +381,7 @@ CairoEpsOutput::init (void) "<_option value=\"page\">" N_("Use document's page size") "</_option>" "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" "</param>" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.eps</extension>\n" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index cf6730650..d7a560f04 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1080,11 +1080,11 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children + if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - SP_ITEM (child)->invoke_show (drawing, dkey, SP_ITEM_REFERENCE_FLAGS); - _renderer->renderItem(pattern_ctx, SP_ITEM (child)); + if (SP_IS_ITEM(child)) { + SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); + _renderer->renderItem(pattern_ctx, SP_ITEM(child)); } } break; // do not go further up the chain if children are found @@ -1109,10 +1109,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children + if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - SP_ITEM (child)->invoke_hide (dkey); + if (SP_IS_ITEM(child)) { + SP_ITEM(child)->invoke_hide(dkey); } } break; // do not go further up the chain if children are found @@ -1181,7 +1181,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain return NULL; } - if (pattern && SP_IS_GRADIENT (paintserver)) { + if (pattern && SP_IS_GRADIENT(paintserver)) { SPGradient *g = SP_GRADIENT(paintserver); // set extend type diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 63e46ad17..6f641fd36 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -251,11 +251,11 @@ CairoRendererPdfOutput::init (void) "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n" "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n" "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n" - "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n" + "<param name=\"area\" gui-text=\"" N_("Output page size:") "\" type=\"optiongroup\" >\n" "<_option value=\"page\">" N_("Use document's page size") "</_option>" "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" "</param>" - "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.pdf</extension>\n" diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h index 10af41d5a..3de6c1ed0 100644 --- a/src/extension/internal/cdr-input.h +++ b/src/extension/internal/cdr-input.h @@ -19,6 +19,10 @@ #ifdef WITH_LIBCDR +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include "../implementation/implementation.h" diff --git a/src/extension/internal/filter/bevels.h b/src/extension/internal/filter/bevels.h index 6fc73e58a..ea9d537ad 100644 --- a/src/extension/internal/filter/bevels.h +++ b/src/extension/internal/filter/bevels.h @@ -52,9 +52,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Diffuse Light") "</name>\n" "<id>org.inkscape.effect.filter.DiffuseLight</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -132,10 +132,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Matte Jelly") "</name>\n" "<id>org.inkscape.effect.filter.MatteJelly</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" - "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -216,10 +216,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Specular Light") "</name>\n" "<id>org.inkscape.effect.filter.SpecularLight</id>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" - "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" - "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 59790b1be..fe1b9c930 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -53,8 +53,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Blur") "</name>\n" "<id>org.inkscape.effect.filter.Blur</id>\n" - "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" - "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" "<param name=\"content\" gui-text=\"" N_("Blur content only") "\" type=\"boolean\">False</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -124,7 +124,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Clean Edges") "</name>\n" "<id>org.inkscape.effect.filter.CleanEdges</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -184,10 +184,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cross Blur") "</name>\n" "<id>org.inkscape.effect.filter.CrossBlur</id>\n" - "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n" - "<param name=\"fade\" gui-text=\"" N_("Fading:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n" - "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" - "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n" + "<param name=\"fade\" gui-text=\"" N_("Fading") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" "<param name=\"blend\" gui-text=\"" N_("Blend:") "\" type=\"enum\">\n" "<_item value=\"darken\">" N_("Darken") "</_item>\n" "<_item value=\"screen\">" N_("Screen") "</_item>\n" @@ -259,7 +259,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Feather") "</name>\n" "<id>org.inkscape.effect.filter.Feather</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -326,11 +326,11 @@ public: "<id>org.inkscape.effect.filter.ImageBlur</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" - "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">6</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">2</param>\n" - "<param name=\"opacity\" gui-text=\"" N_("Opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">6</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">2</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" "</page>\n" "<page name=\"backgroundtab\" _gui-text=\"Background\">\n" "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index f0c4c16aa..b59b1ef50 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -81,13 +81,13 @@ public: "<id>org.inkscape.effect.filter.Bump</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" - "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" - "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" + "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" "<param name=\"background\" gui-text=\"" N_("Bump from background") "\" indent=\"1\" type=\"boolean\">false</param>\n" "</page>\n" "<page name=\"lightingtab\" _gui-text=\"Lighting\">\n" @@ -95,9 +95,9 @@ public: "<_item value=\"specular\">" N_("Specular") "</_item>\n" "<_item value=\"diffuse\">" N_("Diffuse") "</_item>\n" "</param>\n" - "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50.\">5</param>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"5.\">1</param>\n" - "<param name=\"precision\" gui-text=\"" N_("Precision:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"128\">15</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50.\">5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"5.\">1</param>\n" + "<param name=\"precision\" gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"128\">15</param>\n" "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" "</page>\n" "<page name=\"lightsourcetab\" _gui-text=\"" N_("Light source") "\">\n" @@ -107,21 +107,21 @@ public: "<_item value=\"spot\">" N_("Spot") "</_item>\n" "</param>\n" "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">" N_("Distant light options") "</_param>\n" - "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"distantElevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">45</param>\n" + "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"distantElevation\" gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">45</param>\n" "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">" N_("Point light options") "</_param>\n" - "<param name=\"pointX\" gui-text=\"" N_("X location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" - "<param name=\"pointY\" gui-text=\"" N_("Y location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" - "<param name=\"pointZ\" gui-text=\"" N_("Z location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"5000\">150</param>\n" + "<param name=\"pointX\" gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" + "<param name=\"pointY\" gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" + "<param name=\"pointZ\" gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"5000\">150</param>\n" "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">" N_("Spot light options") "</_param>\n" - "<param name=\"spotX\" gui-text=\"" N_("X location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" - "<param name=\"spotY\" gui-text=\"" N_("Y location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" - "<param name=\"spotZ\" gui-text=\"" N_("Z location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">150</param>\n" - "<param name=\"spotAtX\" gui-text=\"" N_("X target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" - "<param name=\"spotAtY\" gui-text=\"" N_("Y target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" - "<param name=\"spotAtZ\" gui-text=\"" N_("Z target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"0\">-1000</param>\n" - "<param name=\"spotExponent\" gui-text=\"" N_("Specular exponent:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"100\">1</param>\n" - "<param name=\"spotConeAngle\" gui-text=\"" N_("Cone angle:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"100\">50</param>\n" + "<param name=\"spotX\" gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" + "<param name=\"spotY\" gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" + "<param name=\"spotZ\" gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">150</param>\n" + "<param name=\"spotAtX\" gui-text=\"" N_("X target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" + "<param name=\"spotAtY\" gui-text=\"" N_("Y target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" + "<param name=\"spotAtZ\" gui-text=\"" N_("Z target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"0\">-1000</param>\n" + "<param name=\"spotExponent\" gui-text=\"" N_("Specular exponent") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"100\">1</param>\n" + "<param name=\"spotConeAngle\" gui-text=\"" N_("Cone angle") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"100\">50</param>\n" "</page>\n" "<page name=\"colortab\" _gui-text=\"Color bump\">\n" "<param name=\"imageColor\" gui-text=\"" N_("Image color") "\" type=\"color\">-987158017</param>\n" @@ -310,27 +310,27 @@ public: "<id>org.inkscape.effect.filter.WaxBump</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n" - "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" - "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n" + "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" "<param name=\"background\" gui-text=\"" N_("Background:") "\" type=\"enum\">\n" "<_item value=\"flood1\">" N_("Color") "</_item>\n" "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n" "<_item value=\"blur1\">" N_("Blurred image") "</_item>\n" "</param>\n" - "<param name=\"bgopacity\" gui-text=\"" N_("Background opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n" + "<param name=\"bgopacity\" gui-text=\"" N_("Background opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n" "</page>\n" "<page name=\"lightingtab\" _gui-text=\"" N_("Lighting") "\">\n" "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" - "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n" - "<param name=\"precision\" gui-text=\"" N_("Precision:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n" - "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"distantElevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n" + "<param name=\"precision\" gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n" + "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"distantElevation\" gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n" "<param name=\"lightingblend\" gui-text=\"" N_("Lighting blend:") "\" type=\"enum\">\n" "<_item value=\"screen\">" N_("Screen") "</_item>\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 09079453f..7059ad29b 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -71,9 +71,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Brilliance") "</name>\n" "<id>org.inkscape.effect.filter.Brilliance</id>\n" - "<param name=\"brightness\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n" - "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" + "<param name=\"brightness\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -153,11 +153,11 @@ public: "<id>org.inkscape.effect.filter.ChannelPaint</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<param name=\"saturation\" gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "</page>\n" "<page name=\"colortab\" _gui-text=\"Color\">\n" @@ -253,8 +253,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Color Shift") "</name>\n" "<id>org.inkscape.effect.filter.ColorShift</id>\n" - "<param name=\"shift\" gui-text=\"" N_("Shift (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" - "<param name=\"sat\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n" + "<param name=\"shift\" gui-text=\"" N_("Shift (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -318,8 +318,8 @@ public: "<id>org.inkscape.effect.filter.Colorize</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"hlight\" gui-text=\"" N_("Harsh light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"nlight\" gui-text=\"" N_("Normal light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" + "<param name=\"hlight\" gui-text=\"" N_("Harsh light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"nlight\" gui-text=\"" N_("Normal light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" "<param name=\"duotone\" gui-text=\"" N_("Duotone") "\" type=\"boolean\" >false</param>\n" "<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n" "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" @@ -510,7 +510,7 @@ public: "<id>org.inkscape.effect.filter.Duochrome</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"2\">0</param>\n" + "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"2\">0</param>\n" "<param name=\"swap\" gui-text=\"" N_("Swap:") "\" type=\"enum\">\n" "<_item value=\"none\">" N_("No swap") "</_item>\n" "<_item value=\"full\">" N_("Color and alpha") "</_item>\n" @@ -739,7 +739,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Fade to Black or White") "</name>\n" "<id>org.inkscape.effect.filter.FadeToBW</id>\n" - "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" "<param name=\"fadeto\" gui-text=\"" N_("Fade to:") "\" type=\"enum\">\n" "<_item value=\"black\">" N_("Black") "</_item>\n" "<_item value=\"white\">" N_("White") "</_item>\n" @@ -818,10 +818,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Greyscale") "</name>\n" "<id>org.inkscape.effect.filter.Greyscale</id>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.072</param>\n" - "<param name=\"strength\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.072</param>\n" + "<param name=\"strength\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" "<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -910,7 +910,7 @@ public: "<_item value=\"2\">" N_("Red and green") "</_item>\n" "<_item value=\"3\">" N_("Green and blue") "</_item>\n" "</param>\n" - "<param name=\"opacify\" gui-text=\"" N_("Light transparency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n" + "<param name=\"opacify\" gui-text=\"" N_("Light transparency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n" "<param name=\"hue\" gui-text=\"" N_("Invert hue") "\" type=\"boolean\" >false</param>\n" "<param name=\"lightness\" gui-text=\"" N_("Invert lightness") "\" type=\"boolean\" >false</param>\n" "<param name=\"transparency\" gui-text=\"" N_("Invert transparency") "\" type=\"boolean\" >false</param>\n" @@ -1039,9 +1039,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Lighting") "</name>\n" "<id>org.inkscape.effect.filter.Lighting</id>\n" - "<param name=\"amplitude\" gui-text=\"" N_("Lights:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" - "<param name=\"exponent\" gui-text=\"" N_("Shadows:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" - "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-1.00\" max=\"1.00\">0</param>\n" + "<param name=\"amplitude\" gui-text=\"" N_("Lights") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" + "<param name=\"exponent\" gui-text=\"" N_("Shadows") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" + "<param name=\"offset\" gui-text=\"" N_("Offset") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-1.00\" max=\"1.00\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -1110,8 +1110,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Lightness-Contrast") "</name>\n" "<id>org.inkscape.effect.filter.LightnessContrast</id>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" - "<param name=\"contrast\" gui-text=\"" N_("Contrast:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" + "<param name=\"contrast\" gui-text=\"" N_("Contrast") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -1192,14 +1192,14 @@ public: "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"offsettab\" _gui-text=\"Offset\">\n" "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n" - "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"rx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"ry\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" "<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n" - "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" - "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" + "<param name=\"gx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"gy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n" - "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" - "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" + "<param name=\"bx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"by\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" "</page>\n" "<page name=\"coltab\" _gui-text=\"Color\">\n" "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n" @@ -1304,14 +1304,14 @@ public: "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"offsettab\" _gui-text=\"Offset\">\n" "<_param name=\"cyanOffset\" type=\"description\" appearance=\"header\">" N_("Cyan offset") "</_param>\n" - "<param name=\"cx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<param name=\"cy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"cx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"cy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" "<_param name=\"magentaOffset\" type=\"description\" appearance=\"header\">" N_("Magenta offset") "</_param>\n" - "<param name=\"mx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" - "<param name=\"my\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" + "<param name=\"mx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"my\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" "<_param name=\"yellowOffset\" type=\"description\" appearance=\"header\">" N_("Yellow offset") "</_param>\n" - "<param name=\"yx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" - "<param name=\"yy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" + "<param name=\"yx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"yy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" "</page>\n" "<page name=\"coltab\" _gui-text=\"Color\">\n" "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" @@ -1407,14 +1407,14 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Quadritone fantasy") "</name>\n" "<id>org.inkscape.effect.filter.Quadritone</id>\n" - "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" - "<param name=\"colors\" gui-text=\"" N_("Colors:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" + "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" + "<param name=\"colors\" gui-text=\"" N_("Colors") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" "<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" "<_item value=\"screen\">" N_("Screen") "</_item>\n" "</param>\n" - "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">0</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">0</param>\n" "<param name=\"blend2\" gui-text=\"" N_("Blend 2:") "\" type=\"enum\">\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" "<_item value=\"screen\">" N_("Screen") "</_item>\n" @@ -1493,7 +1493,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Solarize") "</name>\n" "<id>org.inkscape.effect.filter.Solarize</id>\n" - "<param name=\"rotate\" gui-text=\"" N_("Hue rotation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" + "<param name=\"rotate\" gui-text=\"" N_("Hue rotation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n" "<_item value=\"solarize\">" N_("Solarize") "</_item>\n" "<_item value=\"moonarize\">" N_("Moonarize") "</_item>\n" @@ -1595,14 +1595,14 @@ public: "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" "<_item value=\"darken\">" N_("Darken") "</_item>\n" "</param>\n" - "<param name=\"glow\" gui-text=\"" N_("Glow:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10\">0.01</param>\n" + "<param name=\"glow\" gui-text=\"" N_("Glow") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10\">0.01</param>\n" "<param name=\"glowblend\" gui-text=\"" N_("Glow blend:") "\" type=\"enum\">\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" "<_item value=\"darken\">" N_("Darken") "</_item>\n" "</param>\n" - "<param name=\"llight\" gui-text=\"" N_("Local light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"glight\" gui-text=\"" N_("Global light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" + "<param name=\"llight\" gui-text=\"" N_("Local light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"glight\" gui-text=\"" N_("Global light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" "</page>\n" "<page name=\"co1tab\" _gui-text=\"Color\">\n" "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index 415762466..586d34226 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -70,10 +70,10 @@ public: "<_item value=\"in\">" N_("In") "</_item>\n" "<_item value=\"out\">" N_("Out") "</_item>\n" "</param>\n" - "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" - "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n" "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n" "<_item value=\"atop\">" N_("Normal") "</_item>\n" "<_item value=\"over\">" N_("Wide") "</_item>\n" @@ -84,11 +84,11 @@ public: "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" "</param>\n" - "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" - "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" - "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" - "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" - "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100\">30</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" + "<param name=\"intensity\" gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100\">30</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -193,11 +193,11 @@ public: "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" "</param>\n" - "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" - "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" - "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" - "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" - "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" + "<param name=\"intensity\" gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 0273d1669..0273d1669 100755..100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index 60e1a1665..00cd2cf21 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -53,7 +53,7 @@ public: "<_item value=\"vertical\">" N_("Vertical lines") "</_item>\n" "<_item value=\"horizontal\">" N_("Horizontal lines") "</_item>\n" "</param>\n" - "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"100.0\">1.0</param>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"100.0\">1.0</param>\n" "<param name=\"inverted\" gui-text=\"" N_("Invert colors") "\" type=\"boolean\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index 123d912b0..7e10884a1 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -62,11 +62,11 @@ public: "<_item value=\"over\">" N_("Outer") "</_item>\n" "<_item value=\"xor\">" N_("Open") "</_item>\n" "</param>\n" - "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.\">10</param>\n" - "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.2\" max=\"2\">1</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">10</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">1</param>\n" - "<param name=\"antialias\" gui-text=\"" N_("Antialiasing:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" + "<param name=\"width\" gui-text=\"" N_("Width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.\">10</param>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.2\" max=\"2\">1</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">10</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">1</param>\n" + "<param name=\"antialias\" gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" "<param name=\"content\" gui-text=\"" N_("Blur content") "\" type=\"boolean\" >false</param>\n" "<effect>\n" @@ -181,13 +181,13 @@ public: "<_item value=\"outside\">" N_("Outside") "</_item>\n" "<_item value=\"overlayed\">" N_("Overlayed") "</_item>\n" "</param>\n" - "<param name=\"width1\" gui-text=\"" N_("Width 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n" - "<param name=\"dilat1\" gui-text=\"" N_("Dilatation 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n" - "<param name=\"erosion1\" gui-text=\"" N_("Erosion 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"width2\" gui-text=\"" N_("Width 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n" - "<param name=\"dilat2\" gui-text=\"" N_("Dilatation 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n" - "<param name=\"erosion2\" gui-text=\"" N_("Erosion 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n" - "<param name=\"antialias\" gui-text=\"" N_("Antialiasing:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" + "<param name=\"width1\" gui-text=\"" N_("Width 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n" + "<param name=\"dilat1\" gui-text=\"" N_("Dilatation 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n" + "<param name=\"erosion1\" gui-text=\"" N_("Erosion 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"width2\" gui-text=\"" N_("Width 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n" + "<param name=\"dilat2\" gui-text=\"" N_("Dilatation 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n" + "<param name=\"erosion2\" gui-text=\"" N_("Erosion 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n" + "<param name=\"antialias\" gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" "<param name=\"smooth\" gui-text=\"" N_("Smooth") "\" type=\"boolean\" >false</param>\n" "</page>\n" "<page name=\"co11tab\" _gui-text=\"Color\">\n" diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 4052f4391..d99d1e0e2 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -83,19 +83,19 @@ public: "<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" "<param name=\"dented\" gui-text=\"" N_("Dented") "\" type=\"boolean\" >false</param>\n" "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n" - "<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n" - "<param name=\"noise\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n" - "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" + "<param name=\"light\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"saturation\" gui-text=\"" N_("Saturation") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"noise\" gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" "</page>\n" "<page name=\"graintab\" _gui-text=\"" N_("Grain") "\">\n" "<param name=\"grain\" gui-text=\"" N_("Grain mode") "\" type=\"boolean\" >true</param>\n" - "<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" - "<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" - "<param name=\"grainc\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" - "<param name=\"grainv\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n" - "<param name=\"grainexp\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n" - "<param name=\"grainero\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n" + "<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" + "<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" + "<param name=\"grainc\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" + "<param name=\"grainv\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n" + "<param name=\"grainexp\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n" + "<param name=\"grainero\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n" "<param name=\"graincol\" gui-text=\"" N_("Color") "\" type=\"boolean\" >true</param>\n" "<param name=\"gblend\" gui-text=\"" N_("Grain blend:") "\" type=\"enum\">\n" "<_item value=\"normal\">Normal</_item>\n" @@ -231,11 +231,11 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cross Engraving") "</name>\n" "<id>org.inkscape.effect.filter.CrossEngraving</id>\n" - "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n" - "<param name=\"strength\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n" - "<param name=\"length\" gui-text=\"" N_("Length:") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n" + "<param name=\"clean\" gui-text=\"" N_("Clean-up") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n" + "<param name=\"strength\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n" + "<param name=\"length\" gui-text=\"" N_("Length") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n" "<param name=\"trans\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -333,18 +333,18 @@ public: "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"Options\">\n" "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">" N_("Simplify") "</_param>\n" - "<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" - "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n" - "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n" + "<param name=\"simply\" gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" + "<param name=\"clean\" gui-text=\"" N_("Clean-up") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n" + "<param name=\"erase\" gui-text=\"" N_("Erase") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n" "<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" indent=\"1\" type=\"boolean\" >false</param>\n" "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">" N_("Smoothness") "</_param>\n" - "<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" - "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" - "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">" N_("Melt") "</_param>\n" - "<param name=\"blur\" gui-text=\"" N_("Level:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n" - "<param name=\"bdilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" - "<param name=\"berosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Level") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n" + "<param name=\"bdilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" + "<param name=\"berosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" "</page>\n" "<page name=\"co11tab\" _gui-text=\"Fill color\">\n" "<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-1515870721</param>\n" @@ -353,7 +353,7 @@ public: "<page name=\"co12tab\" _gui-text=\"Stroke color\">\n" "<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">589505535</param>\n" "<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n" - "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n" + "<param name=\"offset\" gui-text=\"" N_("Offset") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -493,12 +493,12 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Electrize") "</name>\n" "<id>org.inkscape.effect.filter.Electrize</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n" "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n" "<_item value=\"table\">" N_("Table") "</_item>\n" "<_item value=\"discrete\">" N_("Discrete") "</_item>\n" "</param>\n" - "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -587,9 +587,9 @@ public: "<_item value=\"table\">" N_("Smoothed") "</_item>\n" "<_item value=\"discrete\">" N_("Contrasted") "</_item>\n" "</param>\n" - "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" - "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n" + "<param name=\"simply\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" + "<param name=\"width\" gui-text=\"" N_("Line width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n" "<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n" "<_item value=\"normal\">Normal</_item>\n" "<_item value=\"multiply\">Multiply</_item>\n" @@ -692,11 +692,11 @@ public: "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" "</param>\n" - "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" - "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" - "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" - "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" - "<param name=\"reduction\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" + "<param name=\"reduction\" gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n" "<param name=\"blend\" gui-text=\"" N_("Noise blend:") "\" type=\"enum\">\n" "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" "<_item value=\"normal\">" N_("Normal") "</_item>\n" @@ -704,10 +704,10 @@ public: "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" "<_item value=\"darken\">" N_("Darken") "</_item>\n" "</param>\n" - "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n" - "<param name=\"grain\" gui-text=\"" N_("Grain lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n" - "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n" - "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n" + "<param name=\"grain\" gui-text=\"" N_("Grain lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n" + "<param name=\"erase\" gui-text=\"" N_("Erase") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n" "</page>\n" "<page name=\"fcolortab\" _gui-text=\"" N_("Fill color") "\">\n" "<param name=\"fcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" @@ -857,7 +857,7 @@ public: "<_item value=\"discrete\">" N_("Poster") "</_item>\n" "<_item value=\"table\">" N_("Painting") "</_item>\n" "</param>\n" - "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n" "<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n" "<_item value=\"lighten\">Lighten</_item>\n" "<_item value=\"normal\">Normal</_item>\n" @@ -865,10 +865,10 @@ public: "<_item value=\"multiply\">Multiply</_item>\n" "<_item value=\"screen\">Screen</_item>\n" "</param>\n" - "<param name=\"blur1\" gui-text=\"" N_("Simplify (primary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n" - "<param name=\"blur2\" gui-text=\"" N_("Simplify (secondary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n" - "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" - "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" + "<param name=\"blur1\" gui-text=\"" N_("Simplify (primary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n" + "<param name=\"blur2\" gui-text=\"" N_("Simplify (secondary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n" + "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" + "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" "<param name=\"antialiasing\" gui-text=\"" N_("Simulate antialiasing") "\" type=\"boolean\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -972,8 +972,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Posterize Basic") "</name>\n" "<id>org.inkscape.effect.filter.PosterizeBasic</id>\n" - "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n" - "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h index 8ba35db62..965a1bdc5 100644 --- a/src/extension/internal/filter/protrusions.h +++ b/src/extension/internal/filter/protrusions.h @@ -47,7 +47,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Snow crest") "</name>\n" "<id>org.inkscape.effect.filter.snow</id>\n" - "<param name=\"drift\" gui-text=\"" N_("Drift Size:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n" + "<param name=\"drift\" gui-text=\"" N_("Drift Size") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 415776607..0d54950bf 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -58,9 +58,9 @@ public: "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n" "<param name=\"tab\" type=\"notebook\">\n" "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n" - "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" - "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" - "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur radius (px)") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" + "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" + "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n" "<_item value=\"outer\">" N_("Outer") "</_item>\n" "<_item value=\"inner\">" N_("Inner") "</_item>\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index b29a0a1b3..dcbae26b5 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -129,10 +129,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Channel Transparency") "</name>\n" "<id>org.inkscape.effect.filter.ChannelTransparency</id>\n" - "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" - "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -204,9 +204,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Light Eraser") "</name>\n" "<id>org.inkscape.effect.filter.LightEraser</id>\n" - "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" - "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" - "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -278,9 +278,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Opacity") "</name>\n" "<id>org.inkscape.effect.filter.Opacity</id>\n" - "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n" - "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n" - "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -340,7 +340,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Silhouette") "</name>\n" "<id>org.inkscape.effect.filter.Silhouette</id>\n" - "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n" "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" "<effect>\n" diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 56bce2fe8..820d1c9d3 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -11,6 +11,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/adjustment.h> #include <gtkmm/spinbutton.h> diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index 51a3fe9c1..3c254a59c 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -21,6 +21,9 @@ #ifdef HAVE_JPEG #define IR_TRY_JFIF 1 #endif +#ifdef WITH_IMAGE_MAGICK +#include <Magick++.h> +#endif namespace Inkscape { namespace Extension { @@ -39,6 +42,9 @@ ImageResolution::ImageResolution(char const *fn) { if (!ok_) { readexif(fn); } + if (!ok_) { + readmagick(fn); + } } bool ImageResolution::ok() const { @@ -328,6 +334,33 @@ void ImageResolution::readjfif(char const *) { #endif +#ifdef WITH_IMAGE_MAGICK +void ImageResolution::readmagick(char const *fn) { + Magick::Image image; + try { + image.read(fn); + } catch (...) {} + Magick::Geometry geo = image.density(); + std::string type = image.magick(); + + if (type == "PNG") { // PNG only supports pixelspercentimeter + x_ = (double)geo.width() * 2.54; + y_ = (double)geo.height() * 2.54; + } else { + x_ = (double)geo.width(); + y_ = (double)geo.height(); + } + ok_ = true; +} + +#else + +// Dummy implementation +void ImageResolution::readmagick(char const *) { +} + +#endif /* WITH_IMAGE_MAGICK */ + } } } diff --git a/src/extension/internal/image-resolution.h b/src/extension/internal/image-resolution.h index c42260f7d..6c4928a35 100644 --- a/src/extension/internal/image-resolution.h +++ b/src/extension/internal/image-resolution.h @@ -18,19 +18,20 @@ namespace Internal { class ImageResolution { public: - ImageResolution(char const *fn); - bool ok() const; - double x() const; - double y() const; + ImageResolution(char const *fn); + bool ok() const; + double x() const; + double y() const; private: - bool ok_; - double x_; - double y_; + bool ok_; + double x_; + double y_; private: - void readpng(char const *fn); - void readexif(char const *fn); - void readexiv(char const *fn); - void readjfif(char const *fn); + void readpng(char const *fn); + void readexif(char const *fn); + void readexiv(char const *fn); + void readjfif(char const *fn); + void readmagick(char const *fn); }; } diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index b23378fc3..9f745cdea 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1191,16 +1191,29 @@ bool OdfOutput::writeMeta(ZipFile &zf) { creator = iter->second; } - Glib::ustring date = ""; + + Glib::ustring date; + Glib::ustring moddate; + char buf [80]; + time_t rawtime; + struct tm * timeinfo; + time (&rawtime); + timeinfo = localtime (&rawtime); + strftime (buf,80,"%Y-%m-%d %H:%M:%S",timeinfo); + moddate = Glib::ustring(buf); + iter = metadata.find("dc:date"); if (iter != metadata.end()) { date = iter->second; } + else + { + date = moddate; + } outs.writeString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); outs.writeString("\n"); - outs.writeString("\n"); outs.writeString("<!--\n"); outs.writeString("*************************************************************************\n"); outs.writeString(" file: meta.xml\n"); @@ -1209,7 +1222,6 @@ bool OdfOutput::writeMeta(ZipFile &zf) outs.writeString("*************************************************************************\n"); outs.writeString("-->\n"); outs.writeString("\n"); - outs.writeString("\n"); outs.writeString("<office:document-meta\n"); outs.writeString("xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"\n"); outs.writeString("xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"); @@ -1221,10 +1233,11 @@ bool OdfOutput::writeMeta(ZipFile &zf) outs.writeString("xmlns:anim=\"urn:oasis:names:tc:opendocument:xmlns:animation:1.0\"\n"); outs.writeString("office:version=\"1.0\">\n"); outs.writeString("<office:meta>\n"); - Glib::ustring tmp = Glib::ustring(" <meta:generator>") + InkscapeVersion + "</meta:generator>\n"; + Glib::ustring tmp = Glib::ustring::compose(" <meta:generator>%1</meta:generator>\n", InkscapeVersion); + tmp += Glib::ustring::compose(" <meta:initial-creator>%1</meta:initial-creator>\n", creator); + tmp += Glib::ustring::compose(" <meta:creation-date>%1</meta:creation-date>\n", date); + tmp += Glib::ustring::compose(" <dc:date>%1</dc:date>\n", moddate); outs.writeUString(tmp); - outs.printf(" <meta:initial-creator>%s</meta:initial-creator>\n", creator.c_str()); - outs.printf(" <meta:creation-date>%s</meta:creation-date>\n", date.c_str()); for (iter = metadata.begin() ; iter != metadata.end() ; ++iter) { Glib::ustring name = iter->first; @@ -1235,18 +1248,15 @@ bool OdfOutput::writeMeta(ZipFile &zf) outs.writeUString(tmp); } } - outs.writeString(" <meta:editing-cycles>2</meta:editing-cycles>\n"); - outs.writeString(" <meta:editing-duration>PT56S</meta:editing-duration>\n"); - outs.writeString(" <meta:user-defined meta:name=\"Info 1\"/>\n"); - outs.writeString(" <meta:user-defined meta:name=\"Info 2\"/>\n"); - outs.writeString(" <meta:user-defined meta:name=\"Info 3\"/>\n"); - outs.writeString(" <meta:user-defined meta:name=\"Info 4\"/>\n"); - outs.writeString(" <meta:document-statistic meta:object-count=\"2\"/>\n"); + // outs.writeString(" <meta:editing-cycles>2</meta:editing-cycles>\n"); + // outs.writeString(" <meta:editing-duration>PT56S</meta:editing-duration>\n"); + // outs.writeString(" <meta:user-defined meta:name=\"Info 1\"/>\n"); + // outs.writeString(" <meta:user-defined meta:name=\"Info 2\"/>\n"); + // outs.writeString(" <meta:user-defined meta:name=\"Info 3\"/>\n"); + // outs.writeString(" <meta:user-defined meta:name=\"Info 4\"/>\n"); + // outs.writeString(" <meta:document-statistic meta:object-count=\"2\"/>\n"); outs.writeString("</office:meta>\n"); outs.writeString("</office:document-meta>\n"); - outs.writeString("\n"); - outs.writeString("\n"); - outs.close(); //Make our entry @@ -1533,7 +1543,7 @@ bool OdfOutput::processGradient(SPItem *item, gradientTable.push_back(gi); gradientLookupTable[id] = gradientName; - int gradientCount = gradientTable.size(); + // int gradientCount = gradientTable.size(); char buf[128]; if (gi.style == "linear") { diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h index 66f1e5e7e..b65d22f48 100644 --- a/src/extension/internal/pdf-input-cairo.h +++ b/src/extension/internal/pdf-input-cairo.h @@ -16,6 +16,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/button.h> #include <gtkmm/buttonbox.h> diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 3710e4667..f22a783ff 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -16,6 +16,10 @@ #ifdef HAVE_POPPLER +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include "../../implementation/implementation.h" diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h index acc52debf..3414e0ec9 100644 --- a/src/extension/internal/vsd-input.h +++ b/src/extension/internal/vsd-input.h @@ -19,6 +19,10 @@ #ifdef WITH_LIBVISIO +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include "../implementation/implementation.h" diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index de9b1c586..548dec4fa 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -10,6 +10,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/spinbutton.h> diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index d8c78c97d..0a2598c56 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -14,6 +14,10 @@ #include <iostream> #include <sstream> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/spinbutton.h> diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index ae2d88ab3..c9cea73d4 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -13,6 +13,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> #include <glibmm/i18n.h> diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 18a73beb6..bb50c06e1 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -18,6 +18,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/comboboxtext.h> #include <glibmm/i18n.h> @@ -173,6 +177,24 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape return _value; } +/** + * function to test if \c guitext is selectable + */ +bool ParamComboBox::contains(const gchar * guitext, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const +{ + if (guitext == NULL) { + return false; /* Can't have NULL string */ + } + + for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { + enumentry * entr = reinterpret_cast<enumentry *>(list->data); + if ( !entr->guitext.compare(guitext) ) + return true; + } + // if we did not find the guitext in this ParamComboBox: + return false; +} + void ParamComboBox::changed (void) { diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h index ac7d72abd..52e018469 100644 --- a/src/extension/param/enum.h +++ b/src/extension/param/enum.h @@ -51,6 +51,11 @@ public: const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); + /** + * @returns true if guitext is part of this enum + */ + bool contains(const gchar * guitext, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const; + void changed (void); }; /* class ParamComboBox */ diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 81508f6c0..464938f03 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -10,6 +10,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index c286018fd..819c75693 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -10,6 +10,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index 85cb5d04c..97002e33f 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -16,6 +16,9 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif #include <gtkmm/adjustment.h> #include <gtkmm/box.h> diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 97e4f9d8c..202b8110f 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -183,6 +183,15 @@ gchar const *Parameter::get_enum(SPDocument const *doc, Inkscape::XML::Node cons return param->get(doc, node); } +bool Parameter::get_enum_contains(gchar const * value, SPDocument const *doc, Inkscape::XML::Node const *node) const +{ + ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this); + if (!param) { + throw Extension::param_not_enum_param(); + } + return param->contains(value, doc, node); +} + gchar const *Parameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const * node) const { ParamRadioButton const *param = dynamic_cast<ParamRadioButton const *>(this); @@ -247,6 +256,15 @@ gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, In return param->set(in, doc, node); } +gchar const *Parameter::set_enum( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node ) +{ + ParamComboBox *param = dynamic_cast<ParamComboBox *>(this); + if (!param) { + throw Extension::param_not_enum_param(); + } + return param->set(in, doc, node); +} + /** Wrapper to cast to the object and use it's function. */ guint32 diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index d08efc554..5e1e3897f 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -88,8 +88,10 @@ public: gchar const *get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const; /** Wrapper to cast to the object and use it's function. */ - gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const; + bool get_enum_contains(gchar const * value, SPDocument const *doc, Inkscape::XML::Node const *node) const; + /** Wrapper to cast to the object and use it's function. */ + gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const; /** Wrapper to cast to the object and use it's function. */ bool set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node); @@ -101,6 +103,8 @@ public: gchar const *set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node); + gchar const *set_enum(gchar const * in, SPDocument * doc, Inkscape::XML::Node *node); + gchar const *set_string(gchar const * in, SPDocument * doc, Inkscape::XML::Node * node); guint32 set_color(guint32 in, SPDocument * doc, Inkscape::XML::Node * node); diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 38ed1fe77..75d5a40e3 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -18,6 +18,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/radiobutton.h> @@ -186,6 +190,8 @@ const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inksc Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setString(extension_pref_root + prefname, _value); g_free(prefname); + } else { + g_warning("Couldn't set ParamRadioButton %s", in); } return _value; @@ -233,8 +239,8 @@ public: void ParamRadioButtonWdg::changed(void) { if (this->get_active()) { - Glib::ustring data = this->get_label(); - _pref->set(data.c_str(), _doc, _node); + Glib::ustring value = _pref->value_from_label(this->get_label()); + _pref->set(value.c_str(), _doc, _node); } if (_changeSignal != NULL) { _changeSignal->emit(); @@ -260,12 +266,32 @@ protected: virtual void on_changed() { if ( base ) { - base->set(get_active_text().c_str(), doc, node); + Glib::ustring value = base->value_from_label(get_active_text()); + base->set(value.c_str(), doc, node); } } }; /** + * Returns the value for the options label parameter + */ +Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) +{ + Glib::ustring value = ""; + + for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { + optionentry * entr = reinterpret_cast<optionentry *>(list->data); + if ( !entr->guitext->compare(label) ) { + value = *(entr->value); + break; + } + } + + return value; + +} + +/** * Creates a combobox widget for an enumeration parameter. */ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index 645faecaf..0e0f643c9 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -51,6 +51,8 @@ public: virtual void string(std::string &string) const; + Glib::ustring value_from_label(const Glib::ustring label); + const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node); diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 4e525ff73..d6e438db5 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -10,6 +10,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/spinbutton.h> diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h index e1999791f..905d35744 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_EXTENSION_DIALOG_H__ #define INKSCAPE_EXTENSION_DIALOG_H__ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <glibmm/value.h> #include <glibmm/ustring.h> diff --git a/src/file.cpp b/src/file.cpp index 5b4110253..5007cd901 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -68,6 +68,7 @@ #include "ui/dialog/font-substitution.h" #include <gtk/gtk.h> +#include <gtkmm/main.h> #include <glibmm/convert.h> #include <glibmm/i18n.h> @@ -209,8 +210,13 @@ SPDesktop* sp_file_new_default() void sp_file_exit() { - sp_ui_close_all(); - // no need to call inkscape_exit here; last document being closed will take care of that + if (SP_ACTIVE_DESKTOP == NULL) { + // We must be in console mode + Gtk::Main::quit(); + } else { + sp_ui_close_all(); + // no need to call inkscape_exit here; last document being closed will take care of that + } } @@ -582,24 +588,25 @@ sp_file_open_dialog(Gtk::Window &parentWindow, gpointer /*object*/, gpointer /*d /** * Remove unreferenced defs from the defs section of the document. */ -void sp_file_vacuum() +void sp_file_vacuum(SPDocument *doc) { - SPDocument *doc = SP_ACTIVE_DOCUMENT; - unsigned int diff = doc->vacuumDocument(); DocumentUndo::done(doc, SP_VERB_FILE_VACUUM, _("Clean up document")); SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (diff > 0) { - dt->messageStack()->flashF(Inkscape::NORMAL_MESSAGE, - ngettext("Removed <b>%i</b> unused definition in <defs>.", - "Removed <b>%i</b> unused definitions in <defs>.", - diff), - diff); - } else { - dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No unused definitions in <defs>.")); + if (dt != NULL) { + // Show status messages when in GUI mode + if (diff > 0) { + dt->messageStack()->flashF(Inkscape::NORMAL_MESSAGE, + ngettext("Removed <b>%i</b> unused definition in <defs>.", + "Removed <b>%i</b> unused definitions in <defs>.", + diff), + diff); + } else { + dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No unused definitions in <defs>.")); + } } } diff --git a/src/file.h b/src/file.h index fe8ad9af3..eeb4c6fc5 100644 --- a/src/file.h +++ b/src/file.h @@ -200,7 +200,7 @@ void sp_file_print (Gtk::Window& parentWindow); /** * clean unused defs out of file */ -void sp_file_vacuum (); +void sp_file_vacuum (SPDocument *doc); #endif // SEEN_SP_FILE_H diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 367597532..3d2975e41 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -485,7 +485,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.", SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->add(reprobj); - sp_selected_path_union_skip_undo(desktop); + sp_selected_path_union_skip_undo(sp_desktop_selection(desktop), desktop); } else { desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.", @@ -1211,7 +1211,7 @@ gint SPFloodContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; default: diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 8cb7e174b..4fa1f263d 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -708,7 +708,7 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-grad"); ret = TRUE; } @@ -716,7 +716,7 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_A: case GDK_KEY_a: - if (MOD__CTRL_ONLY && drag->isNonEmpty()) { + if (MOD__CTRL_ONLY(event) && drag->isNonEmpty()) { drag->selectAll(); ret = TRUE; } @@ -724,7 +724,7 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_L: case GDK_KEY_l: - if (MOD__CTRL_ONLY && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__CTRL_ONLY(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_gradient_simplify(this, 1e-4); ret = TRUE; } @@ -743,23 +743,22 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_Left: // move handle left case GDK_KEY_KP_Left: case GDK_KEY_KP_4: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(mul*-10, 0); // shift } else { drag->selected_move_screen(mul*-1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(mul*-10*nudge, 0); // shift } else { drag->selected_move(mul*-nudge, 0); // no shift } } - ret = TRUE; } break; @@ -767,18 +766,17 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_Up: // move handle up case GDK_KEY_KP_Up: case GDK_KEY_KP_8: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(0, mul*10); // shift } else { drag->selected_move_screen(0, mul*1); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(0, mul*10*nudge); // shift } else { drag->selected_move(0, mul*nudge); // no shift @@ -792,18 +790,18 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_Right: // move handle right case GDK_KEY_KP_Right: case GDK_KEY_KP_6: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(mul*10, 0); // shift } else { drag->selected_move_screen(mul*1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(mul*10*nudge, 0); // shift } else { drag->selected_move(mul*nudge, 0); // no shift @@ -817,18 +815,18 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_Down: // move handle down case GDK_KEY_KP_Down: case GDK_KEY_KP_2: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(0, mul*-10); // shift } else { drag->selected_move_screen(0, mul*-1); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(0, mul*-10*nudge); // shift } else { drag->selected_move(0, mul*-nudge); // no shift @@ -841,7 +839,7 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_r: case GDK_KEY_R: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_gradient_reverse_selected_gradients(desktop); ret = TRUE; } @@ -857,7 +855,7 @@ gint SPGradientContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt index f709c7386..2e1e724f5 100644 --- a/src/helper/CMakeLists.txt +++ b/src/helper/CMakeLists.txt @@ -10,6 +10,7 @@ set(sp_marshal_SRC set(helper_SRC action.cpp + action-context.cpp geom.cpp geom-nodetype.cpp gnome-utils.cpp @@ -29,6 +30,7 @@ set(helper_SRC # ------- # Headers action.h + action-context.h geom-curves.h geom-nodetype.h geom.h diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 2be40e0e0..790d87b14 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -5,6 +5,8 @@ helper/unit-menu.$(OBJEXT): helper/sp-marshal.h ink_common_sources += \ helper/action.cpp \ helper/action.h \ + helper/action-context.cpp \ + helper/action-context.h \ helper/geom.cpp \ helper/geom.h \ helper/geom-curves.h \ diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp new file mode 100644 index 000000000..d52e43d96 --- /dev/null +++ b/src/helper/action-context.cpp @@ -0,0 +1,84 @@ +/* + * ActionContext implementation. + * + * Author: + * Eric Greveson <eric@greveson.co.uk> + * + * Copyright (C) 2013 Eric Greveson + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "desktop.h" +#include "document.h" +#include "layer-model.h" +#include "selection.h" +#include "helper/action-context.h" +#include "ui/view/view.h" + +namespace Inkscape { + +ActionContext::ActionContext() + : _selection(NULL) + , _view(NULL) +{ +} + +ActionContext::ActionContext(Selection *selection) + : _selection(selection) + , _view(NULL) +{ +} + +ActionContext::ActionContext(UI::View::View *view) + : _selection(NULL) + , _view(view) +{ + SPDesktop *desktop = static_cast<SPDesktop *>(view); + if (desktop) { + _selection = desktop->selection; + } +} + +SPDocument *ActionContext::getDocument() const +{ + if (_selection == NULL) { + return NULL; + } + + // Should be the same as the view's document, if view is non-NULL + return _selection->layers()->getDocument(); +} + +Selection *ActionContext::getSelection() const +{ + return _selection; +} + +UI::View::View *ActionContext::getView() const +{ + return _view; +} + +SPDesktop *ActionContext::getDesktop() const +{ + // TODO: this slightly horrible storage of a UI::View::View*, and + // casting to an SPDesktop*, is only done because that's what was + // already the norm in the Inkscape codebase. This seems wrong. Surely + // we should store an SPDesktop* in the first place? Is there a case + // of actions being carried out on a View that is not an SPDesktop? + return static_cast<SPDesktop *>(_view); +} + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/helper/action-context.h b/src/helper/action-context.h new file mode 100644 index 000000000..bb538f413 --- /dev/null +++ b/src/helper/action-context.h @@ -0,0 +1,89 @@ +/** \file + * Inkscape UI action context implementation + *//* + * Author: + * Eric Greveson <eric@greveson.co.uk> + * + * Copyright (C) 2013 Eric Greveson + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_ACTION_CONTEXT_H +#define SEEN_INKSCAPE_ACTION_CONTEXT_H + +class SPDesktop; +class SPDocument; + +namespace Inkscape { + +class Selection; + +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI + +/** This structure contains all the document/view context required + for an action. Some actions may be executed on a document without + requiring a GUI, hence not providing the info directly through + Inkscape::UI::View::View. Actions that do require GUI objects should + check to see if the relevant pointers are NULL before attempting to + use them. + + TODO: we store a UI::View::View* because that's what the actions and verbs + used to take as parameters in their methods. Why is this? They almost + always seemed to cast straight to an SPDesktop* - so shouldn't we actually + be storing an SPDesktop*? Is there a case where a non-SPDesktop + UI::View::View is used by the actions? + + ActionContext is designed to be copyable, so it may be used with stack + storage if required. */ +class ActionContext { + // NB: Only one of these is typically set - selection model if in console mode, view if in GUI mode + Selection *_selection; /**< The selection model to which this action applies, if running in console mode. May be NULL. */ + UI::View::View *_view; /**< The view to which this action applies. May be NULL (e.g. if running in console mode). */ + +public: + /** Construct without any document or GUI */ + ActionContext(); + + /** Construct an action context for when the app is being run without + any GUI, i.e. in console mode */ + ActionContext(Selection *selection); + + /** Construct an action context for when the app is being run in GUI mode */ + ActionContext(UI::View::View *view); + + /** Get the document for the action context. May be NULL. Prefer this + function to getView()->doc() if the action doesn't require a GUI. */ + SPDocument *getDocument() const; + + /** Get the selection for the action context. May be NULL. Should be + non-NULL if getDocument() is non-NULL. */ + Selection *getSelection() const; + + /** Get the view for the action context. May be NULL. Guaranteed to be + NULL if running in console mode. */ + UI::View::View *getView() const; + + /** Get the desktop for the action context. May be NULL. Guaranteed to be + NULL if running in console mode. */ + SPDesktop *getDesktop() const; +}; + +} // namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 0e9957ca3..28cb40334 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -16,6 +16,7 @@ #include "debug/simple-event.h" #include "debug/event-tracker.h" #include "ui/view/view.h" +#include "desktop.h" #include "document.h" #include "helper/action.h" @@ -41,7 +42,7 @@ sp_action_init (SPAction *action) { action->sensitive = 0; action->active = 0; - action->view = NULL; + action->context = Inkscape::ActionContext(); action->id = action->name = action->tip = NULL; action->image = NULL; @@ -76,7 +77,7 @@ sp_action_finalize (GObject *object) * Create new SPAction object and set its properties. */ SPAction * -sp_action_new(Inkscape::UI::View::View *view, +sp_action_new(Inkscape::ActionContext const &context, const gchar *id, const gchar *name, const gchar *tip, @@ -85,7 +86,7 @@ sp_action_new(Inkscape::UI::View::View *view, { SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); - action->view = view; + action->context = context; action->sensitive = TRUE; action->id = g_strdup (id); action->name = g_strdup (name); @@ -111,11 +112,9 @@ public: : ActionEventBase(share_static_string("action")) { _addProperty(share_static_string("timestamp"), timestamp()); - if (action->view) { - SPDocument *document = action->view->doc(); - if (document) { - _addProperty(share_static_string("document"), document->serial()); - } + SPDocument *document = action->context.getDocument(); + if (document) { + _addProperty(share_static_string("document"), document->serial()); } _addProperty(share_static_string("verb"), action->id); } @@ -170,13 +169,47 @@ sp_action_set_name (SPAction *action, Glib::ustring const &name) } /** - * Return View associated with the action. + * Return Document associated with the action. + */ +SPDocument * +sp_action_get_document (SPAction *action) +{ + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getDocument(); +} + +/** + * Return Selection associated with the action + */ +Inkscape::Selection * +sp_action_get_selection (SPAction *action) +{ + g_return_val_if_fail (SP_IS_ACTION (action), NULL); + return action->context.getSelection(); +} + +/** + * Return View associated with the action, if any. */ Inkscape::UI::View::View * sp_action_get_view (SPAction *action) { g_return_val_if_fail (SP_IS_ACTION (action), NULL); - return action->view; + return action->context.getView(); +} + +/** + * Return Desktop associated with the action, if any. + */ +SPDesktop * +sp_action_get_desktop (SPAction *action) +{ + // TODO: this slightly horrible storage of a UI::View::View*, and + // casting to an SPDesktop*, is only done because that's what was + // already the norm in the Inkscape codebase. This seems wrong. Surely + // we should store an SPDesktop* in the first place? Is there a case + // of actions being carried out on a View that is not an SPDesktop? + return static_cast<SPDesktop *>(sp_action_get_view(action)); } /* diff --git a/src/helper/action.h b/src/helper/action.h index 0cd010b34..1f2de87b4 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -12,6 +12,7 @@ #ifndef SEEN_INKSCAPE_SP_ACTION_H #define SEEN_INKSCAPE_SP_ACTION_H +#include "helper/action-context.h" #include <sigc++/sigc++.h> #include <glibmm/ustring.h> #include <glib-object.h> @@ -24,8 +25,13 @@ struct SPActionClass; #define SP_ACTION_CLASS(o) (G_TYPE_CHECK_CLASS_CAST((o), SP_TYPE_ACTION, SPActionClass)) #define SP_IS_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION)) +class SPDesktop; +class SPDocument; namespace Inkscape { + +class Selection; class Verb; + namespace UI { namespace View { class View; @@ -39,7 +45,7 @@ class View; struct SPAction : public GObject { unsigned sensitive : 1; /**< Value to track whether the action is sensitive */ unsigned active : 1; /**< Value to track whether the action is active */ - Inkscape::UI::View::View *view; /**< The View to which this action is attached */ + Inkscape::ActionContext context; /**< The context (doc/view) to which this action is attached */ gchar *id; /**< The identifier for the action */ gchar *name; /**< Full text name of the action */ gchar *tip; /**< A tooltip to describe the action */ @@ -59,7 +65,7 @@ struct SPActionClass { GType sp_action_get_type(); -SPAction *sp_action_new(Inkscape::UI::View::View *view, +SPAction *sp_action_new(Inkscape::ActionContext const &context, gchar const *id, gchar const *name, gchar const *tip, @@ -70,7 +76,10 @@ void sp_action_perform(SPAction *action, void *data); void sp_action_set_active(SPAction *action, unsigned active); void sp_action_set_sensitive(SPAction *action, unsigned sensitive); void sp_action_set_name(SPAction *action, Glib::ustring const &name); +SPDocument *sp_action_get_document(SPAction *action); +Inkscape::Selection *sp_action_get_selection(SPAction *action); Inkscape::UI::View::View *sp_action_get_view(SPAction *action); +SPDesktop *sp_action_get_desktop(SPAction *action); #endif diff --git a/src/helper/window.cpp b/src/helper/window.cpp index 444e1d8b0..cf6fb12ec 100644 --- a/src/helper/window.cpp +++ b/src/helper/window.cpp @@ -12,6 +12,11 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/window.h> #include "inkscape.h" diff --git a/src/inkscape-private.h b/src/inkscape-private.h index 09bcef12b..364e3dab6 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -48,8 +48,6 @@ void inkscape_add_desktop (SPDesktop * desktop); void inkscape_remove_desktop (SPDesktop * desktop); void inkscape_activate_desktop (SPDesktop * desktop); void inkscape_reactivate_desktop (SPDesktop * desktop); -void inkscape_add_document (SPDocument *document); -bool inkscape_remove_document (SPDocument *document); void inkscape_set_color (SPColor *color, float opacity); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index eca19c4b9..a24bd2b8a 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -19,6 +19,11 @@ #include <errno.h> #include <map> + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/messagedialog.h> #include "debug/simple-event.h" #include "debug/event-tracker.h" @@ -53,12 +58,14 @@ #include "extension/system.h" #include "inkscape-private.h" #include "io/sys.h" +#include "layer-model.h" #include "message-stack.h" #include "preferences.h" #include "resource-manager.h" #include "selection.h" #include "ui/dialog/debug.h" #include "xml/repr.h" +#include "helper/action-context.h" #include "helper/sp-marshal.h" static Inkscape::Application *inkscape = NULL; @@ -82,7 +89,7 @@ enum { LAST_SIGNAL }; -#define DESKTOP_IS_ACTIVE(d) ((d) == inkscape->desktops->data) +#define DESKTOP_IS_ACTIVE(d) (inkscape->desktops && ((d) == inkscape->desktops->data)) /*################################ @@ -100,10 +107,27 @@ static void inkscape_dispose (GObject *object); static void inkscape_activate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); static void inkscape_deactivate_desktop_private (Inkscape::Application *inkscape, SPDesktop *desktop); +class AppSelectionModel { + Inkscape::LayerModel _layer_model; + Inkscape::Selection *_selection; + +public: + AppSelectionModel(SPDocument *doc) { + _layer_model.setDocument(doc); + // TODO: is this really how we should manage the lifetime of the selection? + // I just copied this from the initialization of the Selection in SPDesktop. + // When and how is it actually released? + _selection = Inkscape::GC::release(new Inkscape::Selection(&_layer_model, NULL)); + } + + Inkscape::Selection *getSelection() const { return _selection; } +}; + struct Inkscape::Application { GObject object; Inkscape::XML::Document *menus; std::map<SPDocument *, int> document_set; + std::map<SPDocument *, AppSelectionModel *> selection_models; GSList *desktops; gchar *argv0; gboolean dialogs_toggle; @@ -476,6 +500,7 @@ inkscape_init (SPObject * object) } new (&inkscape->document_set) std::map<SPDocument *, int>(); + new (&inkscape->selection_models) std::map<SPDocument *, AppSelectionModel *>(); inkscape->menus = sp_repr_read_mem (_(menus_skeleton), MENUS_SKELETON_SIZE, NULL); inkscape->desktops = NULL; @@ -499,6 +524,7 @@ inkscape_dispose (GObject *object) inkscape->menus = NULL; } + inkscape->selection_models.~map(); inkscape->document_set.~map(); G_OBJECT_CLASS (parent_class)->dispose (object); @@ -1229,6 +1255,14 @@ inkscape_add_document (SPDocument *document) iter->second ++; } } + } else { + // insert succeeded, this document is new. Do we need to create a + // selection model for it, i.e. are we running without a desktop? + if (!inkscape->use_gui) { + // Create layer model and selection model so we can run some verbs without a GUI + g_assert(inkscape->selection_models.find(document) == inkscape->selection_models.end()); + inkscape->selection_models[document] = new AppSelectionModel(document); + } } } @@ -1248,6 +1282,13 @@ inkscape_remove_document (SPDocument *document) if (iter->second < 1) { // this was the last one, remove the pair from list inkscape->document_set.erase (iter); + + // also remove the selection model + std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(document); + if (sel_iter != inkscape->selection_models.end()) { + inkscape->selection_models.erase(sel_iter); + } + return true; } else { return false; @@ -1307,6 +1348,39 @@ inkscape_active_event_context (void) return NULL; } +Inkscape::ActionContext +inkscape_active_action_context() +{ + if (SP_ACTIVE_DESKTOP) { + return Inkscape::ActionContext(SP_ACTIVE_DESKTOP); + } + + SPDocument *doc = inkscape_active_document(); + if (!doc) { + return Inkscape::ActionContext(); + } + + return inkscape_action_context_for_document(doc); +} + +Inkscape::ActionContext +inkscape_action_context_for_document(SPDocument *doc) +{ + // If there are desktops, check them first to see if the document is bound to one of them + for (GSList *iter = inkscape->desktops ; iter ; iter = iter->next) { + SPDesktop *desktop=static_cast<SPDesktop *>(iter->data); + if (desktop->doc() == doc) { + return Inkscape::ActionContext(desktop); + } + } + + // Document is not associated with any desktops - maybe we're in command-line mode + std::map<SPDocument *, AppSelectionModel *>::iterator sel_iter = inkscape->selection_models.find(doc); + if (sel_iter == inkscape->selection_models.end()) { + return Inkscape::ActionContext(); + } + return Inkscape::ActionContext(sel_iter->second->getSelection()); +} /*##################### diff --git a/src/inkscape.h b/src/inkscape.h index 368c7fa60..234b98d2c 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -20,6 +20,7 @@ class SPDocument; struct SPEventContext; namespace Inkscape { + class ActionContext; struct Application; namespace XML { class Node; @@ -56,6 +57,21 @@ SPDocument * inkscape_active_document (void); #define SP_ACTIVE_DESKTOP inkscape_active_desktop () SPDesktop * inkscape_active_desktop (void); +// Use this function to get selection model etc for a document, if possible! +// The "active" alternative below has all the horrible static cling of a singleton. +Inkscape::ActionContext +inkscape_action_context_for_document(SPDocument *doc); + +// More horrible static cling... sorry about this. Should really replace all of +// the static stuff with a single instance of some kind of engine class holding +// all the document / non-GUI stuff, and an optional GUI class that behaves a +// bit like SPDesktop does currently. Then it will be easier to write good code +// that doesn't just expect a GUI all the time (like lots of the app currently +// does). +// Also, while the "active" document / desktop concepts are convenient, they +// appear to have been abused somewhat, further increasing static cling. +Inkscape::ActionContext inkscape_active_action_context(); + bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop); gchar *homedir_path(const char *filename); @@ -74,6 +90,11 @@ void inkscape_dialogs_toggle (); void inkscape_external_change (); void inkscape_subselection_changed (SPDesktop *desktop); +/* Moved document add/remove functions into public inkscape.h as they are used + (rightly or wrongly) by console-mode functions */ +void inkscape_add_document (SPDocument *document); +bool inkscape_remove_document (SPDocument *document); + /* * fixme: This has to be rethought */ diff --git a/src/interface.cpp b/src/interface.cpp index 3f480d5e8..df6831a96 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -52,6 +52,7 @@ #include "sp-namedview.h" #include "ui/view/view.h" #include "helper/action.h" +#include "helper/action-context.h" #include "helper/gnome-utils.h" #include "helper/window.h" #include "io/sys.h" @@ -369,13 +370,13 @@ sp_ui_menu_activate(void */*object*/, SPAction *action) static void sp_ui_menu_select_action(void */*object*/, SPAction *action) { - action->view->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, action->tip); + sp_action_get_view(action)->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, action->tip); } static void sp_ui_menu_deselect_action(void */*object*/, SPAction *action) { - action->view->tipsMessageContext()->clear(); + sp_action_get_view(action)->tipsMessageContext()->clear(); } static void @@ -418,7 +419,7 @@ sp_ui_dialog_title_string(Inkscape::Verb *verb, gchar *c) gchar *s; gchar *atitle; - action = verb->get_action(NULL); + action = verb->get_action(Inkscape::ActionContext()); if (!action) return; @@ -455,7 +456,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb } else { - action = verb->get_action(view); + action = verb->get_action(Inkscape::ActionContext(view)); if (!action) return NULL; if (radio) { @@ -669,7 +670,7 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * Inkscape::Verb *verb) { unsigned int shortcut = (verb) ? sp_shortcut_get_primary(verb) : 0; - SPAction *action = (verb) ? verb->get_action(view) : 0; + SPAction *action = (verb) ? verb->get_action(Inkscape::ActionContext(view)) : 0; GtkWidget *item = gtk_check_menu_item_new_with_mnemonic(action ? action->name : label); #if 0 @@ -954,7 +955,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); } if (verb->get_code() != SP_VERB_NONE) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); #if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(item), "draw", (GCallback) update_view_menu, (void *) action); #else @@ -964,7 +965,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } else if (menu_pntr->attribute("check") != NULL) { SPAction *action = NULL; if (verb->get_code() != SP_VERB_NONE) { - action = verb->get_action(view); + action = verb->get_action(Inkscape::ActionContext(view)); } sp_ui_menu_append_check_item_from_verb(GTK_MENU(menu), view, action->name, action->tip, NULL, checkitem_toggled, checkitem_update, verb); @@ -1670,7 +1671,7 @@ void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)// item->show(); append(*item); } else { - action = verb->get_action(view); + action = verb->get_action(Inkscape::ActionContext(view)); if (!action) { return; } @@ -2009,7 +2010,7 @@ void ContextMenu::MakeGroupMenu(void) void ContextMenu::ActivateGroup(void) { - sp_selection_group(_desktop); + sp_selection_group(_desktop->selection, _desktop); } void ContextMenu::ActivateUngroup(void) @@ -2058,7 +2059,7 @@ void ContextMenu::AnchorLinkFollow(void) // Opening the selected links with a python extension Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.inkscape.followlink" ); if (verb) { - SPAction *action = verb->get_action(_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); if (action) { sp_action_perform(action, NULL); } @@ -2228,7 +2229,7 @@ void ContextMenu::ImageEmbed(void) Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.embedselectedimages" ); if (verb) { - SPAction *action = verb->get_action(_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); if (action) { sp_action_perform(action, NULL); } @@ -2243,7 +2244,7 @@ void ContextMenu::ImageExtract(void) Inkscape::Verb *verb = Inkscape::Verb::getbyid( "org.ekips.filter.extractimage" ); if (verb) { - SPAction *action = verb->get_action(_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); if (action) { sp_action_perform(action, NULL); } diff --git a/src/interface.h b/src/interface.h index 2e9e7fc2e..13fbaf9ac 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,6 +17,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/menu.h> class SPItem; diff --git a/src/layer-model.cpp b/src/layer-model.cpp new file mode 100644 index 000000000..6833852ad --- /dev/null +++ b/src/layer-model.cpp @@ -0,0 +1,259 @@ +/* + * Editable view implementation + * + * Authors: + * Lauris Kaplinski <lauris@kaplinski.com> + * MenTaLguY <mental@rydia.net> + * bulia byak <buliabyak@users.sf.net> + * Ralf Stephan <ralf@ark.in-berlin.de> + * John Bintz <jcoswell@coswellproductions.org> + * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma + * + * Copyright (C) 2007 Jon A. Cruz + * Copyright (C) 2006-2008 Johan Engelen + * Copyright (C) 2006 John Bintz + * Copyright (C) 2004 MenTaLguY + * Copyright (C) 1999-2002 Lauris Kaplinski + * Copyright (C) 2000-2001 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "document.h" +#include "layer-fns.h" +#include "layer-model.h" +#include "object-hierarchy.h" +#include "sp-defs.h" +#include "sp-item.h" +#include "sp-item-group.h" +#include "sp-object.h" +#include "sp-root.h" +#include <glib.h> +#include <glibmm/i18n.h> +#include <sigc++/functors/ptr_fun.h> + +// Callbacks +static void _layer_activated(SPObject *layer, Inkscape::LayerModel *layer_model); +static void _layer_deactivated(SPObject *layer, Inkscape::LayerModel *layer_model); +static void _layer_changed(SPObject *top, SPObject *bottom, Inkscape::LayerModel *layer_model); + +namespace Inkscape { + +LayerModel::LayerModel() + : _doc( 0 ) + , _layer_hierarchy( 0 ) + , _display_key( 0 ) +{ +} + +LayerModel::~LayerModel() +{ + if (_layer_hierarchy) { + delete _layer_hierarchy; +// _layer_hierarchy = NULL; //this should be here, but commented to find other bug somewhere else. + } +} + +void LayerModel::setDocument(SPDocument *doc) +{ + _doc = doc; + if (_layer_hierarchy) { + _layer_hierarchy->clear(); + delete _layer_hierarchy; + } + _layer_hierarchy = new Inkscape::ObjectHierarchy(NULL); + _layer_hierarchy->connectAdded(sigc::bind(sigc::ptr_fun(_layer_activated), this)); + _layer_hierarchy->connectRemoved(sigc::bind(sigc::ptr_fun(_layer_deactivated), this)); + _layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_changed), this)); + _layer_hierarchy->setTop(doc->getRoot()); +} + +void LayerModel::setDisplayKey(unsigned int display_key) +{ + _display_key = display_key; +} + +SPDocument *LayerModel::getDocument() +{ + return _doc; +} + +/** + * Returns current root (=bottom) layer. + */ +SPObject *LayerModel::currentRoot() const +{ + return _layer_hierarchy ? _layer_hierarchy->top() : NULL; +} + +/** + * Returns current top layer. + */ +SPObject *LayerModel::currentLayer() const +{ + return _layer_hierarchy ? _layer_hierarchy->bottom() : NULL; +} + +/** + * Resets the bottom layer to the current root + */ +void LayerModel::reset() { + if (_layer_hierarchy) { + _layer_hierarchy->setBottom(currentRoot()); + } +} + +/** + * Sets the current layer of the desktop. + * + * Make \a object the top layer. + */ +void LayerModel::setCurrentLayer(SPObject *object) { + g_return_if_fail(SP_IS_GROUP(object)); + g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); + // printf("Set Layer to ID: %s\n", object->getId()); + _layer_hierarchy->setBottom(object); +} + +void LayerModel::toggleHideAllLayers(bool hide) { + + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + SP_ITEM(obj)->setHidden(hide); + } +} + +void LayerModel::toggleLockAllLayers(bool lock) { + + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), currentRoot()); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + SP_ITEM(obj)->setLocked(lock); + } +} + +void LayerModel::toggleLockOtherLayers(SPObject *object) { + g_return_if_fail(SP_IS_GROUP(object)); + g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); + + bool othersLocked = false; + std::vector<SPObject*> layers; + for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { + // Dont lock any ancestors, since that would in turn lock the layer as well + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersLocked |= !SP_ITEM(obj)->isLocked(); + } + } + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersLocked |= !SP_ITEM(obj)->isLocked(); + } + } + + SPItem *item = SP_ITEM(object); + if ( item->isLocked() ) { + item->setLocked(false); + } + + for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) { + SP_ITEM(*it)->setLocked(othersLocked); + } +} + + +void LayerModel::toggleLayerSolo(SPObject *object) { + g_return_if_fail(SP_IS_GROUP(object)); + g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); + + bool othersShowing = false; + std::vector<SPObject*> layers; + for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { + // Don't hide ancestors, since that would in turn hide the layer as well + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersShowing |= !SP_ITEM(obj)->isHidden(); + } + } + for ( SPObject* obj = Inkscape::previous_layer(currentRoot(), object); obj; obj = Inkscape::previous_layer(currentRoot(), obj) ) { + if (!obj->isAncestorOf(object)) { + layers.push_back(obj); + othersShowing |= !SP_ITEM(obj)->isHidden(); + } + } + + + SPItem *item = SP_ITEM(object); + if ( item->isHidden() ) { + item->setHidden(false); + } + + for ( std::vector<SPObject*>::iterator it = layers.begin(); it != layers.end(); ++it ) { + SP_ITEM(*it)->setHidden(othersShowing); + } +} + +/** + * Return layer that contains \a object. + */ +SPObject *LayerModel::layerForObject(SPObject *object) { + g_return_val_if_fail(object != NULL, NULL); + + SPObject *root=currentRoot(); + object = object->parent; + while ( object && object != root && !isLayer(object) ) { + // Objects in defs have no layer and are NOT in the root layer + if(SP_IS_DEFS(object)) + return NULL; + object = object->parent; + } + return object; +} + +/** + * True if object is a layer. + */ +bool LayerModel::isLayer(SPObject *object) const { + return ( SP_IS_GROUP(object) + && ( SP_GROUP(object)->effectiveLayerMode(_display_key) + == SPGroup::LAYER ) ); +} + +} // namespace Inkscape + + +/// Callback +static void +_layer_activated(SPObject *layer, Inkscape::LayerModel *layer_model) { + g_return_if_fail(SP_IS_GROUP(layer)); + layer_model->_layer_activated_signal.emit(layer); +} + +/// Callback +static void +_layer_deactivated(SPObject *layer, Inkscape::LayerModel *layer_model) { + g_return_if_fail(SP_IS_GROUP(layer)); + layer_model->_layer_deactivated_signal.emit(layer); +} + +/// Callback +static void +_layer_changed(SPObject *top, SPObject *bottom, Inkscape::LayerModel *layer_model) +{ + layer_model->_layer_changed_signal.emit (top, bottom); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/layer-model.h b/src/layer-model.h new file mode 100644 index 000000000..79b7fbe44 --- /dev/null +++ b/src/layer-model.h @@ -0,0 +1,104 @@ +#ifndef SEEN_INKSCAPE_LAYER_MODEL_H +#define SEEN_INKSCAPE_LAYER_MODEL_H + +/* + * Authors: + * Lauris Kaplinski <lauris@kaplinski.com> + * Frank Felfe <innerspace@iname.com> + * bulia byak <buliabyak@users.sf.net> + * Ralf Stephan <ralf@ark.in-berlin.de> + * John Bintz <jcoswell@coswellproductions.org> + * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> + * Jon A. Cruz <jon@joncruz.org>get + * Abhishek Sharma + * Eric Greveson <eric@greveson.co.uk> + * + * Copyright (C) 2007 Johan Engelen + * Copyright (C) 2006 John Bintz + * Copyright (C) 1999-2013 authors + * Copyright (C) 2000-2001 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stddef.h> +#include <sigc++/sigc++.h> + +class SPDocument; +class SPObject; + +namespace Inkscape { + +class ObjectHierarchy; + +namespace XML { + class Node; +} + +/** + * The layer model for a document. + * + * This class represents the layer model for a document, typically (but + * not necessarily) displayed in an SPDesktop. + * + * It also implements its own asynchronous notification signals that + * UI elements can listen to. + */ +class LayerModel +{ + SPDocument *_doc; + Inkscape::ObjectHierarchy *_layer_hierarchy; + unsigned int _display_key; + +public: + /** Construct a layer model */ + LayerModel(); + + /** Destructor */ + ~LayerModel(); + + // Set document + void setDocument(SPDocument *doc); + + // Set display key. For GUI apps. + void setDisplayKey(unsigned int display_key); + + // Get the document that this layer model refers to. May be NULL. + SPDocument *getDocument(); + + // TODO look into making these return a more specific subclass: + SPObject *currentRoot() const; + SPObject *currentLayer() const; + + void reset(); + void setCurrentLayer(SPObject *object); + void toggleLayerSolo(SPObject *object); + void toggleHideAllLayers(bool hide); + void toggleLockAllLayers(bool lock); + void toggleLockOtherLayers(SPObject *object); + SPObject *layerForObject(SPObject *object); + bool isLayer(SPObject *object) const; + + sigc::signal<void, SPObject *> _layer_activated_signal; + sigc::signal<void, SPObject *> _layer_deactivated_signal; + sigc::signal<void, SPObject *, SPObject *> _layer_changed_signal; +}; + +} // namespace Inkscape + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/libavoid/makefile b/src/libavoid/makefile deleted file mode 100644 index e4f83a52d..000000000 --- a/src/libavoid/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - - - -OBJEXT = o - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libavoid/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libavoid/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index c29444a33..130b1b03a 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -334,8 +334,8 @@ Shape::AddPoint (const Geom::Point x) pData[n].nextLinkedPoint = -1; pData[n].askForWindingS = NULL; pData[n].askForWindingB = -1; - pData[n].rx[0] = Round(p.x[0]); - pData[n].rx[1] = Round(p.x[1]); + pData[n].rx[0] = /*Round*/ (p.x[0]); + pData[n].rx[1] = /*Round*/ (p.x[1]); } if (_has_voronoi_data) { @@ -2116,8 +2116,8 @@ void Shape::initialisePointData() pData[i].pending = 0; pData[i].edgeOnLeft = -1; pData[i].nextLinkedPoint = -1; - pData[i].rx[0] = Round(getPoint(i).x[0]); - pData[i].rx[1] = Round(getPoint(i).x[1]); + pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); + pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); } _point_data_initialised = true; diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index dcd172da2..b999b9dca 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -266,10 +266,10 @@ public: // be careful when using this function // the coordinate rounding function - inline static double Round(double x) - { - return ldexp(rint(ldexp(x, 5)), -5); - } +// inline static double Round(double x) +// { +// return ldexp(rint(ldexp(x, 5)), -5); +// } // 2 miscannellous variations on it, to scale to and back the rounding grid inline static double HalfRound(double x) diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index a7e5a6cdc..5bb8a25ef 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -49,8 +49,8 @@ Shape::ConvertToForme (Path * dest) for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = Round (getPoint(i).x[0]); - pData[i].rx[1] = Round (getPoint(i).x[1]); + pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); + pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { @@ -199,8 +199,8 @@ Shape::ConvertToForme (Path * dest, int nbP, Path * *orig, bool splitWhenForced) for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = Round (getPoint(i).x[0]); - pData[i].rx[1] = Round (getPoint(i).x[1]); + pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); + pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { @@ -352,8 +352,8 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = Round (getPoint(i).x[0]); - pData[i].rx[1] = Round (getPoint(i).x[1]); + pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); + pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { @@ -374,6 +374,8 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in do { int dadContour=-1; + int childEdge = -1; + bool foundChild = false; int startBord = -1; { int fi = 0; @@ -389,6 +391,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in } else { dadContour = GPOINTER_TO_INT(swdData[askTo].misc); dadContour-=1; // pour compenser le decalage + childEdge = getPoint(fi).incidentEdge[FIRST]; } } lastPtUsed = fi + 1; @@ -407,6 +410,9 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in { // parcours en profondeur pour mettre les leF et riF a leurs valeurs swdData[startBord].misc = (void *)(intptr_t)(1 + nbNest); + if (startBord == childEdge) { + foundChild = true; + } //printf("part de %d\n",startBord); int curBord = startBord; bool back = false; @@ -444,22 +450,23 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in } else { - bool escapePath=false; - int tb=curBord; - while ( tb >= 0 && tb < numberOfEdges() ) { - if ( ebData[tb].pathID == wildPath ) { - escapePath=true; - break; - } - tb=swdData[tb].precParc; - } +// bool escapePath=false; +// int tb=curBord; +// while ( tb >= 0 && tb < numberOfEdges() ) { +// if ( ebData[tb].pathID == wildPath ) { +// escapePath=true; +// break; +// } +// tb=swdData[tb].precParc; +// } nesting=(int*)g_realloc(nesting,(nbNest+1)*sizeof(int)); contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int)); contStart[nbNest]=dest->descr_cmd.size(); - if ( escapePath ) { - nesting[nbNest++]=-1; // contient des bouts de coupure -> a part - } else { + if (foundChild) { nesting[nbNest++]=dadContour; + foundChild = false; + } else { + nesting[nbNest++]=-1; // contient des bouts de coupure -> a part } swdData[curBord].suivParc = -1; AddContour (dest, nbP, orig, startBord, curBord,splitWhenForced); @@ -484,24 +491,24 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in if ( getEdge(curBord).en == curStartPt ) { //printf("contour %i ",curStartPt); - bool escapePath=false; - int tb=curBord; - while ( tb >= 0 && tb < numberOfEdges() ) { - if ( ebData[tb].pathID == wildPath ) { - escapePath=true; - break; - } - tb=swdData[tb].precParc; - } +// bool escapePath=false; +// int tb=curBord; +// while ( tb >= 0 && tb < numberOfEdges() ) { +// if ( ebData[tb].pathID == wildPath ) { +// escapePath=true; +// break; +// } +// tb=swdData[tb].precParc; +// } nesting=(int*)g_realloc(nesting,(nbNest+1)*sizeof(int)); contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int)); contStart[nbNest]=dest->descr_cmd.size(); - if ( escapePath ) { - nesting[nbNest++]=-1; // contient des bouts de coupure -> a part - } else { + if (foundChild) { nesting[nbNest++]=dadContour; + foundChild = false; + } else { + nesting[nbNest++]=-1; // contient des bouts de coupure -> a part } - swdData[curBord].suivParc = -1; AddContour (dest, nbP, orig, startBord, curBord,splitWhenForced); startBord=nb; @@ -512,6 +519,9 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in swdData[nb].precParc = curBord; swdData[curBord].suivParc = nb; curBord = nb; + if (nb == childEdge) { + foundChild = true; + } //printf("suite %d\n",curBord); } } diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index c2fd83e31..ffe5a9d73 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -250,8 +250,8 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) } Geom::Point rPtX; - rPtX[0]= Round (ptX[0]); - rPtX[1]= Round (ptX[1]); + rPtX[0]= /*Round*/ (ptX[0]); + rPtX[1]= /*Round*/ (ptX[1]); int lastPointNo = -1; lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; @@ -1051,8 +1051,8 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) } Geom::Point rPtX; - rPtX[0]= Round (ptX[0]); - rPtX[1]= Round (ptX[1]); + rPtX[0]= /*Round*/ (ptX[0]); + rPtX[1]= /*Round*/ (ptX[1]); int lastPointNo = -1; lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 49660c91b..eaf9fe4a6 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -94,6 +94,10 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd bend_path.changed = false; } + if (uskeleton.empty()) { + return pwd2_in; /// \todo or throw an exception instead? might be better to throw an exception so that the UI can display an error message or smth + } + D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(pwd2_in); Piecewise<SBasis> x = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[1]) : Piecewise<SBasis>(patternd2[0]); Piecewise<SBasis> y = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]); @@ -105,9 +109,9 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd x-= bboxHorizontal.min(); y-= bboxVertical.middle(); - double scaling = uskeleton.cuts.back()/bboxHorizontal.extent(); + double scaling = uskeleton.cuts.back()/bboxHorizontal.extent(); - if (scaling != 1.0) { + if (scaling != 1.0) { x*=scaling; } @@ -117,7 +121,6 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd if (prop_scale != 1.0) y *= prop_scale; } - Piecewise<D2<SBasis> > output = compose(uskeleton,x) + y*compose(n,x); return output; } diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 71ab006d6..6e1d9476d 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -4,6 +4,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include "live_effects/parameter/originalpath.h" diff --git a/src/macros.h b/src/macros.h index 9a97820d8..b221ebdc2 100644 --- a/src/macros.h +++ b/src/macros.h @@ -35,12 +35,12 @@ #endif // keyboard modifiers in an event -#define MOD__SHIFT (event->key.state & GDK_SHIFT_MASK) -#define MOD__CTRL (event->key.state & GDK_CONTROL_MASK) -#define MOD__ALT (event->key.state & GDK_MOD1_MASK) -#define MOD__SHIFT_ONLY ((event->key.state & GDK_SHIFT_MASK) && !(event->key.state & GDK_CONTROL_MASK) && !(event->key.state & GDK_MOD1_MASK)) -#define MOD__CTRL_ONLY (!(event->key.state & GDK_SHIFT_MASK) && (event->key.state & GDK_CONTROL_MASK) && !(event->key.state & GDK_MOD1_MASK)) -#define MOD__ALT_ONLY (!(event->key.state & GDK_SHIFT_MASK) && !(event->key.state & GDK_CONTROL_MASK) && (event->key.state & GDK_MOD1_MASK)) +#define MOD__SHIFT(event) ((event)->key.state & GDK_SHIFT_MASK) +#define MOD__CTRL(event) ((event)->key.state & GDK_CONTROL_MASK) +#define MOD__ALT(event) ((event)->key.state & GDK_MOD1_MASK) +#define MOD__SHIFT_ONLY(event) (((event)->key.state & GDK_SHIFT_MASK) && !((event)->key.state & GDK_CONTROL_MASK) && !((event)->key.state & GDK_MOD1_MASK)) +#define MOD__CTRL_ONLY(event) (!((event)->key.state & GDK_SHIFT_MASK) && ((event)->key.state & GDK_CONTROL_MASK) && !((event)->key.state & GDK_MOD1_MASK)) +#define MOD__ALT_ONLY(event) (!((event)->key.state & GDK_SHIFT_MASK) && !((event)->key.state & GDK_CONTROL_MASK) && ((event)->key.state & GDK_MOD1_MASK)) /* Local Variables: diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 9f700292e..6af616e34 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -11,6 +11,7 @@ #include <desktop.h> #include <desktop-handles.h> #include <helper/action.h> +#include <helper/action-context.h> #include <selection.h> #include <verbs.h> #include <inkscape.h> @@ -41,7 +42,7 @@ CmdLineAction::~CmdLineAction () { } void -CmdLineAction::doIt (Inkscape::UI::View::View * view) { +CmdLineAction::doIt (ActionContext const & context) { //printf("Doing: %s\n", _arg); if (_isVerb) { Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); @@ -49,32 +50,33 @@ CmdLineAction::doIt (Inkscape::UI::View::View * view) { printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); return; } - SPAction * action = verb->get_action(view); + SPAction * action = verb->get_action(context); sp_action_perform(action, NULL); } else { - SPDesktop * desktop = dynamic_cast<SPDesktop *>(view); - if (desktop == NULL) { return; } + if (context.getDocument() == NULL || context.getSelection() == NULL) { return; } - SPDocument * doc = view->doc(); + SPDocument * doc = context.getDocument(); SPObject * obj = doc->getObjectById(_arg); if (obj == NULL) { printf(_("Unable to find node ID: '%s'\n"), _arg); return; } - Inkscape::Selection * selection = sp_desktop_selection(desktop); + Inkscape::Selection * selection = context.getSelection(); selection->add(obj, false); } return; } -void -CmdLineAction::doList (Inkscape::UI::View::View * view) { +bool +CmdLineAction::doList (ActionContext const & context) { + bool hasActions = !_list.empty(); for (std::list<CmdLineAction *>::iterator i = _list.begin(); i != _list.end(); ++i) { CmdLineAction * entry = *i; - entry->doIt(view); + entry->doIt(context); } + return hasActions; } bool @@ -87,8 +89,8 @@ CmdLineAction::idle (void) { for (std::list<SPDesktop *>::iterator i = desktops.begin(); i != desktops.end(); ++i) { SPDesktop * desktop = *i; - //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop); - doList(desktop); + //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop); + doList(ActionContext(desktop)); } return false; } diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h index 03f0eb0fc..fe11357fa 100644 --- a/src/main-cmdlineact.h +++ b/src/main-cmdlineact.h @@ -19,6 +19,8 @@ namespace Inkscape { +class ActionContext; + class CmdLineAction { bool _isVerb; gchar * _arg; @@ -29,8 +31,9 @@ public: CmdLineAction (bool isVerb, gchar const * arg); virtual ~CmdLineAction (); - void doIt (Inkscape::UI::View::View * view); - static void doList (Inkscape::UI::View::View * view); + void doIt (ActionContext const & context); + /** Return true if any actions were performed */ + static bool doList (ActionContext const & context); static bool idle (void); }; diff --git a/src/main.cpp b/src/main.cpp index e63373695..a01c56036 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,6 +60,8 @@ #include "macros.h" #include "file.h" #include "document.h" +#include "layer-model.h" +#include "selection.h" #include "sp-object.h" #include "interface.h" #include "print.h" @@ -84,6 +86,7 @@ #include "debug/logger.h" #include "debug/log-display-config.h" +#include "helper/action-context.h" #include "helper/png-write.h" #include "helper/geom.h" @@ -99,6 +102,11 @@ #endif // WIN32 #include "extension/init.h" +// Not ideal, but there doesn't appear to be a nicer system in place for +// passing command-line parameters to extensions before initialization... +#ifdef WITH_DBUS +#include "extension/dbus/dbus-init.h" +#endif // WITH_DBUS #include <glibmm/i18n.h> #include <glibmm/main.h> @@ -146,7 +154,9 @@ enum { SP_ARG_EXPORT_SVG, SP_ARG_EXPORT_PS, SP_ARG_EXPORT_EPS, + SP_ARG_EXPORT_PS_LEVEL, SP_ARG_EXPORT_PDF, + SP_ARG_EXPORT_PDF_VERSION, SP_ARG_EXPORT_LATEX, #ifdef WIN32 SP_ARG_EXPORT_EMF, @@ -163,6 +173,10 @@ enum { SP_ARG_SHELL, SP_ARG_VERSION, SP_ARG_VACUUM_DEFS, +#ifdef WITH_DBUS + SP_ARG_DBUS_LISTEN, + SP_ARG_DBUS_NAME, +#endif // WITH_DBUS SP_ARG_VERB_LIST, SP_ARG_VERB, SP_ARG_SELECT, @@ -199,7 +213,9 @@ static gboolean sp_export_id_only = FALSE; static gchar *sp_export_svg = NULL; static gchar *sp_export_ps = NULL; static gchar *sp_export_eps = NULL; +static gint sp_export_ps_level = 2; static gchar *sp_export_pdf = NULL; +static gchar *sp_export_pdf_version = NULL; #ifdef WIN32 static gchar *sp_export_emf = NULL; #endif //WIN32 @@ -214,7 +230,10 @@ static gboolean sp_query_all = FALSE; static gchar *sp_query_id = NULL; static gboolean sp_shell = FALSE; static gboolean sp_vacuum_defs = FALSE; - +#ifdef WITH_DBUS +static gboolean sp_dbus_listen = FALSE; +static gchar *sp_dbus_name = NULL; +#endif // WITH_DBUS static gchar *sp_export_png_utf8 = NULL; static gchar *sp_export_svg_utf8 = NULL; static gchar *sp_global_printer_utf8 = NULL; @@ -243,7 +262,9 @@ static void resetCommandlineGlobals() { sp_export_svg = NULL; sp_export_ps = NULL; sp_export_eps = NULL; + sp_export_ps_level = 2; sp_export_pdf = NULL; + sp_export_pdf_version = NULL; #ifdef WIN32 sp_export_emf = NULL; #endif //WIN32 @@ -257,6 +278,10 @@ static void resetCommandlineGlobals() { sp_query_all = FALSE; sp_query_id = NULL; sp_vacuum_defs = FALSE; +#ifdef WITH_DBUS + sp_dbus_listen = FALSE; + sp_dbus_name = NULL; +#endif // WITH_DBUS sp_export_png_utf8 = NULL; sp_export_svg_utf8 = NULL; @@ -380,11 +405,23 @@ struct poptOption options[] = { N_("Export document to an EPS file"), N_("FILENAME")}, + {"export-ps-level", 0, + POPT_ARG_INT, &sp_export_ps_level, SP_ARG_EXPORT_PS_LEVEL, + N_("Choose the PostScript Level used to export. Possible choices are" + " 2 (the default) and 3"), + N_("PS Level")}, + {"export-pdf", 'A', POPT_ARG_STRING, &sp_export_pdf, SP_ARG_EXPORT_PDF, N_("Export document to a PDF file"), N_("FILENAME")}, + {"export-pdf-version", 0, + POPT_ARG_STRING, &sp_export_pdf_version, SP_ARG_EXPORT_PDF_VERSION, + // TRANSLATORS: "--export-pdf-version" is an Inkscape command line option; see "inkscape --help" + N_("Export PDF to given version. (hint: make sure to input the exact string found in the PDF export dialog, e.g. \"PDF 1.4\" which is PDF-a conformant)"), + N_("PDF_VERSION")}, + {"export-latex", 0, POPT_ARG_NONE, &sp_export_latex, SP_ARG_EXPORT_LATEX, N_("Export PDF/PS/EPS without text. Besides the PDF/PS/EPS, a LaTeX file is exported, putting the text on top of the PDF/PS/EPS file. Include the result in LaTeX like: \\input{latexfile.tex}"), @@ -451,6 +488,18 @@ struct poptOption options[] = { POPT_ARG_NONE, &sp_vacuum_defs, SP_ARG_VACUUM_DEFS, N_("Remove unused definitions from the defs section(s) of the document"), NULL}, + +#ifdef WITH_DBUS + {"dbus-listen", 0, + POPT_ARG_NONE, &sp_dbus_listen, SP_ARG_DBUS_LISTEN, + N_("Enter a listening loop for D-Bus messages in console mode"), + NULL}, + + {"dbus-name", 0, + POPT_ARG_STRING, &sp_dbus_name, SP_ARG_DBUS_NAME, + N_("Specify the D-Bus bus name to listen for messages on (default is org.inkscape)"), + N_("BUS-NAME")}, +#endif // WITH_DBUS {"verb-list", 0, POPT_ARG_NONE, NULL, SP_ARG_VERB_LIST, @@ -709,6 +758,9 @@ main(int argc, char **argv) || !strcmp(argv[i], "-Y") || !strncmp(argv[i], "--query-y", 9) || !strcmp(argv[i], "--vacuum-defs") +#ifdef WITH_DBUS + || !strcmp(argv[i], "--dbus-listen") +#endif // WITH_DBUS || !strcmp(argv[i], "--shell") ) { @@ -845,6 +897,13 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) if ( sp_global_printer ) sp_global_printer_utf8 = g_strdup( sp_global_printer ); } + +#ifdef WITH_DBUS + // Before initializing extensions, we must set the DBus bus name if required + if (sp_dbus_name != NULL) { + Inkscape::Extension::Dbus::dbus_set_bus_name(sp_dbus_name); + } +#endif // Return the list if wanted, else free it up. if ( flDest ) { @@ -1016,6 +1075,17 @@ sp_main_gui(int argc, char const **argv) static int sp_process_file_list(GSList *fl) { int retVal = 0; +#ifdef WITH_DBUS + if (!fl) { + // If we've been asked to listen for D-Bus messages, enter a main loop here + // The main loop may be exited by calling "exit" on the D-Bus application interface. + if (sp_dbus_listen) { + Gtk::Main main_dbus_loop(0, NULL); + main_dbus_loop.run(); + } + } +#endif // WITH_DBUS + while (fl) { const gchar *filename = (gchar *)fl->data; @@ -1047,7 +1117,20 @@ static int sp_process_file_list(GSList *fl) if (sp_vacuum_defs) { doc->vacuumDocument(); } - if (sp_vacuum_defs && !sp_export_svg) { + + // Execute command-line actions (selections and verbs) using our local models + bool has_performed_actions = Inkscape::CmdLineAction::doList(inkscape_active_action_context()); + +#ifdef WITH_DBUS + // If we've been asked to listen for D-Bus messages, enter a main loop here + // The main loop may be exited by calling "exit" on the D-Bus application interface. + if (sp_dbus_listen) { + Gtk::Main main_dbus_loop(0, NULL); + main_dbus_loop.run(); + } +#endif // WITH_DBUS + + if (!sp_export_svg && (sp_vacuum_defs || has_performed_actions)) { // save under the name given in the command line sp_repr_save_file(doc->rdoc, filename, SP_SVG_NS_URI); } @@ -1213,7 +1296,11 @@ int sp_main_console(int argc, char const **argv) int retVal = sp_common_main( argc, argv, &fl ); g_return_val_if_fail(retVal == 0, 1); - if (fl == NULL && !sp_shell) { + if (fl == NULL && !sp_shell +#ifdef WITH_DBUS + && !sp_dbus_listen +#endif // WITH_DBUS + ) { g_print("Nothing to do!\n"); exit(0); } @@ -1637,12 +1724,54 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } (*i)->set_param_float("bleed", margin); + // handle --export-pdf-version + if (g_strcmp0(mime, "application/pdf") == 0) { + bool set_export_pdf_version_fail=true; + const gchar *pdfver_param_name="PDFversion"; + if(sp_export_pdf_version) { + // combine "PDF " and the given command line + std::string version_gui_string=std::string("PDF ")+sp_export_pdf_version; + try{ + // first, check if the given pdf version is selectable in the ComboBox + if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { + (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); + set_export_pdf_version_fail=false; + } else { + g_warning("Desired PDF export version \"%s\" not supported! Hint: input one of the versions found in the pdf export dialog e.g. \"1.4\".", + sp_export_pdf_version); + } + } catch (...) { + // can be thrown along the way: + // throw Extension::param_not_exist(); + // throw Extension::param_not_enum_param(); + g_warning("Parameter or Enum \"%s\" might not exist",pdfver_param_name); + } + } + + // set default pdf export version to 1.4, also if something went wrong + if(set_export_pdf_version_fail) { + (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + } + } + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); return 1; } + if ( g_strcmp0(mime, "image/x-postscript") == 0 + || g_strcmp0(mime, "image/x-e-postscript") == 0 ) { + if ( sp_export_ps_level < 2 || sp_export_ps_level > 3 ) { + g_warning("Only supported PostScript levels are 2 and 3." + " Defaulting to 2."); + sp_export_ps_level = 2; + } + + (*i)->set_param_enum("PSlevel", (sp_export_ps_level == 3) + ? "PostScript level 3" : "PostScript level 2"); + } + (*i)->save(doc, uri); return 0; } diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 694619089..77e781763 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -199,10 +199,6 @@ static char const menus_skeleton[] = " <verb verb-id=\"ObjectsToPattern\" />\n" " <verb verb-id=\"ObjectsFromPattern\" />\n" " </submenu>\n" -" <submenu name=\"" N_("Symbo_l") "\">\n" -" <verb verb-id=\"ObjectsToSymbol\" />\n" -" <verb verb-id=\"ObjectsFromSymbol\" />\n" -" </submenu>\n" " <verb verb-id=\"ObjectsToMarker\" />\n" " <verb verb-id=\"ObjectsToGuides\" />\n" " <separator/>\n" diff --git a/src/mesh-context.cpp b/src/mesh-context.cpp index c7cf60d06..fce4cbb9a 100644 --- a/src/mesh-context.cpp +++ b/src/mesh-context.cpp @@ -728,7 +728,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_A: case GDK_KEY_a: - if (MOD__CTRL_ONLY && drag->isNonEmpty()) { + if (MOD__CTRL_ONLY(event) && drag->isNonEmpty()) { drag->selectAll(); ret = TRUE; } @@ -748,17 +748,17 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_Left: // move handle left case GDK_KEY_KP_Left: case GDK_KEY_KP_4: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(mul*-10, 0); // shift } else { drag->selected_move_screen(mul*-1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(mul*-10*nudge, 0); // shift } else { drag->selected_move(mul*-nudge, 0); // no shift @@ -772,17 +772,17 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_Up: // move handle up case GDK_KEY_KP_Up: case GDK_KEY_KP_8: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(0, mul*10); // shift } else { drag->selected_move_screen(0, mul*1); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(0, mul*10*nudge); // shift } else { drag->selected_move(0, mul*nudge); // no shift @@ -796,17 +796,17 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_Right: // move handle right case GDK_KEY_KP_Right: case GDK_KEY_KP_6: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(mul*10, 0); // shift } else { drag->selected_move_screen(mul*1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(mul*10*nudge, 0); // shift } else { drag->selected_move(mul*nudge, 0); // no shift @@ -820,17 +820,17 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_Down: // move handle down case GDK_KEY_KP_Down: case GDK_KEY_KP_2: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { drag->selected_move_screen(0, mul*-10); // shift } else { drag->selected_move_screen(0, mul*-1); // no shift } } else { // no alt - if (MOD__SHIFT) { + if (MOD__SHIFT(event)) { drag->selected_move(0, mul*-10*nudge); // shift } else { drag->selected_move(0, mul*-nudge); // no shift @@ -862,7 +862,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_b: // Toggle mesh side between lineto and curveto. case GDK_KEY_B: - if (MOD__ALT && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_mesh_context_corner_operation ( this, MG_CORNER_SIDE_TOGGLE ); ret = TRUE; } @@ -870,7 +870,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_c: // Convert mesh side from generic Bezier to Bezier approximating arc, case GDK_KEY_C: // preserving handle direction. - if (MOD__ALT && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_mesh_context_corner_operation ( this, MG_CORNER_SIDE_ARC ); ret = TRUE; } @@ -878,7 +878,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_g: // Toggle mesh tensor points on/off case GDK_KEY_G: - if (MOD__ALT && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_mesh_context_corner_operation ( this, MG_CORNER_TENSOR_TOGGLE ); ret = TRUE; } @@ -886,7 +886,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_j: // Smooth corner color case GDK_KEY_J: - if (MOD__ALT && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_mesh_context_corner_operation ( this, MG_CORNER_COLOR_SMOOTH ); ret = TRUE; } @@ -894,7 +894,7 @@ gint SPMeshContext::root_handler(GdkEvent* event) { case GDK_KEY_k: // Pick corner color case GDK_KEY_K: - if (MOD__ALT && drag->isNonEmpty() && drag->hasSelection()) { + if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { sp_mesh_context_corner_operation ( this, MG_CORNER_COLOR_PICK ); ret = TRUE; } diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 67c097067..b192904ce 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -382,6 +382,14 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec } if (SP_IS_PATH(item) && !SP_SHAPE(item)->_curve_before_lpe) { + // remove connector attributes + if (item->getAttribute("inkscape:connector-type") != NULL) { + item->removeAttribute("inkscape:connection-start"); + item->removeAttribute("inkscape:connection-end"); + item->removeAttribute("inkscape:connector-type"); + item->removeAttribute("inkscape:connector-curvature"); + did = true; + } continue; // already a path, and no path effect } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 4281fdc54..21fc4fc51 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -944,13 +944,13 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_KEY_Left: // move last point left case GDK_KEY_KP_Left: - if (!MOD__CTRL) { // not ctrl - if (MOD__ALT) { // alt - if (MOD__SHIFT) pen_lastpoint_move_screen(pc, -10, 0); // shift + if (!MOD__CTRL(event)) { // not ctrl + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) pen_lastpoint_move_screen(pc, -10, 0); // shift else pen_lastpoint_move_screen(pc, -1, 0); // no shift } else { // no alt - if (MOD__SHIFT) pen_lastpoint_move(pc, -10*nudge, 0); // shift + if (MOD__SHIFT(event)) pen_lastpoint_move(pc, -10*nudge, 0); // shift else pen_lastpoint_move(pc, -nudge, 0); // no shift } ret = TRUE; @@ -958,13 +958,13 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; case GDK_KEY_Up: // move last point up case GDK_KEY_KP_Up: - if (!MOD__CTRL) { // not ctrl - if (MOD__ALT) { // alt - if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, 10); // shift + if (!MOD__CTRL(event)) { // not ctrl + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) pen_lastpoint_move_screen(pc, 0, 10); // shift else pen_lastpoint_move_screen(pc, 0, 1); // no shift } else { // no alt - if (MOD__SHIFT) pen_lastpoint_move(pc, 0, 10*nudge); // shift + if (MOD__SHIFT(event)) pen_lastpoint_move(pc, 0, 10*nudge); // shift else pen_lastpoint_move(pc, 0, nudge); // no shift } ret = TRUE; @@ -972,13 +972,13 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; case GDK_KEY_Right: // move last point right case GDK_KEY_KP_Right: - if (!MOD__CTRL) { // not ctrl - if (MOD__ALT) { // alt - if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 10, 0); // shift + if (!MOD__CTRL(event)) { // not ctrl + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) pen_lastpoint_move_screen(pc, 10, 0); // shift else pen_lastpoint_move_screen(pc, 1, 0); // no shift } else { // no alt - if (MOD__SHIFT) pen_lastpoint_move(pc, 10*nudge, 0); // shift + if (MOD__SHIFT(event)) pen_lastpoint_move(pc, 10*nudge, 0); // shift else pen_lastpoint_move(pc, nudge, 0); // no shift } ret = TRUE; @@ -986,13 +986,13 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; case GDK_KEY_Down: // move last point down case GDK_KEY_KP_Down: - if (!MOD__CTRL) { // not ctrl - if (MOD__ALT) { // alt - if (MOD__SHIFT) pen_lastpoint_move_screen(pc, 0, -10); // shift + if (!MOD__CTRL(event)) { // not ctrl + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) pen_lastpoint_move_screen(pc, 0, -10); // shift else pen_lastpoint_move_screen(pc, 0, -1); // no shift } else { // no alt - if (MOD__SHIFT) pen_lastpoint_move(pc, 0, -10*nudge); // shift + if (MOD__SHIFT(event)) pen_lastpoint_move(pc, 0, -10*nudge); // shift else pen_lastpoint_move(pc, 0, -nudge); // no shift } ret = TRUE; @@ -1002,7 +1002,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) /*TODO: this is not yet enabled?? looks like some traces of the Geometry tool case GDK_KEY_P: case GDK_KEY_p: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PARALLEL, 2); ret = TRUE; } @@ -1010,7 +1010,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_KEY_C: case GDK_KEY_c: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::CIRCLE_3PTS, 3); ret = TRUE; } @@ -1018,7 +1018,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_KEY_B: case GDK_KEY_b: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PERP_BISECTOR, 2); ret = TRUE; } @@ -1026,7 +1026,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_KEY_A: case GDK_KEY_a: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::ANGLE_BISECTOR, 3); ret = TRUE; } @@ -1035,14 +1035,14 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) case GDK_KEY_U: case GDK_KEY_u: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { pen_lastpoint_tocurve(pc); ret = TRUE; } break; case GDK_KEY_L: case GDK_KEY_l: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { pen_lastpoint_toline(pc); ret = TRUE; } @@ -1064,7 +1064,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__CTRL_ONLY && pc->npoints != 0) { + if (MOD__CTRL_ONLY(event) && pc->npoints != 0) { // if drawing, cancel, otherwise pass it up for undo pen_cancel (pc); ret = TRUE; @@ -1072,7 +1072,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) break; case GDK_KEY_g: case GDK_KEY_G: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_selection_to_guides(SP_EVENT_CONTEXT(pc)->desktop); ret = true; } diff --git a/src/pixmaps/cursor-tweak-less.xpm b/src/pixmaps/cursor-tweak-less.xpm new file mode 100644 index 000000000..6c065ba62 --- /dev/null +++ b/src/pixmaps/cursor-tweak-less.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_less_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. ", +" ... ", +" .. .. ", +" .+. .+. ", +" .+. .+. ", +" .+. .+. ", +" .+. ...... .+. ", +" .+..++++..+. ", +" .+++ +++. ", +" ..+ . . +.. ", +" .++.+..+.++. ", +" .+ .++. +. ", +" .+ .++. +. ", +" .++.+..+.++. ", +" ..+ . . +.. ", +" .+++ +++. ", +" .+..++++..+. ", +" .+. ...... .+. ", +" .+. .+. ", +" .+. .+. ", +" .+. .+. ", +" .. .. ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-more.xpm b/src/pixmaps/cursor-tweak-more.xpm new file mode 100644 index 000000000..0e80bb9c5 --- /dev/null +++ b/src/pixmaps/cursor-tweak-more.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_more_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ...... ", +" .+. ..++++.. ", +"....+.... .+++..+++. ", +".+++ +++. ..+.. ..+.. ", +"....+.... .++. .++. ", +" .+. .+. .+. ", +" .+. .+. .+. ", +" ... .++. .++. ", +" ..+.. ..+.. ", +" .+++..+++. ", +" ..++++.. ", +" ... .+ ...... .. ", +" .+. .+. .+. ", +" .+..+. +. .+. .+ ", +" .+.+. .+..+..+. ", +" .++.... .+.+.+. ", +" .+++++. .+++. ", +" ...... .+. ", +" ...... . ", +" ..++++.. ...... ", +" .+++..+++. ..++++.. ", +" ..+.. ..+.. .+++..+++. ", +" .++. .++. ..+.. ..+..", +" .+. .+. .++. .++.", +" .+. .+. .+. .+.", +" .++. .++. .+. .+.", +" ..+.. ..+.. .++. .++.", +" .+++..+++. ..+.. ..+..", +" ..++++.. .+++..+++. ", +" ...... ..++++.. ", +" ...... "}; diff --git a/src/pixmaps/cursor-tweak-move-in.xpm b/src/pixmaps/cursor-tweak-move-in.xpm new file mode 100644 index 000000000..11ee4c3e1 --- /dev/null +++ b/src/pixmaps/cursor-tweak-move-in.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_move_in_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. ", +" ... ........ ", +" .+++++++ ", +" .+++ ", +" .++++ ", +" .+.+++ ", +" .+..+++ ", +" .+...+++ ", +" .+. ..+++ ", +" .. ..+++ ", +" ..+++ ", +" ..+++ ", +" ..+++ ", +" ..++ ", +" ... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-move-jitter.xpm b/src/pixmaps/cursor-tweak-move-jitter.xpm new file mode 100644 index 000000000..1f2b1d26a --- /dev/null +++ b/src/pixmaps/cursor-tweak-move-jitter.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_move_jitter_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. + ", +" .+. +++ ", +"....+.... +.+.+ +++++++ ", +".+++ +++. +..+ .+ ....+++ ", +"....+.... . .+ . ++.+ ", +" .+. .+ ++..+ ", +" .+. .+ ++. .+ ", +" ... ++. .+ ", +" ++. .+ ", +" ++ +. .. ", +" .++ ", +" ..++ ", +" ..++ ", +" ..++ ", +" ..++ + ", +" ..++ + ", +" .. ..++ + ", +" .. .++ ..++ + ", +" +. ..++ ..+++ ", +" +. .++ ..++ .+ ", +" +..++ .+++++++. .+ ", +" +.++ ......... .+ ", +" +++ .+ ", +" ++..... + .+ + ", +" +++++++ + .+.+ +. ", +" +. .+++. ", +" +. .+. ", +" .+++++ . ", +" .+... ", +" .+ ", +" .+ "}; diff --git a/src/pixmaps/cursor-tweak-move-out.xpm b/src/pixmaps/cursor-tweak-move-out.xpm new file mode 100644 index 000000000..7d4569dfe --- /dev/null +++ b/src/pixmaps/cursor-tweak-move-out.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_move_out_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ", +" .+. ", +" .+. ", +" ... ", +" ", +" ++ ", +" +++ ", +" .+++ ", +" ..+++ ", +" ..+++ ", +" ..+++ + ", +" ..+++ + ", +" ..+++ + ", +" ..+++ + ", +" ..++++ ", +" ..+++ ", +" .+++++++. ", +" ......... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-move.xpm b/src/pixmaps/cursor-tweak-move.xpm index 2bb1391e3..e44028f6c 100644 --- a/src/pixmaps/cursor-tweak-move.xpm +++ b/src/pixmaps/cursor-tweak-move.xpm @@ -7,29 +7,29 @@ static char const * cursor_tweak_move_xpm[] = { " ... ", " .+. ", " .+. ", -"....+.... ", -".+++ +++. ", -"....+.... ", -" .+. ", -" .+. ", -" ... ", -" ... ... ... ... ", -" ..+. ..+. ..+. ..+. ", -" .+++ .+++ .+++ .+++ ", -" ..+. .+++ .+++ ..+ ", -" .... .+++ .+++ .... ", -" ..+. ..+ ..+ ..+. ", -" .+++ ..+. ..+. .+++ ", -" ..+ .+++ .+++ ..+ ", -" .... ..+ ..+ .... ", -" ..+. .... .... ..+. ", -" .+++ ..+. ..+. .+++ ", -" ..+ .+++ .+++ ..+ ", -" ..+ ..+ ", -" ... ... ", -" ..+. ..+. ", -" .+++ .+++ ", -" ..+ ..+ ", +"....+.... +++++++ ", +".+++ +++. ....+++ ", +"....+.... ++.+ ", +" .+. ++..+ ", +" .+. ++. .+ ", +" ... ++. .+ ", +" ++. .+ ", +" ++ +. .. ", +" .++ ", +" ..++ ", +" ..++ ", +" ..++ ", +" ..++ + ", +" ..++ + ", +" .. ..++ + ", +" .. .++ ..++ + ", +" +. ..++ ..+++ ", +" +. .++ ..++ ", +" +..++ .+++++++. ", +" +.++ ......... ", +" +++ ", +" ++..... ", +" +++++++ ", " ", " ", " ", diff --git a/src/pixmaps/cursor-tweak-rotate-clockwise.xpm b/src/pixmaps/cursor-tweak-rotate-clockwise.xpm new file mode 100644 index 000000000..20bad59af --- /dev/null +++ b/src/pixmaps/cursor-tweak-rotate-clockwise.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_rotate_clockwise_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. ", +"....+.... ... ", +" .+. .+. ", +" .+. .+. ", +" ... .+. ", +" .+. ", +" .+. ", +" .+. ", +" .+. ", +" .. .++. ", +" .+. .++.. ", +" .+. .++. ", +" .+. .++. ", +" .+......++. ", +" .+++++++++. ", +" .+........ ", +" .+. ", +" .+. ", +" .+. ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm b/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm new file mode 100644 index 000000000..c5fcc70e8 --- /dev/null +++ b/src/pixmaps/cursor-tweak-rotate-counterclockwise.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_rotate_counterclockwise_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +"....+.... ", +".+++ +++. . ", +"....+.... .+. ", +" .+. .+++. ", +" .+. .+.+.+. ", +" ... .+..+..+. ", +" .+. .+. .+. ", +" .. .+. .. ", +" .+. ", +" .+. ", +" .++. ", +" .++.. ", +" .++. ", +" .++. ", +" .........++. ", +" .+++++++++. ", +" ........... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-scale-down.xpm b/src/pixmaps/cursor-tweak-scale-down.xpm new file mode 100644 index 000000000..cfd804aab --- /dev/null +++ b/src/pixmaps/cursor-tweak-scale-down.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_scale_down_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. .++++++++++++ ", +"....+.... .+. + ", +".+++ +++. .+. + ", +"....+.... .+. + ", +" .+. .+. + ", +" .+. .+. + ", +" ... .+. + ", +" .+. + ", +" .+. + ", +" .+. + ", +" .+..........+ ", +" .++++++++++++ ", +" ............. ", +" ", +" +. ", +" +. ", +" .+ +. ", +" .+ +. ", +" .+ +. ", +" .++. ", +" .+++++ ", +" ..... ", +" .+++++ ", +" .+. + ", +" .+. + ", +" .+...+ ", +" .+++++ ", +" ...... ", +" ", +" "}; diff --git a/src/pixmaps/cursor-tweak-scale-up.xpm b/src/pixmaps/cursor-tweak-scale-up.xpm new file mode 100644 index 000000000..547346f4c --- /dev/null +++ b/src/pixmaps/cursor-tweak-scale-up.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static char const * cursor_tweak_scale_up_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. .++++++++++++ ", +"....+.... .+. + ", +".+++ +++. .+. + ", +"....+.... .+. + ", +" .+. .+. + ", +" .+. .+. + ", +" ... .+. + ", +" .+. + ", +" .+. + ", +" .+. + ", +" .+..........+ ", +" .++++++++++++ ", +" ............. ", +" ", +" +++++ ", +" ++ ", +" +.+ ", +" +..+ ", +" +. .+ ", +" +. . ", +" +. ", +" ", +" .+++++ ", +" .+. + ", +" .+. + ", +" .+...+ ", +" .+++++ ", +" ...... ", +" ", +" "}; diff --git a/src/pixmaps/handles.xpm b/src/pixmaps/handles.xpm index f2afa026b..b61ad377c 100644 --- a/src/pixmaps/handles.xpm +++ b/src/pixmaps/handles.xpm @@ -1,5 +1,5 @@ -/* XPM */ -static char const *handle_scale_nw_xpm[] = { +/* XPM North-West */ +static char const *handle_scale_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -18,28 +18,8 @@ static char const *handle_scale_nw_xpm[] = { " ....... ", " "}; -/* XPM */ -static char const *handle_scale_ne_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ....... ", -" ..+++. ", -" .++++. ", -" .+++++. ", -" . .+++++.. ", -" ...+++++... ", -" ..+++++. . ", -" .+++++. ", -" .++++. ", -" .+++.. ", -" ....... ", -" "}; - -/* XPM */ -static char const *handle_scale_h_xpm[] = { +/* XPM Vertical */ +static char const *handle_stretch_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -58,28 +38,8 @@ static char const *handle_scale_h_xpm[] = { " ", " "}; -/* XPM */ -static char const *handle_scale_v_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -" ..+++++.. ", -" .+++. ", -" .+++. ", -" .+++. ", -" ..+++++.. ", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_nw_xpm[] = { +/* XPM North-West */ +static char const *handle_rotate_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -98,8 +58,8 @@ static char const *handle_rotate_nw_xpm[] = { " ... ", " . "}; -/* XPM */ -static char const *handle_rotate_n_xpm[] = { +/* XPM North */ +static char const *handle_skew_xpm[] = { "13 13 3 1", " c None", ". c #000000", @@ -119,127 +79,6 @@ static char const *handle_rotate_n_xpm[] = { " "}; /* XPM */ -static char const *handle_rotate_ne_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" .. ", -" .... ", -" ..++... ", -"..++++++. ", -" .+++++++. ", -" .+..++++. ", -" . .+++. ", -" .+++...", -" .++++.. ", -" .++.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_e_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -" ...+++...", -" .+++. ", -" .+++. ", -" .+++. ", -" ...+++...", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ -static char const *handle_rotate_se_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" .++.. ", -" .++++.. ", -" .+++...", -" . .+++. ", -" .+..++++. ", -" .+++++++. ", -"..++++++. ", -" ..++... ", -" .... ", -" .. ", -" . "}; - - -/* XPM */ -static char const *handle_rotate_s_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" ", -" . . ", -" .. .. ", -" ......... ", -" ..+++++++.. ", -"..+++++++++..", -" ..+++++++.. ", -" ......... ", -" .. .. ", -" . . "}; - -/* XPM */ -static char const *handle_rotate_sw_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..++. ", -" ..++++. ", -"...+++. ", -" .+++. . ", -" .++++..+. ", -" .+++++++. ", -" .++++++..", -" ...++.. ", -" .... ", -" .. ", -" . "}; - -/* XPM */ -static char const *handle_rotate_w_xpm[] = { -"13 13 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" . ", -" ... ", -" ..+.. ", -" ..+++.. ", -"...+++... ", -" .+++. ", -" .+++. ", -" .+++. ", -"...+++. . ", -" ..+++.. ", -" ..+.. ", -" ... ", -" . "}; - -/* XPM */ static char const *handle_center_xpm[] = { "13 13 3 1", " c None", @@ -258,3 +97,4 @@ static char const *handle_center_xpm[] = { " . ", " . ", " "}; + diff --git a/src/rdf.cpp b/src/rdf.cpp index 017de42c1..72aea4898 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -202,8 +202,8 @@ struct rdf_license_t rdf_licenses [] = { rdf_license_cc_a_nc_nd, }, - { N_("Public Domain"), - "http://creativecommons.org/licenses/publicdomain/", + { N_("CC0 Public Domain Dedication"), + "http://creativecommons.org/publicdomain/zero/1.0/", rdf_license_pd, }, diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 441b573f0..f93ddf6c3 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -310,13 +310,13 @@ gint SPRectContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-rect"); ret = TRUE; } @@ -324,7 +324,7 @@ gint SPRectContext::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_selection_to_guides(desktop); ret = true; } @@ -358,7 +358,7 @@ gint SPRectContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/selcue.cpp b/src/selcue.cpp index 4c35307f7..3f8a93e21 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -25,8 +25,20 @@ #include "preferences.h" #include "selcue.h" +Inkscape::SelCue::BoundingBoxPrefsObserver::BoundingBoxPrefsObserver(SelCue &sel_cue) : + Observer("/tools/bounding_box"), + _sel_cue(sel_cue) +{ +} + +void Inkscape::SelCue::BoundingBoxPrefsObserver::notify(Preferences::Entry const &val) +{ + _sel_cue._boundingBoxPrefsChanged(static_cast<int>(val.getBool())); +} + Inkscape::SelCue::SelCue(SPDesktop *desktop) - : _desktop(desktop) + : _desktop(desktop), + _bounding_box_prefs_observer(*this) { _selection = sp_desktop_selection(_desktop); @@ -34,11 +46,16 @@ Inkscape::SelCue::SelCue(SPDesktop *desktop) sigc::hide(sigc::mem_fun(*this, &Inkscape::SelCue::_newItemBboxes)) ); - _sel_modified_connection = _selection->connectModified( - sigc::hide(sigc::hide(sigc::mem_fun(*this, &Inkscape::SelCue::_updateItemBboxes))) + { + void(SelCue::*modifiedSignal)() = &SelCue::_updateItemBboxes; + _sel_modified_connection = _selection->connectModified( + sigc::hide(sigc::hide(sigc::mem_fun(*this, modifiedSignal))) ); + } - _updateItemBboxes(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _updateItemBboxes(prefs); + prefs->addObserver(_bounding_box_prefs_observer); } Inkscape::SelCue::~SelCue() @@ -59,7 +76,11 @@ Inkscape::SelCue::~SelCue() void Inkscape::SelCue::_updateItemBboxes() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _updateItemBboxes(Inkscape::Preferences::get()); +} + +void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) +{ gint mode = prefs->getInt("/options/selcue/value", MARK); if (mode == NONE) { return; @@ -69,6 +90,11 @@ void Inkscape::SelCue::_updateItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); + _updateItemBboxes(mode, prefs_bbox); +} + +void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) +{ GSList const *items = _selection->itemList(); if (_item_bboxes.size() != g_slist_length((GSList *) items)) { _newItemBboxes(); @@ -201,6 +227,18 @@ void Inkscape::SelCue::_newTextBaselines() } } +void Inkscape::SelCue::_boundingBoxPrefsChanged(int prefs_bbox) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gint mode = prefs->getInt("/options/selcue/value", MARK); + if (mode == NONE) { + return; + } + + g_return_if_fail(_selection != NULL); + + _updateItemBboxes(mode, prefs_bbox); +} /* Local Variables: diff --git a/src/selcue.h b/src/selcue.h index f62ef768a..bcac7315f 100644 --- a/src/selcue.h +++ b/src/selcue.h @@ -37,10 +37,25 @@ public: }; private: + class BoundingBoxPrefsObserver: public Preferences::Observer + { + public: + BoundingBoxPrefsObserver(SelCue &sel_cue); + + void notify(Preferences::Entry const &val); + + private: + SelCue &_sel_cue; + }; + + friend class Inkscape::SelCue::BoundingBoxPrefsObserver; void _updateItemBboxes(); + void _updateItemBboxes(Inkscape::Preferences *prefs); + void _updateItemBboxes(gint mode, int prefs_bbox); void _newItemBboxes(); void _newTextBaselines(); + void _boundingBoxPrefsChanged(int prefs_bbox); SPDesktop *_desktop; Selection *_selection; @@ -48,6 +63,8 @@ private: sigc::connection _sel_modified_connection; std::vector<SPCanvasItem*> _item_bboxes; std::vector<SPCanvasItem*> _text_baselines; + + BoundingBoxPrefsObserver _bounding_box_prefs_observer; }; } diff --git a/src/select-context.cpp b/src/select-context.cpp index 365d2f905..4badac3d8 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -26,6 +26,7 @@ #include "document-undo.h" #include "selection.h" #include "sp-cursor.h" +#include "style.h" #include "pixmaps/cursor-select-m.xpm" #include "pixmaps/cursor-select-d.xpm" #include "pixmaps/handles.xpm" @@ -57,12 +58,6 @@ GdkPixbuf *handles[13]; static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect static gint drag_escaped = 0; // if non-zero, drag was canceled by esc - -//static gint xp = 0, yp = 0; // where drag started -//static gint tolerance = 0; -//static bool within_tolerance = false; - - #include "tool-factory.h" namespace { @@ -79,6 +74,17 @@ const std::string& SPSelectContext::getPrefsPath() { const std::string SPSelectContext::prefsPath = "/tools/select"; + +//Creates rotated variations for handles +static void +sp_load_handles(int start, int count, char const **xpm) { + handles[start] = gdk_pixbuf_new_from_xpm_data((gchar const **)xpm); + for(int i = start + 1; i < start + count; i++) { + // We use either the original at *start or previous loop item to rotate + handles[i] = gdk_pixbuf_rotate_simple(handles[i-1], GDK_PIXBUF_ROTATE_CLOCKWISE); + } +} + SPSelectContext::SPSelectContext() : SPEventContext() { this->grabbed = 0; this->item = 0; @@ -96,26 +102,27 @@ SPSelectContext::SPSelectContext() : SPEventContext() { this->_seltrans = NULL; this->_describer = NULL; + // cursors in select context CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1); CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1); // selection handles - handles[0] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_nw_xpm); - handles[1] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_ne_xpm); - handles[2] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_h_xpm); - handles[3] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_scale_v_xpm); - handles[4] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_nw_xpm); - handles[5] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_n_xpm); - handles[6] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_ne_xpm); - handles[7] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_e_xpm); - handles[8] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_se_xpm); - handles[9] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_s_xpm); - handles[10] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_sw_xpm); - handles[11] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_rotate_w_xpm); - handles[12] = gdk_pixbuf_new_from_xpm_data((gchar const **)handle_center_xpm); + sp_load_handles(0, 2, handle_scale_xpm); + sp_load_handles(2, 2, handle_stretch_xpm); + sp_load_handles(4, 4, handle_rotate_xpm); + sp_load_handles(8, 4, handle_skew_xpm); + sp_load_handles(12, 1, handle_center_xpm); } +static gint xp = 0, yp = 0; // where drag started +static gint tolerance = 0; +static bool within_tolerance = false; +static bool is_cycling = false; +static bool moved_while_cycling = false; +SPEventContext *prev_event_context = NULL; + + SPSelectContext::~SPSelectContext() { this->enableGrDrag(false); @@ -428,6 +435,26 @@ sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection * selection->set(item); } + +static void +sp_select_context_reset_opacities(SPEventContext *event_context) +{ + // SPDesktop *desktop = event_context->desktop; + SPSelectContext *sc = SP_SELECT_CONTEXT(event_context); + Inkscape::DrawingItem *arenaitem; + for (GList *l = sc->cycling_items; l != NULL; l = g_list_next(l)) { + arenaitem = SP_ITEM(l->data)->get_arenaitem(event_context->desktop->dkey); + arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value)); + } + g_list_free(sc->cycling_items); + g_list_free(sc->cycling_items_selected_before); + g_list_free(sc->cycling_items_cmp); + sc->cycling_items = NULL; + sc->cycling_items_selected_before = NULL; + sc->cycling_cur_item = NULL; + sc->cycling_items_cmp = NULL; +} + gint SPSelectContext::root_handler(GdkEvent* event) { SPItem *item = NULL; SPItem *item_at_point = NULL, *group_at_point = NULL, *item_in_group = NULL; @@ -510,8 +537,15 @@ gint SPSelectContext::root_handler(GdkEvent* event) { } break; - case GDK_MOTION_NOTIFY: { - tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); + case GDK_MOTION_NOTIFY: + { + if (is_cycling) + { + moved_while_cycling = true; + prev_event_context = this; + } + + tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); if ((event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) { Geom::Point const motion_pt(event->motion.x, event->motion.y); @@ -769,6 +803,15 @@ gint SPSelectContext::root_handler(GdkEvent* event) { GdkEventScroll *scroll_event = (GdkEventScroll*) event; if (scroll_event->state & GDK_MOD1_MASK) { // alt modified pressed + if (moved_while_cycling) + { + moved_while_cycling = false; + sp_select_context_reset_opacities(prev_event_context); + prev_event_context = NULL; + } + + is_cycling = true; + bool shift_pressed = scroll_event->state & GDK_SHIFT_MASK; /* Rebuild list of items underneath the mouse pointer */ @@ -850,6 +893,13 @@ gint SPSelectContext::root_handler(GdkEvent* event) { sp_select_context_cycle_through_items(this, selection, scroll_event, shift_pressed); ret = TRUE; + + GtkWindow *w =GTK_WINDOW(gtk_widget_get_toplevel( GTK_WIDGET(desktop->canvas) )); + if (w) + { + gtk_window_present(w); + gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas)); + } } break; } @@ -860,7 +910,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { { guint keyval = get_group0_keyval(&event->key); - bool alt = ( MOD__ALT + bool alt = ( MOD__ALT(event) || (keyval == GDK_KEY_Alt_L) || (keyval == GDK_KEY_Alt_R) || (keyval == GDK_KEY_Meta_L) @@ -902,20 +952,20 @@ gint SPSelectContext::root_handler(GdkEvent* event) { switch (get_group0_keyval (&event->key)) { case GDK_KEY_Left: // move selection left case GDK_KEY_KP_Left: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { - sp_selection_move_screen(desktop, mul*-10, 0); // shift + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { + sp_selection_move_screen(sp_desktop_selection(desktop), mul*-10, 0); // shift } else { - sp_selection_move_screen(desktop, mul*-1, 0); // no shift + sp_selection_move_screen(sp_desktop_selection(desktop), mul*-1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { - sp_selection_move(desktop, mul*-10*nudge, 0); // shift + if (MOD__SHIFT(event)) { + sp_selection_move(sp_desktop_selection(desktop), mul*-10*nudge, 0); // shift } else { - sp_selection_move(desktop, mul*-nudge, 0); // no shift + sp_selection_move(sp_desktop_selection(desktop), mul*-nudge, 0); // no shift } } @@ -925,20 +975,20 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_Up: // move selection up case GDK_KEY_KP_Up: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { - sp_selection_move_screen(desktop, 0, mul*10); // shift + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { + sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*10); // shift } else { - sp_selection_move_screen(desktop, 0, mul*1); // no shift + sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*1); // no shift } } else { // no alt - if (MOD__SHIFT) { - sp_selection_move(desktop, 0, mul*10*nudge); // shift + if (MOD__SHIFT(event)) { + sp_selection_move(sp_desktop_selection(desktop), 0, mul*10*nudge); // shift } else { - sp_selection_move(desktop, 0, mul*nudge); // no shift + sp_selection_move(sp_desktop_selection(desktop), 0, mul*nudge); // no shift } } @@ -948,20 +998,20 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_Right: // move selection right case GDK_KEY_KP_Right: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { - sp_selection_move_screen(desktop, mul*10, 0); // shift + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { + sp_selection_move_screen(sp_desktop_selection(desktop), mul*10, 0); // shift } else { - sp_selection_move_screen(desktop, mul*1, 0); // no shift + sp_selection_move_screen(sp_desktop_selection(desktop), mul*1, 0); // no shift } } else { // no alt - if (MOD__SHIFT) { - sp_selection_move(desktop, mul*10*nudge, 0); // shift + if (MOD__SHIFT(event)) { + sp_selection_move(sp_desktop_selection(desktop), mul*10*nudge, 0); // shift } else { - sp_selection_move(desktop, mul*nudge, 0); // no shift + sp_selection_move(sp_desktop_selection(desktop), mul*nudge, 0); // no shift } } @@ -971,20 +1021,20 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_Down: // move selection down case GDK_KEY_KP_Down: - if (!MOD__CTRL) { // not ctrl + if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - if (MOD__ALT) { // alt - if (MOD__SHIFT) { - sp_selection_move_screen(desktop, 0, mul*-10); // shift + if (MOD__ALT(event)) { // alt + if (MOD__SHIFT(event)) { + sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*-10); // shift } else { - sp_selection_move_screen(desktop, 0, mul*-1); // no shift + sp_selection_move_screen(sp_desktop_selection(desktop), 0, mul*-1); // no shift } } else { // no alt - if (MOD__SHIFT) { - sp_selection_move(desktop, 0, mul*-10*nudge); // shift + if (MOD__SHIFT(event)) { + sp_selection_move(sp_desktop_selection(desktop), 0, mul*-10*nudge); // shift } else { - sp_selection_move(desktop, 0, mul*-nudge); // no shift + sp_selection_move(sp_desktop_selection(desktop), 0, mul*-nudge); // no shift } } @@ -1002,7 +1052,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_a: case GDK_KEY_A: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { sp_edit_select_all(desktop); ret = TRUE; } @@ -1019,17 +1069,17 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx"); ret = TRUE; } break; case GDK_KEY_bracketleft: - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask sp_selection_rotate_screen(selection, mul*1); - } else if (MOD__CTRL) { + } else if (MOD__CTRL(event)) { sp_selection_rotate(selection, 90); } else if (snaps) { sp_selection_rotate(selection, 180.0/snaps); @@ -1039,10 +1089,10 @@ gint SPSelectContext::root_handler(GdkEvent* event) { break; case GDK_KEY_bracketright: - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask sp_selection_rotate_screen(selection, -1*mul); - } else if (MOD__CTRL) { + } else if (MOD__CTRL(event)) { sp_selection_rotate(selection, -90); } else if (snaps) { sp_selection_rotate(selection, -180.0/snaps); @@ -1053,10 +1103,10 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_less: case GDK_KEY_comma: - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask sp_selection_scale_screen(selection, -2*mul); - } else if (MOD__CTRL) { + } else if (MOD__CTRL(event)) { sp_selection_scale_times(selection, 0.5); } else { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask @@ -1068,10 +1118,10 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_greater: case GDK_KEY_period: - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask sp_selection_scale_screen(selection, 2*mul); - } else if (MOD__CTRL) { + } else if (MOD__CTRL(event)) { sp_selection_scale_times(selection, 2); } else { gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask @@ -1082,7 +1132,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Return: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { if (selection->singleItem()) { SPItem *clicked_item = selection->singleItem(); @@ -1099,7 +1149,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { break; case GDK_KEY_BackSpace: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { sp_select_context_up_one_layer(desktop); ret = TRUE; } @@ -1107,7 +1157,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_s: case GDK_KEY_S: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { if (!selection->isEmpty()) { _seltrans->increaseState(); } @@ -1118,7 +1168,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: - if (MOD__SHIFT_ONLY) { + if (MOD__SHIFT_ONLY(event)) { sp_selection_to_guides(desktop); ret = true; } @@ -1135,7 +1185,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { this->defaultMessageContext()->clear(); } - bool alt = ( MOD__ALT + bool alt = ( MOD__ALT(event) || (keyval == GDK_KEY_Alt_L) || (keyval == GDK_KEY_Alt_R) || (keyval == GDK_KEY_Meta_L) @@ -1149,21 +1199,11 @@ gint SPSelectContext::root_handler(GdkEvent* event) { } else { if (alt) { // TODO: Should we have a variable like is_cycling or is it harmless to run this piece of code each time? // quit cycle-selection and reset opacities - Inkscape::DrawingItem *arenaitem; - - for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) { - arenaitem = SP_ITEM(l->data)->get_arenaitem(desktop->dkey); - arenaitem->setOpacity(1.0); - } - - g_list_free(this->cycling_items); - g_list_free(this->cycling_items_selected_before); - g_list_free(this->cycling_items_cmp); - - this->cycling_items = NULL; - this->cycling_items_selected_before = NULL; - this->cycling_cur_item = NULL; - this->cycling_items_cmp = NULL; + if (is_cycling) + { + sp_select_context_reset_opacities(this); + is_cycling = false; + } } } @@ -1187,6 +1227,7 @@ gint SPSelectContext::root_handler(GdkEvent* event) { return ret; } + /* Local Variables: mode:c++ diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index bea65a8e6..983742d32 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -35,6 +35,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "desktop.h" #include "desktop-style.h" #include "dir-util.h" +#include "layer-model.h" #include "selection.h" #include "tools-switch.h" #include "desktop-handles.h" @@ -124,6 +125,21 @@ because the layer manipulation code uses them. It should be rewritten specifical for that purpose. */ +// helper for printing error messages, regardless of whether we have a GUI or not +// If desktop == NULL, errors will be shown on stderr +static void +selection_display_message(SPDesktop *desktop, Inkscape::MessageType msgType, Glib::ustring const &msg) +{ + if (desktop) { + desktop->messageStack()->flash(msgType, msg); + } else { + if (msgType == Inkscape::IMMEDIATE_MESSAGE || + msgType == Inkscape::WARNING_MESSAGE || + msgType == Inkscape::ERROR_MESSAGE) { + g_printerr("%s\n", msg.c_str()); + } + } +} namespace Inkscape { @@ -250,6 +266,36 @@ void SelectionHelper::selectPrev(SPDesktop *dt) } } +/* + * Fixes the current selection, removing locked objects from it + */ +void SelectionHelper::fixSelection(SPDesktop *dt) +{ + if(!dt) + return; + + Inkscape::Selection *selection = sp_desktop_selection(dt); + + GSList *items = NULL; + + GSList const *selList = selection->itemList(); + + for( GSList const *i = selList; i; i = i->next ) { + if( SP_IS_ITEM(i->data) && + !dt->isLayer(SP_ITEM(i->data)) && + (!SP_ITEM(i->data)->isLocked())) + { + items = g_slist_prepend(items, SP_ITEM(i->data)); + } + } + + selection->setList(items); + + if(items) { + g_slist_free(items); + } +} + } // namespace Inkscape @@ -491,16 +537,16 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) g_slist_free(newsel); } -void sp_edit_clear_all(SPDesktop *dt) +void sp_edit_clear_all(Inkscape::Selection *selection) { - if (!dt) + if (!selection) return; - SPDocument *doc = sp_desktop_document(dt); - sp_desktop_selection(dt)->clear(); + SPDocument *doc = selection->layers()->getDocument(); + selection->clear(); - g_return_if_fail(SP_IS_GROUP(dt->currentLayer())); - GSList *items = sp_item_group_item_list(SP_GROUP(dt->currentLayer())); + g_return_if_fail(SP_IS_GROUP(selection->layers()->currentLayer())); + GSList *items = sp_item_group_item_list(SP_GROUP(selection->layers()->currentLayer())); while (items) { reinterpret_cast<SPObject*>(items->data)->deleteObject(); @@ -691,20 +737,14 @@ static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inksc group->setPosition(topmost + 1); } -void sp_selection_group(SPDesktop *desktop) +void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) { - if (desktop == NULL) { - return; - } - - SPDocument *doc = sp_desktop_document(desktop); + SPDocument *doc = selection->layers()->getDocument(); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::Selection *selection = sp_desktop_selection(desktop); - // Check if something is selected. if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group.")); return; } @@ -718,22 +758,17 @@ void sp_selection_group(SPDesktop *desktop) sp_selection_group_impl(p, group, xml_doc, doc); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, + DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, _("Group")); selection->set(group); Inkscape::GC::release(group); } -void sp_selection_ungroup(SPDesktop *desktop) +void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) { - if (desktop == NULL) - return; - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup.")); return; } @@ -754,8 +789,10 @@ void sp_selection_ungroup(SPDesktop *desktop) continue; } - /* We do not allow ungrouping <svg> etc. (lauris) */ - if (strcmp(group->getRepr()->name(), "svg:g") && strcmp(group->getRepr()->name(), "svg:switch")) { + // This check reflects the g_return_if_fail in sp_item_group_ungroup and + // may be a redundent. It also allows ungrouping of 'a' tags and we dont + if (strcmp(group->getRepr()->name(), "svg:g") && strcmp(group->getRepr()->name(), "svg:switch") && + strcmp(group->getRepr()->name(), "svg:svg")) { // keep the non-group item in the new selection new_select = g_slist_append(new_select, group); continue; @@ -774,12 +811,12 @@ void sp_selection_ungroup(SPDesktop *desktop) g_slist_free(new_select); } if (!ungrouped) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection.")); + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection.")); } g_slist_free(items); - - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); } @@ -857,22 +894,17 @@ static SPObject *prev_sibling(SPObject *child) } void -sp_selection_raise(SPDesktop *desktop) +sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - if (!desktop) - return; - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList const *items = const_cast<GSList *>(selection->itemList()); if (!items) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); return; } SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } @@ -910,21 +942,17 @@ sp_selection_raise(SPDesktop *desktop) g_slist_free(rev); } - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, //TRANSLATORS: "Raise" means "to raise an object" in the undo history C_("Undo action", "Raise")); } -void sp_selection_raise_to_top(SPDesktop *desktop) +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop) { - if (desktop == NULL) - return; - - SPDocument *document = sp_desktop_document(desktop); - Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPDocument *document = selection->layers()->getDocument(); if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top.")); return; } @@ -932,7 +960,7 @@ void sp_selection_raise_to_top(SPDesktop *desktop) SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } @@ -950,22 +978,17 @@ void sp_selection_raise_to_top(SPDesktop *desktop) _("Raise to top")); } -void sp_selection_lower(SPDesktop *desktop) +void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - if (desktop == NULL) - return; - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList const *items = const_cast<GSList *>(selection->itemList()); if (!items) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); return; } SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } @@ -1008,20 +1031,16 @@ void sp_selection_lower(SPDesktop *desktop) g_slist_free(rev); } - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, _("Lower")); } -void sp_selection_lower_to_bottom(SPDesktop *desktop) +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop) { - if (desktop == NULL) - return; - - SPDocument *document = sp_desktop_document(desktop); - Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPDocument *document = selection->layers()->getDocument(); if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom.")); + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom.")); return; } @@ -1029,7 +1048,7 @@ void sp_selection_lower_to_bottom(SPDesktop *desktop) SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } @@ -2125,49 +2144,49 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times) } void -sp_selection_move(SPDesktop *desktop, gdouble dx, gdouble dy) +sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy) { - Inkscape::Selection *selection = sp_desktop_selection(desktop); if (selection->isEmpty()) { return; } sp_selection_move_relative(selection, dx, dy); + SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { - DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, + DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically")); } else if (dy == 0) { - DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, + DocumentUndo::maybeDone(doc, "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, _("Move horizontally")); } else { - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, + DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT, _("Move")); } } void -sp_selection_move_screen(SPDesktop *desktop, gdouble dx, gdouble dy) +sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) { - Inkscape::Selection *selection = sp_desktop_selection(desktop); - if (selection->isEmpty()) { + if (selection->isEmpty() || !selection->desktop()) { return; } // same as sp_selection_move but divide deltas by zoom factor - gdouble const zoom = desktop->current_zoom(); + gdouble const zoom = selection->desktop()->current_zoom(); gdouble const zdx = dx / zoom; gdouble const zdy = dy / zoom; sp_selection_move_relative(selection, zdx, zdy); + SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { - DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, + DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT, _("Move vertically by pixels")); } else if (dy == 0) { - DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, + DocumentUndo::maybeDone(doc, "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, _("Move horizontally by pixels")); } else { - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, + DocumentUndo::done(doc, SP_VERB_CONTEXT_SELECT, _("Move")); } } @@ -3000,19 +3019,17 @@ void sp_selection_unsymbol(SPDesktop *desktop) return; } - SPObject* use = selection->single(); + SPObject* symbol = selection->single(); // Make sure we have only one object in selection. // Require that we really have a <use> that references a <symbol>. - if( use == NULL || ( !SP_IS_USE( use ) && !SP_IS_SYMBOL( use->firstChild() ))) { + if( symbol == NULL || !SP_IS_SYMBOL( symbol )) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> to convert to group.")); return; } doc->ensureUpToDate(); - SPObject* symbol = use->firstChild(); - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); group->setAttribute("style", symbol->getAttribute("style")); group->setAttribute("title", symbol->getAttribute("title")); @@ -3030,14 +3047,14 @@ void sp_selection_unsymbol(SPDesktop *desktop) child->deleteObject(true); } - SPObject* parent = use->parent; // So we insert <g> next to <use> (easier to find) + // So we insert <g> inside the current layer + SPObject *parent = desktop->currentLayer(); // Need to delete <symbol>; all other <use> elements that referenced <symbol> should // auto-magically reference <g>. symbol->deleteObject(true); group->setAttribute("id",id.c_str()); // After we delete symbol with same id. parent->getRepr()->appendChild(group); - //use->deleteObject(true); SPItem *group_item = static_cast<SPItem *>(sp_desktop_document(desktop)->getObjectByRepr(group)); Inkscape::GC::release(group); @@ -3765,7 +3782,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } // collect distinct mask object (and associate with item to apply transform) - if (NULL != uri_ref && NULL != uri_ref->getObject()) { + if ((NULL != uri_ref) && (NULL != uri_ref->getObject())) { referenced_objects[uri_ref->getObject()] = item; } } diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 1c627fd1a..f7a4f928c 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -47,12 +47,13 @@ namespace Inkscape { static void reverse(SPDesktop *dt); static void selectNext(SPDesktop *desktop); static void selectPrev(SPDesktop *desktop); + static void fixSelection(SPDesktop *desktop); }; } // namespace Inkscape void sp_selection_delete(SPDesktop *desktop); void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone = false); -void sp_edit_clear_all(SPDesktop *desktop); +void sp_edit_clear_all(Inkscape::Selection *selection); void sp_edit_select_all(SPDesktop *desktop); void sp_edit_select_all_in_all_layers (SPDesktop *desktop); @@ -76,13 +77,13 @@ void sp_selection_tile(SPDesktop *desktop, bool apply = true); void sp_selection_untile(SPDesktop *desktop); //void sp_selection_group_impl(GSList const *reprs_to_group, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc); -void sp_selection_group(SPDesktop *desktop); -void sp_selection_ungroup(SPDesktop *desktop); +void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise(SPDesktop *desktop); -void sp_selection_raise_to_top(SPDesktop *desktop); -void sp_selection_lower(SPDesktop *desktop); -void sp_selection_lower_to_bottom(SPDesktop *desktop); +void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); SPCSSAttr *take_style_from_item (SPItem *item); @@ -121,8 +122,8 @@ void sp_selection_scale (Inkscape::Selection *selection, gdouble grow); void sp_selection_scale_screen (Inkscape::Selection *selection, gdouble grow_pixels); void sp_selection_scale_times (Inkscape::Selection *selection, gdouble times); -void sp_selection_move (SPDesktop *desktop, gdouble dx, gdouble dy); -void sp_selection_move_screen (SPDesktop *desktop, gdouble dx, gdouble dy); +void sp_selection_move (Inkscape::Selection *selection, gdouble dx, gdouble dy); +void sp_selection_move_screen (Inkscape::Selection *selection, gdouble dx, gdouble dy); void sp_selection_item_next (SPDesktop *desktop); void sp_selection_item_prev (SPDesktop *desktop); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index b9e1ed510..1490bc6a6 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -17,6 +17,7 @@ #include <glibmm/i18n.h> #include "xml/quote.h" +#include "layer-model.h" #include "selection.h" #include "selection-describer.h" #include "desktop.h" @@ -37,9 +38,11 @@ #include "sp-polyline.h" #include "sp-spiral.h" -//static const gchar * -//type2term(GType type) -//{ +// CPPIFY: this is ugly. +static const gchar * +type2term(SPItem *item) +{ +// GType type = G_OBJECT_TYPE( item ); // if (type == SP_TYPE_ANCHOR) // //TRANSLATORS: "Link" means internet link (anchor) // { return C_("Web", "Link"); } @@ -68,6 +71,8 @@ // if (type == SP_TYPE_TEXT) // { return C_("Object", "Text"); } // if (type == SP_TYPE_USE) +// if (SP_IS_SYMBOL(item->firstChild())) +// { return C_("Object", "Symbol"); } // // TRANSLATORS: "Clone" is a noun, type of object // { return C_("Object", "Clone"); } // if (type == SP_TYPE_ARC) @@ -79,57 +84,14 @@ // if (type == SP_TYPE_STAR) // { return _("Star"); } // return NULL; -//} - -// CPPIFY: this is ugly. -static const char* object2term(SPObject* object) { - if (SP_IS_ANCHOR(object)) - //TRANSLATORS: "Link" means internet link (anchor) - { return C_("Web", "Link"); } - if (SP_IS_CIRCLE(object)) - { return _("Circle"); } - if (SP_IS_ELLIPSE(object)) - { return _("Ellipse"); } - if (SP_IS_FLOWTEXT(object)) - { return _("Flowed text"); } - if (SP_IS_GROUP(object)) - { return _("Group"); } - if (SP_IS_IMAGE(object)) - { return _("Image"); } - if (SP_IS_LINE(object)) - { return _("Line"); } - if (SP_IS_PATH(object)) - { return _("Path"); } - if (SP_IS_POLYGON(object)) - { return _("Polygon"); } - if (SP_IS_POLYLINE(object)) - { return _("Polyline"); } - if (SP_IS_RECT(object)) - { return _("Rectangle"); } - if (SP_IS_BOX3D(object)) - { return _("3D Box"); } - if (SP_IS_TEXT(object)) - { return C_("Object", "Text"); } - if (SP_IS_USE(object)) - // TRANSLATORS: "Clone" is a noun, type of object - { return C_("Object", "Clone"); } - if (SP_IS_ARC(object)) - { return _("Ellipse"); } - if (SP_IS_OFFSET(object)) - { return _("Offset path"); } - if (SP_IS_SPIRAL(object)) - { return _("Spiral"); } - if (SP_IS_STAR(object)) - { return _("Star"); } - return NULL; + return "Selektion-Describer ---"; } static GSList *collect_terms (GSList *items) { GSList *r = NULL; for (GSList *i = items; i != NULL; i = i->next) { - //const gchar *term = type2term (G_OBJECT_TYPE(i->data)); - const char* term = object2term(SP_OBJECT(i->data)); + const gchar *term = type2term ( SP_ITEM(i->data) ); if (term != NULL && g_slist_find (r, term) == NULL) r = g_slist_prepend (r, (void *) term); } @@ -185,13 +147,15 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); } else { SPItem *item = SP_ITEM(items->data); - SPObject *layer = selection->desktop()->layerForObject(item); - SPObject *root = selection->desktop()->currentRoot(); + SPObject *layer = selection->layers()->layerForObject(item); + SPObject *root = selection->layers()->currentRoot(); // Layer name gchar *layer_name; if (layer == root) { layer_name = g_strdup(_("root")); + } else if(!layer) { + layer_name = g_strdup(_("none")); } else { char const *layer_label; bool is_label = false; @@ -224,6 +188,8 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select if (num_parents == 1) { if (layer == parent) in_phrase = g_strdup_printf(_(" in %s"), layer_name); + else if (!layer) + in_phrase = g_strdup_printf(_(" hidden in definitions")); else in_phrase = g_strdup_printf(_(" in group %s (%s)"), parent_name, layer_name); } else { @@ -236,12 +202,16 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free (parent_name); if (!items->next) { // one item - char *item_desc = item->getDetailedDescription(); + char *item_desc = item->description(); if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, _("Convert symbol to group to edit"), _when_selected); - } else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) { + } else if (SP_IS_SYMBOL(item)) { + _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s.", + item_desc, in_phrase, + _("Remove from symbols tray to edit symbol")); + } else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref)) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, _("Use <b>Shift+D</b> to look up original"), _when_selected); diff --git a/src/selection.cpp b/src/selection.cpp index 564f1fdd3..784219c88 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -21,9 +21,8 @@ #endif #include "macros.h" #include "inkscape-private.h" -#include "desktop.h" -#include "desktop-handles.h" #include "document.h" +#include "layer-model.h" #include "selection.h" #include <2geom/rect.h> #include "xml/repr.h" @@ -42,10 +41,11 @@ namespace Inkscape { -Selection::Selection(SPDesktop *desktop) : +Selection::Selection(LayerModel *layers, SPDesktop *desktop) : _objs(NULL), _reprs(NULL), _items(NULL), + _layers(layers), _desktop(desktop), _selection_context(NULL), _flags(0), @@ -55,7 +55,7 @@ Selection::Selection(SPDesktop *desktop) : Selection::~Selection() { _clear(); - _desktop = NULL; + _layers = NULL; if (_idle) { g_source_remove(_idle); _idle = 0; @@ -96,7 +96,7 @@ void Selection::_emitModified(guint flags) { void Selection::_emitChanged(bool persist_selection_context/* = false */) { if (persist_selection_context) { if (NULL == _selection_context) { - _selection_context = desktop()->currentLayer(); + _selection_context = _layers->currentLayer(); sp_object_ref(_selection_context, NULL); _context_release_connection = _selection_context->connectRelease(sigc::mem_fun(*this, &Selection::_releaseContext)); } @@ -139,7 +139,7 @@ void Selection::_clear() { SPObject *Selection::activeContext() { if (NULL != _selection_context) return _selection_context; - return desktop()->currentLayer(); + return _layers->currentLayer(); } bool Selection::includes(SPObject *obj) const { @@ -358,6 +358,35 @@ SPItem *Selection::singleItem() { } } +SPItem *Selection::smallestItem(Selection::CompareSize compare) { + return _sizeistItem(true, compare); +} + +SPItem *Selection::largestItem(Selection::CompareSize compare) { + return _sizeistItem(false, compare); +} + +SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { + GSList const *items = const_cast<Selection *>(this)->itemList(); + gdouble max = sml ? 1e18 : 0; + SPItem *ist = NULL; + + for ( GSList const *i = items; i != NULL ; i = i->next ) { + Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds(); + if (!obox || obox.isEmpty()) continue; + Geom::Rect bbox = *obox; + + gdouble size = compare == 2 ? bbox.area() : + (compare == 1 ? bbox.width() : bbox.height()); + size = sml ? size : size * -1; + if (size < max) { + max = size; + ist = SP_ITEM(i->data); + } + } + return ist; +} + Inkscape::XML::Node *Selection::singleRepr() { SPObject *obj=single(); return obj ? obj->getRepr() : NULL; @@ -487,7 +516,7 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { g_return_val_if_fail(repr != NULL, NULL); gchar const *id = repr->attribute("id"); g_return_val_if_fail(id != NULL, NULL); - SPObject *object=sp_desktop_document(_desktop)->getObjectById(id); + SPObject *object=_layers->getDocument()->getObjectById(id); g_return_val_if_fail(object != NULL, NULL); return object; } @@ -496,7 +525,7 @@ guint Selection::numberOfLayers() { GSList const *items = const_cast<Selection *>(this)->itemList(); GSList *layers = NULL; for (GSList const *iter = items; iter != NULL; iter = iter->next) { - SPObject *layer = desktop()->layerForObject(SP_OBJECT(iter->data)); + SPObject *layer = _layers->layerForObject(SP_OBJECT(iter->data)); if (g_slist_find (layers, layer) == NULL) { layers = g_slist_prepend (layers, layer); } diff --git a/src/selection.h b/src/selection.h index 10775dcb5..32eade21f 100644 --- a/src/selection.h +++ b/src/selection.h @@ -27,12 +27,14 @@ #include "sp-item.h" #include "snapped-point.h" + class SPDesktop; class SPItem; class SPBox3D; struct Persp3D; namespace Inkscape { +class LayerModel; namespace XML { class Node; } @@ -41,10 +43,10 @@ class Node; namespace Inkscape { /** - * The set of selected SPObjects for a given desktop. + * The set of selected SPObjects for a given document and layer model. * * This class represents the set of selected SPItems for a given - * SPDesktop. + * document (referenced in LayerModel). * * An SPObject and its parent cannot be simultaneously selected; * selecting an SPObjects has the side-effect of unselecting any of @@ -62,19 +64,29 @@ class Selection : public Inkscape::GC::Managed<>, public Inkscape::GC::Anchored { public: + enum CompareSize { HORIZONTAL, VERTICAL, AREA }; /** * Constructs an selection object, bound to a particular - * SPDesktop + * layer model * - * @param desktop the desktop in question + * @param layers the layer model (for the SPDesktop, if GUI) + * @param desktop the desktop associated with the layer model, or NULL if in console mode */ - Selection(SPDesktop *desktop); + Selection(LayerModel *layers, SPDesktop *desktop); ~Selection(); /** + * Returns the layer model the selection is bound to (works in console or GUI mode) + * + * @return the layer model the selection is bound to, which is the same as the desktop + * layer model for GUI mode + */ + LayerModel *layers() { return _layers; } + + /** * Returns the desktop the selection is bound to * - * @return the desktop the selection is bound to + * @return the desktop the selection is bound to, or NULL if in console mode */ SPDesktop *desktop() { return _desktop; } @@ -210,6 +222,16 @@ public: SPItem *singleItem(); /** + * Returns the smallest item from this selection. + */ + SPItem *smallestItem(CompareSize compare); + + /** + * Returns the largest item from this selection. + */ + SPItem *largestItem(CompareSize compare); + + /** * Returns a single selected object's xml node. * * @return NULL unless exactly one object is selected @@ -339,9 +361,11 @@ private: void add_3D_boxes_recursively(SPObject *obj); void remove_box_perspective(SPBox3D *box); void remove_3D_boxes_recursively(SPObject *obj); + SPItem *_sizeistItem(bool sml, CompareSize compare); std::list<SPBox3D *> _3dboxes; + LayerModel *_layers; GC::soft_ptr<SPDesktop> _desktop; SPObject* _selection_context; guint _flags; diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index fc03789d6..6dd94d297 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -1,33 +1,40 @@ #include "seltrans-handles.h" +#ifdef __cplusplus +#undef N_ +#define N_(x) x +#endif -SPSelTransHandle const handles_scale[] = { -//anchor cursor control action request x y - {SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 1}, - {SP_ANCHOR_S, GDK_TOP_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 1}, - {SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 1}, - {SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 1, 0.5}, - {SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, sp_sel_trans_scale, sp_sel_trans_scale_request, 1, 0}, - {SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0.5, 0}, - {SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, sp_sel_trans_scale, sp_sel_trans_scale_request, 0, 0}, - {SP_ANCHOR_E, GDK_LEFT_SIDE, 2, sp_sel_trans_stretch, sp_sel_trans_stretch_request, 0, 0.5} +SPSelTransTypeInfo const handtypes[] = { + { DEF_COLOR, N_("<b>Squeeze or stretch</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center") }, + { DEF_COLOR, N_("<b>Scale</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center") }, + { DEF_COLOR, N_("<b>Skew</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to skew around the opposite side") }, + { DEF_COLOR, N_("<b>Rotate</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to rotate around the opposite corner") }, + { CEN_COLOR, N_("<b>Center</b> of rotation and skewing: drag to reposition; scaling with Shift also uses this center") } }; -SPSelTransHandle const handles_rotate[] = { - {SP_ANCHOR_SE, GDK_EXCHANGE, 4, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 1}, - {SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 5, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 1}, - {SP_ANCHOR_SW, GDK_EXCHANGE, 6, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 1}, - {SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 7, sp_sel_trans_skew, sp_sel_trans_skew_request, 1, 0.5}, - {SP_ANCHOR_NW, GDK_EXCHANGE, 8, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 1, 0}, - {SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 9, sp_sel_trans_skew, sp_sel_trans_skew_request, 0.5, 0}, - {SP_ANCHOR_NE, GDK_EXCHANGE, 10, sp_sel_trans_rotate, sp_sel_trans_rotate_request, 0, 0}, - {SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, sp_sel_trans_skew, sp_sel_trans_skew_request, 0, 0.5} +SPSelTransHandle const hands[] = { +//center handle will be 0 so we can reference it quickly. + {HANDLE_CENTER, SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, 0.5, 0.5}, +//handle-type anchor-nudge cursor image x y + {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, + {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, + {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, + {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5}, + {HANDLE_SCALE, SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, 0, 1}, + {HANDLE_SCALE, SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, 1, 1}, + {HANDLE_SCALE, SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, 1, 0}, + {HANDLE_SCALE, SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, 0, 0}, + {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, + {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, + {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, + {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, + {HANDLE_ROTATE, SP_ANCHOR_SE, GDK_EXCHANGE, 4, 0, 1}, + {HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 5, 1, 1}, + {HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 6, 1, 0}, + {HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 7, 0, 0}, }; -SPSelTransHandle const handle_center = - {SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, sp_sel_trans_center, sp_sel_trans_center_request, 0.5, 0.5}; - - /* Local Variables: mode:c++ diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index 14f50d784..740729a6e 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -21,40 +21,36 @@ namespace Inkscape class SelTrans; } -struct SPSelTransHandle; +guint32 const DEF_COLOR[] = { 0xff, 0xff6600, 0xff6600, 0xff, 0xff, 0xff }; +guint32 const CEN_COLOR[] = { 0x0, 0x0, 0x0, 0xff, 0xff0000b0, 0xff0000b0 }; + +enum SPSelTransType { + HANDLE_STRETCH, + HANDLE_SCALE, + HANDLE_SKEW, + HANDLE_ROTATE, + HANDLE_CENTER +}; -// request handlers -gboolean sp_sel_trans_scale_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &p, guint state); -gboolean sp_sel_trans_stretch_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &p, guint state); -gboolean sp_sel_trans_skew_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &p, guint state); -gboolean sp_sel_trans_rotate_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &p, guint state); -gboolean sp_sel_trans_center_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &p, guint state); +struct SPSelTransTypeInfo { + guint32 const *color; + gchar const *tip; +}; +// One per handle type in order +extern SPSelTransTypeInfo const handtypes[5]; -// action handlers -void sp_sel_trans_scale(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); -void sp_sel_trans_stretch(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); -void sp_sel_trans_skew(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); -void sp_sel_trans_rotate(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); -void sp_sel_trans_center(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); +struct SPSelTransHandle; struct SPSelTransHandle { + SPSelTransType type; SPAnchorType anchor; GdkCursorType cursor; guint control; - void (* action) (Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); - gboolean (* request) (Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &p, guint state); gdouble x, y; }; - -// TODO these must be purged: -extern SPSelTransHandle const handles_scale[8]; -extern SPSelTransHandle const handles_rotate[8]; -extern SPSelTransHandle const handle_center; +// These are 4 * each handle type + 1 for center +int const NUMHANDS = 17; +extern SPSelTransHandle const hands[17]; #endif // SEEN_SP_SELTRANS_HANDLES_H diff --git a/src/seltrans.cpp b/src/seltrans.cpp index b6c6baaf7..33bfe3e4a 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -48,12 +48,11 @@ #include <2geom/angle.h> #include "display/snap-indicator.h" #include "ui/control-manager.h" +#include "seltrans-handles.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; -static void sp_remove_handles(SPKnot *knot[], gint num); - static void sp_sel_trans_handle_grab(SPKnot *knot, guint state, gpointer data); static void sp_sel_trans_handle_ungrab(SPKnot *knot, guint state, gpointer data); static void sp_sel_trans_handle_click(SPKnot *knot, guint state, gpointer data); @@ -62,7 +61,7 @@ static gboolean sp_sel_trans_handle_request(SPKnot *knot, Geom::Point *p, guint extern GdkPixbuf *handles[]; -static gboolean sp_seltrans_handle_event(SPKnot *knot, GdkEvent *event, gpointer) +static gboolean sp_sel_trans_handle_event(SPKnot *knot, GdkEvent *event, gpointer) { switch (event->type) { case GDK_MOTION_NOTIFY: @@ -86,6 +85,17 @@ static gboolean sp_seltrans_handle_event(SPKnot *knot, GdkEvent *event, gpointer return FALSE; } +Inkscape::SelTrans::BoundingBoxPrefsObserver::BoundingBoxPrefsObserver(SelTrans &sel_trans) : + Observer("/tools/bounding_box"), + _sel_trans(sel_trans) +{ +} + +void Inkscape::SelTrans::BoundingBoxPrefsObserver::notify(Preferences::Entry const &val) +{ + _sel_trans._boundingBoxPrefsChanged(static_cast<int>(val.getBool())); +} + Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _desktop(desktop), _selcue(desktop), @@ -101,9 +111,9 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _chandle(NULL), _stamp_cache(NULL), - _message_context(desktop->messageStack()) + _message_context(desktop->messageStack()), + _bounding_box_prefs_observer(*this) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); @@ -112,16 +122,12 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : g_return_if_fail(desktop != NULL); - for (int i = 0; i < 8; i++) { - _shandle[i] = NULL; - _rhandle[i] = NULL; - } - _updateVolatileState(); _current_relative_affine.setIdentity(); _center_is_set = false; // reread _center from items, or set to bbox midpoint + _makeHandles(); _updateHandles(); _selection = sp_desktop_selection(desktop); @@ -169,6 +175,8 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : ); _all_snap_sources_iter = _all_snap_sources_sorted.end(); + + prefs->addObserver(_bounding_box_prefs_observer); } Inkscape::SelTrans::~SelTrans() @@ -176,19 +184,9 @@ Inkscape::SelTrans::~SelTrans() _sel_changed_connection.disconnect(); _sel_modified_connection.disconnect(); - for (unsigned int i = 0; i < 8; i++) { - if (_shandle[i]) { - g_object_unref(G_OBJECT(_shandle[i])); - _shandle[i] = NULL; - } - if (_rhandle[i]) { - g_object_unref(G_OBJECT(_rhandle[i])); - _rhandle[i] = NULL; - } - } - if (_chandle) { - g_object_unref(G_OBJECT(_chandle)); - _chandle = NULL; + for (int i = 0; i < NUMHANDS; i++) { + g_object_unref(G_OBJECT(knots[i])); + knots[i] = NULL; } if (_norm) { @@ -570,13 +568,11 @@ void Inkscape::SelTrans::stamp() void Inkscape::SelTrans::_updateHandles() { + for (int i = 0; i < NUMHANDS; i++) + sp_knot_hide(knots[i]); + if ( !_show_handles || _empty ) - { - sp_remove_handles(_shandle, 8); - sp_remove_handles(_rhandle, 8); - sp_remove_handles(&_chandle, 1); return; - } if (!_center_is_set) { _center = _desktop->selection->center(); @@ -584,57 +580,12 @@ void Inkscape::SelTrans::_updateHandles() } if ( _state == STATE_SCALE ) { - sp_remove_handles(_rhandle, 8); - sp_remove_handles(&_chandle, 1); - _showHandles(_shandle, handles_scale, 8, - _("<b>Squeeze or stretch</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center"), - _("<b>Scale</b> selection; with <b>Ctrl</b> to scale uniformly; with <b>Shift</b> to scale around rotation center")); + _showHandles(HANDLE_STRETCH); + _showHandles(HANDLE_SCALE); } else { - sp_remove_handles(_shandle, 8); - _showHandles(_rhandle, handles_rotate, 8, - _("<b>Skew</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to skew around the opposite side"), - _("<b>Rotate</b> selection; with <b>Ctrl</b> to snap angle; with <b>Shift</b> to rotate around the opposite corner")); - // center handle - /* Assuming that the center handle is in its default position, ie. in the center: - * Multiple handles will be shown, for rotating, skewing and the center handle. For straight lines, the bounding box of the center handle will be - * fully overlapped by bounding boxes of two of the skew handles. Due to the internals of sp_canvas_group_point, the center handle must be the - * last handle in the SPCanvasGroup if it is to be selectable in such a case. So we have made sure here that the center handle is added to the - * group after the rotation handles (determined by the chronological order of sp_knot_new() calls) - * Now when the center handle is in still in the center, the skew handles can be selected because because the bounding box of the - * center handle does not fully overlap the bounding box of either of the skew handles. However, if the center handle has been moved such that it - * covers one of the other eight handles, then either the opposite handle has to be used (in case of rotating), or the center handle has to be moved. - * Although this is annoying, this is still better than not being able to select the center handle at all - */ - if ( _chandle == NULL ) { - _chandle = sp_knot_new(_desktop, _("<b>Center</b> of rotation and skewing: drag to reposition; scaling with Shift also uses this center")); - - _chandle->setShape (SP_CTRL_SHAPE_BITMAP); - _chandle->setSize (13); - _chandle->setAnchor (handle_center.anchor); - _chandle->setMode (SP_CTRL_MODE_XOR); - _chandle->setFill(0x00000000, 0x00000000, 0x00000000); - _chandle->setStroke(0x000000ff, 0xff0000b0, 0xff0000b0); - _chandle->setPixbuf(handles[handle_center.control]); - sp_knot_update_ctrl(_chandle); - - g_signal_connect(G_OBJECT(_chandle), "request", - G_CALLBACK(sp_sel_trans_handle_request), (gpointer) &handle_center); - g_signal_connect(G_OBJECT(_chandle), "moved", - G_CALLBACK(sp_sel_trans_handle_new_event), (gpointer) &handle_center); - g_signal_connect(G_OBJECT(_chandle), "grabbed", - G_CALLBACK(sp_sel_trans_handle_grab), (gpointer) &handle_center); - g_signal_connect(G_OBJECT(_chandle), "ungrabbed", - G_CALLBACK(sp_sel_trans_handle_ungrab), (gpointer) &handle_center); - g_signal_connect(G_OBJECT(_chandle), "clicked", - G_CALLBACK(sp_sel_trans_handle_click), (gpointer) &handle_center); - } - - if ( _center ) { - sp_knot_show(_chandle); - sp_knot_moveto(_chandle, *_center); - } else { - sp_remove_handles(&_chandle, 1); - } + _showHandles(HANDLE_SKEW); + _showHandles(HANDLE_ROTATE); + _showHandles(HANDLE_CENTER); } } @@ -659,53 +610,55 @@ void Inkscape::SelTrans::_updateVolatileState() _strokewidth = stroke_average_width (selection->itemList()); } -static void sp_remove_handles(SPKnot *knot[], gint num) +void Inkscape::SelTrans::_showHandles(SPSelTransType type) { - for (int i = 0; i < num; i++) { - if (knot[i] != NULL) { - sp_knot_hide(knot[i]); - } + // shouldn't have nullary bbox, but knots + g_assert(_bbox); + + for (int i = 0; i < NUMHANDS; i++) { + if (hands[i].type != type) + continue; + + // Position knots to scale the selection bbox + Geom::Point const bpos(hands[i].x, hands[i].y); + Geom::Point p(_bbox->min() + (_bbox->dimensions() * Geom::Scale(bpos))); + sp_knot_moveto(knots[i], p); + sp_knot_show(knots[i]); + + // This controls the center handle's position, because the default can + // be moved and needs to be remembered. + if( type == HANDLE_CENTER && _center ) + sp_knot_moveto(knots[i], *_center); } } -void Inkscape::SelTrans::_showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num, - gchar const *even_tip, gchar const *odd_tip) +void Inkscape::SelTrans::_makeHandles() { - g_return_if_fail( !_empty ); - - for (int i = 0; i < num; i++) { - if (knot[i] == NULL) { - knot[i] = sp_knot_new(_desktop, i % 2 ? even_tip : odd_tip); - - knot[i]->setShape (SP_CTRL_SHAPE_BITMAP); - knot[i]->setSize (13); - knot[i]->setAnchor (handle[i].anchor); - knot[i]->setMode (SP_CTRL_MODE_XOR); - knot[i]->setFill(0x000000ff, 0x00ff6600, 0x00ff6600); // inversion, green, green - knot[i]->setStroke(0x000000ff, 0x000000ff, 0x000000ff); // inversion - knot[i]->setPixbuf(handles[handle[i].control]); - sp_knot_update_ctrl(knot[i]); - - g_signal_connect(G_OBJECT(knot[i]), "request", - G_CALLBACK(sp_sel_trans_handle_request), (gpointer) &handle[i]); - g_signal_connect(G_OBJECT(knot[i]), "moved", - G_CALLBACK(sp_sel_trans_handle_new_event), (gpointer) &handle[i]); - g_signal_connect(G_OBJECT(knot[i]), "grabbed", - G_CALLBACK(sp_sel_trans_handle_grab), (gpointer) &handle[i]); - g_signal_connect(G_OBJECT(knot[i]), "ungrabbed", - G_CALLBACK(sp_sel_trans_handle_ungrab), (gpointer) &handle[i]); - g_signal_connect(G_OBJECT(knot[i]), "event", G_CALLBACK(sp_seltrans_handle_event), (gpointer) &handle[i]); - } - sp_knot_show(knot[i]); - - Geom::Point const handle_pt(handle[i].x, handle[i].y); - // shouldn't have nullary bbox, but knots - g_assert(_bbox); - Geom::Point p( _bbox->min() - + ( _bbox->dimensions() - * Geom::Scale(handle_pt) ) ); - - sp_knot_moveto(knot[i], p); + for (int i = 0; i < NUMHANDS; i++) { + SPSelTransTypeInfo info = handtypes[hands[i].type]; + knots[i] = sp_knot_new(_desktop, info.tip); + + knots[i]->setShape(SP_CTRL_SHAPE_BITMAP); + knots[i]->setSize(13); + knots[i]->setAnchor(hands[i].anchor); + knots[i]->setMode(SP_CTRL_MODE_XOR); + knots[i]->setFill(info.color[0], info.color[1], info.color[2]); + knots[i]->setStroke(info.color[3], info.color[4], info.color[5]); + knots[i]->setPixbuf(handles[hands[i].control]); + sp_knot_update_ctrl(knots[i]); + + g_signal_connect(G_OBJECT(knots[i]), "request", + G_CALLBACK(sp_sel_trans_handle_request), (gpointer) &hands[i]); + g_signal_connect(G_OBJECT(knots[i]), "moved", + G_CALLBACK(sp_sel_trans_handle_new_event), (gpointer) &hands[i]); + g_signal_connect(G_OBJECT(knots[i]), "grabbed", + G_CALLBACK(sp_sel_trans_handle_grab), (gpointer) &hands[i]); + g_signal_connect(G_OBJECT(knots[i]), "ungrabbed", + G_CALLBACK(sp_sel_trans_handle_ungrab), (gpointer) &hands[i]); + g_signal_connect(G_OBJECT(knots[i]), "clicked", + G_CALLBACK(sp_sel_trans_handle_click), (gpointer) &hands[i]); + g_signal_connect(G_OBJECT(knots[i]), "event", + G_CALLBACK(sp_sel_trans_handle_event), (gpointer) &hands[i]); } } @@ -744,8 +697,8 @@ static void sp_sel_trans_handle_click(SPKnot *knot, guint state, gpointer data) void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHandle const &handle) { - switch (handle.anchor) { - case SP_ANCHOR_CENTER: + switch (handle.type) { + case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { @@ -766,8 +719,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa void Inkscape::SelTrans::handleGrab(SPKnot *knot, guint /*state*/, SPSelTransHandle const &handle) { - switch (handle.anchor) { - case SP_ANCHOR_CENTER: + switch (handle.type) { + case HANDLE_CENTER: g_object_set(G_OBJECT(_grip), "shape", SP_CTRL_SHAPE_BITMAP, "size", 13.0, @@ -781,7 +734,6 @@ void Inkscape::SelTrans::handleGrab(SPKnot *knot, guint /*state*/, SPSelTransHan NULL); sp_canvas_item_show(_norm); sp_canvas_item_show(_grip); - break; } @@ -802,21 +754,35 @@ void Inkscape::SelTrans::handleNewEvent(SPKnot *knot, Geom::Point *position, gui return; } } - - handle.action(this, handle, *position, state); + switch (handle.type) { + case HANDLE_SCALE: + scale(*position, state); + break; + case HANDLE_STRETCH: + stretch(handle, *position, state); + break; + case HANDLE_SKEW: + skew(handle, *position, state); + break; + case HANDLE_ROTATE: + rotate(*position, state); + break; + case HANDLE_CENTER: + setCenter(*position); + break; + } } gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle) { - if (!SP_KNOT_IS_GRABBED(knot)) { + if (!SP_KNOT_IS_GRABBED(knot)) return TRUE; - } // When holding shift while rotating or skewing, the transformation will be // relative to the point opposite of the handle; otherwise it will be relative // to the center as set for the selection - if ((!(state & GDK_SHIFT_MASK) == !(_state == STATE_ROTATE)) && (&handle != &handle_center)) { + if ((!(state & GDK_SHIFT_MASK) == !(_state == STATE_ROTATE)) && (handle.type != HANDLE_CENTER)) { _origin = _opposite; _origin_for_bboxpoints = _opposite_for_bboxpoints; _origin_for_specpoints = _opposite_for_specpoints; @@ -828,10 +794,10 @@ gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, Geom::Point *position, // FIXME return TRUE; } - if (handle.request(this, handle, *position, state)) { + if (request(handle, *position, state)) { sp_knot_set_position(knot, *position, state); SP_CTRL(_grip)->moveto(*position); - if (&handle == &handle_center) { + if (handle.type == HANDLE_CENTER) { SP_CTRL(_norm)->moveto(*position); } else { SP_CTRL(_norm)->moveto(_origin); @@ -873,6 +839,15 @@ void Inkscape::SelTrans::_selModified(Inkscape::Selection */*selection*/, guint } } +void Inkscape::SelTrans::_boundingBoxPrefsChanged(int prefs_bbox) +{ + _snap_bbox_type = !prefs_bbox ? + SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; + + _updateVolatileState(); + _updateHandles(); +} + /* * handlers for handle move-request */ @@ -885,36 +860,6 @@ static double sign(double const x) : 1 ); } -gboolean sp_sel_trans_scale_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &, Geom::Point &pt, guint state) -{ - return seltrans->scaleRequest(pt, state); -} - -gboolean sp_sel_trans_stretch_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &pt, guint state) -{ - return seltrans->stretchRequest(handle, pt, state); -} - -gboolean sp_sel_trans_skew_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &handle, Geom::Point &pt, guint state) -{ - return seltrans->skewRequest(handle, pt, state); -} - -gboolean sp_sel_trans_rotate_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &, Geom::Point &pt, guint state) -{ - return seltrans->rotateRequest(pt, state); -} - -gboolean sp_sel_trans_center_request(Inkscape::SelTrans *seltrans, - SPSelTransHandle const &, Geom::Point &pt, guint state) -{ - return seltrans->centerRequest(pt, state); -} - gboolean Inkscape::SelTrans::scaleRequest(Geom::Point &pt, guint state) { @@ -1094,6 +1039,24 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, Geom return TRUE; } +gboolean Inkscape::SelTrans::request(SPSelTransHandle const &handle, Geom::Point &pt, guint state) +{ + // These _should_ be in the handstype somewhere instead + switch (handle.type) { + case HANDLE_SCALE: + return scaleRequest(pt, state); + case HANDLE_STRETCH: + return stretchRequest(handle, pt, state); + case HANDLE_SKEW: + return skewRequest(handle, pt, state); + case HANDLE_ROTATE: + return rotateRequest(pt, state); + case HANDLE_CENTER: + return centerRequest(pt, state); + } + return FALSE; +} + gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state) { /* When skewing (or rotating): @@ -1324,25 +1287,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) * */ -void sp_sel_trans_stretch(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &pt, guint state) -{ - seltrans->stretch(handle, pt, state); -} -void sp_sel_trans_scale(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint state) -{ - seltrans->scale(pt, state); -} - -void sp_sel_trans_skew(Inkscape::SelTrans *seltrans, SPSelTransHandle const &handle, Geom::Point &pt, guint state) -{ - seltrans->skew(handle, pt, state); -} - -void sp_sel_trans_rotate(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint state) -{ - seltrans->rotate(pt, state); -} void Inkscape::SelTrans::stretch(SPSelTransHandle const &/*handle*/, Geom::Point &/*pt*/, guint /*state*/) { @@ -1364,12 +1309,6 @@ void Inkscape::SelTrans::rotate(Geom::Point &/*pt*/, guint /*state*/) transform(_relative_affine, _origin); } -void sp_sel_trans_center(Inkscape::SelTrans *seltrans, SPSelTransHandle const &, Geom::Point &pt, guint /*state*/) -{ - seltrans->setCenter(pt); -} - - void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) { SnapManager &m = _desktop->namedview->snap_manager; diff --git a/src/seltrans.h b/src/seltrans.h index effc767e3..d97375520 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -25,6 +25,7 @@ #include "message-context.h" #include <vector> #include "sp-item.h" +#include "seltrans-handles.h" struct SPKnot; class SPDesktop; @@ -64,6 +65,7 @@ public: void scale(Geom::Point &pt, guint state); void skew(SPSelTransHandle const &handle, Geom::Point &pt, guint state); void rotate(Geom::Point &pt, guint state); + gboolean request(SPSelTransHandle const &handle, Geom::Point &pt, guint state); gboolean scaleRequest(Geom::Point &pt, guint state); gboolean stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state); gboolean skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state); @@ -91,18 +93,32 @@ public: return _grabbed; } bool centerIsVisible() { - return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) ); + return ( SP_KNOT_IS_VISIBLE (knots[0]) ); } void getNextClosestPoint(bool reverse); private: + class BoundingBoxPrefsObserver: public Preferences::Observer + { + public: + BoundingBoxPrefsObserver(SelTrans &sel_trans); + + void notify(Preferences::Entry const &val); + + private: + SelTrans &_sel_trans; + }; + + friend class Inkscape::SelTrans::BoundingBoxPrefsObserver; + void _updateHandles(); void _updateVolatileState(); void _selChanged(Inkscape::Selection *selection); void _selModified(Inkscape::Selection *selection, guint flags); - void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num, - gchar const *even_tip, gchar const *odd_tip); + void _boundingBoxPrefsChanged(int prefs_bbox); + void _makeHandles(); + void _showHandles(SPSelTransType type); Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos); Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale); Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale); @@ -162,10 +178,9 @@ private: boost::optional<Geom::Point> _center; bool _center_is_set; ///< we've already set _center, no need to reread it from items + int _center_handle; - SPKnot *_shandle[8]; - SPKnot *_rhandle[8]; - SPKnot *_chandle; + SPKnot *knots[NUMHANDS]; SPCanvasItem *_norm; SPCanvasItem *_grip; SPCtrlLine *_l[4]; @@ -179,6 +194,7 @@ private: Inkscape::MessageContext _message_context; sigc::connection _sel_changed_connection; sigc::connection _sel_modified_connection; + BoundingBoxPrefsObserver _bounding_box_prefs_observer; }; } diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 2af04929e..231e33e4a 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -35,6 +35,7 @@ #include <glibmm/miscutils.h> #include "helper/action.h" +#include "helper/action-context.h" #include "io/sys.h" #include "io/resource.h" #include "verbs.h" @@ -68,7 +69,7 @@ sp_shortcut_invoke(unsigned int shortcut, Inkscape::UI::View::View *view) { Inkscape::Verb *verb = sp_shortcut_get_verb(shortcut); if (verb) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if (action) { sp_action_perform(action, NULL); return true; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index d4cd2eff2..0b6ec3537 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -42,6 +42,7 @@ #include "xml/quote.h" #include "xml/repr.h" #include "snap-candidate.h" +#include "preferences.h" #include "io/sys.h" #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -63,7 +64,7 @@ g_message( __VA_ARGS__ );\ } -#include "preferences.h" + #include <gtk/gtk.h> #endif // DEBUG_LCMS #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -1441,9 +1442,12 @@ void sp_embed_image( Inkscape::XML::Node *image_node, GdkPixbuf *pb, Glib::ustri format = "png"; } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring quality = Glib::ustring::format(prefs->getInt("/dialogs/import/quality", 100)); + gchar *data = 0; gsize length = 0; - gdk_pixbuf_save_to_buffer(pb, &data, &length, format.data(), NULL, NULL); + gdk_pixbuf_save_to_buffer(pb, &data, &length, format.data(), NULL, "quality", quality.c_str(), NULL); // Save base64 encoded data in image node // this formula taken from Glib docs diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index ab38636f6..7044f2f7f 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -405,7 +405,10 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) SPItem *gitem = group; Inkscape::XML::Node *grepr = gitem->getRepr(); - g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch")); + g_return_if_fail (!strcmp (grepr->name(), "svg:g") + || !strcmp (grepr->name(), "svg:a") + || !strcmp (grepr->name(), "svg:switch") + || !strcmp (grepr->name(), "svg:svg")); // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); @@ -546,8 +549,9 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) item->doWriteTransform(repr, item->transform, NULL, false); Inkscape::GC::release(repr); - if (children && SP_IS_ITEM (item)) - *children = g_slist_prepend (*children, item); + if (children && SP_IS_ITEM(item)) { + *children = g_slist_prepend(*children, item); + } items = g_slist_remove (items, items->data); } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c2e502e7e..ed1a2ef79 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -604,7 +604,7 @@ void SPItem::update(SPCtx *ctx, guint flags) { /* Update bounding box data used by filters */ if (item->style->filter.set && item->display) { - Geom::OptRect item_bbox = item->geometricBounds(); + Geom::OptRect item_bbox = item->visualBounds(); SPItemView *itemview = item->display; do { @@ -1057,6 +1057,9 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned sp_mask_set_bbox(SP_MASK(mask), mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } + if (style->filter.set && display) { + item_bbox = visualBounds(); + } ai->setData(this); ai->setItemBounds(item_bbox); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 31074732d..e05ce7fd2 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -8,7 +8,7 @@ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> - * Copyright (C) 1999-2008 Authors + * Copyright (C) 1999-2013 Authors * Copyright (C) 2000-2001 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -751,7 +751,27 @@ void SPNamedView::show(SPDesktop *desktop) desktop->showGrids(grids_visible, false); } -#define MIN_ONSCREEN_DISTANCE 50 +namespace { + +gint const MIN_ONSCREEN_DISTANCE = 50; +gdouble const NEWDOC_X_SCALE = 0.75; +gdouble const NEWDOC_Y_SCALE = NEWDOC_X_SCALE; + +Geom::Point calcAnchorPoint(gint const x, gint const y, + gint const w, gint const h, gint const minOnscreen) +{ + // prevent the window from moving off the screen to the right or to the bottom + gint ax = MIN(gdk_screen_width() - minOnscreen, x); + gint ay = MIN(gdk_screen_height() - minOnscreen, y); + + // prevent the window from moving off the screen to the left or to the top + ax = MAX(minOnscreen - w, ax); + ay = MAX(minOnscreen - h, ay); + + return Geom::Point(ax, ay); +} + +} // namespace void SPNamedView::writeNewGrid(SPDocument *document,int gridtype) { @@ -767,42 +787,49 @@ void sp_namedview_window_from_document(SPDesktop *desktop) SPNamedView *nv = desktop->namedview; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool geometry_from_file = (1 == prefs->getInt("/options/savewindowgeometry/value", 0)); - bool show_dialogs = TRUE; + gint default_geometry = prefs->getInt("/options/defaultwindowsize/value", 1); + bool new_document = (nv->window_width <= 0) || (nv->window_height <= 0); + bool show_dialogs = true; // restore window size and position stored with the document - if (geometry_from_file) { - if (nv->window_maximized) { - Gtk::Window *win = desktop->getToplevel(); - if (win){ - win->maximize(); - } - } else { - gint w = MIN(gdk_screen_width(), nv->window_width); - gint h = MIN(gdk_screen_height(), nv->window_height); - // prevent the window from moving off the screen to the right or to the bottom - gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x); - gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y); - // prevent the window from moving off the screen to the left or to the top - x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x); - y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y); - if (w>0 && h>0) { - - #ifndef WIN32 - gint dx, dy, dw, dh; - desktop->getWindowGeometry(dx, dy, dw, dh); - if (w != dw || h != dh) { - // Don't show dialogs when window is initially resized on OSX/Linux due to gdl dock bug - // This will happen on sp_desktop_widget_size_allocate - show_dialogs = FALSE; - } - #endif - - desktop->setWindowSize(w, h); - desktop->setWindowPosition(Geom::Point(x, y)); + bool sizeSet = false; + if ((geometry_from_file && nv->window_maximized) || (new_document && (default_geometry == 2))) { + Gtk::Window *win = desktop->getToplevel(); + if (win) { + win->maximize(); + } + sizeSet = true; + } else if (geometry_from_file && !nv->window_maximized) { + gint w = MIN(gdk_screen_width(), nv->window_width); + gint h = MIN(gdk_screen_height(), nv->window_height); + if ((w > 0) && (h > 0)) { +#ifndef WIN32 + gint dx= 0; + gint dy = 0; + gint dw = 0; + gint dh = 0; + desktop->getWindowGeometry(dx, dy, dw, dh); + if ((w != dw) || (h != dh)) { + // Don't show dialogs when window is initially resized on OSX/Linux due to gdl dock bug + // This will happen on sp_desktop_widget_size_allocate + show_dialogs = FALSE; } +#endif + Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE); + desktop->setWindowSize(w, h); + desktop->setWindowPosition(origin); + sizeSet = true; } + } + if (!sizeSet && new_document && (default_geometry == 1)) + { + gint w = gdk_screen_width() * NEWDOC_X_SCALE; + gint h = gdk_screen_height() * NEWDOC_Y_SCALE; + Geom::Point origin = calcAnchorPoint(nv->window_x, nv->window_y, w, h, MIN_ONSCREEN_DISTANCE); + desktop->setWindowSize(w, h); + desktop->setWindowPosition(origin); } // restore zoom and view diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 79c83e38d..167d8a331 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -447,13 +447,15 @@ void SPObject::setLabel(gchar const *label) void SPObject::requestOrphanCollection() { g_return_if_fail(document != NULL); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // do not remove style or script elements (Bug #276244) if (SP_IS_STYLE_ELEM(this)) { // leave it } else if (SP_IS_SCRIPT(this)) { // leave it - } else if (SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) { + + } else if ((! prefs->getBool("/options/cleanupswatches/value", false)) && SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) { // leave it } else if (IS_COLORPROFILE(this)) { // leave it diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 94588e443..34063cb16 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -593,7 +593,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { // find the first one with item children - if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { + if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { shown = pat_i; break; // do not go further up the chain if children are found } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index b1fd31f3d..8f3d5117f 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -783,6 +783,13 @@ int SPShape::hasMarkers() const all three settings. This should be fixed later such that if 'marker' is specified, then all three should appear. */ + // Ignore markers for objects which are inside markers themselves. + for (SPObject *parent = this->parent; parent != NULL; parent = parent->parent) { + if(SP_IS_MARKER(parent)) { + return 0; + } + } + return ( this->_curve && (this->_marker[SP_MARKER_LOC] || @@ -805,8 +812,8 @@ int SPShape::numberOfMarkers(int type) if (pathv.size() == 0) { return 0; } - switch(type) { + case SP_MARKER_LOC: { if ( this->_marker[SP_MARKER_LOC] ) { @@ -830,7 +837,9 @@ int SPShape::numberOfMarkers(int type) for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { n += path_it->size_default() + 1; } - return n - 2; // minus the start and end marker. + n = (n > 1) ? (n - 2) : 0; // Minus the start and end marker, but never negative. + // A path or polyline may have only one point. + return n; } else { return 0; } diff --git a/src/sp-string.cpp b/src/sp-string.cpp index 67f86033e..690903ce8 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -116,10 +116,10 @@ void SPString::read_content() { void SPString::update(SPCtx *ctx, unsigned flags) { // SPObject::onUpdate(ctx, flags); - if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG)) { - /* Parent style or we ourselves changed, so recalculate */ - flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // won't be "just a transformation" anymore, we're going to recompute "x" and "y" attributes - } + // if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG)) { + // /* Parent style or we ourselves changed, so recalculate */ + // flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // won't be "just a transformation" anymore, we're going to recompute "x" and "y" attributes + // } } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 6ee377bc6..b2346ac91 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -366,8 +366,9 @@ void SPSymbol::hide(unsigned int key) { Geom::OptRect SPSymbol::bbox(Geom::Affine const &transform, SPItem::BBoxType type) { Geom::OptRect bbox; + // We don't need a bounding box for Symbols dialog when selecting + // symbols. They have no canvas location. But cloned symbols are. if (this->cloned) { - // Cloned <symbol> is actually renderable Geom::Affine const a( this->c2p * transform ); bbox = SPGroup::bbox(a, type); } diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 70109a3a7..cf0e81dbe 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -278,13 +278,13 @@ gint SPSpiralContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-spiral"); ret = TRUE; } @@ -318,7 +318,7 @@ gint SPSpiralContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 2015ffd27..356cf0161 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -34,6 +34,7 @@ #include "style.h" #include "document.h" #include "document-undo.h" +#include "layer-model.h" #include "message-stack.h" #include "selection.h" #include "desktop-handles.h" @@ -58,79 +59,89 @@ using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -void sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); +void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); void -sp_selected_path_union(SPDesktop *desktop) +sp_selected_path_union(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); + sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); } void -sp_selected_path_union_skip_undo(SPDesktop *desktop) +sp_selected_path_union_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_union, SP_VERB_NONE, _("Union")); + sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_NONE, _("Union")); } void -sp_selected_path_intersect(SPDesktop *desktop) +sp_selected_path_intersect(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); + sp_selected_path_boolop(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); } void -sp_selected_path_diff(SPDesktop *desktop) +sp_selected_path_diff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); + sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); } void -sp_selected_path_diff_skip_undo(SPDesktop *desktop) +sp_selected_path_diff_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_diff, SP_VERB_NONE, _("Difference")); + sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_NONE, _("Difference")); } void -sp_selected_path_symdiff(SPDesktop *desktop) +sp_selected_path_symdiff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); + sp_selected_path_boolop(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); } void -sp_selected_path_cut(SPDesktop *desktop) +sp_selected_path_cut(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); + sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); } void -sp_selected_path_slice(SPDesktop *desktop) +sp_selected_path_slice(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); + sp_selected_path_boolop(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); } +// helper for printing error messages, regardless of whether we have a GUI or not +// If desktop == NULL, errors will be shown on stderr +static void +boolop_display_error_message(SPDesktop *desktop, Glib::ustring const &msg) +{ + if (desktop) { + desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, msg); + } else { + g_printerr("%s\n", msg.c_str()); + } +} // boolean operations // take the source paths from the file, do the operation, delete the originals and add the results void -sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) +sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) { - Inkscape::Selection *selection = sp_desktop_selection(desktop); - + SPDocument *doc = selection->layers()->getDocument(); GSList *il = (GSList *) selection->itemList(); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) if ( (g_slist_length(il) < 2) && (bop != bool_op_union)) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Select <b>at least 2 paths</b> to perform a boolean operation.")); + boolop_display_error_message(desktop, _("Select <b>at least 2 paths</b> to perform a boolean operation.")); return; } else if ( g_slist_length(il) < 1 ) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Select <b>at least 1 path</b> to perform a boolean union.")); + boolop_display_error_message(desktop, _("Select <b>at least 1 path</b> to perform a boolean union.")); return; } if (g_slist_length(il) > 2) { if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Select <b>exactly 2 paths</b> to perform difference, division, or path cut.")); + boolop_display_error_message(desktop, _("Select <b>exactly 2 paths</b> to perform difference, division, or path cut.")); return; } } @@ -146,7 +157,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb Inkscape::XML::Node *b = reinterpret_cast<SPObject *>(il->next->data)->getRepr(); if (a == NULL || b == NULL) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); + boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); return; } @@ -161,7 +172,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // find their lowest common ancestor Inkscape::XML::Node *dad = LCA(a, b); if (dad == NULL) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); + boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); return; } @@ -191,7 +202,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb SPItem *item = SP_ITEM(l->data); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) { - desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("One of the objects is <b>not a path</b>, cannot perform boolean operation.")); + boolop_display_error_message(desktop, _("One of the objects is <b>not a path</b>, cannot perform boolean operation.")); g_slist_free(il); return; } @@ -207,6 +218,11 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb curOrig = 0; for (GSList *l = il; l != NULL; l = l->next) { + // apply live path effects prior to performing boolean operation + if (SP_IS_LPE_ITEM(l->data)) { + sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(l->data), true); + } + SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast<SPObject *>(il->data)->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { @@ -427,8 +443,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb { SP_OBJECT(l->data)->deleteObject(); } - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, - description); + DocumentUndo::done(doc, SP_VERB_NONE, description); selection->clear(); delete res; @@ -450,8 +465,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb sorted = g_slist_sort(sorted, (GCompareFunc) sp_repr_compare_position); - source = sp_desktop_document(desktop)-> - getObjectByRepr((Inkscape::XML::Node *)sorted->data); + source = doc->getObjectByRepr((Inkscape::XML::Node *)sorted->data); g_slist_free(sorted); } @@ -491,7 +505,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb g_slist_free(il); // premultiply by the inverse of parent's repr - SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent)); + SPItem *parent_item = SP_ITEM(doc->getObjectByRepr(parent)); Geom::Affine local (parent_item->i2doc_affine()); gchar *transform = sp_svg_transform_write(local.inverse()); @@ -521,7 +535,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb for (int i=0;i<nbRP;i++) { gchar *d = resPath[i]->svg_dump_path(); - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("style", style); if (mask) @@ -567,7 +581,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb } else { gchar *d = res->svg_dump_path(); - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("style", style); @@ -585,10 +599,10 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb repr->setAttribute("id", id); parent->appendChild(repr); if (title) { - sp_desktop_document(desktop)->getObjectByRepr(repr)->setTitle(title); + doc->getObjectByRepr(repr)->setTitle(title); } if (desc) { - sp_desktop_document(desktop)->getObjectByRepr(repr)->setDesc(desc); + doc->getObjectByRepr(repr)->setDesc(desc); } repr->setPosition(pos > 0 ? pos : 0); @@ -601,7 +615,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb if (desc) g_free(desc); if (verb != SP_VERB_NONE) { - DocumentUndo::done(sp_desktop_document(desktop), verb, description); + DocumentUndo::done(doc, verb, description); } delete res; diff --git a/src/splivarot.h b/src/splivarot.h index 3d2a1ee58..0cefed3c2 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -11,19 +11,28 @@ #include <2geom/forward.h> #include <2geom/path.h> class SPCurve; +class SPDesktop; class SPItem; +namespace Inkscape { + class Selection; +} + // boolean operations // work on the current selection // selection has 2 contain exactly 2 items -void sp_selected_path_union (SPDesktop *desktop); -void sp_selected_path_union_skip_undo (SPDesktop *desktop); -void sp_selected_path_intersect (SPDesktop *desktop); -void sp_selected_path_diff (SPDesktop *desktop); -void sp_selected_path_diff_skip_undo (SPDesktop *desktop); -void sp_selected_path_symdiff (SPDesktop *desktop); -void sp_selected_path_cut (SPDesktop *desktop); -void sp_selected_path_slice (SPDesktop *desktop); + +// UPDATE: these signatures have been modified so they may work in +// command-line mode, i.e. without a desktop. If a desktop is not +// provided (desktop == NULL), error messages will be shown on stderr. +void sp_selected_path_union (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_union_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_intersect (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_diff (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_diff_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_symdiff (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_cut (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_slice (Inkscape::Selection *selection, SPDesktop *desktop); // offset/inset of a curve // takes the fill-rule in consideration diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8bedb237b..66cc30c6d 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -513,7 +513,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, selection->clear(); selection->add(item_copied); selection->add(unionResult); - sp_selected_path_union_skip_undo(selection->desktop()); + sp_selected_path_union_skip_undo(selection, selection->desktop()); selection->add(father); Inkscape::GC::release(copy2); did = true; @@ -651,7 +651,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { tc->has_dilated = false; if(tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { - sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } tc->has_dilated = true; @@ -744,7 +744,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { if (!tc->has_dilated) { // if we did not rub, do a light tap tc->pressure = 0.03; - sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + sp_spray_dilate(tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } tc->is_dilating = false; tc->has_dilated = false; @@ -770,28 +770,28 @@ gint SPSprayContext::root_handler(GdkEvent* event) { switch (get_group0_keyval (&event->key)) { case GDK_KEY_j: case GDK_KEY_J: - if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_spray_switch_mode(tc, SPRAY_MODE_COPY, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_k: case GDK_KEY_K: - if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_spray_switch_mode(tc, SPRAY_MODE_CLONE, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_l: case GDK_KEY_L: - if (MOD__SHIFT_ONLY) { - sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_spray_switch_mode(tc, SPRAY_MODE_SINGLE_PATH, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_Up: case GDK_KEY_KP_Up: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { tc->population += 0.01; if (tc->population > 1.0) { tc->population = 1.0; @@ -802,7 +802,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Down: case GDK_KEY_KP_Down: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { tc->population -= 0.01; if (tc->population < 0.0) { tc->population = 0.0; @@ -813,7 +813,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Right: case GDK_KEY_KP_Right: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { tc->width += 0.01; if (tc->width > 1.0) { tc->width = 1.0; @@ -826,7 +826,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Left: case GDK_KEY_KP_Left: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { tc->width -= 0.01; if (tc->width < 0.01) { tc->width = 0.01; @@ -852,7 +852,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo("altx-spray"); ret = TRUE; } @@ -867,7 +867,7 @@ gint SPSprayContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: @@ -884,11 +884,11 @@ gint SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: - sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); + sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT(event)); tc->_message_context->clear(); break; default: - sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT); + sp_spray_switch_mode (tc, prefs->getInt("/tools/spray/mode"), MOD__SHIFT(event)); break; } } diff --git a/src/star-context.cpp b/src/star-context.cpp index cb3e663d7..4272fb1a0 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -297,13 +297,13 @@ gint SPStarContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-star"); ret = TRUE; } @@ -338,7 +338,7 @@ gint SPStarContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index e045a23c7..57f542373 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -26,6 +26,7 @@ #include <map> +#include "colorspace.h" #include "strneq.h" #include "preferences.h" #include "svg-color.h" @@ -453,30 +454,24 @@ sp_svg_create_color_hash() } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -//helper function borrowed from src/widgets/sp-color-icc-selector.cpp: -void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const**& tippies, guint const*& scalies ); -void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b){ +void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b) +{ guchar color_out[4]; guchar color_in[4]; - if (icc){ + if (icc) { g_message("profile name: %s", icc->colorProfile.c_str()); Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str()); if ( prof ) { cmsHTRANSFORM trans = prof->getTransfToSRGB8(); if ( trans ) { - gchar const** names = 0; - gchar const** tips = 0; - guint const* scales = 0; - getThings( prof, names, tips, scales ); - - gint count = CMSSystem::getChannelCount( prof ); - if (count > 4) { - count = 4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) - } - for (gint i = 0; i < count; i++){ - color_in[i] = static_cast<guchar>((((gdouble)icc->colors[i])*256.0) * (gdouble)scales[i]); -g_message("input[%d]: %d",i, color_in[i]); + std::vector<colorspace::Component> comps = colorspace::getColorSpaceInfo( prof ); + + size_t count = CMSSystem::getChannelCount( prof ); + size_t cap = std::min(count, comps.size()); + for (size_t i = 0; i < cap; i++) { + color_in[i] = static_cast<guchar>((((gdouble)icc->colors[i]) * 256.0) * (gdouble)comps[i].scale); + g_message("input[%d]: %d", (int)i, (int)color_in[i]); } CMSSystem::doTransform( trans, color_in, color_out, 1 ); diff --git a/src/text-context.cpp b/src/text-context.cpp index 1170f5129..254fafe6b 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -220,7 +220,7 @@ void SPTextContext::setup() { ec->shape_editor = new ShapeEditor(ec->desktop); SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); - if (item && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) { + if (item && SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) { ec->shape_editor->set_item(item, SH_KNOTHOLDER); } @@ -309,6 +309,7 @@ gint SPTextContext::item_handler(SPItem* item, GdkEvent* event) { gint ret = FALSE; sp_text_context_validate_cursor_iterators(tc); + Inkscape::Text::Layout::iterator old_start = tc->text_sel_start; switch (event->type) { case GDK_BUTTON_PRESS: @@ -321,7 +322,12 @@ gint SPTextContext::item_handler(SPItem* item, GdkEvent* event) { // find out click point in document coordinates Geom::Point p = desktop->w2d(Geom::Point(event->button.x, event->button.y)); // set the cursor closest to that point - tc->text_sel_start = tc->text_sel_end = sp_te_get_position_by_coords(tc->text, p); + if (event->button.state & GDK_SHIFT_MASK) { + tc->text_sel_start = old_start; + tc->text_sel_end = sp_te_get_position_by_coords(tc->text, p); + } else { + tc->text_sel_start = tc->text_sel_end = sp_te_get_position_by_coords(tc->text, p); + } // update display sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@ -732,12 +738,12 @@ gint SPTextContext::root_handler(GdkEvent* event) { // there is an active text object in this context, or a new object was just created if (tc->unimode || !tc->imc - || (MOD__CTRL && MOD__SHIFT) // input methods tend to steal this for unimode, + || (MOD__CTRL(event) && MOD__SHIFT(event)) // input methods tend to steal this for unimode, // but we have our own so make sure they don't swallow it || !gtk_im_context_filter_keypress(tc->imc, (GdkEventKey*) event)) { //IM did not consume the key, or we're in unimode - if (!MOD__CTRL_ONLY && tc->unimode) { + if (!MOD__CTRL_ONLY(event) && tc->unimode) { /* TODO: ISO 14755 (section 3 Definitions) says that we should also accept the first 6 characters of alphabets other than the latin alphabet "if the Latin alphabet is not used". The below is also @@ -833,13 +839,13 @@ gint SPTextContext::root_handler(GdkEvent* event) { switch (group0_keyval) { case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-text"); return TRUE; } break; case GDK_KEY_space: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY(event)) { /* No-break space */ if (!tc->text) { // printable key; create text if none (i.e. if nascent_object) sp_text_context_setup_text(tc); @@ -856,7 +862,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { break; case GDK_KEY_U: case GDK_KEY_u: - if (MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT)) { + if (MOD__CTRL_ONLY(event) || (MOD__CTRL(event) && MOD__SHIFT(event))) { if (tc->unimode) { tc->unimode = false; event_context->defaultMessageContext()->clear(); @@ -873,7 +879,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { break; case GDK_KEY_B: case GDK_KEY_b: - if (MOD__CTRL_ONLY && tc->text) { + if (MOD__CTRL_ONLY(event) && tc->text) { SPStyle const *style = sp_te_style_at_position(tc->text, std::min(tc->text_sel_start, tc->text_sel_end)); SPCSSAttr *css = sp_repr_css_attr_new(); if (style->font_weight.computed == SP_CSS_FONT_WEIGHT_NORMAL @@ -895,7 +901,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { break; case GDK_KEY_I: case GDK_KEY_i: - if (MOD__CTRL_ONLY && tc->text) { + if (MOD__CTRL_ONLY(event) && tc->text) { SPStyle const *style = sp_te_style_at_position(tc->text, std::min(tc->text_sel_start, tc->text_sel_end)); SPCSSAttr *css = sp_repr_css_attr_new(); if (style->font_style.computed != SP_CSS_FONT_STYLE_NORMAL) @@ -914,7 +920,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_A: case GDK_KEY_a: - if (MOD__CTRL_ONLY && tc->text) { + if (MOD__CTRL_ONLY(event) && tc->text) { Inkscape::Text::Layout const *layout = te_get_layout(tc->text); if (layout) { tc->text_sel_start = layout->begin(); @@ -952,13 +958,21 @@ gint SPTextContext::root_handler(GdkEvent* event) { bool noSelection = false; - if (tc->text_sel_start == tc->text_sel_end) { - tc->text_sel_start.prevCursorPosition(); + if (MOD__CTRL(event)) { + tc->text_sel_start = tc->text_sel_end; + } + + if (tc->text_sel_start == tc->text_sel_end) { + if (MOD__CTRL(event)) { + tc->text_sel_start.prevStartOfWord(); + } else { + tc->text_sel_start.prevCursorPosition(); + } noSelection = true; } - iterator_pair bspace_pair; - bool success = sp_te_delete(tc->text, tc->text_sel_start, tc->text_sel_end, bspace_pair); + iterator_pair bspace_pair; + bool success = sp_te_delete(tc->text, tc->text_sel_start, tc->text_sel_end, bspace_pair); if (noSelection) { if (success) { @@ -986,8 +1000,16 @@ gint SPTextContext::root_handler(GdkEvent* event) { if (tc->text) { bool noSelection = false; + if (MOD__CTRL(event)) { + tc->text_sel_start = tc->text_sel_end; + } + if (tc->text_sel_start == tc->text_sel_end) { - tc->text_sel_end.nextCursorPosition(); + if (MOD__CTRL(event)) { + tc->text_sel_end.nextEndOfWord(); + } else { + tc->text_sel_end.nextCursorPosition(); + } noSelection = true; } @@ -1016,10 +1038,10 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Left: case GDK_KEY_KP_4: if (tc->text) { - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*-10, 0)); else sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*-1, 0)); @@ -1028,7 +1050,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, _("Kern to the left")); } else { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.cursorLeftWithControl(); else tc->text_sel_end.cursorLeft(); @@ -1041,10 +1063,10 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Right: case GDK_KEY_KP_6: if (tc->text) { - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*10, 0)); else sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*1, 0)); @@ -1053,7 +1075,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, _("Kern to the right")); } else { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.cursorRightWithControl(); else tc->text_sel_end.cursorRight(); @@ -1066,10 +1088,10 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_8: if (tc->text) { - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*-10)); else sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*-1)); @@ -1078,7 +1100,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, _("Kern up")); } else { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.cursorUpWithControl(); else tc->text_sel_end.cursorUp(); @@ -1091,10 +1113,10 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Down: case GDK_KEY_KP_2: if (tc->text) { - if (MOD__ALT) { + if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*10)); else sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*1)); @@ -1103,7 +1125,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, _("Kern down")); } else { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.cursorDownWithControl(); else tc->text_sel_end.cursorDown(); @@ -1115,7 +1137,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_Home: case GDK_KEY_KP_Home: if (tc->text) { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.thisStartOfShape(); else tc->text_sel_end.thisStartOfLine(); @@ -1126,7 +1148,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_End: case GDK_KEY_KP_End: if (tc->text) { - if (MOD__CTRL) + if (MOD__CTRL(event)) tc->text_sel_end.nextStartOfShape(); else tc->text_sel_end.thisEndOfLine(); @@ -1165,9 +1187,9 @@ gint SPTextContext::root_handler(GdkEvent* event) { return TRUE; case GDK_KEY_bracketleft: if (tc->text) { - if (MOD__ALT || MOD__CTRL) { - if (MOD__ALT) { - if (MOD__SHIFT) { + if (MOD__ALT(event) || MOD__CTRL(event)) { + if (MOD__ALT(event)) { + if (MOD__SHIFT(event)) { // FIXME: alt+shift+[] does not work, don't know why sp_te_adjust_rotation_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); } else { @@ -1186,9 +1208,9 @@ gint SPTextContext::root_handler(GdkEvent* event) { break; case GDK_KEY_bracketright: if (tc->text) { - if (MOD__ALT || MOD__CTRL) { - if (MOD__ALT) { - if (MOD__SHIFT) { + if (MOD__ALT(event) || MOD__CTRL(event)) { + if (MOD__ALT(event)) { + if (MOD__SHIFT(event)) { // FIXME: alt+shift+[] does not work, don't know why sp_te_adjust_rotation_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); } else { @@ -1208,16 +1230,16 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_less: case GDK_KEY_comma: if (tc->text) { - if (MOD__ALT) { - if (MOD__CTRL) { - if (MOD__SHIFT) + if (MOD__ALT(event)) { + if (MOD__CTRL(event)) { + if (MOD__SHIFT(event)) sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -1); DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, _("Contract line spacing")); } else { - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -1); @@ -1233,16 +1255,16 @@ gint SPTextContext::root_handler(GdkEvent* event) { case GDK_KEY_greater: case GDK_KEY_period: if (tc->text) { - if (MOD__ALT) { - if (MOD__CTRL) { - if (MOD__SHIFT) + if (MOD__ALT(event)) { + if (MOD__CTRL(event)) { + if (MOD__SHIFT(event)) sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 1); DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, _("Expand line spacing")); } else { - if (MOD__SHIFT) + if (MOD__SHIFT(event)) sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 1); @@ -1260,7 +1282,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { } if (cursor_moved) { - if (!MOD__SHIFT) + if (!MOD__SHIFT(event)) tc->text_sel_start = tc->text_sel_end; if (old_start != tc->text_sel_start || old_end != tc->text_sel_end) { sp_text_context_update_cursor(tc); @@ -1276,7 +1298,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { group0_keyval == GDK_KEY_Down || group0_keyval == GDK_KEY_KP_Up || group0_keyval == GDK_KEY_KP_Down ) - && !MOD__CTRL_ONLY) { + && !MOD__CTRL_ONLY(event)) { return TRUE; } else if (group0_keyval == GDK_KEY_Escape) { // cancel rubberband if (tc->creating) { @@ -1287,7 +1309,7 @@ gint SPTextContext::root_handler(GdkEvent* event) { } Inkscape::Rubberband::get(desktop)->stop(); } - } else if ((group0_keyval == GDK_KEY_x || group0_keyval == GDK_KEY_X) && MOD__ALT_ONLY) { + } else if ((group0_keyval == GDK_KEY_x || group0_keyval == GDK_KEY_X) && MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-text"); return TRUE; } @@ -1459,7 +1481,7 @@ sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext ec->shape_editor->unset_item(SH_KNOTHOLDER); SPItem *item = selection->singleItem(); - if (item && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) { + if (item && SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) { ec->shape_editor->set_item(item, SH_KNOTHOLDER); } diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 1a1426b83..8c9130412 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -2,18 +2,8 @@ Copyright 2005, 2006 by Gerald Friedland, Kristian Jantz and Lars Knipping Conversion to C++ for Inkscape by Bob Jamison - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Released under GNU GPL, read the file 'COPYING' for more information */ #include "siox.h" diff --git a/src/trace/siox.h b/src/trace/siox.h index 9a44ce1cf..fa18ac238 100644 --- a/src/trace/siox.h +++ b/src/trace/siox.h @@ -5,17 +5,7 @@ * * Conversion to C++ for Inkscape by Bob Jamison * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Released under GNU GPL, read the file 'COPYING' for more information */ /* diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index d1cf8bbf9..4e842abbb 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -32,6 +32,15 @@ #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-tweak-move.xpm" +#include "pixmaps/cursor-tweak-move-in.xpm" +#include "pixmaps/cursor-tweak-move-out.xpm" +#include "pixmaps/cursor-tweak-move-jitter.xpm" +#include "pixmaps/cursor-tweak-scale-up.xpm" +#include "pixmaps/cursor-tweak-scale-down.xpm" +#include "pixmaps/cursor-tweak-rotate-clockwise.xpm" +#include "pixmaps/cursor-tweak-rotate-counterclockwise.xpm" +#include "pixmaps/cursor-tweak-more.xpm" +#include "pixmaps/cursor-tweak-less.xpm" #include "pixmaps/cursor-thin.xpm" #include "pixmaps/cursor-thicken.xpm" #include "pixmaps/cursor-attract.xpm" @@ -178,23 +187,39 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) break; case TWEAK_MODE_MOVE_IN_OUT: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + if (with_shift) { + event_context->cursor_shape = cursor_tweak_move_out_xpm; + } else { + event_context->cursor_shape = cursor_tweak_move_in_xpm; + } break; case TWEAK_MODE_MOVE_JITTER: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + event_context->cursor_shape = cursor_tweak_move_jitter_xpm; break; case TWEAK_MODE_SCALE: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + if (with_shift) { + event_context->cursor_shape = cursor_tweak_scale_up_xpm; + } else { + event_context->cursor_shape = cursor_tweak_scale_down_xpm; + } break; case TWEAK_MODE_ROTATE: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + if (with_shift) { + event_context->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; + } else { + event_context->cursor_shape = cursor_tweak_rotate_clockwise_xpm; + } break; case TWEAK_MODE_MORELESS: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + if (with_shift) { + event_context->cursor_shape = cursor_tweak_less_xpm; + } else { + event_context->cursor_shape = cursor_tweak_more_xpm; + } break; case TWEAK_MODE_PUSH: tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); @@ -1207,7 +1232,7 @@ gint SPTweakContext::root_handler(GdkEvent* event) { if (!this->has_dilated) { // if we did not rub, do a light tap this->pressure = 0.03; - sp_tweak_dilate (this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT); + sp_tweak_dilate (this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } this->is_dilating = false; this->has_dilated = false; @@ -1274,24 +1299,24 @@ gint SPTweakContext::root_handler(GdkEvent* event) { case GDK_KEY_m: case GDK_KEY_M: case GDK_KEY_0: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_MOVE, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_i: case GDK_KEY_I: case GDK_KEY_1: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_z: case GDK_KEY_Z: case GDK_KEY_2: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1300,84 +1325,84 @@ gint SPTweakContext::root_handler(GdkEvent* event) { case GDK_KEY_greater: case GDK_KEY_period: case GDK_KEY_3: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_SCALE, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_SCALE, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_bracketright: case GDK_KEY_bracketleft: case GDK_KEY_4: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_ROTATE, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_ROTATE, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_d: case GDK_KEY_D: case GDK_KEY_5: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_MORELESS, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_MORELESS, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_p: case GDK_KEY_P: case GDK_KEY_6: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_PUSH, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_PUSH, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_s: case GDK_KEY_S: case GDK_KEY_7: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_a: case GDK_KEY_A: case GDK_KEY_8: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_r: case GDK_KEY_R: case GDK_KEY_9: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_ROUGHEN, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_ROUGHEN, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_c: case GDK_KEY_C: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_COLORPAINT, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_COLORPAINT, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_j: case GDK_KEY_J: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_COLORJITTER, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_COLORJITTER, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_b: case GDK_KEY_B: - if (MOD__SHIFT_ONLY) { - sp_tweak_switch_mode(this, TWEAK_MODE_BLUR, MOD__SHIFT); + if (MOD__SHIFT_ONLY(event)) { + sp_tweak_switch_mode(this, TWEAK_MODE_BLUR, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_Up: case GDK_KEY_KP_Up: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->force += 0.05; if (this->force > 1.0) { this->force = 1.0; @@ -1388,7 +1413,7 @@ gint SPTweakContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Down: case GDK_KEY_KP_Down: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->force -= 0.05; if (this->force < 0.0) { this->force = 0.0; @@ -1399,7 +1424,7 @@ gint SPTweakContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Right: case GDK_KEY_KP_Right: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->width += 0.01; if (this->width > 1.0) { this->width = 1.0; @@ -1411,7 +1436,7 @@ gint SPTweakContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Left: case GDK_KEY_KP_Left: - if (!MOD__CTRL_ONLY) { + if (!MOD__CTRL_ONLY(event)) { this->width -= 0.01; if (this->width < 0.01) { this->width = 0.01; @@ -1437,7 +1462,7 @@ gint SPTweakContext::root_handler(GdkEvent* event) { break; case GDK_KEY_x: case GDK_KEY_X: - if (MOD__ALT_ONLY) { + if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-tweak"); ret = TRUE; } @@ -1450,12 +1475,12 @@ gint SPTweakContext::root_handler(GdkEvent* event) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: - sp_tweak_switch_mode_temporarily(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT); + sp_tweak_switch_mode_temporarily(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); break; case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: @@ -1472,11 +1497,11 @@ gint SPTweakContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: - sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); + sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); this->_message_context->clear(); break; default: - sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT); + sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); break; } } diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index ba9670d86..6f1137e46 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -359,7 +359,7 @@ void AboutBox::initStrings() { "Nick\n" "Andreas Nilsson\n" "Mitsuru Oka\n" -"Marten Owens\n" +"Martin Owens\n" "Alvin Penner\n" "Jon Phillips\n" "Zdenko Podobny\n" diff --git a/src/ui/dialog/aboutbox.h b/src/ui/dialog/aboutbox.h index 622b1324f..7b3308672 100644 --- a/src/ui/dialog/aboutbox.h +++ b/src/ui/dialog/aboutbox.h @@ -15,6 +15,14 @@ #ifndef INKSCAPE_UI_DIALOG_ABOUTBOX_H #define INKSCAPE_UI_DIALOG_ABOUTBOX_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> namespace Inkscape { diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index dbd06d9e8..8845b60e5 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -88,119 +88,73 @@ Action::Action(const Glib::ustring &id, } -void ActionAlign::do_action(SPDesktop *desktop, int index) { - +void ActionAlign::do_action(SPDesktop *desktop, int index) +{ Inkscape::Selection *selection = sp_desktop_selection(desktop); if (!selection) return; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - int prefs_bbox = prefs->getBool("/tools/bounding_box"); using Inkscape::Util::GSListConstIterator; std::list<SPItem *> selected; selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL); if (selected.empty()) return; - Geom::Point mp; //Anchor point - AlignAndDistribute::AlignTarget target = AlignAndDistribute::getAlignTarget(); - const Coeffs &a= _allCoeffs[index]; - switch (target) - { - case AlignAndDistribute::LAST: - case AlignAndDistribute::FIRST: - case AlignAndDistribute::BIGGEST: - case AlignAndDistribute::SMALLEST: + const Coeffs &a = _allCoeffs[index]; + SPItem *focus = NULL; + Geom::OptRect b = Geom::OptRect(); + Selection::CompareSize horiz = (a.mx0 != 0.0) || (a.mx1 != 0.0) + ? Selection::HORIZONTAL : Selection::VERTICAL; + + switch (AlignTarget(prefs->getInt("/dialogs/align/align-to", 6))) { - //Check 2 or more selected objects - std::list<SPItem *>::iterator second(selected.begin()); - ++second; - if (second == selected.end()) - return; - //Find the master (anchor on which the other objects are aligned) - std::list<SPItem *>::iterator master( - AlignAndDistribute::find_master ( - selected, - (a.mx0 != 0.0) || - (a.mx1 != 0.0) ) - ); - //remove the master from the selection - SPItem * thing = *master; - // TODO: either uncomment or remove the following commented lines, depending on which - // behaviour of moving objects makes most sense; also cf. discussion at - // https://bugs.launchpad.net/inkscape/+bug/255933 - /*if (!sel_as_group) { */ - selected.erase(master); - /*}*/ - //Compute the anchor point - Geom::OptRect b = !prefs_bbox ? thing->desktopVisualBounds() : thing->desktopGeometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case LAST: + focus = SP_ITEM(*selected.begin()); break; - } - - case AlignAndDistribute::PAGE: - mp = Geom::Point(a.mx1 * sp_desktop_document(desktop)->getWidth(), - a.my1 * sp_desktop_document(desktop)->getHeight()); + case FIRST: + focus = SP_ITEM(*--(selected.end())); break; - - case AlignAndDistribute::DRAWING: - { - Geom::OptRect b = !prefs_bbox ? sp_desktop_document(desktop)->getRoot()->desktopVisualBounds() - : sp_desktop_document(desktop)->getRoot()->desktopGeometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case BIGGEST: + focus = selection->largestItem(horiz); break; - } - - case AlignAndDistribute::SELECTION: - { - Geom::OptRect b = !prefs_bbox ? selection->visualBounds() : selection->geometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case SMALLEST: + focus = selection->smallestItem(horiz); + break; + case PAGE: + b = sp_desktop_document(desktop)->preferredBounds(); + break; + case DRAWING: + b = sp_desktop_document(desktop)->getRoot()->desktopPreferredBounds(); + break; + case SELECTION: + b = selection->preferredBounds(); break; - } - default: g_assert_not_reached (); break; - }; // end of switch + }; + + if(focus) + b = focus->desktopPreferredBounds(); + g_return_if_fail(b); - // Top hack: temporarily set clone compensation to unmoved, so that we can align/distribute - // clones with their original (and the move of the original does not disturb the - // clones). The only problem with this is that if there are outside-of-selection clones of - // a selected original, they will be unmoved too, possibly contrary to user's - // expecation. However this is a minor point compared to making align/distribute always - // work as expected, and "unmoved" is the default option anyway. - int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + // Generate the move point from the selected bounding box + Geom::Point mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], + a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); bool changed = false; - Geom::OptRect b; if (sel_as_group) - b = !prefs_bbox ? selection->visualBounds() : selection->geometricBounds(); + b = selection->preferredBounds(); //Move each item in the selected list separately for (std::list<SPItem *>::iterator it(selected.begin()); - it != selected.end(); - it++) + it != selected.end(); ++it) { sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { + b = (*it)->desktopPreferredBounds(); + if (b && (!focus || (*it) != focus)) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); Geom::Point const mp_rel( mp - sp ); @@ -211,15 +165,10 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) { } } - // restore compensation setting - prefs->setInt("/options/clonecompensation/value", saved_compensation); - if (changed) { DocumentUndo::done( sp_desktop_document(desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Align")); } - - } @@ -347,7 +296,7 @@ private : float pos = sorted.front().bbox.min()[_orientation]; for ( std::vector<BBoxSort> ::iterator it (sorted.begin()); it < sorted.end(); - it ++ ) + ++it ) { if (!Geom::are_near(pos, it->bbox.min()[_orientation], 1e-6)) { Geom::Point t(0.0, 0.0); @@ -1265,69 +1214,6 @@ void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib:: *this, table, orientation, distribute)); } - - - -std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem *> &list, bool horizontal){ - std::list<SPItem *>::iterator master = list.end(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int prefs_bbox = prefs->getBool("/tools/bounding_box"); - switch (getAlignTarget()) { - case LAST: - return list.begin(); - break; - - case FIRST: - return --(list.end()); - break; - - case BIGGEST: - { - gdouble max = -1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { - Geom::OptRect b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { - gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); - if (dim > max) { - max = dim; - master = it; - } - } - } - return master; - } - - case SMALLEST: - { - gdouble max = 1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { - Geom::OptRect b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { - gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); - if (dim < max) { - max = dim; - master = it; - } - } - } - return master; - } - - default: - g_assert_not_reached (); - break; - - } // end of switch statement - return master; -} - -AlignAndDistribute::AlignTarget AlignAndDistribute::getAlignTarget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - return AlignTarget(prefs->getInt("/dialogs/align/align-to", 6)); -} - - - } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index c9165a83e..dfd84535b 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -47,12 +47,6 @@ public: static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); } - enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION }; - - - - static AlignTarget getAlignTarget(); - #if WITH_GTKMM_3_0 Gtk::Grid &align_table(){return _alignTable;} Gtk::Grid &distribute_table(){return _distributeTable;} @@ -67,7 +61,6 @@ public: Gtk::Table &nodes_table(){return _nodesTable;} #endif - static std::list<SPItem *>::iterator find_master(std::list <SPItem *> &list, bool horizontal); void setMode(bool nodeEdit); Geom::OptRect randomize_bbox; @@ -189,6 +182,7 @@ public : double sx0, sx1, sy0, sy1; int verb_id; }; + enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION }; ActionAlign(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, @@ -204,6 +198,7 @@ public : * Static function called to align from a keyboard shortcut */ static void do_verb_action(SPDesktop *desktop, int verb); + static int verb_to_coeff(int verb); private : @@ -217,7 +212,6 @@ private : } static void do_action(SPDesktop *desktop, int index); - static int verb_to_coeff(int verb); guint _index; AlignAndDistribute &_dialog; diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index 4ef71900b..3256338eb 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -15,6 +15,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/entry.h> #include <gtkmm/label.h> diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index e09d9b1d1..2292b66fc 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -11,7 +11,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <errno.h> + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/label.h> #include <glibmm/i18n.h> #include <cairo.h> diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index d127261c0..9e2287f80 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -13,6 +13,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/dialog.h> #include <gtkmm/textview.h> diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 3017dc117..a851503fe 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -20,6 +20,10 @@ // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include <png.h> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/buttonbox.h> #include <gtkmm/dialog.h> @@ -87,6 +91,7 @@ #include <windows.h> #include <commdlg.h> #include <gdk/gdkwin32.h> +#include <glibmm/fileutils.h> #endif #include <gtk/gtk.h> diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 3413b0b0d..e71605739 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -15,9 +15,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "filedialogimpl-win32.h" #include "filedialogimpl-gtkmm.h" #include "filedialog.h" -#include "filedialogimpl-win32.h" #include "gc-core.h" #include <dialogs/dialog-events.h> diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index 7501b5e14..6687915d7 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -17,6 +17,14 @@ #ifndef __FILE_DIALOGIMPL_H__ #define __FILE_DIALOGIMPL_H__ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + //Gtk includes #include <gtkmm/filechooserdialog.h> #include <glib/gstdio.h> diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 496836c4d..9d91f5d56 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -16,7 +16,7 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif - +#include "filedialogimpl-win32.h" //General includes #include <list> #include <unistd.h> @@ -26,9 +26,7 @@ #include <gdk/gdkwin32.h> #include <glib/gstdio.h> #include <glibmm/i18n.h> -#if GLIB_CHECK_VERSION(2,32,0) -#include <glibmm/thread.h> -#endif +#include <glibmm/fileutils.h> #include <gtkmm/window.h> //Inkscape includes @@ -44,7 +42,7 @@ #include "display/canvas-arena.h" #include "filedialog.h" -#include "filedialogimpl-win32.h" + #include "sp-root.h" #include <zlib.h> diff --git a/src/ui/dialog/filedialogimpl-win32.h b/src/ui/dialog/filedialogimpl-win32.h index e9d8829f7..2e6bb4bb8 100644 --- a/src/ui/dialog/filedialogimpl-win32.h +++ b/src/ui/dialog/filedialogimpl-win32.h @@ -9,11 +9,21 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ +#if HAVE_CONFIG_H +# include "config.h" +#endif #ifdef WIN32 +#if WITH_GLIBMM_2_32 +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +# include <glibmm/threads.h> +#endif +#endif #include "gc-core.h" #include <windows.h> +#include "filedialogimpl-gtkmm.h" + namespace Inkscape { diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 0d2d0757c..4401d5658 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1155,7 +1155,13 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) sw->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _list.get_column(1)->set_resizable(true); - + _list.set_reorderable(true); + + // We can track the drag/drop reordering from the row_delete (occurs after + // row_inserted and may occur many times when adding a new item) + _model->signal_row_deleted().connect( + sigc::mem_fun(*this, &FilterModifier::on_filter_reorder)); + sw->set_shadow_type(Gtk::SHADOW_IN); show_all_children(); _add.signal_clicked().connect(sigc::mem_fun(*this, &FilterModifier::add_filter)); @@ -1260,6 +1266,7 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } if (style->filter.set && style->getFilter()) { + SP_ITEM(obj)->bbox_valid = FALSE; used.insert(style->getFilter()); } else { used.insert(0); @@ -1300,6 +1307,13 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } } +void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& path) { + for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { + SPObject* object = (*i)[_columns.filter]; + object->getRepr()->setPosition(0); + } +} + void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) { Gtk::TreeIter iter = _model->get_iter(path); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 658aac790..a2a2a3c6e 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -86,6 +86,7 @@ private: void on_filter_selection_changed(); void on_name_edited(const Glib::ustring&, const Glib::ustring&); + void on_filter_reorder(const Gtk::TreeModel::Path& path); void on_selection_toggled(const Glib::ustring&); void update_filters(); diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index d70c5f187..dd07f009a 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -10,6 +10,14 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/stock.h> #include <glibmm/main.h> diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 9fa94ca8f..bf9133086 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -10,6 +10,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/messagedialog.h> #include <gtkmm/checkbutton.h> #include <gtkmm/scrolledwindow.h> diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index a15667152..422fed7fe 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -15,6 +15,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #if WITH_GTKMM_3_0 diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 1a52410b8..468e85d36 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -17,6 +17,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/buttonbox.h> #include <boost/scoped_ptr.hpp> diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 65c6a20fe..bc648002d 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -8,7 +8,7 @@ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bruno Dilly <bruno.dilly@gmail.com> * - * Copyright (C) 2004-2011 Authors + * Copyright (C) 2004-2013 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -642,6 +642,15 @@ void InkscapePreferences::initPageUI() _win_ontop_normal.init ( _("Normal"), "/options/transientpolicy/value", 1, true, &_win_ontop_none); _win_ontop_agressive.init ( _("Aggressive"), "/options/transientpolicy/value", 2, false, &_win_ontop_none); + { + Glib::ustring defaultSizeLabels[] = {_("Small"), _("Large"), _("Maximized")}; + int defaultSizeValues[] = {0, 1, 2}; + + _win_default_size.init( "/options/defaultwindowsize/value", defaultSizeLabels, defaultSizeValues, G_N_ELEMENTS(defaultSizeLabels), 1 ); + _page_windows.add_line( false, _("Default window size:"), _win_default_size, "", + _("Set the default window size"), false); + } + _page_windows.add_group_header( _("Saving window geometry (size and position)")); _page_windows.add_line( true, "", _win_save_geom_off, "", _("Let the window manager determine placement of all windows")); @@ -1332,6 +1341,13 @@ void InkscapePreferences::initPageBehavior() _("Update marker color when object color changes")); this->AddPage(_page_markers, _("Markers"), iter_behavior, PREFS_PAGE_BEHAVIOR_MARKERS); + + + _page_cleanup.add_group_header( _("Document cleanup")); + _cleanup_swatches.init ( _("Remove unused swatches when doing a document cleanup"), "/options/cleanupswatches/value", false); // text label + _page_cleanup.add_line( true, "", _cleanup_swatches, "", + _("Remove unused swatches when doing a document cleanup")); // tooltip + this->AddPage(_page_cleanup, _("Cleanup"), iter_behavior, PREFS_PAGE_BEHAVIOR_CLEANUP); } void InkscapePreferences::initPageRendering() @@ -1423,6 +1439,9 @@ void InkscapePreferences::initPageBitmaps() Glib::ustring values[] = {"embed", "link", "ask"}; _bitmap_import.init("/dialogs/import/link", labels, values, G_N_ELEMENTS(values), "ask"); _page_bitmaps.add_line( false, _("Bitmap import:"), _bitmap_import, "", "", false); + + _bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false); + _page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false); } _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); _page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"), diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index eaf1ffc3d..37c05df05 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -7,7 +7,7 @@ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bruno Dilly <bruno.dilly@gmail.com> * - * Copyright (C) 2004-2007 Authors + * Copyright (C) 2004-2013 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -74,6 +74,7 @@ enum { PREFS_PAGE_BEHAVIOR_CLONES, PREFS_PAGE_BEHAVIOR_MASKS, PREFS_PAGE_BEHAVIOR_MARKERS, + PREFS_PAGE_BEHAVIOR_CLEANUP, PREFS_PAGE_IO, PREFS_PAGE_IO_MOUSE, PREFS_PAGE_IO_SVGOUTPUT, @@ -167,6 +168,7 @@ protected: UI::Widget::DialogPage _page_clones; UI::Widget::DialogPage _page_mask; UI::Widget::DialogPage _page_markers; + UI::Widget::DialogPage _page_cleanup; UI::Widget::DialogPage _page_io; UI::Widget::DialogPage _page_mouse; @@ -241,6 +243,7 @@ protected: UI::Widget::PrefRadioButton _win_gtk; UI::Widget::PrefRadioButton _win_save_dialog_pos_on; UI::Widget::PrefRadioButton _win_save_dialog_pos_off; + UI::Widget::PrefCombo _win_default_size; UI::Widget::PrefRadioButton _win_ontop_none; UI::Widget::PrefRadioButton _win_ontop_normal; UI::Widget::PrefRadioButton _win_ontop_agressive; @@ -310,6 +313,8 @@ protected: UI::Widget::PrefCheckButton _markers_color_stock; UI::Widget::PrefCheckButton _markers_color_custom; UI::Widget::PrefCheckButton _markers_color_update; + + UI::Widget::PrefCheckButton _cleanup_swatches; UI::Widget::PrefSpinButton _importexport_export_res; UI::Widget::PrefSpinButton _importexport_import_res; @@ -366,6 +371,7 @@ protected: UI::Widget::PrefCheckButton _misc_bitmap_autoreload; UI::Widget::PrefSpinButton _bitmap_copy_res; UI::Widget::PrefCombo _bitmap_import; + UI::Widget::PrefSpinButton _bitmap_import_quality; UI::Widget::PrefEntry _kb_search; UI::Widget::PrefCombo _kb_filelist; diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index 0e2f8ed94..d38b8edf5 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -16,6 +16,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/entry.h> #include <gtkmm/label.h> diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index dd147d00f..c41046123 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -27,6 +27,7 @@ #include "document.h" #include "document-undo.h" #include "helper/action.h" +#include "helper/action-context.h" #include "inkscape.h" #include "layer-fns.h" #include "layer-manager.h" @@ -41,6 +42,7 @@ #include "xml/repr.h" #include "sp-root.h" #include "event-context.h" +#include "selection-chemistry.h" //#define DUMP_LAYERS 1 @@ -98,7 +100,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !set && action && action->image ) { GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image ); gtk_widget_show( child ); @@ -130,7 +132,7 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); } @@ -171,7 +173,7 @@ void LayersPanel::_fireAction( unsigned int code ) if ( _desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); if ( action ) { sp_action_perform( action, NULL ); // } else { @@ -403,13 +405,13 @@ void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::R SPObject *child = _desktop->layer_manager->nthChildOf(layer, i); if ( child ) { #if DUMP_LAYERS - g_message(" %3d layer:%p {%s} [%s]", level, child, child->id, child->label() ); + g_message(" %3d layer:%p {%s} [%s]", level, child, child->getId(), child->label() ); #endif // DUMP_LAYERS Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row row = *iter; row[_model->_colObject] = child; - row[_model->_colLabel] = child->label() ? child->label() : child->getId(); + row[_model->_colLabel] = child->defaultLabel(); row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false; row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false; @@ -536,6 +538,7 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) break; } } + Inkscape::SelectionHelper::fixSelection(_desktop); } bool LayersPanel::_handleKeyEvent(GdkEventKey *event) diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index e9fd9ebc6..ae0ac6040 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -12,6 +12,14 @@ #ifndef SEEN_LAYERS_PANEL_H #define SEEN_LAYERS_PANEL_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/treeview.h> #include <gtkmm/treestore.h> diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 00f58b038..7fa766272 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -11,6 +11,14 @@ #ifndef INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H #define INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/liststore.h> #include <gtkmm/treeview.h> diff --git a/src/ui/dialog/messages.h b/src/ui/dialog/messages.h index 6ed246ece..54ca84f47 100644 --- a/src/ui/dialog/messages.h +++ b/src/ui/dialog/messages.h @@ -16,6 +16,14 @@ #ifndef INKSCAPE_UI_DIALOG_MESSAGES_H #define INKSCAPE_UI_DIALOG_MESSAGES_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/textview.h> #include <gtkmm/button.h> diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index c597bc849..f87288494 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -919,7 +919,7 @@ void ImportDialog::on_image_downloaded(Glib::ustring path, bool success) m_signal_response.emit(path); widget_status->set_info(_("Clipart downloaded successfully")); } catch(Glib::Error) { - success = false; + // success = false; //has no effect, value not returned } cancelled_image = false; @@ -943,7 +943,7 @@ void ImportDialog::on_thumbnail_downloaded(Glib::ustring path, bool success) widget_status->clear(); preview_files->set_image(path); } catch(Glib::Error) { - success = false; + // success = false; //has no effect, value not returned } cancelled_thumbnail = false; diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 8cb247766..e21030bcd 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -13,6 +13,14 @@ #ifndef __OCAL_DIALOG_H__ #define __OCAL_DIALOG_H__ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + //Gtk includes #include <gtkmm/box.h> #include <gtkmm/eventbox.h> diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h index ab75809f3..27b89e34e 100644 --- a/src/ui/dialog/spellcheck.h +++ b/src/ui/dialog/spellcheck.h @@ -12,6 +12,14 @@ #ifndef SEEN_SPELLCHECK_H #define SEEN_SPELLCHECK_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/button.h> #include <gtkmm/buttonbox.h> diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 2884de173..d4d80c9b1 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -56,6 +56,7 @@ #include "verbs.h" #include "gradient-chemistry.h" #include "helper/action.h" +#include "helper/action-context.h" namespace Inkscape { namespace UI { @@ -153,7 +154,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) // Invoke the gradient tool Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT ); if ( verb ) { - SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP); + SPAction *action = verb->get_action( Inkscape::ActionContext( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP ) ); if ( action ) { sp_action_perform( action, NULL ); } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 989375bbd..26bc52947 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -18,10 +18,15 @@ #include <functional> #include <sstream> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/buttonbox.h> #include <gtkmm/label.h> #if WITH_GTKMM_3_0 +# include <gtkmm/togglebutton.h> # include <gtkmm/grid.h> #else # include <gtkmm/table.h> @@ -40,9 +45,11 @@ #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 "desktop-handles.h" #include "document.h" @@ -51,6 +58,7 @@ #include "sp-use.h" #include "sp-defs.h" #include "sp-symbol.h" +#include "widgets/icon.h" #ifdef WITH_LIBVISIO #include <libvisio/libvisio.h> @@ -58,6 +66,8 @@ #endif #include "verbs.h" +#include "helper/action.h" +#include "helper/action-context.h" #include "xml/repr.h" namespace Inkscape { @@ -96,8 +106,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), store(Gtk::ListStore::create(*getColumns())), iconView(0), - previewScale(0), - previewSize(0), currentDesktop(0), deskTrack(), currentDocument(0), @@ -136,8 +144,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); #endif - sigc::connection connSet = - symbolSet->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + sigc::connection connSet = symbolSet->signal_changed().connect( + sigc::mem_fun(*this, &SymbolsDialog::rebuild)); instanceConns.push_back(connSet); ++row; @@ -148,7 +156,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : iconView = new Gtk::IconView(static_cast<Glib::RefPtr<Gtk::TreeModel> >(store)); //iconView->set_text_column( columns->symbol_id ); iconView->set_tooltip_column( 1 ); - iconView->set_pixbuf_column( columns->symbol_image ); + iconView->set_pixbuf_column( columns->symbol_image ); // Giving the iconview a small minimum size will help users understand // What the dialog does. iconView->set_size_request( 100, 200 ); @@ -157,11 +165,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); - iconView->signal_drag_data_get().connect(sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); + iconView->signal_drag_data_get().connect( + sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); sigc::connection connIconChanged; - connIconChanged = - iconView->signal_selection_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); + connIconChanged = iconView->signal_selection_changed().connect( + sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); instanceConns.push_back(connIconChanged); Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); @@ -178,63 +187,68 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; - /******************** Preview Scale ***********************/ - Gtk::Label* labelScale = new Gtk::Label(_("Preview scale: ")); + /******************** Tools *******************************/ + Gtk::Button* button; + Gtk::HBox* tools = new Gtk::HBox(); + //tools->set_layout( Gtk::BUTTONBOX_END ); #if WITH_GTKMM_3_0 - table->attach(*Gtk::manage(labelScale),0,row,1,1); + scroller->set_hexpand(); + table->attach(*Gtk::manage(tools),0,row,2,1); #else - table->attach(*Gtk::manage(labelScale),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); + table->attach(*Gtk::manage(tools),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL); #endif - previewScale = new Gtk::ComboBoxText(); - const gchar *scales[] = - {_("Fit"), _("Fit to width"), _("Fit to height"), "0.1", "0.2", "0.5", "1.0", "2.0", "5.0", NULL}; - for( int i = 0; scales[i]; ++i ) { - previewScale->append(scales[i]); - } - previewScale->set_active_text(scales[0]); + addSymbol = Gtk::manage(new Gtk::Button()); + addSymbol->add(*Gtk::manage(Glib::wrap( + sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-add")))) ); + addSymbol->set_tooltip_text(_("Add Symbol from the current document.")); + addSymbol->set_relief( Gtk::RELIEF_NONE ); + addSymbol->set_focus_on_click( false ); + addSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); + tools->pack_start(* addSymbol, Gtk::PACK_SHRINK); + + removeSymbol = Gtk::manage(new Gtk::Button()); + removeSymbol->add(*Gtk::manage(Glib::wrap( + sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-remove")))) ); + removeSymbol->set_tooltip_text(_("Remove Symbol from the current document.")); + removeSymbol->set_relief( Gtk::RELIEF_NONE ); + removeSymbol->set_focus_on_click( false ); + removeSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol)); + tools->pack_start(* removeSymbol, Gtk::PACK_SHRINK); + + Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); + tools->pack_start(* Gtk::manage(spacer)); + + in_sizes = 2; // Default 32px + button = Gtk::manage(new Gtk::Button()); + button->add(*Gtk::manage(Glib::wrap( + sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-bigger")))) ); + button->set_tooltip_text(_("Make Icons bigger by zooming in.")); + button->set_relief( Gtk::RELIEF_NONE ); + button->set_focus_on_click( false ); + button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin)); + tools->pack_start(* button, Gtk::PACK_SHRINK); + + button = Gtk::manage(new Gtk::Button()); + button->add(*Gtk::manage(Glib::wrap( + sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-smaller")))) ); + button->set_tooltip_text(_("Make Icons smaller by zooming out.")); + button->set_relief( Gtk::RELIEF_NONE ); + button->set_focus_on_click( false ); + button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); + tools->pack_start(* button, Gtk::PACK_SHRINK); + + fitSymbol = Gtk::manage(new Gtk::ToggleButton()); + fitSymbol->add(*Gtk::manage(Glib::wrap( + sp_icon_new (Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("symbol-fit")))) ); + fitSymbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); + fitSymbol->set_relief( Gtk::RELIEF_NONE ); + fitSymbol->set_focus_on_click( false ); + fitSymbol->set_active( true ); + fitSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + tools->pack_start(* fitSymbol, Gtk::PACK_SHRINK); -#if WITH_GTKMM_3_0 - previewScale->set_hexpand(); - table->attach(*Gtk::manage(previewScale),1,row,1,1); -#else - table->attach(*Gtk::manage(previewScale),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); -#endif - - sigc::connection connScale = - previewScale->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); - instanceConns.push_back(connScale); - - ++row; - - /******************** Preview Size ************************/ - Gtk::Label* labelSize = new Gtk::Label(_("Preview size: ")); - -#if WITH_GTKMM_3_0 - table->attach(*Gtk::manage(labelSize),0,row,1,1); -#else - table->attach(*Gtk::manage(labelSize),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); -#endif - - previewSize = new Gtk::ComboBoxText(); - const gchar *sizes[] = {"16", "24", "32", "48", "64", NULL}; - for( int i = 0; sizes[i]; ++i ) { - previewSize->append(sizes[i]); - } - previewSize->set_active_text(sizes[2]); - -#if WITH_GTKMM_3_0 - previewSize->set_hexpand(); - table->attach(*Gtk::manage(previewSize),1,row,1,1); -#else - table->attach(*Gtk::manage(previewSize),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); -#endif - - sigc::connection connSize = - previewSize->signal_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); - instanceConns.push_back(connSize); - ++row; /**********************************************************/ @@ -253,6 +267,10 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); + sigc::connection selectionChangedConn = currentDesktop->selection->connectChanged( + sigc::mem_fun(*this, &SymbolsDialog::selectionChanged)); + instanceConns.push_back(selectionChangedConn); + get_symbols(); draw_symbols( currentDocument ); /* Defaults to current document */ @@ -277,6 +295,20 @@ SymbolsDialog& SymbolsDialog::getInstance() return *new SymbolsDialog(); } +void SymbolsDialog::zoomin() { + if(in_sizes < 4) { + in_sizes++; + rebuild(); + } +} + +void SymbolsDialog::zoomout() { + if(in_sizes > 0) { + in_sizes--; + rebuild(); + } +} + void SymbolsDialog::rebuild() { store->clear(); @@ -287,10 +319,27 @@ void SymbolsDialog::rebuild() { // Symbol must be from Current Document (this method of // checking should be language independent). symbolDocument = currentDocument; + addSymbol->set_sensitive( true ); + removeSymbol->set_sensitive( true ); + } else { + addSymbol->set_sensitive( false ); + removeSymbol->set_sensitive( false ); } draw_symbols( symbolDocument ); } +void SymbolsDialog::insertSymbol() { + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop) ); + sp_action_perform (action, NULL); +} + +void SymbolsDialog::revertSymbol() { + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop ) ); + sp_action_perform (action, NULL); +} + void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) { #if WITH_GTKMM_3_0 @@ -312,55 +361,75 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*cont } -void SymbolsDialog::defsModified(SPObject *object, guint flags) +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(); -#else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); -#endif +void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { + Glib::ustring symbol_id = selectedSymbolId(); + SPDocument* symbolDocument = selectedSymbols(); + SPObject* symbol = symbolDocument->getObjectById(symbol_id); - if( iconArray.empty() ) { - //std::cout << " iconArray empty: huh? " << std::endl; - } else { + if(symbol && !selection->includes(symbol)) { + iconView->unselect_all(); + } +} + +SPDocument* SymbolsDialog::selectedSymbols() { + /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ + Glib::ustring symbolSetString = symbolSet->get_active_text(); + + SPDocument* symbolDocument = symbolSets[symbolSetString]; + if( !symbolDocument ) { + // Symbol must be from Current Document (this method of checking should be language independent). + return currentDocument; + } + return symbolDocument; +} + +Glib::ustring SymbolsDialog::selectedSymbolId() { + #if WITH_GTKMM_3_0 + std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items(); + #else + Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); + #endif + if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); Gtk::ListStore::iterator row = store->get_iter(path); - Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; + return (*row)[getColumns()->symbol_id]; + } + return Glib::ustring(""); +} - /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ - Glib::ustring symbolSetString = symbolSet->get_active_text(); +void SymbolsDialog::iconChanged() { - SPDocument* symbolDocument = symbolSets[symbolSetString]; - if( !symbolDocument ) { - // Symbol must be from Current Document (this method of - // checking should be language independent). - symbolDocument = currentDocument; - } + Glib::ustring symbol_id = selectedSymbolId(); + SPDocument* symbolDocument = selectedSymbols(); + SPObject* symbol = symbolDocument->getObjectById(symbol_id); - SPObject* symbol = symbolDocument->getObjectById(symbol_id); - if( symbol ) { - - // Find style for use in <use> - // First look for default style stored in <symbol> - gchar const* style = symbol->getAttribute("inkscape:symbol-style"); - if( !style ) { - // If no default style in <symbol>, look in documents. - if( symbolDocument == currentDocument ) { - style = style_from_use( symbol_id.c_str(), currentDocument ); - } else { - style = symbolDocument->getReprRoot()->attribute("style"); - } - } + if( symbol ) { + if( symbolDocument == currentDocument ) { + // Select the symbol on the canvas so it can be manipulated + currentDesktop->selection->set( symbol, false ); + } - ClipboardManager *cm = ClipboardManager::get(); - cm->copySymbol(symbol->getRepr(), style); + // Find style for use in <use> + // First look for default style stored in <symbol> + gchar const* style = symbol->getAttribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in <symbol>, look in documents. + if( symbolDocument == currentDocument ) { + style = style_from_use( symbol_id.c_str(), currentDocument ); + } else { + style = symbolDocument->getReprRoot()->attribute("style"); + } } + + ClipboardManager *cm = ClipboardManager::get(); + cm->copySymbol(symbol->getRepr(), style); } } @@ -485,6 +554,9 @@ void SymbolsDialog::get_symbols() { symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { gchar *title = symbol_doc->getRoot()->title(); + if( title == NULL ) { + title = _("Unnamed Symbols"); + } symbolSets[Glib::ustring(title)] = symbol_doc; symbolSet->append(title); } @@ -672,11 +744,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) SPItem *item = SP_ITEM(object_temp); - Glib::ustring previewSizeString = previewSize->get_active_text(); - unsigned psize = atol( previewSizeString.c_str() ); - - Glib::ustring previewScaleString = previewScale->get_active_text(); - int previewScaleRow = previewScale->get_active_row_number(); + unsigned psize = SYMBOL_ICON_SIZES[in_sizes]; /* Update to renderable state */ Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize); @@ -707,21 +775,9 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) height = 1.0; } - switch (previewScaleRow) { - case 0: - /* Fit */ - scale = psize/std::max(width,height); - break; - case 1: - /* Fit width */ - scale = psize/width; - break; - case 2: - /* Fit height */ - scale = psize/height; - break; - default: - scale = atof( previewScaleString.c_str() ); + if( fitSymbol->get_active() ) { + /* Fit */ + scale = psize/std::max(width,height); } pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index b81f6981e..54b1a3ab0 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -2,9 +2,10 @@ * @brief Symbols dialog */ /* Authors: - * Tavmjong Bah + * Tavmjong Bah, Martin Owens * * Copyright (C) 2012 Tavmjong Bah + * 2013 Martin Owens * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -29,8 +30,27 @@ namespace Dialog { class SymbolColumns; // For Gtk::ListStore /** - * A dialog that displays selectable symbols. + * A dialog that displays selectable symbols and allows users to drag or paste + * those symbols from the dialog into the document. + * + * Symbol documents are loaded from the preferences paths and displayed in a + * drop-down list to the user. The user then selects which of the symbols + * documents they want to get symbols from. The first document in the list is + * always the current document. + * + * This then updates an icon-view with all the symbols available. Selecting one + * puts it onto the clipboard. Dragging it or pasting it onto the canvas copies + * the symbol from the symbol document, into the current document and places a + * new <use element at the correct location on the canvas. + * + * Selected groups on the canvas can be added to the current document's symbols + * table, and symbols can be removed from the current document. This allows + * new symbols documents to be constructed and if saved in the prefs folder will + * make those symbols available for all future documents. */ + +const int SYMBOL_ICON_SIZES[] = {16, 24, 32, 48, 64}; + class SymbolsDialog : public UI::Widget::Panel { public: @@ -45,8 +65,15 @@ private: static SymbolColumns *getColumns(); + void zoomin(); + void zoomout(); void rebuild(); + void insertSymbol(); + void revertSymbol(); void defsModified(SPObject *object, guint flags); + void selectionChanged(Inkscape::Selection *selection); + SPDocument* selectedSymbols(); + Glib::ustring selectedSymbolId(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time); @@ -67,12 +94,15 @@ private: /* Keep track of all symbol template documents */ std::map<Glib::ustring, SPDocument*> symbolSets; + // Index into sizes which is selected + int in_sizes; Glib::RefPtr<Gtk::ListStore> store; Gtk::ComboBoxText* symbolSet; Gtk::IconView* iconView; - Gtk::ComboBoxText* previewScale; - Gtk::ComboBoxText* previewSize; + Gtk::Button* addSymbol; + Gtk::Button* removeSymbol; + Gtk::ToggleButton* fitSymbol; void setTargetDesktop(SPDesktop *desktop); SPDesktop* currentDesktop; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 9f3294275..a662495a0 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -650,7 +650,7 @@ void TextEdit::onFontChange(SPFontSelector * /*fontsel*/, gchar* fontspec, TextE } -void TextEdit::onStartOffsetChange(GtkTextBuffer *text_buffer, TextEdit *self) +void TextEdit::onStartOffsetChange(GtkTextBuffer * /*text_buffer*/, TextEdit *self) { SPItem *text = self->getSelectedTextItem(); if (text && SP_IS_TEXT_TEXTPATH(text)) diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index 0e3ebafa7..8683d80a3 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -18,6 +18,14 @@ #ifndef INKSCAPE_UI_DIALOG_TEXT_EDIT_H #define INKSCAPE_UI_DIALOG_TEXT_EDIT_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/notebook.h> #include <gtkmm/button.h> diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 86dbd25a9..6e41723fd 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -19,6 +19,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/notebook.h> #include <gtkmm/checkbutton.h> diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index c071fcf95..ce8af3f1f 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -15,6 +15,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/stock.h> #include <2geom/transforms.h> @@ -27,6 +31,7 @@ #include "inkscape.h" #include "selection.h" #include "selection-chemistry.h" +#include "message-stack.h" #include "verbs.h" #include "preferences.h" #include "sp-namedview.h" @@ -758,7 +763,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) double move = x; for ( std::vector<BBoxSort> ::iterator it (sorted.begin()); it < sorted.end(); - it ++ ) + ++it ) { sp_item_move_rel(it->item, Geom::Translate(move, 0)); // move each next object by x relative to previous @@ -782,7 +787,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) double move = y; for ( std::vector<BBoxSort> ::iterator it (sorted.begin()); it < sorted.end(); - it ++ ) + ++it ) { sp_item_move_rel(it->item, Geom::Translate(0, move)); // move each next object by x relative to previous @@ -898,10 +903,21 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); double skewY = _scalar_skew_vertical.getValue("%"); + if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } sp_item_skew_rel (item, 0.01*skewX, 0.01*skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); + if ((fabs(angleX - angleY + M_PI/2) < Geom::EPSILON) + || (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON) + || (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON) + || (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } double skewX = tan(-angleX); double skewY = tan(angleY); sp_item_skew_rel (item, skewX, skewY); @@ -912,6 +928,10 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; + if (fabs(skewX*skewY - width*height) < Geom::EPSILON) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } sp_item_skew_rel (item, skewX/height, skewY/width); } } @@ -927,16 +947,31 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); double skewY = _scalar_skew_vertical.getValue("%"); + if (fabs(0.01*skewX*0.01*skewY - 1.0) < Geom::EPSILON) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); + if ((fabs(angleX - angleY + M_PI/2) < Geom::EPSILON) + || (fabs(angleX - angleY - M_PI/2) < Geom::EPSILON) + || (fabs((angleX - angleY)/3 + M_PI/2) < Geom::EPSILON) + || (fabs((angleX - angleY)/3 - M_PI/2) < Geom::EPSILON)) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } double skewX = tan(-angleX); double skewY = tan(angleY); sp_selection_skew_relative(selection, *center, skewX, skewY); } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); + if (fabs(skewX*skewY - width*height) < Geom::EPSILON) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } sp_selection_skew_relative(selection, *center, skewX/height, skewY/width); } } @@ -957,6 +992,10 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) double f = _scalar_transform_f.getValue(); Geom::Affine displayed(a, b, c, d, e, f); + if (displayed.isSingular()) { + sp_desktop_message_stack(getDesktop())->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); + return; + } if (_check_replace_matrix.get_active()) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index f6d1985cc..f9f923be4 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -16,6 +16,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/bin.h> diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 70bd0e859..5d5ea2adc 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -224,10 +224,12 @@ void MultiPathManipulator::shiftSelection(int dir) SubpathList::iterator last_j; NodeList::iterator last_k; bool anything_found = false; + bool anynode_found = false; for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) { SubpathList &sp = i->second->subpathList(); for (SubpathList::iterator j = sp.begin(); j != sp.end(); ++j) { + anynode_found = true; for (NodeList::iterator k = (*j)->begin(); k != (*j)->end(); ++k) { if (k->selected()) { last_i = i; @@ -249,10 +251,12 @@ void MultiPathManipulator::shiftSelection(int dir) if (!anything_found) { // select first / last node // this should never fail because there must be at least 1 non-empty manipulator - if (dir == 1) { + if (anynode_found) { + if (dir == 1) { _selection.insert((*_mmap.begin()->second->subpathList().begin())->begin().ptr()); - } else { + } else { _selection.insert((--(*--(--_mmap.end())->second->subpathList().end())->end()).ptr()); + } } return; } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 348420994..daed3a523 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -459,9 +459,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _corner_to_pixbuf(unsigned c) { //sp_select_context_get_type(); switch (c % 4) { - case 0: return Glib::wrap(handles[10], true); - case 1: return Glib::wrap(handles[8], true); - case 2: return Glib::wrap(handles[6], true); + case 0: return Glib::wrap(handles[7], true); + case 1: return Glib::wrap(handles[6], true); + case 2: return Glib::wrap(handles[5], true); default: return Glib::wrap(handles[4], true); } } @@ -606,9 +606,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _side_to_pixbuf(unsigned s) { //sp_select_context_get_type(); switch (s % 4) { - case 0: return Glib::wrap(handles[9], true); - case 1: return Glib::wrap(handles[7], true); - case 2: return Glib::wrap(handles[5], true); + case 0: return Glib::wrap(handles[10], true); + case 1: return Glib::wrap(handles[9], true); + case 2: return Glib::wrap(handles[8], true); default: return Glib::wrap(handles[11], true); } } diff --git a/src/ui/widget/button.h b/src/ui/widget/button.h index efadfad07..a214dd881 100644 --- a/src/ui/widget/button.h +++ b/src/ui/widget/button.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_BUTTON_H #define INKSCAPE_UI_WIDGET_BUTTON_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/checkbutton.h> #include <gtkmm/radiobutton.h> diff --git a/src/ui/widget/color-picker.h b/src/ui/widget/color-picker.h index e20212615..b4da5dbf2 100644 --- a/src/ui/widget/color-picker.h +++ b/src/ui/widget/color-picker.h @@ -13,7 +13,16 @@ #ifndef __COLOR_PICKER_H__ #define __COLOR_PICKER_H__ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <stddef.h> + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> #include <gtkmm/button.h> #include <sigc++/sigc++.h> diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index caddfb9a2..959b5e09b 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -15,6 +15,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/widget.h> namespace Inkscape { diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 608badb62..cc0c13eea 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -11,6 +11,14 @@ #ifndef INKSCAPE_UI_WIGET_DOCK_ITEM_H #define INKSCAPE_UI_WIGET_DOCK_ITEM_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/frame.h> #include <gtkmm/window.h> diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 2bfc7e0df..52e9ea605 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -48,11 +48,21 @@ const int Dock::_default_dock_bar_width = 36; Dock::Dock(Gtk::Orientation orientation) - : _gdl_dock (GDL_DOCK (gdl_dock_new())), - _gdl_dock_bar (GDL_DOCK_BAR (gdl_dock_bar_new(GDL_DOCK(_gdl_dock)))), + : _gdl_dock(gdl_dock_new()), +#if WITH_GDL_3_6 + _gdl_dock_bar(GDL_DOCK_BAR(gdl_dock_bar_new(G_OBJECT(_gdl_dock)))), +#else + _gdl_dock_bar(GDL_DOCK_BAR(gdl_dock_bar_new(GDL_DOCK(_gdl_dock)))), +#endif _scrolled_window (Gtk::manage(new Gtk::ScrolledWindow)) { - gdl_dock_bar_set_orientation(_gdl_dock_bar, static_cast<GtkOrientation>(orientation)); +#if WITH_GDL_3_6 + gtk_orientable_set_orientation(GTK_ORIENTABLE(_gdl_dock_bar), + static_cast<GtkOrientation>(orientation)); +#else + gdl_dock_bar_set_orientation(_gdl_dock_bar, + static_cast<GtkOrientation>(orientation)); +#endif #if WITH_GTKMM_3_0 switch(orientation) { @@ -127,7 +137,9 @@ Dock::~Dock() void Dock::addItem(DockItem& item, DockItem::Placement placement) { _dock_items.push_back(&item); - gdl_dock_add_item(_gdl_dock, GDL_DOCK_ITEM(item.gobj()), (GdlDockPlacement)placement); + gdl_dock_add_item(GDL_DOCK(_gdl_dock), + GDL_DOCK_ITEM(item.gobj()), + (GdlDockPlacement)placement); // FIXME: This is a hack to prevent the dock from expanding the main window, this can't be done // initially as the paned doesn't exist. diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 28ab42740..33e60b836 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -12,6 +12,14 @@ #ifndef INKSCAPE_UI_WIDGET_DOCK_H #define INKSCAPE_UI_WIDGET_DOCK_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <list> #include "ui/widget/dock-item.h" @@ -66,11 +74,11 @@ protected: /** Interface widgets, will be packed like * _scrolled_window -> (_dock_box -> (_paned -> (_dock -> _filler) | _dock_bar)) */ - Gtk::Box *_dock_box; - Gtk::Paned* _paned; - GdlDock *_gdl_dock; - GdlDockBar *_gdl_dock_bar; - Gtk::VBox _filler; + Gtk::Box *_dock_box; + Gtk::Paned *_paned; + GtkWidget *_gdl_dock; + GdlDockBar *_gdl_dock_bar; + Gtk::VBox _filler; Gtk::ScrolledWindow *_scrolled_window; /** Internal signal handlers */ diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index c622796b2..0f526f77a 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -17,6 +17,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/scrolledwindow.h> #include <gtkmm/entry.h> diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h index ae3ec07c4..6f0c2f26e 100644 --- a/src/ui/widget/filter-effect-chooser.h +++ b/src/ui/widget/filter-effect-chooser.h @@ -12,6 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/combobox.h> diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h index a04666651..55638ad40 100644 --- a/src/ui/widget/frame.h +++ b/src/ui/widget/frame.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_FRAME_H #define INKSCAPE_UI_WIDGET_FRAME_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/alignment.h> #include <gtkmm/frame.h> #include <gtkmm/label.h> diff --git a/src/ui/widget/imageicon.h b/src/ui/widget/imageicon.h index 2ea8b8533..8faf13cb1 100644 --- a/src/ui/widget/imageicon.h +++ b/src/ui/widget/imageicon.h @@ -12,6 +12,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <glibmm/ustring.h> diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h index 7b02fa4dc..df6eb7ded 100644 --- a/src/ui/widget/imagetoggler.h +++ b/src/ui/widget/imagetoggler.h @@ -14,6 +14,10 @@ #include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/cellrendererpixbuf.h> #include <gtkmm/widget.h> #include <glibmm/property.h> diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h index 88eb3ce19..5334454bc 100644 --- a/src/ui/widget/labelled.h +++ b/src/ui/widget/labelled.h @@ -11,6 +11,14 @@ #ifndef INKSCAPE_UI_WIDGET_LABELLED_H #define INKSCAPE_UI_WIDGET_LABELLED_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> namespace Gtk { diff --git a/src/ui/widget/licensor.h b/src/ui/widget/licensor.h index ab6abd0a4..0ac3e5ab8 100644 --- a/src/ui/widget/licensor.h +++ b/src/ui/widget/licensor.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_LICENSOR_H #define INKSCAPE_UI_WIDGET_LICENSOR_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> class SPDocument; diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index d8b8fb0c4..38ae9e054 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -14,6 +14,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> namespace Gtk { diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index bee9f09b9..19a6cb2a5 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -11,6 +11,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/alignment.h> #include <gtkmm/adjustment.h> diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index fa3f8e3a1..988c4e5de 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -36,6 +36,7 @@ #include "document.h" #include "desktop.h" #include "helper/action.h" +#include "helper/action-context.h" #include "helper/units.h" #include "inkscape.h" #include "sp-namedview.h" @@ -619,7 +620,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); if (verb) { - SPAction *action = verb->get_action(dt); + SPAction *action = verb->get_action(Inkscape::ActionContext(dt)); if (action) { sp_action_perform(action, NULL); } diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 7eb114d0a..d60eeefe0 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -15,6 +15,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/dialog.h> // for Gtk::RESPONSE_* #include <gtkmm/menu.h> #include <gtkmm/stock.h> diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 5bb054577..0c3d822b8 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -17,6 +17,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/arrow.h> #include <gtkmm/button.h> diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index d32de6871..567f29f91 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -18,6 +18,10 @@ #include <windows.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/frame.h> #include <gtkmm/alignment.h> diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index e3968045d..cb4ce17d1 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -15,8 +15,17 @@ #ifndef INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H #define INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <iostream> #include <vector> + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/filechooserbutton.h> #include "ui/widget/spinbutton.h" #include <stddef.h> diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 1d91515e5..18d53bf5c 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -7,6 +7,14 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/eventbox.h> #include <glibmm/i18n.h> diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 9b78cb17f..e5bc4f883 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -15,6 +15,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #if WITH_GTKMM_3_0 diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp index 548e9a6a6..ade3d1e60 100644 --- a/src/ui/widget/spin-scale.cpp +++ b/src/ui/widget/spin-scale.cpp @@ -6,11 +6,12 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ +#include "spin-scale.h" + #include <gtkmm/adjustment.h> #include <glibmm/i18n.h> #include <glibmm/stringutils.h> -#include "spin-scale.h" #include "ui/widget/gimpspinscale.h" namespace Inkscape { diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h index a8403307f..5fec8b1d8 100644 --- a/src/ui/widget/spin-scale.h +++ b/src/ui/widget/spin-scale.h @@ -9,6 +9,14 @@ #ifndef INKSCAPE_UI_WIDGET_SPIN_SCALE_H #define INKSCAPE_UI_WIDGET_SPIN_SCALE_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index 8a45299e5..5f86fd15a 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_SPIN_SLIDER_H #define INKSCAPE_UI_WIDGET_SPIN_SLIDER_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 57c48369e..fe5d699e7 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_SPINBUTTON_H #define INKSCAPE_UI_WIDGET_SPINBUTTON_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/spinbutton.h> namespace Inkscape { diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 2880961be..7ab47cb2e 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -28,6 +28,7 @@ #include "widgets/widget-sizes.h" #include "helper/units.h" #include "helper/action.h" +#include "helper/action-context.h" #include "preferences.h" #include "inkscape.h" #include "verbs.h" @@ -200,7 +201,7 @@ StyleSwatch::on_click(GdkEventButton */*event*/) { if (this->_desktop && this->_verb_t != SP_VERB_NONE) { Inkscape::Verb *verb = Inkscape::Verb::get(this->_verb_t); - SPAction *action = verb->get_action((Inkscape::UI::View::View *) this->_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext((Inkscape::UI::View::View *) this->_desktop)); sp_action_perform (action, NULL); return true; } diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index d7bab3732..6bdb5e248 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -17,6 +17,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/eventbox.h> diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index f92a08d0a..d166e3831 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -12,6 +12,10 @@ # include <config.h> #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/label.h> diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 142b11186..3104d5aef 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -10,6 +10,14 @@ #ifndef INKSCAPE_UI_WIDGET_UNIT_H #define INKSCAPE_UI_WIDGET_UNIT_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/comboboxtext.h> #include "util/units.h" diff --git a/src/unicoderange.cpp b/src/unicoderange.cpp index dcf461214..67239d0d2 100644 --- a/src/unicoderange.cpp +++ b/src/unicoderange.cpp @@ -37,8 +37,10 @@ int UnicodeRange::add_range(gchar* val){ Urange r; int i=0, count=0; - while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=',') i++; - r.start = (gchar*) malloc((i+1)*sizeof(gchar*)); + while(val[i]!='\0' && val[i]!='-' && val[i]!=' ' && val[i]!=','){ + i++; + } + r.start = (gchar*) malloc((i+1)*sizeof(gchar*)); strncpy(r.start, val, i); r.start[i] = '\0'; val+=i; @@ -50,7 +52,7 @@ UnicodeRange::add_range(gchar* val){ r.end = (gchar*) malloc((i+1)*sizeof(gchar*)); strncpy(r.end, val, i); r.end[i] = '\0'; - val+=i; + // val+=i; count+=i; } else { r.end=NULL; diff --git a/src/util/units.cpp b/src/util/units.cpp index f822d01de..d1275b082 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -11,6 +11,39 @@ #include "path-prefix.h" #include "streq.h" +using Inkscape::Util::UNIT_TYPE_DIMENSIONLESS; +using Inkscape::Util::UNIT_TYPE_LINEAR; +using Inkscape::Util::UNIT_TYPE_RADIAL; +using Inkscape::Util::UNIT_TYPE_FONT_HEIGHT; + +namespace +{ + +/** + * A std::map that gives the data type value for the string version. + * + * Note that we'd normally not return a reference to an internal version, but + * for this constant case it allows us to check against getTypeMappings().end(). + */ +/** @todo consider hiding map behind hasFoo() and getFoo() type functions.*/ +std::map<Glib::ustring, Inkscape::Util::UnitType> &getTypeMappings() +{ + static bool init = false; + static std::map<Glib::ustring, Inkscape::Util::UnitType> typeMap; + if (!init) + { + init = true; + typeMap["DIMENSIONLESS"] = UNIT_TYPE_DIMENSIONLESS; + typeMap["LINEAR"] = UNIT_TYPE_LINEAR; + typeMap["RADIAL"] = UNIT_TYPE_RADIAL; + typeMap["FONT_HEIGHT"] = UNIT_TYPE_FONT_HEIGHT; + // Note that code was not yet handling LINEAR_SCALED, TIME, QTY and NONE + } + return typeMap; +} + +} // namespace + namespace Inkscape { namespace Util { @@ -40,179 +73,172 @@ UnitsSAXHandler::UnitsSAXHandler(UnitTable *table) : #define BUFSIZE (255) -/** - * Returns the suggested precision to use for displaying numbers - * of this unit. - */ +Unit::Unit() : + type(UNIT_TYPE_DIMENSIONLESS), // should this or NONE be the default? + factor(1.0), + name(), + name_plural(), + abbr(), + description() +{ +} + +Unit::Unit(UnitType type, + double factor, + Glib::ustring const &name, + Glib::ustring const &name_plural, + Glib::ustring const &abbr, + Glib::ustring const &description) : + type(type), + factor(factor), + name(name), + name_plural(name_plural), + abbr(abbr), + description(description) +{ +} + +void Unit::clear() +{ + *this = Unit(); +} + int Unit::defaultDigits() const { int factor_digits = int(log10(factor)); if (factor_digits < 0) { g_warning("factor = %f, factor_digits = %d", factor, factor_digits); g_warning("factor_digits < 0 - returning 0"); - return 0; - } else { - return factor_digits; + factor_digits = 0; } + return factor_digits; } -/** - * Initializes the unit tables and identifies the primary unit types. - * - * The primary unit's conversion factor is required to be 1.00 - */ -UnitTable::UnitTable() +UnitTable::UnitTable() { // if we swich to the xml file, don't forget to force locale to 'C' - // load("share/ui/units.xml"); // <-- Buggy + // load("share/ui/units.xml"); // <-- Buggy gchar *filename = g_build_filename(INKSCAPE_UIDIR, "units.txt", NULL); loadText(filename); g_free(filename); } UnitTable::~UnitTable() { - UnitMap::iterator iter = _unit_map.begin(); - while (iter != _unit_map.end()) { - delete (*iter).second; - ++iter; + for (UnitMap::iterator iter = _unit_map.begin(); iter != _unit_map.end(); ++iter) + { + delete (*iter).second; } } -/** Add a new unit to the table */ void UnitTable::addUnit(Unit const &u, bool primary) { _unit_map[u.abbr] = new Unit(u); if (primary) { - _primary_unit[u.type] = u.abbr; + _primary_unit[u.type] = u.abbr; } } -/** Retrieve a given unit based on its string identifier */ Unit UnitTable::getUnit(Glib::ustring const &unit_abbr) const { UnitMap::const_iterator iter = _unit_map.find(unit_abbr); if (iter != _unit_map.end()) { - return *((*iter).second); + return *((*iter).second); } else { - return Unit(); + return Unit(); } } -/** Remove a unit definition from the given unit type table */ bool UnitTable::deleteUnit(Unit const &u) { - if (u.abbr == _primary_unit[u.type]) { - // Cannot delete the primary unit type since it's - // used for conversions - return false; - } - UnitMap::iterator iter = _unit_map.find(u.abbr); - if (iter != _unit_map.end()) { - delete (*iter).second; - _unit_map.erase(iter); - return true; - } else { - return false; + bool deleted = false; + // Cannot delete the primary unit type since it's + // used for conversions + if (u.abbr != _primary_unit[u.type]) { + UnitMap::iterator iter = _unit_map.find(u.abbr); + if (iter != _unit_map.end()) { + delete (*iter).second; + _unit_map.erase(iter); + deleted = true; + } } + return deleted; } -/** Returns true if the given string 'name' is a valid unit in the table */ bool UnitTable::hasUnit(Glib::ustring const &unit) const { UnitMap::const_iterator iter = _unit_map.find(unit); return (iter != _unit_map.end()); } -/** Provides an iteratable list of items in the given unit table */ UnitTable::UnitMap UnitTable::units(UnitType type) const { UnitMap submap; - for (UnitMap::const_iterator iter = _unit_map.begin(); - iter != _unit_map.end(); ++iter) { - if (((*iter).second)->type == type) { - submap.insert(UnitMap::value_type((*iter).first, new Unit(*((*iter).second)))); - } + for (UnitMap::const_iterator iter = _unit_map.begin(); iter != _unit_map.end(); ++iter) { + if (((*iter).second)->type == type) { + submap.insert(UnitMap::value_type((*iter).first, new Unit(*((*iter).second)))); + } } return submap; } -/** Returns the default unit abbr for the given type */ Glib::ustring UnitTable::primary(UnitType type) const { return _primary_unit[type]; } -/** Loads units from a text file. - - loadText loads and merges the contents of the given file into the UnitTable, - possibly overwriting existing unit definitions. - - @param filename: file to be loaded*/ bool UnitTable::loadText(Glib::ustring const &filename) { - char buf[BUFSIZE]; + char buf[BUFSIZE] = {0}; // Open file for reading FILE * f = fopen(filename.c_str(), "r"); if (f == NULL) { - g_warning("Could not open units file '%s': %s\n", - filename.c_str(), strerror(errno)); + g_warning("Could not open units file '%s': %s\n", + filename.c_str(), strerror(errno)); g_warning("* INKSCAPE_DATADIR is: '%s'\n", INKSCAPE_DATADIR); g_warning("* INKSCAPE_UIDIR is: '%s'\n", INKSCAPE_UIDIR); - return false; + return false; } + /** @todo fix this to use C++ means and explicit locale to avoid need to change. */ // bypass current locale in order to make // sscanf read floats with '.' as a separator // set locale to 'C' and keep old locale - char *old_locale; - old_locale = g_strdup (setlocale (LC_NUMERIC, NULL)); + char *old_locale = g_strdup(setlocale(LC_NUMERIC, NULL)); setlocale (LC_NUMERIC, "C"); while (fgets(buf, BUFSIZE, f) != NULL) { - char name[BUFSIZE]; - char plural[BUFSIZE]; - char abbr[BUFSIZE]; - char type[BUFSIZE]; - double factor; - char primary[BUFSIZE]; - - int nchars = 0; - // locale is set to C, scanning %lf should work _everywhere_ - if (sscanf(buf, "%15s %15s %15s %15s %8lf %1s %15n", - name, plural, abbr, type, &factor, primary, &nchars) != 6) - { - // Skip the line - doesn't appear to be valid - continue; - } - - g_assert(nchars < BUFSIZE); - - char *desc = buf; - desc += nchars; // buf is now only the description - - // insert into _unit_map - Unit u; - u.name = name; - u.name_plural = plural; - u.abbr = abbr; - u.description = desc; - u.factor = factor; - - if (streq(type, "DIMENSIONLESS")) { - u.type = UNIT_TYPE_DIMENSIONLESS; - } else if (streq(type, "LINEAR")) { - u.type = UNIT_TYPE_LINEAR; - } else if (streq(type, "RADIAL")) { - u.type = UNIT_TYPE_RADIAL; - } else if (streq(type, "FONT_HEIGHT")) { - u.type = UNIT_TYPE_FONT_HEIGHT; - } else { - g_warning("Skipping unknown unit type '%s' for %s.\n", - type, name); - continue; - } - - // if primary is 'Y', list this unit as a primary - addUnit(u, (primary[0]=='Y' || primary[0]=='y')); + char name[BUFSIZE] = {0}; + char plural[BUFSIZE] = {0}; + char abbr[BUFSIZE] = {0}; + char type[BUFSIZE] = {0}; + double factor = 0.0; + char primary[BUFSIZE] = {0}; + + int nchars = 0; + // locale is set to C, scanning %lf should work _everywhere_ + /** @todo address %15n, which causes a warning: */ + if (sscanf(buf, "%15s %15s %15s %15s %8lf %1s %15n", + name, plural, abbr, type, &factor, primary, &nchars) != 6) + { + // Skip the line - doesn't appear to be valid + continue; + } + + g_assert(nchars < BUFSIZE); + + char *desc = buf; + desc += nchars; // buf is now only the description + + // insert into _unit_map + if (getTypeMappings().find(type) == getTypeMappings().end()) + { + g_warning("Skipping unknown unit type '%s' for %s.\n", type, name); + continue; + } + UnitType utype = getTypeMappings()[type]; + + Unit u(utype, factor, name, plural, abbr, desc); + // if primary is 'Y', list this unit as a primary + addUnit(u, (primary[0]=='Y' || primary[0]=='y')); } // set back the saved locale @@ -221,9 +247,8 @@ bool UnitTable::loadText(Glib::ustring const &filename) // close file if (fclose(f) != 0) { - g_warning("Error closing units file '%s': %s\n", - filename.c_str(), strerror(errno)); - return false; + g_warning("Error closing units file '%s': %s\n", filename.c_str(), strerror(errno)); + return false; } return true; @@ -235,23 +260,20 @@ bool UnitTable::load(Glib::ustring const &filename) { int result = handler.parseFile( filename.c_str() ); if ( result != 0 ) { // perhaps - g_warning("Problem loading units file '%s': %d\n", - filename.c_str(), result); - return false; + g_warning("Problem loading units file '%s': %d\n", filename.c_str(), result); + return false; } return true; } -/** Saves the current UnitTable to the given file. */ bool UnitTable::save(Glib::ustring const &filename) { // open file for writing FILE *f = fopen(filename.c_str(), "w"); if (f == NULL) { - g_warning("Could not open units file '%s': %s\n", - filename.c_str(), strerror(errno)); - return false; + g_warning("Could not open units file '%s': %s\n", filename.c_str(), strerror(errno)); + return false; } // write out header @@ -268,9 +290,8 @@ bool UnitTable::save(Glib::ustring const &filename) { // close file if (fclose(f) != 0) { - g_warning("Error closing units file '%s': %s\n", - filename.c_str(), strerror(errno)); - return false; + g_warning("Error closing units file '%s': %s\n", filename.c_str(), strerror(errno)); + return false; } return true; @@ -281,12 +302,7 @@ void UnitsSAXHandler::_startElement(xmlChar const *name, xmlChar const **attrs) { if (streq("unit", (char const *)name)) { // reset for next use - unit.name.clear(); - unit.name_plural.clear(); - unit.abbr.clear(); - unit.description.clear(); - unit.type = UNIT_TYPE_DIMENSIONLESS; - unit.factor = 1.0; + unit.clear(); primary = false; skip = false; @@ -294,14 +310,9 @@ void UnitsSAXHandler::_startElement(xmlChar const *name, xmlChar const **attrs) char const *const key = (char const *)attrs[i]; if (streq("type", key)) { char const *type = (char const*)attrs[i+1]; - if (streq(type, "DIMENSIONLESS")) { - unit.type = UNIT_TYPE_DIMENSIONLESS; - } else if (streq(type, "LINEAR")) { - unit.type = UNIT_TYPE_LINEAR; - } else if (streq(type, "RADIAL")) { - unit.type = UNIT_TYPE_RADIAL; - } else if (streq(type, "FONT_HEIGHT")) { - unit.type = UNIT_TYPE_FONT_HEIGHT; + if (getTypeMappings().find(type) != getTypeMappings().end()) + { + unit.type = getTypeMappings()[type]; } else { g_warning("Skipping unknown unit type '%s' for %s.\n", type, name); skip = true; diff --git a/src/util/units.h b/src/util/units.h index b22bdb1f2..40c89a4a0 100644 --- a/src/util/units.h +++ b/src/util/units.h @@ -36,40 +36,78 @@ const char DEG[] = "°"; class Unit { public: - Glib::ustring name; - Glib::ustring name_plural; - Glib::ustring abbr; - Glib::ustring description; - - UnitType type; + Unit(); + Unit(UnitType type, + double factor, + Glib::ustring const &name, + Glib::ustring const &name_plural, + Glib::ustring const &abbr, + Glib::ustring const &description); - double factor; + void clear(); bool isAbsolute() const { return type != UNIT_TYPE_DIMENSIONLESS; } + + /** + * Returns the suggested precision to use for displaying numbers + * of this unit. + */ int defaultDigits() const; + + UnitType type; + double factor; + Glib::ustring name; + Glib::ustring name_plural; + Glib::ustring abbr; + Glib::ustring description; }; class UnitTable { public: + /** + * Initializes the unit tables and identifies the primary unit types. + * + * The primary unit's conversion factor is required to be 1.00 + */ UnitTable(); virtual ~UnitTable(); typedef std::map<Glib::ustring, Unit*> UnitMap; + /** Add a new unit to the table */ void addUnit(Unit const& u, bool primary); + + /** Retrieve a given unit based on its string identifier */ Unit getUnit(Glib::ustring const& name) const; + + /** Remove a unit definition from the given unit type table */ bool deleteUnit(Unit const& u); + + /** Returns true if the given string 'name' is a valid unit in the table */ bool hasUnit(Glib::ustring const &name) const; + /** Provides an iteratable list of items in the given unit table */ UnitTable::UnitMap units(UnitType type) const; + /** Returns the default unit abbr for the given type */ Glib::ustring primary(UnitType type) const; double getScale() const; + void setScale(); bool load(Glib::ustring const &filename); + + /** Loads units from a text file. + * + * loadText loads and merges the contents of the given file into the UnitTable, + * possibly overwriting existing unit definitions. + * + * @param filename file to be loaded + */ bool loadText(Glib::ustring const &filename); + + /** Saves the current UnitTable to the given file. */ bool save(Glib::ustring const &filename); protected: @@ -88,3 +126,13 @@ class UnitTable { } // namespace Inkscape #endif // define INKSCAPE_UTIL_UNITS_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/verbs.cpp b/src/verbs.cpp index ec7cad8dd..d0396155c 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -32,6 +32,10 @@ #include <cstring> #include <string> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/filechooserdialog.h> #include <gtkmm/messagedialog.h> #include <gtkmm/stock.h> @@ -43,9 +47,11 @@ #include "document.h" #include "draw-context.h" #include "extension/effect.h" +#include "event-context.h" #include "file.h" #include "gradient-drag.h" #include "helper/action.h" +#include "helper/action-context.h" #include "help.h" #include "inkscape-private.h" #include "interface.h" @@ -120,7 +126,7 @@ class FileVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ FileVerb(unsigned int const code, @@ -139,7 +145,7 @@ class EditVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ EditVerb(unsigned int const code, @@ -158,7 +164,7 @@ class SelectionVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ SelectionVerb(unsigned int const code, @@ -177,7 +183,7 @@ class LayerVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ LayerVerb(unsigned int const code, @@ -196,7 +202,7 @@ class ObjectVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ ObjectVerb(unsigned int const code, @@ -215,7 +221,7 @@ class ContextVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ ContextVerb(unsigned int const code, @@ -234,7 +240,7 @@ class ZoomVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ ZoomVerb(unsigned int const code, @@ -254,7 +260,7 @@ class DialogVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ DialogVerb(unsigned int const code, @@ -273,7 +279,7 @@ class HelpVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ HelpVerb(unsigned int const code, @@ -292,7 +298,7 @@ class TutorialVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ TutorialVerb(unsigned int const code, @@ -311,7 +317,7 @@ class TextVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ TextVerb(unsigned int const code, @@ -378,10 +384,10 @@ Verb::~Verb(void) * for a function that every subclass should write. Most * can be written using \c make_action_helper. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return NULL to represent error (this function shouldn't ever be called) */ -SPAction *Verb::make_action(Inkscape::UI::View::View */*view*/) +SPAction *Verb::make_action(Inkscape::ActionContext const & /*context*/) { //std::cout << "make_action" << std::endl; return NULL; @@ -391,13 +397,13 @@ SPAction *Verb::make_action(Inkscape::UI::View::View */*view*/) * Create an action for a \c FileVerb. * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *FileVerb::make_action(Inkscape::UI::View::View *view) +SPAction *FileVerb::make_action(Inkscape::ActionContext const & context) { //std::cout << "fileverb: make_action: " << &perform << std::endl; - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -405,13 +411,13 @@ SPAction *FileVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *EditVerb::make_action(Inkscape::UI::View::View *view) +SPAction *EditVerb::make_action(Inkscape::ActionContext const & context) { //std::cout << "editverb: make_action: " << &perform << std::endl; - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -419,12 +425,12 @@ SPAction *EditVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *SelectionVerb::make_action(Inkscape::UI::View::View *view) +SPAction *SelectionVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -432,12 +438,12 @@ SPAction *SelectionVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *LayerVerb::make_action(Inkscape::UI::View::View *view) +SPAction *LayerVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -445,12 +451,12 @@ SPAction *LayerVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *ObjectVerb::make_action(Inkscape::UI::View::View *view) +SPAction *ObjectVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -458,12 +464,12 @@ SPAction *ObjectVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *ContextVerb::make_action(Inkscape::UI::View::View *view) +SPAction *ContextVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -471,12 +477,12 @@ SPAction *ContextVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *ZoomVerb::make_action(Inkscape::UI::View::View *view) +SPAction *ZoomVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -484,12 +490,12 @@ SPAction *ZoomVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *DialogVerb::make_action(Inkscape::UI::View::View *view) +SPAction *DialogVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -497,12 +503,12 @@ SPAction *DialogVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *HelpVerb::make_action(Inkscape::UI::View::View *view) +SPAction *HelpVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -510,12 +516,12 @@ SPAction *HelpVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *TutorialVerb::make_action(Inkscape::UI::View::View *view) +SPAction *TutorialVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -523,12 +529,12 @@ SPAction *TutorialVerb::make_action(Inkscape::UI::View::View *view) * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *TextVerb::make_action(Inkscape::UI::View::View *view) +SPAction *TextVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -542,16 +548,16 @@ SPAction *TextVerb::make_action(Inkscape::UI::View::View *view) * if the action gets crated, a listener is added to the action with * the vector that is passed in. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @param vector The function vector for the verb. * @return The created action. */ -SPAction *Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr) +SPAction *Verb::make_action_helper(Inkscape::ActionContext const & context, void (*perform_fun)(SPAction *, void *), void *in_pntr) { SPAction *action; //std::cout << "Adding action: " << _code << std::endl; - action = sp_action_new(view, _id, _(_name), + action = sp_action_new(context, _id, _(_name), _(_tip), _image, this); if (action == NULL) return NULL; @@ -583,22 +589,22 @@ SPAction *Verb::make_action_helper(Inkscape::UI::View::View *view, void (*perfor * looked for, and the sensitivity is matched. Unfortunately, this is * currently a linear search. * - * @param view The view which this action would relate to. + * @param context The action context which this action relates to. * @return The action, or NULL if there is an error. */ -SPAction *Verb::get_action(Inkscape::UI::View::View *view) +SPAction *Verb::get_action(Inkscape::ActionContext const & context) { SPAction *action = NULL; if ( _actions == NULL ) { _actions = new ActionTable; } - ActionTable::iterator action_found = _actions->find(view); + ActionTable::iterator action_found = _actions->find(context.getView()); if (action_found != _actions->end()) { action = action_found->second; } else { - action = this->make_action(view); + action = this->make_action(context); // if (action == NULL) printf("Hmm, NULL in %s\n", _name); if (action == NULL) printf("Hmm, NULL in %s\n", _name); @@ -606,21 +612,31 @@ SPAction *Verb::get_action(Inkscape::UI::View::View *view) sp_action_set_sensitive(action, 0); } else { for (ActionTable::iterator cur_action = _actions->begin(); - cur_action != _actions->end() && view != NULL; + cur_action != _actions->end() && context.getView() != NULL; ++cur_action) { - if (cur_action->first != NULL && cur_action->first->doc() == view->doc()) { + if (cur_action->first != NULL && cur_action->first->doc() == context.getDocument()) { sp_action_set_sensitive(action, cur_action->second->sensitive); break; } } } - _actions->insert(ActionTable::value_type(view, action)); + _actions->insert(ActionTable::value_type(context.getView(), action)); } return action; } +/* static */ +bool Verb::ensure_desktop_valid(SPAction *action) +{ + if (sp_action_get_desktop(action) != NULL) { + return true; + } + g_printerr("WARNING: ignoring verb %s - GUI required for this verb.\n", action->id); + return false; +} + void Verb::sensitive(SPDocument *in_doc, bool in_sensitive) { // printf("Setting sensitivity of \"%s\" to %d\n", _name, in_sensitive); @@ -795,15 +811,30 @@ Verb *Verb::getbyid(gchar const *id) */ void FileVerb::perform(SPAction *action, void *data) { -#if 0 - // These aren't used, but are here to remind people not to use - // the CURRENT_DOCUMENT macros unless they really have to. - Inkscape::UI::View::View *current_view = sp_action_get_view(action); - SPDocument *current_document = current_view->doc(); -#endif + // Convert verb impls to use this where possible, to reduce static cling + // to macros like SP_ACTIVE_DOCUMENT, which end up enforcing GUI-mode operation + SPDocument *doc = sp_action_get_document(action); + + // We can vacuum defs, or exit, without needing a desktop! + bool handled = true; + switch (reinterpret_cast<std::size_t>(data)) { + case SP_VERB_FILE_VACUUM: + sp_file_vacuum(doc); + break; + case SP_VERB_FILE_QUIT: + sp_file_exit(); + break; + default: + handled = false; + break; + } + if (handled) { + return; + } + + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *desktop = sp_action_get_desktop(action); - SPDesktop *desktop = dynamic_cast<SPDesktop*>(sp_action_get_view(action)); - g_assert(desktop != NULL); Gtk::Window *parent = desktop->getToplevel(); g_assert(parent != NULL); @@ -829,9 +860,6 @@ void FileVerb::perform(SPAction *action, void *data) case SP_VERB_FILE_PRINT: sp_file_print(*parent); break; - case SP_VERB_FILE_VACUUM: - sp_file_vacuum(); - break; case SP_VERB_FILE_IMPORT: sp_file_import(*parent); break; @@ -853,9 +881,6 @@ void FileVerb::perform(SPAction *action, void *data) case SP_VERB_FILE_CLOSE_VIEW: sp_ui_close_view(NULL); break; - case SP_VERB_FILE_QUIT: - sp_file_exit(); - break; default: break; } @@ -868,9 +893,22 @@ void FileVerb::perform(SPAction *action, void *data) */ void EditVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) + // We can clear all without a desktop + bool handled = true; + switch (reinterpret_cast<std::size_t>(data)) { + case SP_VERB_EDIT_CLEAR_ALL: + sp_edit_clear_all(sp_action_get_selection(action)); + break; + default: + handled = false; + break; + } + if (handled) { return; + } + + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_EDIT_UNDO: @@ -960,9 +998,6 @@ void EditVerb::perform(SPAction *action, void *data) case SP_VERB_EDIT_UNSYMBOL: sp_selection_unsymbol(dt); break; - case SP_VERB_EDIT_CLEAR_ALL: - sp_edit_clear_all(dt); - break; case SP_VERB_EDIT_SELECT_ALL: SelectionHelper::selectAll(dt); break; @@ -1024,33 +1059,68 @@ void EditVerb::perform(SPAction *action, void *data) */ void SelectionVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); + Inkscape::Selection *selection = sp_action_get_selection(action); + SPDesktop *dt = sp_action_get_desktop(action); - if (!dt) + // Some of these operations have been modified so they work in command-line mode! + // In this case, all we need is a selection + if (!selection) { return; + } - g_assert(dt->_dlg_mgr != NULL); - + bool handled = true; switch (reinterpret_cast<std::size_t>(data)) { + case SP_VERB_SELECTION_UNION: + sp_selected_path_union(selection, dt); + break; + case SP_VERB_SELECTION_INTERSECT: + sp_selected_path_intersect(selection, dt); + break; + case SP_VERB_SELECTION_DIFF: + sp_selected_path_diff(selection, dt); + break; + case SP_VERB_SELECTION_SYMDIFF: + sp_selected_path_symdiff(selection, dt); + break; + case SP_VERB_SELECTION_CUT: + sp_selected_path_cut(selection, dt); + break; + case SP_VERB_SELECTION_SLICE: + sp_selected_path_slice(selection, dt); + break; case SP_VERB_SELECTION_TO_FRONT: - sp_selection_raise_to_top(dt); + sp_selection_raise_to_top(selection, dt); break; case SP_VERB_SELECTION_TO_BACK: - sp_selection_lower_to_bottom(dt); + sp_selection_lower_to_bottom(selection, dt); break; case SP_VERB_SELECTION_RAISE: - sp_selection_raise(dt); + sp_selection_raise(selection, dt); break; case SP_VERB_SELECTION_LOWER: - sp_selection_lower(dt); + sp_selection_lower(selection, dt); break; case SP_VERB_SELECTION_GROUP: - sp_selection_group(dt); + sp_selection_group(selection, dt); break; case SP_VERB_SELECTION_UNGROUP: - sp_selection_ungroup(dt); + sp_selection_ungroup(selection, dt); + break; + default: + handled = false; break; + } + if (handled) { + return; + } + + // The remaining operations require a desktop + g_return_if_fail(ensure_desktop_valid(action)); + + g_assert(dt->_dlg_mgr != NULL); + + switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_SELECTION_TEXTTOPATH: text_put_on_path(); break; @@ -1061,26 +1131,6 @@ void SelectionVerb::perform(SPAction *action, void *data) text_remove_all_kerns(); break; - case SP_VERB_SELECTION_UNION: - sp_selected_path_union(dt); - break; - case SP_VERB_SELECTION_INTERSECT: - sp_selected_path_intersect(dt); - break; - case SP_VERB_SELECTION_DIFF: - sp_selected_path_diff(dt); - break; - case SP_VERB_SELECTION_SYMDIFF: - sp_selected_path_symdiff(dt); - break; - - case SP_VERB_SELECTION_CUT: - sp_selected_path_cut(dt); - break; - case SP_VERB_SELECTION_SLICE: - sp_selected_path_slice(dt); - break; - case SP_VERB_SELECTION_OFFSET: sp_selected_path_offset(dt); break; @@ -1145,10 +1195,11 @@ void SelectionVerb::perform(SPAction *action, void *data) */ void LayerVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); size_t verb = reinterpret_cast<std::size_t>(data); - - if ( !dt || !dt->currentLayer() ) { + + if ( !dt->currentLayer() ) { return; } @@ -1396,9 +1447,8 @@ void LayerVerb::perform(SPAction *action, void *data) */ void ObjectVerb::perform( SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) - return; + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); SPEventContext *ec = dt->event_context; @@ -1483,11 +1533,9 @@ void ContextVerb::perform(SPAction *action, void *data) SPDesktop *dt; sp_verb_t verb; int vidx; - - dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - - if (!dt) - return; + + g_return_if_fail(ensure_desktop_valid(action)); + dt = sp_action_get_desktop(action); verb = (sp_verb_t)GPOINTER_TO_INT((gpointer)data); @@ -1496,7 +1544,7 @@ void ContextVerb::perform(SPAction *action, void *data) */ for (vidx = SP_VERB_CONTEXT_SELECT; vidx <= SP_VERB_CONTEXT_PAINTBUCKET_PREFS; vidx++) { - SPAction *tool_action= get((sp_verb_t)vidx)->get_action(dt); + SPAction *tool_action= get((sp_verb_t)vidx)->get_action(action->context); if (tool_action) { sp_action_set_active(tool_action, vidx == (int)verb); } @@ -1556,7 +1604,7 @@ void ContextVerb::perform(SPAction *action, void *data) tools_switch(dt, TOOLS_MEASURE); break; case SP_VERB_CONTEXT_DROPPER: - tools_switch(dt, TOOLS_DROPPER); + sp_toggle_dropper(dt); // Functionality defined in event-context.cpp break; case SP_VERB_CONTEXT_CONNECTOR: tools_switch(dt, TOOLS_CONNECTOR); @@ -1685,9 +1733,8 @@ void ContextVerb::perform(SPAction *action, void *data) */ void TextVerb::perform(SPAction *action, void */*data*/) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) - return; + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); SPDocument *doc = sp_desktop_document(dt); (void)doc; @@ -1700,9 +1747,8 @@ void TextVerb::perform(SPAction *action, void */*data*/) */ void ZoomVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) - return; + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); SPEventContext *ec = dt->event_context; SPDocument *doc = sp_desktop_document(dt); @@ -1889,8 +1935,9 @@ void DialogVerb::perform(SPAction *action, void *data) // unhide all when opening a new dialog inkscape_dialogs_unhide(); } - - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); + + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); g_assert(dt->_dlg_mgr != NULL); switch (reinterpret_cast<std::size_t>(data)) { @@ -2002,7 +2049,8 @@ void DialogVerb::perform(SPAction *action, void *data) */ void HelpVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); g_assert(dt->_dlg_mgr != NULL); switch (reinterpret_cast<std::size_t>(data)) { @@ -2035,8 +2083,9 @@ void HelpVerb::perform(SPAction *action, void *data) /** * Decode the verb code and take appropriate action. */ -void TutorialVerb::perform(SPAction */*action*/, void *data) +void TutorialVerb::perform(SPAction *action, void *data) { + g_return_if_fail(ensure_desktop_valid(action)); switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_TUTORIAL_BASIC: // TRANSLATORS: If you have translated the tutorial-basic.en.svgz file to your language, @@ -2086,7 +2135,7 @@ class EffectLastVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ EffectLastVerb(unsigned int const code, @@ -2105,12 +2154,12 @@ public: * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *EffectLastVerb::make_action(Inkscape::UI::View::View *view) +SPAction *EffectLastVerb::make_action(Inkscape::ActionContext const & context) { - return make_action_helper(view, &perform); + return make_action_helper(context, &perform); } /** @@ -2118,14 +2167,12 @@ SPAction *EffectLastVerb::make_action(Inkscape::UI::View::View *view) */ void EffectLastVerb::perform(SPAction *action, void *data) { - // These aren't used, but are here to remind people not to use - // the CURRENT_DOCUMENT macros unless they really have to. + g_return_if_fail(ensure_desktop_valid(action)); Inkscape::UI::View::View *current_view = sp_action_get_view(action); - // SPDocument *current_document = SP_VIEW_DOCUMENT(current_view); + Inkscape::Extension::Effect *effect = Inkscape::Extension::Effect::get_last_effect(); if (effect == NULL) return; - if (current_view == NULL) return; switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_EFFECT_LAST_PREF: @@ -2151,7 +2198,7 @@ class FitCanvasVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ FitCanvasVerb(unsigned int const code, @@ -2170,12 +2217,12 @@ public: * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *FitCanvasVerb::make_action(Inkscape::UI::View::View *view) +SPAction *FitCanvasVerb::make_action(Inkscape::ActionContext const & context) { - SPAction *action = make_action_helper(view, &perform); + SPAction *action = make_action_helper(context, &perform); return action; } @@ -2184,8 +2231,8 @@ SPAction *FitCanvasVerb::make_action(Inkscape::UI::View::View *view) */ void FitCanvasVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) return; + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); SPDocument *doc = sp_desktop_document(dt); if (!doc) return; @@ -2217,7 +2264,7 @@ class LockAndHideVerb : public Verb { private: static void perform(SPAction *action, void *mydata); protected: - virtual SPAction *make_action(Inkscape::UI::View::View *view); + virtual SPAction *make_action(Inkscape::ActionContext const & context); public: /** Use the Verb initializer with the same parameters. */ LockAndHideVerb(unsigned int const code, @@ -2236,12 +2283,12 @@ public: * * Calls \c make_action_helper with the \c vector. * - * @param view Which view the action should be created for. + * @param context Which context the action should be created for. * @return The built action. */ -SPAction *LockAndHideVerb::make_action(Inkscape::UI::View::View *view) +SPAction *LockAndHideVerb::make_action(Inkscape::ActionContext const & context) { - SPAction *action = make_action_helper(view, &perform); + SPAction *action = make_action_helper(context, &perform); return action; } @@ -2250,8 +2297,8 @@ SPAction *LockAndHideVerb::make_action(Inkscape::UI::View::View *view) */ void LockAndHideVerb::perform(SPAction *action, void *data) { - SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action)); - if (!dt) return; + g_return_if_fail(ensure_desktop_valid(action)); + SPDesktop *dt = sp_action_get_desktop(action); SPDocument *doc = sp_desktop_document(dt); if (!doc) return; @@ -2856,7 +2903,17 @@ Verb *Verb::_base_verbs[] = { N_("Link an ICC color profile"), NULL), new EditVerb(SP_VERB_EDIT_REMOVE_COLOR_PROFILE, "RemoveColorProfile", N_("Remove Color Profile"), N_("Remove a linked ICC color profile"), NULL), - + // Scripting + new ContextVerb(SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, "AddExternalScript", + N_("Add External Script"), N_("Add an external script"), NULL), + new ContextVerb(SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, "AddEmbeddedScript", + N_("Add Embedded Script"), N_("Add an embedded script"), NULL), + new ContextVerb(SP_VERB_EDIT_EMBEDDED_SCRIPT, "EditEmbeddedScript", + N_("Edit Embedded Script"), N_("Edit an embedded script"), NULL), + new ContextVerb(SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, "RemoveExternalScript", + N_("Remove External Script"), N_("Remove an external script"), NULL), + new ContextVerb(SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, "RemoveEmbeddedScript", + N_("Remove Embedded Script"), N_("Remove an embedded script"), NULL), // Align new ContextVerb(SP_VERB_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR, "AlignHorizontalRightToAnchor", N_("Align right edges of objects to the left edge of the anchor"), N_("Align right edges of objects to the left edge of the anchor"), INKSCAPE_ICON("align-horizontal-right-to-anchor")), diff --git a/src/verbs.h b/src/verbs.h index dab524d7a..053441b89 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -23,6 +23,9 @@ struct SPAction; class SPDocument; namespace Inkscape { + +class ActionContext; + namespace UI { namespace View { class View; @@ -472,8 +475,8 @@ public: protected: - SPAction *make_action_helper (Inkscape::UI::View::View *view, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL); - virtual SPAction *make_action (Inkscape::UI::View::View *view); + SPAction *make_action_helper (Inkscape::ActionContext const & context, void (*perform_fun)(SPAction *, void *), void *in_pntr = NULL); + virtual SPAction *make_action (Inkscape::ActionContext const & context); public: @@ -521,7 +524,7 @@ public: Verb (gchar const * id, gchar const * name, gchar const * tip, gchar const * image, gchar const * group); virtual ~Verb (void); - SPAction * get_action(Inkscape::UI::View::View * view); + SPAction * get_action(Inkscape::ActionContext const & context); private: static Verb * get_search (unsigned int code); @@ -547,6 +550,11 @@ public: } } static Verb * getbyid (gchar const * id); + + /** + * Print a message to stderr indicating that this verb needs a GUI to run + */ + static bool ensure_desktop_valid(SPAction *action); static void delete_all_view (Inkscape::UI::View::View * view); void delete_view (Inkscape::UI::View::View * view); diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 467f0d70e..a1bd9b792 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -20,6 +20,7 @@ #include "icon.h" #include "shortcuts.h" #include "interface.h" +#include "helper/action-context.h" #include <gdk/gdkkeysyms.h> @@ -309,7 +310,7 @@ sp_button_new_from_data( Inkscape::IconSize size, const gchar *tip ) { GtkWidget *button; - SPAction *action=sp_action_new(view, name, name, tip, name, 0); + SPAction *action=sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); button = sp_button_new (size, type, action, NULL); g_object_unref(action); return button; diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index 0a572f4de..faa667ac7 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -10,6 +10,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/combobox.h> #include <gtkmm/liststore.h> diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 3c24bcc67..99d273855 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -41,6 +41,8 @@ #include "ege-select-one-action.h" #include <extension/db.h> #include "file.h" +#include "helper/action.h" +#include "helper/action-context.h" #include "helper/units.h" #include "helper/unit-tracker.h" #include "inkscape-private.h" @@ -55,7 +57,6 @@ #include "ui/widget/dock.h" #include "ui/widget/layer-selector.h" #include "ui/widget/selected-style.h" -#include "ui/widget/gimpspinscale.h" #include "ui/uxmanager.h" #include "util/ege-appear-time-tracker.h" #include "sp-root.h" @@ -315,13 +316,12 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) * This adjusts the range of the rulers when the dock container is adjusted * (fixes lp:950552) */ -static void -canvas_tbl_size_allocate(GtkWidget *widget, - GdkRectangle *allocation, - gpointer data) +static void canvas_tbl_size_allocate(GtkWidget * /*widget*/, + GdkRectangle * /*allocation*/, + gpointer data) { SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); - sp_desktop_widget_update_rulers (dtw); + sp_desktop_widget_update_rulers(dtw); } /** @@ -487,7 +487,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gchar const* tip = ""; Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE ); if ( verb ) { - SPAction *act = verb->get_action( dtw->viewwidget.view ); + SPAction *act = verb->get_action( Inkscape::ActionContext( dtw->viewwidget.view ) ); if ( act && act->tip ) { tip = act->tip; } @@ -629,14 +629,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_end (GTK_BOX (dtw->statusbar), statusbar_tail, FALSE, FALSE, 0); // zoom status spinbutton -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _adjustment = Gtk::Adjustment::create(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0); -#else - Gtk::Adjustment *_adjustment = new Gtk::Adjustment(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0); -#endif - dtw->zoom_status = gimp_spin_scale_new (_adjustment->gobj(), _("Zoom"), 1); - - //dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1); + dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1); gtk_widget_set_tooltip_text (dtw->zoom_status, _("Zoom")); gtk_widget_set_size_request (dtw->zoom_status, STATUS_ZOOM_WIDTH, -1); gtk_entry_set_width_chars (GTK_ENTRY (dtw->zoom_status), 6); @@ -697,18 +690,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->coord_status_y = gtk_label_new(NULL); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" ); gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); - //GtkWidget* label_z = gtk_label_new(_("Z:")); + GtkWidget* label_z = gtk_label_new(_("Z:")); #if GTK_CHECK_VERSION(3,0,0) gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); - //gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); - gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 3, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); + gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); #else gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0); - //gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); - gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0); #endif sp_set_font_size_smaller (dtw->coord_status); @@ -1069,7 +1062,7 @@ void cms_adjust_set_sensitive( SPDesktopWidget *dtw, bool enabled ) { Inkscape::Verb* verb = Inkscape::Verb::get( SP_VERB_VIEW_CMS_TOGGLE ); if ( verb ) { - SPAction *act = verb->get_action( dtw->viewwidget.view ); + SPAction *act = verb->get_action( Inkscape::ActionContext( dtw->viewwidget.view ) ); if ( act ) { sp_action_set_sensitive( act, enabled ); } @@ -1897,6 +1890,67 @@ sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) spinbutton_defocus (GTK_WIDGET(spin)); } + +static void +sp_dtw_zoom_10 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.1); +} + +static void +sp_dtw_zoom_25 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.25); +} + +static void +sp_dtw_zoom_50 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.5); +} + +static void +sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 1.0); +} + +static void +sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 2.0); +} + +static void +sp_dtw_zoom_500 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 5.0); +} + +static void +sp_dtw_zoom_1000 (GtkMenuItem */*item*/, gpointer data) +{ + sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 10.0); +} + +static void +sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_page(); +} + +static void +sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_drawing(); +} + +static void +sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) +{ + static_cast<SPDesktop*>(data)->zoom_selection(); +} + static void sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) { @@ -1910,6 +1964,14 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) } g_list_free (children); + item = gtk_menu_item_new_with_label ("1000%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_1000), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("500%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_500), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_menu_item_new_with_label ("200%"); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_200), dt); gtk_widget_show (item); @@ -1922,6 +1984,15 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_50), dt); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("25%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_25), dt); + gtk_widget_show (item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); + item = gtk_menu_item_new_with_label ("10%"); + g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (sp_dtw_zoom_10), dt); + gtk_widget_show (item); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); item = gtk_separator_menu_item_new (); gtk_widget_show (item); @@ -1948,41 +2019,6 @@ sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], factor); } -static void -sp_dtw_zoom_50 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 0.5); -} - -static void -sp_dtw_zoom_100 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 1.0); -} - -static void -sp_dtw_zoom_200 (GtkMenuItem */*item*/, gpointer data) -{ - sp_dtw_zoom_menu_handler (static_cast<SPDesktop*>(data), 2.0); -} - -static void -sp_dtw_zoom_page (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_page(); -} - -static void -sp_dtw_zoom_drawing (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_drawing(); -} - -static void -sp_dtw_zoom_selection (GtkMenuItem */*item*/, gpointer data) -{ - static_cast<SPDesktop*>(data)->zoom_selection(); -} static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *, gpointer data) diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 9188838b3..9031ac854 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -12,6 +12,14 @@ * ? -2004 */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/window.h> #include "message.h" #include "ui/view/view-widget.h" diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 60e115f54..d9d62d3ec 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -22,6 +22,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <glibmm/i18n.h> diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 453ef683f..7fa848f1e 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -332,7 +332,7 @@ static void sp_font_selector_family_select_row(GtkTreeSelection *selection, } // Callback when row changed -static void sp_font_selector_style_select_row (GtkTreeSelection *selection, +static void sp_font_selector_style_select_row (GtkTreeSelection * /*selection*/, SPFontSelector *fsel) { if (!fsel->block_emit) diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 7a7f0d8ff..5ac994509 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -26,6 +26,7 @@ #include "inkscape.h" #include "verbs.h" #include "helper/action.h" +#include "helper/action-context.h" #include "preferences.h" #include <glibmm/i18n.h> @@ -535,7 +536,7 @@ sp_gradient_selector_edit_vector_clicked (GtkWidget */*w*/, SPGradientSelector * // Invoke the gradient tool Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT ); if ( verb ) { - SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP); + SPAction *action = verb->get_action( Inkscape::ActionContext( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP ) ); if ( action ) { sp_action_perform( action, NULL ); } diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index ea83ff819..c88666b06 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -15,6 +15,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <glib.h> #include <gtk/gtk.h> diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index e15f81e0f..118d8a68a 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -1001,8 +1001,6 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) { - GtkWidget *wid; - if (dlg == NULL) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1044,7 +1042,7 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); - wid = static_cast<GtkWidget*>(sp_gradient_vector_widget_new(gradient, stop)); + GtkWidget *wid = static_cast<GtkWidget*>(sp_gradient_vector_widget_new(gradient, stop)); g_object_set_data(G_OBJECT(dlg), "gradient-vector-widget", wid); /* Connect signals */ gtk_widget_show(wid); diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 463d77912..64e40a35b 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -15,6 +15,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/liststore.h> #include <stddef.h> diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7580d9602..dda453bc4 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -16,6 +16,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/icontheme.h> #include <cstring> #include <glib.h> @@ -863,6 +867,13 @@ GtkWidget *sp_icon_new( Inkscape::IconSize lsize, gchar const *name ) return IconImpl::newFull( lsize, name ); } +// PUBLIC CALL for when you REALLY need a pixbuf +GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize lsize, gchar const *name ) +{ + int psize = IconImpl::getPhysSize(lsize); + return IconImpl::renderup(name, lsize, psize); +} + // PUBLIC CALL: Gtk::Widget *sp_icon_get_icon( Glib::ustring const &oid, Inkscape::IconSize size ) { diff --git a/src/widgets/icon.h b/src/widgets/icon.h index 6bce2e330..e1dae0d6a 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,6 +14,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/widget.h> #include "icon-size.h" @@ -45,7 +53,7 @@ struct SPIcon { GtkWidget *sp_icon_new( Inkscape::IconSize size, const gchar *name ); - +GdkPixbuf *sp_pixbuf_new( Inkscape::IconSize size, const gchar *name ); // Might return a wrapped SPIcon, or Gtk::Image Gtk::Widget *sp_icon_get_icon( const Glib::ustring &oid, Inkscape::IconSize size = Inkscape::ICON_SIZE_BUTTON ); diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 3126175b3..c7659ab42 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -55,6 +55,8 @@ #include "../xml/repr.h" #include "ui/uxmanager.h" #include "../ui/icon-names.h" +#include "../helper/action.h" +#include "../helper/action-context.h" #include "../helper/unit-menu.h" #include "../helper/units.h" #include "../helper/unit-tracker.h" @@ -286,7 +288,7 @@ static void lpetool_open_lpe_dialog(GtkToggleAction *act, gpointer data) SPDesktop *desktop = static_cast<SPDesktop *>(data); if (tools_isactive(desktop, TOOLS_LPETOOL)) { - sp_action_perform(Inkscape::Verb::get(SP_VERB_DIALOG_LIVE_PATH_EFFECT)->get_action(desktop), NULL); + sp_action_perform(Inkscape::Verb::get(SP_VERB_DIALOG_LIVE_PATH_EFFECT)->get_action(Inkscape::ActionContext(desktop)), NULL); } gtk_toggle_action_set_active(act, false); } diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 3509bf6b2..0bd7a8852 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -24,6 +24,9 @@ #include <cstring> #include <string> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif #include "widgets/swatch-selector.h" #include "../sp-pattern.h" @@ -1138,14 +1141,14 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele gtk_widget_set_sensitive(psel->style, TRUE); - SwatchSelector *swatchsel = 0; + SwatchSelector *swatchsel = NULL; if (psel->mode == SPPaintSelector::MODE_SWATCH){ - swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); + // swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector")); } else { sp_paint_selector_clear_frame(psel); // Create new gradient selector - SwatchSelector *swatchsel = new SwatchSelector(); + swatchsel = new SwatchSelector(); swatchsel->show(); swatchsel->connectGrabbedHandler( G_CALLBACK(sp_paint_selector_gradient_grabbed), psel ); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 549581610..1bfc841e3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -37,6 +37,8 @@ #include "sp-namedview.h" #include "toolbox.h" #include <glibmm/i18n.h> +#include "helper/action.h" +#include "helper/action-context.h" #include "helper/unit-menu.h" #include "helper/units.h" #include "inkscape.h" @@ -413,7 +415,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi { GtkAction* act = 0; - SPAction* targetAction = verb->get_action(view); + SPAction* targetAction = verb->get_action(Inkscape::ActionContext(view)); InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp index 941a0466c..3558780ed 100644 --- a/src/widgets/shrink-wrap-button.cpp +++ b/src/widgets/shrink-wrap-button.cpp @@ -13,6 +13,10 @@ #include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/button.h> #include <gtk/gtk.h> diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index 1f0fcd94e..fb7eb1420 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -101,14 +101,12 @@ SPAttributeTable::~SPAttributeTable () void SPAttributeTable::clear(void) { - Gtk::Widget *w; - if (table) { std::vector<Gtk::Widget*> ch = table->get_children(); for (int i = (ch.size())-1; i >=0 ; i--) { - w = ch[i]; + Gtk::Widget *w = ch[i]; ch.pop_back(); if (w != NULL) { @@ -261,7 +259,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { - if (flags && SP_OBJECT_MODIFIED_FLAG) + if (flags & SP_OBJECT_MODIFIED_FLAG) { std::vector<Glib::ustring> attributes = spat->get_attributes(); std::vector<Gtk::Entry *> entries = spat->get_entries(); @@ -272,7 +270,7 @@ static void sp_attribute_table_object_modified ( SPObject */*object*/, text = e->get_text (); if (val || !text.empty()) { if (text != val) { - /* We are different */ + // We are different spat->blocked = true; e->set_text (val ? val : (const gchar *) ""); spat->blocked = false; diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index d9b972201..4bd6c6959 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -19,6 +19,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/widget.h> #include <stddef.h> #include <sigc++/connection.h> diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index ce9323311..53e73dd57 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -6,10 +6,16 @@ #include <math.h> #include <gtk/gtk.h> #include <glibmm/i18n.h> +#include <map> +#include <set> +#include <vector> + #include "../dialogs/dialog-events.h" #include "sp-color-icc-selector.h" #include "sp-color-scales.h" +#include "sp-color-slider.h" #include "svg/svg-icc-color.h" +#include "colorspace.h" #include "document.h" #include "inkscape.h" #include "profile-manager.h" @@ -68,30 +74,174 @@ static void sp_color_icc_selector_dispose(GObject *object); static void sp_color_icc_selector_show_all (GtkWidget *widget); static void sp_color_icc_selector_hide(GtkWidget *widget); - G_END_DECLS +/** + * Class containing the parts for a single color component's UI presence. + */ +class ComponentUI +{ +public: + ComponentUI() : + _component(), + _adj(0), + _slider(0), + _btn(0), + _label(0), + _map(0) + { + } + + ComponentUI(colorspace::Component const &component) : + _component(component), + _adj(0), + _slider(0), + _btn(0), + _label(0), + _map(0) + { + } + + colorspace::Component _component; + GtkAdjustment *_adj; // Component adjustment + GtkWidget *_slider; + GtkWidget *_btn; // spinbutton + GtkWidget *_label; // Label + guchar *_map; +}; + +/** + * Class that implements the internals of the selector. + */ +class ColorICCSelectorImpl +{ +public: + + ColorICCSelectorImpl( ColorICCSelector *owner); + + ~ColorICCSelectorImpl(); + + static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); + + static void _sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs ); + static void _sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs ); + static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); + + static void _profileSelected( GtkWidget* src, gpointer data ); + static void _fixupHit( GtkWidget* src, gpointer data ); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + void _setProfile( SVGICCColor* profile ); + void _switchToProfile( gchar const* name ); +#endif + void _updateSliders( gint ignore ); + void _profilesChanged( std::string const & name ); + + ColorICCSelector *_owner; + + gboolean _updating : 1; + gboolean _dragging : 1; + + guint32 _fixupNeeded; + GtkWidget* _fixupBtn; + GtkWidget* _profileSel; + + std::vector<ComponentUI> _compUI; + + GtkAdjustment* _adj; // Channel adjustment + GtkWidget* _slider; + GtkWidget* _sbtn; // Spinbutton + GtkWidget* _label; // Label + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + std::string _profileName; + Inkscape::ColorProfile* _prof; + guint _profChannelCount; + gulong _profChangedID; +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +}; + + static SPColorSelectorClass *parent_class; #define XPAD 4 #define YPAD 1 -GType -sp_color_icc_selector_get_type (void) +namespace +{ + +size_t maxColorspaceComponentCount = 0; + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + +/** + * Internal variable to track all known colorspaces. + */ +std::set<cmsUInt32Number> knownColorspaces; + +#endif + + +/** + * Simple helper to allow bitwise or on GtkAttachOptions. + */ +GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs) +{ + return static_cast<GtkAttachOptions>(static_cast<int>(lhs) | static_cast<int>(rhs)); +} + +/** + * Helper function to handle GTK2/GTK3 attachment #ifdef code. + */ +void attachToGridOrTable(GtkWidget *parent, + GtkWidget *child, + guint left, + guint top, + guint width, + guint height, + bool hexpand = false, + bool centered = false, + guint xpadding = XPAD, + guint ypadding = YPAD) +{ +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_margin_left( child, xpadding ); + gtk_widget_set_margin_right( child, xpadding ); + gtk_widget_set_margin_top( child, ypadding ); + gtk_widget_set_margin_bottom( child, ypadding ); + if (hexpand) { + gtk_widget_set_hexpand(child, TRUE); + } + if (centered) { + gtk_widget_set_halign( child, GTK_ALIGN_CENTER ); + gtk_widget_set_valign( child, GTK_ALIGN_CENTER ); + } + gtk_grid_attach( GTK_GRID(parent), child, left, top, width, height ); +#else + GtkAttachOptions xoptions = centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; + GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL; + + gtk_table_attach( GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, ypadding ); +#endif +} + +} // namespace + +GType sp_color_icc_selector_get_type(void) { static GType type = 0; if (!type) { static const GTypeInfo info = { sizeof (SPColorICCSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ + NULL, // base_init + NULL, // base_finalize (GClassInitFunc) sp_color_icc_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ + NULL, // class_finalize + NULL, // class_data sizeof (SPColorICCSelector), - 0, /* n_preallocs */ + 0, // n_preallocs (GInstanceInitFunc) sp_color_icc_selector_init, - 0, /* value_table */ + 0, // value_table }; type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, @@ -123,40 +273,20 @@ static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) ColorICCSelector::ColorICCSelector( SPColorSelector* csel ) : ColorSelector( csel ), - _updating( FALSE ), - _dragging( FALSE ), - _fixupNeeded(0), - _fixupBtn(0), - _profileSel(0), - _fooCount(0), - _fooScales(0), - _fooAdj(0), - _fooSlider(0), - _fooBtn(0), - _fooLabel(0), - _fooMap(0), - _adj(0), - _slider(0), - _sbtn(0), - _label(0) -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - , - _profileName(""), - _prof(), - _profChannelCount(0), - _profChangedID(0) -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + _impl(NULL) { } ColorICCSelector::~ColorICCSelector() { - _adj = 0; - _sbtn = 0; - _label = 0; + if (_impl) + { + delete _impl; + _impl = 0; + } } -void sp_color_icc_selector_init (SPColorICCSelector *cs) +void sp_color_icc_selector_init(SPColorICCSelector *cs) { SP_COLOR_SELECTOR(cs)->base = new ColorICCSelector( SP_COLOR_SELECTOR(cs) ); @@ -185,95 +315,127 @@ static cmsUInt16Number* getScratch() { return scritch; } -struct MapMap { - cmsUInt32Number space; - cmsUInt32Number inForm; -}; +colorspace::Component::Component() : + name(), + tip(), + scale(1) +{ +} + +colorspace::Component::Component(std::string const &name, std::string const &tip, guint scale) : + name(name), + tip(tip), + scale(scale) +{ +} + +std::vector<colorspace::Component> colorspace::getColorSpaceInfo( uint32_t space ) +{ + static std::map<cmsUInt32Number, std::vector<Component> > sets; + if (sets.empty()) + { + sets[cmsSigXYZData].push_back(Component("_X", "X", 2)); // TYPE_XYZ_16 + sets[cmsSigXYZData].push_back(Component("_Y", "Y", 1)); + sets[cmsSigXYZData].push_back(Component("_Z", "Z", 2)); + + sets[cmsSigLabData].push_back(Component("_L", "L", 100)); // TYPE_Lab_16 + sets[cmsSigLabData].push_back(Component("_a", "a", 256)); + sets[cmsSigLabData].push_back(Component("_b", "b", 256)); -void getThings( cmsUInt32Number space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { - MapMap possible[] = { - {cmsSigXYZData, TYPE_XYZ_16}, - {cmsSigLabData, TYPE_Lab_16}, //cmsSigLuvData - {cmsSigYCbCrData, TYPE_YCbCr_16}, - {cmsSigYxyData, TYPE_Yxy_16}, - {cmsSigRgbData, TYPE_RGB_16}, - {cmsSigGrayData, TYPE_GRAY_16}, - {cmsSigHsvData, TYPE_HSV_16}, - {cmsSigHlsData, TYPE_HLS_16}, - {cmsSigCmykData, TYPE_CMYK_16}, - {cmsSigCmyData, TYPE_CMY_16}, - }; - - static gchar const *names[][6] = { - {"_X", "_Y", "_Z", "", "", ""}, - {"_L", "_a", "_b", "", "", ""}, - // - {"_Y", "C_b", "C_r", "", "", ""}, - {"_Y", "_x", "y", "", "", ""}, - {_("_R:"), _("_G:"), _("_B:"), "", "", ""}, - {_("_G:"), "", "", "", "", ""}, - {_("_H:"), _("_S:"), "_V:", "", "", ""}, - {_("_H:"), _("_L:"), _("_S:"), "", "", ""}, - {_("_C:"), _("_M:"), _("_Y:"), _("_K:"), "", ""}, - {_("_C:"), _("_M:"), _("_Y:"), "", "", ""}, - }; - - static gchar const *tips[][6] = { - {"X", "Y", "Z", "", "", ""}, - {"L", "a", "b", "", "", ""}, - // - {"Y", "Cb", "Cr", "", "", ""}, - {"Y", "x", "y", "", "", ""}, - {_("Red"), _("Green"), _("Blue"), "", "", ""}, - {_("Gray"), "", "", "", "", ""}, - {_("Hue"), _("Saturation"), "Value", "", "", ""}, - {_("Hue"), _("Lightness"), _("Saturation"), "", "", ""}, - {_("Cyan"), _("Magenta"), _("Yellow"), _("Black"), "", ""}, - {_("Cyan"), _("Magenta"), _("Yellow"), "", "", ""}, - }; - - static guint scales[][6] = { - {2, 1, 2, 1, 1, 1}, - {100, 256, 256, 1, 1, 1}, - // - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {360, 1, 1, 1, 1, 1}, - {360, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1, 1}, - }; - - int index = 0; - for ( guint i = 0; i < G_N_ELEMENTS(possible); i++ ) { - if ( possible[i].space == space ) { - index = i; - break; + + sets[cmsSigYCbCrData].push_back(Component("_Y", "Y", 1)); // TYPE_YCbCr_16 + sets[cmsSigYCbCrData].push_back(Component("C_b", "Cb", 1)); + sets[cmsSigYCbCrData].push_back(Component("C_r", "Cr", 1)); + + sets[cmsSigYxyData].push_back(Component("_Y", "Y", 1)); // TYPE_Yxy_16 + sets[cmsSigYxyData].push_back(Component("_x", "x", 1)); + sets[cmsSigYxyData].push_back(Component("y", "y", 1)); + + sets[cmsSigRgbData].push_back(Component(_("_R:"), _("Red"), 1)); // TYPE_RGB_16 + sets[cmsSigRgbData].push_back(Component(_("_G:"), _("Green"), 1)); + sets[cmsSigRgbData].push_back(Component(_("_B:"), _("Blue"), 1)); + + sets[cmsSigGrayData].push_back(Component(_("G:"), _("Gray"), 1)); // TYPE_GRAY_16 + + sets[cmsSigHsvData].push_back(Component(_("_H:"), _("Hue"), 360)); // TYPE_HSV_16 + sets[cmsSigHsvData].push_back(Component(_("_S:"), _("Saturation"), 1)); + sets[cmsSigHsvData].push_back(Component("_V:", "Value", 1)); + + sets[cmsSigHlsData].push_back(Component(_("_H:"), _("Hue"), 360)); // TYPE_HLS_16 + sets[cmsSigHlsData].push_back(Component(_("_L:"), _("Lightness"), 1)); + sets[cmsSigHlsData].push_back(Component(_("_S:"), _("Saturation"), 1)); + + sets[cmsSigCmykData].push_back(Component(_("_C:"), _("Cyan"), 1)); // TYPE_CMYK_16 + sets[cmsSigCmykData].push_back(Component(_("_M:"), _("Magenta"), 1)); + sets[cmsSigCmykData].push_back(Component(_("_Y:"), _("Yellow"), 1)); + sets[cmsSigCmykData].push_back(Component(_("_K:"), _("Black"), 1)); + + sets[cmsSigCmyData].push_back(Component(_("_C:"), _("Cyan"), 1)); // TYPE_CMY_16 + sets[cmsSigCmyData].push_back(Component(_("_M:"), _("Magenta"), 1)); + sets[cmsSigCmyData].push_back(Component(_("_Y:"), _("Yellow"), 1)); + + for (std::map<cmsUInt32Number, std::vector<Component> >::iterator it = sets.begin(); it != sets.end(); ++it) + { + knownColorspaces.insert(it->first); + maxColorspaceComponentCount = std::max(maxColorspaceComponentCount, it->second.size()); } } - namers = names[index]; - tippies = tips[index]; - scalies = scales[index]; + std::vector<Component> target; + + if (sets.find(space) != sets.end()) + { + target = sets[space]; + } + return target; } -void getThings( Inkscape::ColorProfile *prof, gchar const**& namers, gchar const**& tippies, guint const*& scalies ) { - getThings( asICColorSpaceSig(prof->getColorSpace()), namers, tippies, scalies ); +std::vector<colorspace::Component> colorspace::getColorSpaceInfo( Inkscape::ColorProfile *prof ) +{ + return getColorSpaceInfo( asICColorSpaceSig(prof->getColorSpace()) ); } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +ColorICCSelectorImpl::ColorICCSelectorImpl(ColorICCSelector *owner) : + _owner(owner), + _updating( FALSE ), + _dragging( FALSE ), + _fixupNeeded(0), + _fixupBtn(0), + _profileSel(0), + _compUI(), + _adj(0), + _slider(0), + _sbtn(0), + _label(0) +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + , + _profileName(), + _prof(0), + _profChannelCount(0), + _profChangedID(0) +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +{ +} + +ColorICCSelectorImpl::~ColorICCSelectorImpl() +{ + _adj = 0; + _sbtn = 0; + _label = 0; +} void ColorICCSelector::init() { + if (_impl) delete(_impl); + _impl = new ColorICCSelectorImpl(this); gint row = 0; - _updating = FALSE; - _dragging = FALSE; + _impl->_updating = FALSE; + _impl->_dragging = FALSE; #if GTK_CHECK_VERSION(3,0,0) GtkWidget *t = gtk_grid_new(); @@ -284,232 +446,162 @@ void ColorICCSelector::init() gtk_widget_show (t); gtk_box_pack_start (GTK_BOX (_csel), t, TRUE, TRUE, 4); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - //guint partCount = _cmsChannelsOf( icSigRgbData ); - gchar const** names = 0; - gchar const** tips = 0; - getThings( cmsSigRgbData, names, tips, _fooScales ); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + _impl->_compUI.clear(); - /* Create components */ + // Create components row = 0; - _fixupBtn = gtk_button_new_with_label(_("Fix")); - g_signal_connect( G_OBJECT(_fixupBtn), "clicked", G_CALLBACK(_fixupHit), (gpointer)this ); - gtk_widget_set_sensitive( _fixupBtn, FALSE ); - gtk_widget_set_tooltip_text( _fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); - //gtk_misc_set_alignment( GTK_MISC (_fixupBtn), 1.0, 0.5 ); - gtk_widget_show( _fixupBtn ); + _impl->_fixupBtn = gtk_button_new_with_label(_("Fix")); + g_signal_connect( G_OBJECT(_impl->_fixupBtn), "clicked", G_CALLBACK(ColorICCSelectorImpl::_fixupHit), (gpointer)_impl ); + gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); + gtk_widget_set_tooltip_text( _impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value.") ); + //gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 ); + gtk_widget_show( _impl->_fixupBtn ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fixupBtn, XPAD); - gtk_widget_set_margin_right(_fixupBtn, XPAD); - gtk_widget_set_margin_top(_fixupBtn, YPAD); - gtk_widget_set_margin_bottom(_fixupBtn, YPAD); - gtk_grid_attach(GTK_GRID(t), _fixupBtn, 0, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _fixupBtn, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1); // Combobox and store with 2 columns : label (0) and full name (1) GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - _profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); + _impl->_profileSel = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (_profileSel), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (_profileSel), renderer, "text", 0, NULL); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(_impl->_profileSel), renderer, "text", 0, NULL); GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); - gtk_widget_show( _profileSel ); - gtk_combo_box_set_active( GTK_COMBO_BOX(_profileSel), 0 ); + gtk_widget_show( _impl->_profileSel ); + gtk_combo_box_set_active( GTK_COMBO_BOX(_impl->_profileSel), 0 ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_profileSel, XPAD); - gtk_widget_set_margin_right(_profileSel, XPAD); - gtk_widget_set_margin_top(_profileSel, YPAD); - gtk_widget_set_margin_bottom(_profileSel, YPAD); - gtk_grid_attach(GTK_GRID(t), _profileSel, 1, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE(t), _profileSel, 1, 2, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_profileSel, 1, row, 1, 1); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this ); + _impl->_profChangedID = g_signal_connect( G_OBJECT(_impl->_profileSel), "changed", G_CALLBACK(ColorICCSelectorImpl::_profileSelected), (gpointer)_impl ); #else - gtk_widget_set_sensitive( _profileSel, false ); + gtk_widget_set_sensitive( _impl->_profileSel, false ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) row++; - _fooCount = 4; - _fooAdj = new GtkAdjustment*[_fooCount]; - _fooSlider = new GtkWidget*[_fooCount]; - _fooBtn = new GtkWidget*[_fooCount]; - _fooLabel = new GtkWidget*[_fooCount]; - _fooMap = new guchar*[_fooCount]; - - for ( guint i = 0; i < _fooCount; i++ ) { - /* Label */ + // populate the data for colorspaces and channels: #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _fooLabel[i] = gtk_label_new_with_mnemonic( names[i] ); -#else - _fooLabel[i] = gtk_label_new_with_mnemonic( "." ); + std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo( cmsSigRgbData ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_misc_set_alignment( GTK_MISC (_fooLabel[i]), 1.0, 0.5 ); - gtk_widget_show( _fooLabel[i] ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooLabel[i], XPAD); - gtk_widget_set_margin_right(_fooLabel[i], XPAD); - gtk_widget_set_margin_top(_fooLabel[i], YPAD); - gtk_widget_set_margin_bottom(_fooLabel[i], YPAD); - gtk_grid_attach(GTK_GRID(t), _fooLabel[i], 0, row, 1, 1); + for ( size_t i = 0; i < maxColorspaceComponentCount; i++ ) { +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + if (i < things.size()) { + _impl->_compUI.push_back(ComponentUI(things[i])); + } else { + _impl->_compUI.push_back(ComponentUI()); + } + + std::string labelStr = (i < things.size()) ? things[i].name.c_str() : ""; #else - gtk_table_attach( GTK_TABLE (t), _fooLabel[i], 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD ); + _impl->_compUI.push_back(ComponentUI()); + + std::string labelStr = "."; #endif - /* Adjustment */ - gdouble step = static_cast<gdouble>(_fooScales[i]) / 100.0; - gdouble page = static_cast<gdouble>(_fooScales[i]) / 10.0; + _impl->_compUI[i]._label = gtk_label_new_with_mnemonic( labelStr.c_str() ); + gtk_misc_set_alignment( GTK_MISC (_impl->_compUI[i]._label), 1.0, 0.5 ); + gtk_widget_show( _impl->_compUI[i]._label ); + + attachToGridOrTable(t, _impl->_compUI[i]._label, 0, row, 1, 1); + + // Adjustment + guint scaleValue = _impl->_compUI[i]._component.scale; + gdouble step = static_cast<gdouble>(scaleValue) / 100.0; + gdouble page = static_cast<gdouble>(scaleValue) / 10.0; gint digits = (step > 0.9) ? 0 : 2; - _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, _fooScales[i], step, page, page ) ); + _impl->_compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, 0.0, scaleValue, step, page, page ) ); - /* Slider */ - _fooSlider[i] = sp_color_slider_new( _fooAdj[i] ); + // Slider + _impl->_compUI[i]._slider = sp_color_slider_new( _impl->_compUI[i]._adj ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); #else - gtk_widget_set_tooltip_text( _fooSlider[i], "." ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._slider, "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_show( _fooSlider[i] ); + gtk_widget_show( _impl->_compUI[i]._slider ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooSlider[i], XPAD); - gtk_widget_set_margin_right(_fooSlider[i], XPAD); - gtk_widget_set_margin_top(_fooSlider[i], YPAD); - gtk_widget_set_margin_bottom(_fooSlider[i], YPAD); - gtk_widget_set_hexpand(_fooSlider[i], TRUE); - gtk_grid_attach(GTK_GRID(t), _fooSlider[i], 1, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _fooSlider[i], 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_compUI[i]._slider, 1, row, 1, 1, true); - _fooBtn[i] = gtk_spin_button_new( _fooAdj[i], step, digits ); + _impl->_compUI[i]._btn = gtk_spin_button_new( _impl->_compUI[i]._adj, step, digits ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); #else - gtk_widget_set_tooltip_text( _fooBtn[i], "." ); + gtk_widget_set_tooltip_text( _impl->_compUI[i]._btn, "." ); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - sp_dialog_defocus_on_enter( _fooBtn[i] ); - gtk_label_set_mnemonic_widget( GTK_LABEL(_fooLabel[i]), _fooBtn[i] ); - gtk_widget_show( _fooBtn[i] ); + sp_dialog_defocus_on_enter( _impl->_compUI[i]._btn ); + gtk_label_set_mnemonic_widget( GTK_LABEL(_impl->_compUI[i]._label), _impl->_compUI[i]._btn ); + gtk_widget_show( _impl->_compUI[i]._btn ); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_fooBtn[i], XPAD); - gtk_widget_set_margin_right(_fooBtn[i], XPAD); - gtk_widget_set_margin_top(_fooBtn[i], YPAD); - gtk_widget_set_margin_bottom(_fooBtn[i], YPAD); - gtk_widget_set_halign(_fooBtn[i], GTK_ALIGN_CENTER); - gtk_widget_set_valign(_fooBtn[i], GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _fooBtn[i], 2, row, 1, 1); -#else - gtk_table_attach( GTK_TABLE (t), _fooBtn[i], 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD ); -#endif + attachToGridOrTable(t, _impl->_compUI[i]._btn, 2, row, 1, 1, false, true); - _fooMap[i] = g_new( guchar, 4 * 1024 ); - memset( _fooMap[i], 0x0ff, 1024 * 4 ); + _impl->_compUI[i]._map = g_new( guchar, 4 * 1024 ); + memset( _impl->_compUI[i]._map, 0x0ff, 1024 * 4 ); - /* Signals */ - g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); + // Signals + g_signal_connect( G_OBJECT( _impl->_compUI[i]._adj ), "value_changed", G_CALLBACK( ColorICCSelectorImpl::_adjustmentChanged ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "grabbed", G_CALLBACK( _sliderGrabbed ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "released", G_CALLBACK( _sliderReleased ), _csel ); - g_signal_connect( G_OBJECT( _fooSlider[i] ), "changed", G_CALLBACK( _sliderChanged ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "grabbed", G_CALLBACK( ColorICCSelectorImpl::_sliderGrabbed ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "released", G_CALLBACK( ColorICCSelectorImpl::_sliderReleased ), _csel ); + g_signal_connect( G_OBJECT( _impl->_compUI[i]._slider ), "changed", G_CALLBACK( ColorICCSelectorImpl::_sliderChanged ), _csel ); row++; } - /* Label */ - _label = gtk_label_new_with_mnemonic (_("_A:")); - gtk_misc_set_alignment (GTK_MISC (_label), 1.0, 0.5); - gtk_widget_show (_label); + // Label + _impl->_label = gtk_label_new_with_mnemonic(_("_A:")); + gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5); + gtk_widget_show(_impl->_label); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_label, XPAD); - gtk_widget_set_margin_right(_label, XPAD); - gtk_widget_set_margin_top(_label, YPAD); - gtk_widget_set_margin_bottom(_label, YPAD); - gtk_grid_attach(GTK_GRID(t), _label, 0, row, 1, 1); -#else - gtk_table_attach (GTK_TABLE (t), _label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_label, 0, row, 1, 1); - /* Adjustment */ - _adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); + // Adjustment + _impl->_adj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 255.0, 1.0, 10.0, 10.0)); - /* Slider */ - _slider = sp_color_slider_new (_adj); - gtk_widget_set_tooltip_text (_slider, _("Alpha (opacity)")); - gtk_widget_show (_slider); + // Slider + _impl->_slider = sp_color_slider_new(_impl->_adj); + gtk_widget_set_tooltip_text(_impl->_slider, _("Alpha (opacity)")); + gtk_widget_show(_impl->_slider); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_slider, XPAD); - gtk_widget_set_margin_right(_slider, XPAD); - gtk_widget_set_margin_top(_slider, YPAD); - gtk_widget_set_margin_bottom(_slider, YPAD); - gtk_widget_set_hexpand(_slider, TRUE); - gtk_grid_attach(GTK_GRID(t), _slider, 1, row, 1, 1); -#else - gtk_table_attach (GTK_TABLE (t), _slider, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), GTK_FILL, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_slider, 1, row, 1, 1, true); - sp_color_slider_set_colors( SP_COLOR_SLIDER( _slider ), + sp_color_slider_set_colors( SP_COLOR_SLIDER( _impl->_slider ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.0 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 0.5 ), SP_RGBA32_F_COMPOSE( 1.0, 1.0, 1.0, 1.0 ) ); - /* Spinbutton */ - _sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (_adj), 1.0, 0); - gtk_widget_set_tooltip_text (_sbtn, _("Alpha (opacity)")); - sp_dialog_defocus_on_enter (_sbtn); - gtk_label_set_mnemonic_widget (GTK_LABEL(_label), _sbtn); - gtk_widget_show (_sbtn); + // Spinbutton + _impl->_sbtn = gtk_spin_button_new(GTK_ADJUSTMENT(_impl->_adj), 1.0, 0); + gtk_widget_set_tooltip_text(_impl->_sbtn, _("Alpha (opacity)")); + sp_dialog_defocus_on_enter(_impl->_sbtn); + gtk_label_set_mnemonic_widget(GTK_LABEL(_impl->_label), _impl->_sbtn); + gtk_widget_show(_impl->_sbtn); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_margin_left(_sbtn, XPAD); - gtk_widget_set_margin_right(_sbtn, XPAD); - gtk_widget_set_margin_top(_sbtn, YPAD); - gtk_widget_set_margin_bottom(_sbtn, YPAD); - gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER); - gtk_widget_set_valign(_sbtn, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(t), _sbtn, 2, row, 1, 1); -#else - gtk_table_attach (GTK_TABLE (t), _sbtn, 2, 3, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); -#endif + attachToGridOrTable(t, _impl->_sbtn, 2, row, 1, 1, false, true); - /* Signals */ - g_signal_connect (G_OBJECT (_adj), "value_changed", - G_CALLBACK (_adjustmentChanged), _csel); + // Signals + g_signal_connect(G_OBJECT(_impl->_adj), "value_changed", G_CALLBACK(ColorICCSelectorImpl::_adjustmentChanged), _csel); - g_signal_connect (G_OBJECT (_slider), "grabbed", - G_CALLBACK (_sliderGrabbed), _csel); - g_signal_connect (G_OBJECT (_slider), "released", - G_CALLBACK (_sliderReleased), _csel); - g_signal_connect (G_OBJECT (_slider), "changed", - G_CALLBACK (_sliderChanged), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "grabbed", G_CALLBACK(ColorICCSelectorImpl::_sliderGrabbed), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "released", G_CALLBACK(ColorICCSelectorImpl::_sliderReleased), _csel); + g_signal_connect(G_OBJECT(_impl->_slider), "changed", G_CALLBACK(ColorICCSelectorImpl::_sliderChanged), _csel); } static void sp_color_icc_selector_dispose(GObject *object) { - if ((G_OBJECT_CLASS(parent_class))->dispose) + if ((G_OBJECT_CLASS(parent_class))->dispose) { (* (G_OBJECT_CLASS(parent_class))->dispose)(object); + } } static void @@ -534,24 +626,24 @@ sp_color_icc_selector_new (void) } -void ColorICCSelector::_fixupHit( GtkWidget* /*src*/, gpointer data ) +void ColorICCSelectorImpl::_fixupHit( GtkWidget* /*src*/, gpointer data ) { - ColorICCSelector* self = reinterpret_cast<ColorICCSelector*>(data); + ColorICCSelectorImpl* self = reinterpret_cast<ColorICCSelectorImpl*>(data); gtk_widget_set_sensitive( self->_fixupBtn, FALSE ); - self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_csel) ); + self->_adjustmentChanged( self->_compUI[0]._adj, SP_COLOR_ICC_SELECTOR(self->_owner->_csel) ); } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data ) +void ColorICCSelectorImpl::_profileSelected( GtkWidget* /*src*/, gpointer data ) { - ColorICCSelector* self = reinterpret_cast<ColorICCSelector*>(data); + ColorICCSelectorImpl* self = reinterpret_cast<ColorICCSelectorImpl*>(data); GtkTreeIter iter; - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(self->_profileSel), &iter)) { - GtkTreeModel *store = gtk_combo_box_get_model (GTK_COMBO_BOX(self->_profileSel)); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(self->_profileSel), &iter)) { + GtkTreeModel *store = gtk_combo_box_get_model(GTK_COMBO_BOX(self->_profileSel)); gchar* name = 0; - gtk_tree_model_get (store, &iter, 1, &name, -1); + gtk_tree_model_get(store, &iter, 1, &name, -1); self->_switchToProfile( name ); gtk_widget_set_tooltip_text(self->_profileSel, name ); @@ -559,15 +651,14 @@ void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data ) g_free( name ); } } - } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_switchToProfile( gchar const* name ) +void ColorICCSelectorImpl::_switchToProfile( gchar const* name ) { bool dirty = false; - SPColor tmp( _color ); + SPColor tmp( _owner->_color ); if ( name ) { if ( tmp.icc && tmp.icc->colorProfile == name ) { @@ -588,7 +679,7 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) if ( newProf ) { cmsHTRANSFORM trans = newProf->getTransfFromSRGB8(); if ( trans ) { - guint32 val = _color.toRGBA32(0); + guint32 val = _owner->_color.toRGBA32(0); guchar pre[4] = { static_cast<guchar>(SP_RGBA32_R_U(val)), static_cast<guchar>(SP_RGBA32_G_U(val)), @@ -608,15 +699,12 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) guint count = cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); #endif - gchar const** names = 0; - gchar const** tips = 0; - guint const* scales = 0; - getThings( asICColorSpaceSig(newProf->getColorSpace()), names, tips, scales ); + std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(newProf->getColorSpace())); for ( guint i = 0; i < count; i++ ) { - gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)scales[i]; + gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)((i < things.size()) ? things[i].scale : 1); #ifdef DEBUG_LCMS - g_message(" scaled %d by %d to be %f", i, scales[i], val); + g_message(" scaled %d by %d to be %f", i, ((i < things.size()) ? things[i].scale : 1), val); #endif // DEBUG_LCMS tmp.icc->colors.push_back(val); } @@ -654,8 +742,8 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) g_message("+ new color is [%s]", tmp.toString().c_str()); #endif // DEBUG_LCMS _setProfile( tmp.icc ); - //_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) ); - setColorAlpha( tmp, _alpha, true ); + //_adjustmentChanged( _compUI[0]._adj, SP_COLOR_ICC_SELECTOR(_csel) ); + _owner->setColorAlpha( tmp, _owner->_alpha, true ); #ifdef DEBUG_LCMS g_message("+_________________"); #endif // DEBUG_LCMS @@ -664,7 +752,7 @@ void ColorICCSelector::_switchToProfile( gchar const* name ) #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_profilesChanged( std::string const & name ) +void ColorICCSelectorImpl::_profilesChanged( std::string const & name ) { GtkComboBox* combo = GTK_COMBO_BOX(_profileSel); @@ -675,7 +763,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) GtkTreeIter iter; gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, _("<none>"), 1, _("<none>"), -1); + gtk_list_store_set(store, &iter, 0, _("<none>"), 1, _("<none>"), -1); gtk_combo_box_set_active( combo, 0 ); @@ -686,7 +774,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); + gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); if ( name == prof->name ) { gtk_combo_box_set_active( combo, index ); @@ -700,16 +788,16 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) g_signal_handler_unblock( G_OBJECT(_profileSel), _profChangedID ); } #else -void ColorICCSelector::_profilesChanged( std::string const & /*name*/ ) +void ColorICCSelectorImpl::_profilesChanged( std::string const & /*name*/ ) { } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -/* Helpers for setting color value */ +// Helpers for setting color value void ColorICCSelector::_colorChanged() { - _updating = TRUE; + _impl->_updating = TRUE; //sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color ); #ifdef DEBUG_LCMS @@ -722,36 +810,36 @@ void ColorICCSelector::_colorChanged() g_message("FLIPPIES!!!! %p '%s'", _color.icc, (_color.icc ? _color.icc->colorProfile.c_str():"<null>")); #endif // DEBUG_LCMS - _profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); - ColorScales::setScaled( _adj, _alpha ); + _impl->_profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); + ColorScales::setScaled( _impl->_adj, _alpha ); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _setProfile( _color.icc ); - _fixupNeeded = 0; - gtk_widget_set_sensitive( _fixupBtn, FALSE ); + _impl->_setProfile( _color.icc ); + _impl->_fixupNeeded = 0; + gtk_widget_set_sensitive( _impl->_fixupBtn, FALSE ); - if (_prof) { - if (_prof->getTransfToSRGB8() ) { + if (_impl->_prof) { + if (_impl->_prof->getTransfToSRGB8() ) { cmsUInt16Number tmp[4]; - for ( guint i = 0; i < _profChannelCount; i++ ) { + for ( guint i = 0; i < _impl->_profChannelCount; i++ ) { gdouble val = 0.0; if ( _color.icc->colors.size() > i ) { - if ( _fooScales[i] == 256 ) { - val = (_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_fooScales[i]); + if ( _impl->_compUI[i]._component.scale == 256 ) { + val = (_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_impl->_compUI[i]._component.scale); } else { - val = _color.icc->colors[i] / static_cast<gdouble>(_fooScales[i]); + val = _color.icc->colors[i] / static_cast<gdouble>(_impl->_compUI[i]._component.scale); } } tmp[i] = val * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); + cmsHTRANSFORM trans = _impl->_prof->getTransfToSRGB8(); if ( trans ) { cmsDoTransform( trans, tmp, post, 1 ); guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); if ( other != _color.toRGBA32(255) ) { - _fixupNeeded = other; - gtk_widget_set_sensitive( _fixupBtn, TRUE ); + _impl->_fixupNeeded = other; + gtk_widget_set_sensitive( _impl->_fixupBtn, TRUE ); #ifdef DEBUG_LCMS g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 ); #endif // DEBUG_LCMS @@ -762,17 +850,17 @@ void ColorICCSelector::_colorChanged() #else //(void)color; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - _updateSliders( -1 ); + _impl->_updateSliders( -1 ); - _updating = FALSE; + _impl->_updating = FALSE; #ifdef DEBUG_LCMS g_message( "\\_________ %p::_colorChanged()", this ); #endif // DEBUG_LCMS } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_setProfile( SVGICCColor* profile ) +void ColorICCSelectorImpl::_setProfile( SVGICCColor* profile ) { #ifdef DEBUG_LCMS g_message( "/^^^^^^^^^ %p::_setProfile(%s)", this, @@ -790,10 +878,10 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) profChanged = true; } - for ( guint i = 0; i < _fooCount; i++ ) { - gtk_widget_hide( _fooLabel[i] ); - gtk_widget_hide( _fooSlider[i] ); - gtk_widget_hide( _fooBtn[i] ); + for ( size_t i = 0; i < _compUI.size(); i++ ) { + gtk_widget_hide( _compUI[i]._label ); + gtk_widget_hide( _compUI[i]._slider ); + gtk_widget_hide( _compUI[i]._btn ); } if ( profile ) { @@ -805,39 +893,41 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) _profChannelCount = cmsChannelsOf( asICColorSpaceSig(_prof->getColorSpace()) ); #endif - gchar const** names = 0; - gchar const** tips = 0; - getThings( asICColorSpaceSig(_prof->getColorSpace()), names, tips, _fooScales ); - if ( profChanged ) { + std::vector<colorspace::Component> things = colorspace::getColorSpaceInfo(asICColorSpaceSig(_prof->getColorSpace())); + for (size_t i = 0; (i < things.size()) && (i < _profChannelCount); ++i) + { + _compUI[i]._component = things[i]; + } + for ( guint i = 0; i < _profChannelCount; i++ ) { - gtk_label_set_text_with_mnemonic( GTK_LABEL(_fooLabel[i]), names[i]); + gtk_label_set_text_with_mnemonic( GTK_LABEL(_compUI[i]._label), (i < things.size()) ? things[i].name.c_str() : ""); - gtk_widget_set_tooltip_text( _fooSlider[i], tips[i] ); - gtk_widget_set_tooltip_text( _fooBtn[i], tips[i] ); + gtk_widget_set_tooltip_text( _compUI[i]._slider, (i < things.size()) ? things[i].tip.c_str() : "" ); + gtk_widget_set_tooltip_text( _compUI[i]._btn, (i < things.size()) ? things[i].tip.c_str() : "" ); - sp_color_slider_set_colors( SP_COLOR_SLIDER(_fooSlider[i]), + sp_color_slider_set_colors( SP_COLOR_SLIDER(_compUI[i]._slider), SPColor(0.0, 0.0, 0.0).toRGBA32(0xff), SPColor(0.5, 0.5, 0.5).toRGBA32(0xff), SPColor(1.0, 1.0, 1.0).toRGBA32(0xff) ); /* - _fooAdj[i] = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); - g_signal_connect( G_OBJECT( _fooAdj[i] ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); + _compUI[i]._adj = GTK_ADJUSTMENT( gtk_adjustment_new( val, 0.0, _fooScales[i], step, page, page ) ); + g_signal_connect( G_OBJECT( _compUI[i]._adj ), "value_changed", G_CALLBACK( _adjustmentChanged ), _csel ); - sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_fooSlider[i]), _fooAdj[i] ); - gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_fooBtn[i]), _fooAdj[i] ); - gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_fooBtn[i]), digits ); + sp_color_slider_set_adjustment( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._adj ); + gtk_spin_button_set_adjustment( GTK_SPIN_BUTTON(_compUI[i]._btn), _compUI[i]._adj ); + gtk_spin_button_set_digits( GTK_SPIN_BUTTON(_compUI[i]._btn), digits ); */ - gtk_widget_show( _fooLabel[i] ); - gtk_widget_show( _fooSlider[i] ); - gtk_widget_show( _fooBtn[i] ); - //gtk_adjustment_set_value( _fooAdj[i], 0.0 ); - //gtk_adjustment_set_value( _fooAdj[i], val ); + gtk_widget_show( _compUI[i]._label ); + gtk_widget_show( _compUI[i]._slider ); + gtk_widget_show( _compUI[i]._btn ); + //gtk_adjustment_set_value( _compUI[i]._adj, 0.0 ); + //gtk_adjustment_set_value( _compUI[i]._adj, val ); } - for ( guint i = _profChannelCount; i < _fooCount; i++ ) { - gtk_widget_hide( _fooLabel[i] ); - gtk_widget_hide( _fooSlider[i] ); - gtk_widget_hide( _fooBtn[i] ); + for ( size_t i = _profChannelCount; i < _compUI.size(); i++ ) { + gtk_widget_hide( _compUI[i]._label ); + gtk_widget_hide( _compUI[i]._slider ); + gtk_widget_hide( _compUI[i]._btn ); } } } else { @@ -852,31 +942,31 @@ void ColorICCSelector::_setProfile( SVGICCColor* profile ) } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -void ColorICCSelector::_updateSliders( gint ignore ) +void ColorICCSelectorImpl::_updateSliders( gint ignore ) { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - if ( _color.icc ) + if ( _owner->_color.icc ) { for ( guint i = 0; i < _profChannelCount; i++ ) { gdouble val = 0.0; - if ( _color.icc->colors.size() > i ) { - if ( _fooScales[i] == 256 ) { - val = (_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_fooScales[i]); + if ( _owner->_color.icc->colors.size() > i ) { + if ( _compUI[i]._component.scale == 256 ) { + val = (_owner->_color.icc->colors[i] + 128.0) / static_cast<gdouble>(_compUI[i]._component.scale); } else { - val = _color.icc->colors[i] / static_cast<gdouble>(_fooScales[i]); + val = _owner->_color.icc->colors[i] / static_cast<gdouble>(_compUI[i]._component.scale); } } - gtk_adjustment_set_value( _fooAdj[i], val ); + gtk_adjustment_set_value( _compUI[i]._adj, val ); } - if ( _prof) { - if (_prof->getTransfToSRGB8() ) { + if ( _prof ) { + if ( _prof->getTransfToSRGB8() ) { for ( guint i = 0; i < _profChannelCount; i++ ) { if ( static_cast<gint>(i) != ignore ) { cmsUInt16Number* scratch = getScratch(); cmsUInt16Number filler[4] = {0, 0, 0, 0}; for ( guint j = 0; j < _profChannelCount; j++ ) { - filler[j] = 0x0ffff * ColorScales::getScaled( _fooAdj[j] ); + filler[j] = 0x0ffff * ColorScales::getScaled( _compUI[j]._adj ); } cmsUInt16Number* p = scratch; @@ -892,8 +982,8 @@ void ColorICCSelector::_updateSliders( gint ignore ) cmsHTRANSFORM trans = _prof->getTransfToSRGB8(); if ( trans ) { - cmsDoTransform( trans, scratch, _fooMap[i], 1024 ); - sp_color_slider_set_map( SP_COLOR_SLIDER(_fooSlider[i]), _fooMap[i] ); + cmsDoTransform( trans, scratch, _compUI[i]._map, 1024 ); + sp_color_slider_set_map( SP_COLOR_SLIDER(_compUI[i]._slider), _compUI[i]._map ); } } } @@ -904,16 +994,15 @@ void ColorICCSelector::_updateSliders( gint ignore ) (void)ignore; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - guint32 start = _color.toRGBA32( 0x00 ); - guint32 mid = _color.toRGBA32( 0x7f ); - guint32 end = _color.toRGBA32( 0xff ); + guint32 start = _owner->_color.toRGBA32( 0x00 ); + guint32 mid = _owner->_color.toRGBA32( 0x7f ); + guint32 end = _owner->_color.toRGBA32( 0xff ); sp_color_slider_set_colors( SP_COLOR_SLIDER(_slider), start, mid, end ); - } -void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICCSelector *cs ) +void ColorICCSelectorImpl::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICCSelector *cs ) { // // TODO check this. It looks questionable: // // if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100 @@ -926,24 +1015,24 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC #endif // DEBUG_LCMS ColorICCSelector* iccSelector = static_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); - if (iccSelector->_updating) { + if (iccSelector->_impl->_updating) { return; } - iccSelector->_updating = TRUE; + iccSelector->_impl->_updating = TRUE; gint match = -1; SPColor newColor( iccSelector->_color ); - gfloat scaled = ColorScales::getScaled( iccSelector->_adj ); - if ( iccSelector->_adj == adjustment ) { + gfloat scaled = ColorScales::getScaled( iccSelector->_impl->_adj ); + if ( iccSelector->_impl->_adj == adjustment ) { #ifdef DEBUG_LCMS g_message("ALPHA"); #endif // DEBUG_LCMS } else { #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - for ( guint i = 0; i < iccSelector->_fooCount; i++ ) { - if ( iccSelector->_fooAdj[i] == adjustment ) { + for ( size_t i = 0; i < iccSelector->_impl->_compUI.size(); i++ ) { + if ( iccSelector->_impl->_compUI[i]._adj == adjustment ) { match = i; break; } @@ -957,11 +1046,11 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC cmsUInt16Number tmp[4]; for ( guint i = 0; i < 4; i++ ) { - tmp[i] = ColorScales::getScaled( iccSelector->_fooAdj[i] ) * 0x0ffff; + tmp[i] = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ) * 0x0ffff; } guchar post[4] = {0,0,0,0}; - cmsHTRANSFORM trans = iccSelector->_prof->getTransfToSRGB8(); + cmsHTRANSFORM trans = iccSelector->_impl->_prof->getTransfToSRGB8(); if ( trans ) { cmsDoTransform( trans, tmp, post, 1 ); } @@ -982,39 +1071,37 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC #endif // DEBUG_LCMS newColor = other; newColor.icc->colors.clear(); - for ( guint i = 0; i < iccSelector->_profChannelCount; i++ ) { - gdouble val = ColorScales::getScaled( iccSelector->_fooAdj[i] ); - if ( iccSelector->_fooScales ) { - val *= iccSelector->_fooScales[i]; - if ( iccSelector->_fooScales[i] == 256 ) { - val -= 128; - } + for ( guint i = 0; i < iccSelector->_impl->_profChannelCount; i++ ) { + gdouble val = ColorScales::getScaled( iccSelector->_impl->_compUI[i]._adj ); + val *= iccSelector->_impl->_compUI[i]._component.scale; + if ( iccSelector->_impl->_compUI[i]._component.scale == 256 ) { + val -= 128; } newColor.icc->colors.push_back( val ); } } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) } - iccSelector->_updateInternals( newColor, scaled, iccSelector->_dragging ); - iccSelector->_updateSliders( match ); + iccSelector->_updateInternals( newColor, scaled, iccSelector->_impl->_dragging ); + iccSelector->_impl->_updateSliders( match ); - iccSelector->_updating = FALSE; + iccSelector->_impl->_updating = FALSE; #ifdef DEBUG_LCMS g_message( "\\_________ %p::_adjustmentChanged()", cs ); #endif // DEBUG_LCMS } -void ColorICCSelector::_sliderGrabbed( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderGrabbed( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) { // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); // if (!iccSelector->_dragging) { // iccSelector->_dragging = TRUE; // iccSelector->_grabbed(); -// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_adj ), iccSelector->_dragging ); +// iccSelector->_updateInternals( iccSelector->_color, ColorScales::getScaled( iccSelector->_impl->_adj ), iccSelector->_dragging ); // } } -void ColorICCSelector::_sliderReleased( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderReleased( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) { // ColorICCSelector* iccSelector = dynamic_cast<ColorICCSelector*>(SP_COLOR_SELECTOR(cs)->base); // if (iccSelector->_dragging) { @@ -1025,9 +1112,9 @@ void ColorICCSelector::_sliderReleased( SPColorSlider */*slider*/, SPColorICCSel } #ifdef DEBUG_LCMS -void ColorICCSelector::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ) +void ColorICCSelectorImpl::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ) #else -void ColorICCSelector::_sliderChanged( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ ) +void ColorICCSelectorImpl::_sliderChanged( SPColorSlider * /*slider*/, SPColorICCSelector * /*cs*/ ) #endif // DEBUG_LCMS { #ifdef DEBUG_LCMS diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index 67fedf590..404bc7265 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -5,7 +5,6 @@ #include <gtk/gtk.h> #include "../color.h" -#include "sp-color-slider.h" #include "sp-color-selector.h" namespace Inkscape { @@ -15,6 +14,7 @@ struct ColorProfile; struct SPColorICCSelector; struct SPColorICCSelectorClass; +class ColorICCSelectorImpl; class ColorICCSelector: public ColorSelector { @@ -27,63 +27,25 @@ public: protected: virtual void _colorChanged(); - static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); - - static void _sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs ); - static void _sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs ); - static void _sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs ); - - static void _fixupHit( GtkWidget* src, gpointer data ); - static void _profileSelected( GtkWidget* src, gpointer data ); - void _recalcColor( gboolean changing ); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - void _setProfile( SVGICCColor* profile ); - void _switchToProfile( gchar const* name ); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - void _updateSliders( gint ignore ); - void _profilesChanged( std::string const & name ); - - gboolean _updating : 1; - gboolean _dragging : 1; - - guint32 _fixupNeeded; - GtkWidget* _fixupBtn; - GtkWidget* _profileSel; - - guint _fooCount; - guint const* _fooScales; - GtkAdjustment** _fooAdj; - GtkWidget** _fooSlider; - GtkWidget** _fooBtn; - GtkWidget** _fooLabel; - guchar** _fooMap; - - GtkAdjustment* _adj; /* Channel adjustment */ - GtkWidget* _slider; - GtkWidget* _sbtn; /* Spinbutton */ - GtkWidget* _label; /* Label */ - -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - std::string _profileName; - Inkscape::ColorProfile* _prof; - guint _profChannelCount; - gulong _profChangedID; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) private: + friend class ColorICCSelectorImpl; + // By default, disallow copy constructor and assignment operator ColorICCSelector( const ColorICCSelector& obj ); ColorICCSelector& operator=( const ColorICCSelector& obj ); + + ColorICCSelectorImpl *_impl; }; -#define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type ()) -#define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) -#define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) -#define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_ICC_SELECTOR)) -#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_TYPE_COLOR_ICC_SELECTOR (sp_color_icc_selector_get_type()) +#define SP_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelector)) +#define SP_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_COLOR_ICC_SELECTOR, SPColorICCSelectorClass)) +#define SP_IS_COLOR_ICC_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COLOR_ICC_SELECTOR)) +#define SP_IS_COLOR_ICC_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COLOR_ICC_SELECTOR)) struct SPColorICCSelector { SPColorSelector parent; @@ -93,9 +55,9 @@ struct SPColorICCSelectorClass { SPColorSelectorClass parent_class; }; -GType sp_color_icc_selector_get_type (void); +GType sp_color_icc_selector_get_type(void); -GtkWidget *sp_color_icc_selector_new (void); +GtkWidget *sp_color_icc_selector_new(void); diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 588221a7c..c709e9775 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -129,7 +129,7 @@ void ColorNotebook::switchPage(GtkNotebook*, csel->base->getColorAlpha(_color, _alpha); } widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), page_num); - if ( widget && SP_IS_COLOR_SELECTOR (widget) ) + if ( widget && SP_IS_COLOR_SELECTOR(widget) ) { csel = SP_COLOR_SELECTOR (widget); csel->base->setColorAlpha( _color, _alpha ); @@ -165,9 +165,7 @@ gint ColorNotebook::menuHandler( GdkEvent* event ) static void sp_color_notebook_menuitem_response (GtkMenuItem *menuitem, gpointer user_data) { - gboolean active = FALSE; - - active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); + gboolean active = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (menuitem)); SPColorNotebookTracker *entry = reinterpret_cast< SPColorNotebookTracker* > (user_data); if ( entry ) { @@ -234,7 +232,7 @@ void ColorNotebook::init() { guint howmany = 1; gpointer klass = g_type_class_ref (selector_types[i]); - if ( klass && SP_IS_COLOR_SELECTOR_CLASS (klass) ) + if ( klass && SP_IS_COLOR_SELECTOR_CLASS(klass) ) { SPColorSelectorClass *ck = SP_COLOR_SELECTOR_CLASS (klass); howmany = MAX (1, ck->submode_count); @@ -653,8 +651,11 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) void ColorNotebook::_setCurrentPage(int i) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), i); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); + gtk_notebook_set_current_page(GTK_NOTEBOOK(_book), i); + + if (_buttons && _trackerList && (static_cast<size_t>(i) < _trackerList->len) ) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_buttons[i]), TRUE); + } } void ColorNotebook::_buttonClicked(GtkWidget *widget, SPColorNotebook *colorbook) diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 471ee3852..9b13ba1c5 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -729,7 +729,7 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, { static guchar *buf = NULL; static gint bs = 0; - guchar *dp, *sp; + guchar *dp; gint x, y; if (buf && (bs < width * height)) { @@ -744,13 +744,12 @@ sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, dp = buf; for (x = x0; x < x0 + width; x++) { gint cr, cg, cb, ca; - guchar *d; - sp = map + 4 * (start >> 16); + guchar *d = dp; + guchar *sp = map + 4 * (start >> 16); cr = *sp++; cg = *sp++; cb = *sp++; ca = *sp++; - d = dp; for (y = y0; y < y0 + height; y++) { guint bg, fc; /* Background value */ diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index ce8ce388d..87ca80f2f 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -17,6 +17,10 @@ #include <cstring> #include <string> +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/label.h> @@ -333,7 +337,6 @@ gpointer sp_search_by_data_recursive(GtkWidget *w, gpointer key) GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) { gchar *r = NULL; - GtkWidget *child; if (w && G_IS_OBJECT(w)) { r = (gchar *) g_object_get_data(G_OBJECT(w), key); @@ -343,7 +346,7 @@ GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); + GtkWidget *child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); if (child) return child; } } diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 62fa47603..2d1c932d3 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -38,6 +38,7 @@ #include "helper/stock-items.h" #include "gradient-vector.h" +#include <gtkmm/icontheme.h> #include <gtkmm/adjustment.h> #include "ui/widget/spinbutton.h" #include "stroke-style.h" @@ -56,14 +57,11 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : marker_store = Gtk::ListStore::create(marker_columns); set_model(marker_store); pack_start(image_renderer, false); - pack_end(label_renderer, true); - label_renderer.set_padding(2, 0); - image_renderer.set_padding(2, 0); - set_cell_data_func(label_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareLabelRenderer)); set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL); - empty_image = new Gtk::Image(); + empty_image = new Gtk::Image( Glib::wrap( + sp_pixbuf_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("no-marker") ) ) ); sandbox = ink_markers_preview_doc (); desktop = inkscape_active_desktop(); @@ -559,12 +557,6 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname, return pb; } -void MarkerComboBox::prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ) { - Glib::ustring name=(*row)[marker_columns.label]; - label_renderer.property_markup() = name.c_str(); - label_renderer.property_scale() = 0.8; -} - void MarkerComboBox::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) { Gtk::Image *image = (*row)[marker_columns.image]; diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index 02038ea42..27ac76d6f 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -10,6 +10,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/combobox.h> #include <gtkmm/liststore.h> @@ -60,7 +68,6 @@ private: SPDocument *doc; SPDocument *sandbox; Gtk::Image *empty_image; - Gtk::CellRendererText label_renderer; Gtk::CellRendererPixbuf image_renderer; class MarkerColumns : public Gtk::TreeModel::ColumnRecord { @@ -91,7 +98,6 @@ private: /* * Callbacks for drawing the combo box */ - void prepareLabelRenderer( Gtk::TreeModel::const_iterator const &row ); void prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ); static gboolean separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index c6934f0a6..0a5b3781b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -342,62 +342,37 @@ StrokeStyle::StrokeStyle() : // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path. + spw_label(table, _("Markers:"), 0, i, NULL); + + hb = spw_hbox(table, 1, 1, i); + i++; + startMarkerCombo = manage(new MarkerComboBox("marker-start", SP_MARKER_LOC_START)); - spw_label(table, _("_Start Markers:"), 0, i, startMarkerCombo); startMarkerCombo->set_tooltip_text(_("Start Markers are drawn on the first node of a path or shape")); startMarkerConn = startMarkerCombo->signal_changed().connect( sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), startMarkerCombo, this, SP_MARKER_LOC_START)); startMarkerCombo->show(); -#if WITH_GTKMM_3_0 - startMarkerCombo->set_hexpand(); - startMarkerCombo->set_halign(Gtk::ALIGN_FILL); - startMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*startMarkerCombo, 1, i, 3, 1); -#else - table->attach(*startMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + hb->pack_start(*startMarkerCombo, true, true, 0); midMarkerCombo = manage(new MarkerComboBox("marker-mid", SP_MARKER_LOC_MID)); - spw_label(table, _("_Mid Markers:"), 0, i, midMarkerCombo); midMarkerCombo->set_tooltip_text(_("Mid Markers are drawn on every node of a path or shape except the first and last nodes")); midMarkerConn = midMarkerCombo->signal_changed().connect( sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), midMarkerCombo, this, SP_MARKER_LOC_MID)); midMarkerCombo->show(); -#if WITH_GTKMM_3_0 - midMarkerCombo->set_hexpand(); - midMarkerCombo->set_halign(Gtk::ALIGN_FILL); - midMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*midMarkerCombo, 1, i, 3, 1); -#else - table->attach(*midMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + hb->pack_start(*midMarkerCombo, true, true, 0); endMarkerCombo = manage(new MarkerComboBox("marker-end", SP_MARKER_LOC_END)); - spw_label(table, _("_End Markers:"), 0, i, endMarkerCombo); endMarkerCombo->set_tooltip_text(_("End Markers are drawn on the last node of a path or shape")); endMarkerConn = endMarkerCombo->signal_changed().connect( sigc::bind<MarkerComboBox *, StrokeStyle *, SPMarkerLoc>( sigc::ptr_fun(&StrokeStyle::markerSelectCB), endMarkerCombo, this, SP_MARKER_LOC_END)); endMarkerCombo->show(); -#if WITH_GTKMM_3_0 - endMarkerCombo->set_hexpand(); - endMarkerCombo->set_halign(Gtk::ALIGN_FILL); - endMarkerCombo->set_valign(Gtk::ALIGN_CENTER); - table->attach(*endMarkerCombo, 1, i, 3, 1); -#else - table->attach(*endMarkerCombo, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0); -#endif - - i++; + hb->pack_start(*endMarkerCombo, true, true, 0); setDesktop(desktop); updateLine(); diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 4b7aa483f..c8c9983a6 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,6 +1,14 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> class SPDocument; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 17ff4834f..0b47b1e15 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -29,6 +29,10 @@ # include "config.h" #endif +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/action.h> #include <gtkmm/actiongroup.h> @@ -43,6 +47,8 @@ #include "../ege-output-action.h" #include "../ege-select-one-action.h" #include "../graphlayout.h" +#include "../helper/action.h" +#include "../helper/action-context.h" #include "../helper/unit-menu.h" #include "../helper/units.h" #include "../helper/unit-tracker.h" @@ -589,9 +595,9 @@ private: Glib::RefPtr<VerbAction> VerbAction::create(Inkscape::Verb* verb, Inkscape::Verb* verb2, Inkscape::UI::View::View *view) { Glib::RefPtr<VerbAction> result; - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if ( action ) { - //SPAction* action2 = verb2 ? verb2->get_action(view) : 0; + //SPAction* action2 = verb2 ? verb2->get_action(Inkscape::ActionContext(view)) : 0; result = Glib::RefPtr<VerbAction>(new VerbAction(verb, verb2, view)); } @@ -678,7 +684,7 @@ void VerbAction::set_active(bool active) void VerbAction::on_activate() { if ( verb ) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if ( action ) { sp_action_perform(action, 0); } @@ -768,14 +774,14 @@ GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick(GtkWidget *t Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb, Inkscape::UI::View::View *view) { - SPAction *action = verb->get_action(view); + SPAction *action = verb->get_action(Inkscape::ActionContext(view)); if (!action) { return NULL; } SPAction *doubleclick_action; if (doubleclick_verb) { - doubleclick_action = doubleclick_verb->get_action(view); + doubleclick_action = doubleclick_verb->get_action(Inkscape::ActionContext(view)); } else { doubleclick_action = NULL; } @@ -820,7 +826,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi { GtkAction* act = 0; - SPAction* targetAction = verb->get_action(view); + SPAction* targetAction = verb->get_action(Inkscape::ActionContext(view)); InkAction* inky = ink_action_new( verb->get_id(), _(verb->get_name()), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); gtk_action_set_sensitive( act, targetAction->sensitive ); diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h index 8db036734..87c7ca2e0 100644 --- a/src/widgets/widget-sizes.h +++ b/src/widgets/widget-sizes.h @@ -27,7 +27,7 @@ #define STATUS_BAR_FONT_SIZE 10000 -#define STATUS_ZOOM_WIDTH 100 +#define STATUS_ZOOM_WIDTH 57 #define SELECTED_STYLE_SB_WIDTH 48 #define SELECTED_STYLE_WIDTH 190 diff --git a/src/winconsole.cpp b/src/winconsole.cpp index 1515d2062..085fb441c 100644 --- a/src/winconsole.cpp +++ b/src/winconsole.cpp @@ -5,13 +5,13 @@ * Windows has two types of executables: GUI and console. * The GUI executables detach immediately when run from the command * prompt (cmd.exe), and whatever you write to standard output - * disappears into a black hole. Console executables handle + * disappears into a black hole. Console executables * do display standard output and take standard input from the console, * but when you run them from the GUI, an extra console window appears. - * It's possible to hide it, but it still flashes from a fraction + * It's possible to hide it, but it still flashes for a fraction * of a second. * - * To provide an Unix-like experienve, where the application will behave + * To provide an Unix-like experience, where the application will behave * correctly in command line mode and at the same time won't create * the ugly console window when run from the GUI, we have to have two * executables. The first one, inkscape.exe, is the GUI application. @@ -31,7 +31,7 @@ *//* * Authors: * Jos Hirth <jh@kaioa.com> - * Krzysztof Kosiński <tweenk.pl@gmail.com> + * Krzysztof Kosinski <tweenk.pl@gmail.com> * * Copyright (C) 2008-2010 Authors * diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index b86fee0ee..99577648f 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -201,7 +201,7 @@ gint SPZoomContext::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_Down: // prevent the zoom field from activation - if (!MOD__CTRL_ONLY) + if (!MOD__CTRL_ONLY(event)) ret = TRUE; break; @@ -214,7 +214,7 @@ gint SPZoomContext::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: |
