diff options
| author | Andrew Higginson <at.higginson@gmail.com> | 2011-12-27 21:04:47 +0000 |
|---|---|---|
| committer | Andrew <at.higginson@gmail.com> | 2011-12-27 21:04:47 +0000 |
| commit | 80960b623a99aae1402ab651b2974ef544ed3b03 (patch) | |
| tree | ba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/ui | |
| parent | try to fix bug (diff) | |
| parent | GDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff) | |
| download | inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip | |
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/ui')
177 files changed, 3597 insertions, 4310 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 01dadb7c2..e697fba99 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -1,24 +1,243 @@ -SET(uifolders -cache -dialog -view -widget -) -FOREACH(uilistsrc ${uifolders}) - ADD_SUBDIRECTORY(${uilistsrc}) -ENDFOREACH(uilistsrc) - -SET(ui_SRC -clipboard.cpp -context-menu.cpp -previewholder.cpp -stock.cpp -stock-items.cpp -${ui_cache_SRC} -${ui_dialog_SRC} -${ui_view_SRC} -${ui_widget_SRC} + +set(ui_SRC + clipboard.cpp + context-menu.cpp + previewholder.cpp + uxmanager.cpp + + cache/svg_preview_cache.cpp + + tool/control-point-selection.cpp + tool/control-point.cpp + tool/curve-drag-point.cpp + tool/event-utils.cpp + tool/manipulator.cpp + tool/modifier-tracker.cpp + tool/multi-path-manipulator.cpp + tool/node-tool.cpp + tool/node.cpp + tool/path-manipulator.cpp + tool/selectable-control-point.cpp + tool/selector.cpp + tool/transform-handle-set.cpp + + dialog/aboutbox.cpp + dialog/align-and-distribute.cpp + dialog/calligraphic-profile-rename.cpp + dialog/color-item.cpp + dialog/debug.cpp + dialog/desktop-tracker.cpp + dialog/dialog-manager.cpp + dialog/dialog.cpp + dialog/dock-behavior.cpp + dialog/document-metadata.cpp + dialog/document-properties.cpp + dialog/extension-editor.cpp + dialog/extensions.cpp + dialog/filedialog.cpp + dialog/filedialogimpl-gtkmm.cpp + dialog/fill-and-stroke.cpp + dialog/filter-effects-dialog.cpp + dialog/find.cpp + dialog/floating-behavior.cpp + dialog/glyphs.cpp + dialog/guides.cpp + dialog/icon-preview.cpp + dialog/inkscape-preferences.cpp + dialog/input.cpp + dialog/layer-properties.cpp + dialog/layers.cpp + dialog/livepatheffect-editor.cpp + dialog/memory.cpp + dialog/messages.cpp + dialog/ocaldialogs.cpp + dialog/print-colors-preview-dialog.cpp + dialog/print.cpp + dialog/scriptdialog.cpp + # dialog/session-player.cpp + dialog/svg-fonts-dialog.cpp + dialog/swatches.cpp + dialog/tile.cpp + dialog/tracedialog.cpp + dialog/transformation.cpp + dialog/undo-history.cpp + # dialog/whiteboard-connect.cpp + # dialog/whiteboard-sharewithchat.cpp + # dialog/whiteboard-sharewithuser.cpp + + widget/button.cpp + widget/color-picker.cpp + widget/color-preview.cpp + widget/combo-text.cpp + widget/dock-item.cpp + widget/dock.cpp + widget/entity-entry.cpp + widget/entry.cpp + widget/filter-effect-chooser.cpp + widget/handlebox.cpp + widget/icon-widget.cpp + widget/imageicon.cpp + widget/imagetoggler.cpp + widget/labelled.cpp + widget/layer-selector.cpp + widget/licensor.cpp + widget/notebook-page.cpp + widget/object-composite-settings.cpp + widget/page-sizer.cpp + widget/panel.cpp + widget/point.cpp + widget/preferences-widget.cpp + widget/random.cpp + widget/registered-widget.cpp + widget/registry.cpp + widget/rendering-options.cpp + widget/rotateable.cpp + widget/ruler.cpp + widget/scalar-unit.cpp + widget/scalar.cpp + widget/selected-style.cpp + widget/spin-slider.cpp + widget/spinbutton.cpp + widget/style-subject.cpp + widget/style-swatch.cpp + widget/svg-canvas.cpp + widget/text.cpp + widget/tolerance-slider.cpp + widget/toolbox.cpp + widget/unit-menu.cpp + widget/zoom-status.cpp + + view/view.cpp + view/view-widget.cpp + + + # ------- + # Headers + clipboard.h + context-menu.h + icon-names.h + previewable.h + previewfillable.h + previewholder.h + uxmanager.h + + cache/svg_preview_cache.h + + dialog/aboutbox.h + dialog/align-and-distribute.h + dialog/behavior.h + dialog/calligraphic-profile-rename.h + dialog/color-item.h + dialog/debug.h + dialog/desktop-tracker.h + dialog/dialog-manager.h + dialog/dialog.h + dialog/dock-behavior.h + dialog/document-metadata.h + dialog/document-properties.h + dialog/extension-editor.h + dialog/extensions.h + dialog/filedialog.h + dialog/filedialogimpl-gtkmm.h + dialog/filedialogimpl-win32.h + dialog/fill-and-stroke.h + dialog/filter-effects-dialog.h + dialog/find.h + dialog/floating-behavior.h + dialog/glyphs.h + dialog/guides.h + dialog/icon-preview.h + dialog/inkscape-preferences.h + dialog/input.h + dialog/layer-properties.h + dialog/layers.h + dialog/livepatheffect-editor.h + dialog/memory.h + dialog/messages.h + dialog/ocaldialogs.h + dialog/panel-dialog.h + dialog/print-colors-preview-dialog.h + dialog/print.h + dialog/scriptdialog.h + dialog/svg-fonts-dialog.h + dialog/swatches.h + dialog/tile.h + dialog/tracedialog.h + dialog/transformation.h + dialog/undo-history.h + + tool/commit-events.h + tool/control-point-selection.h + tool/control-point.h + tool/curve-drag-point.h + tool/event-utils.h + tool/manipulator.h + tool/modifier-tracker.h + tool/multi-path-manipulator.h + tool/node-tool.h + tool/node-types.h + tool/node.h + tool/path-manipulator.h + tool/selectable-control-point.h + tool/selector.h + tool/shape-record.h + tool/transform-handle-set.h + + view/edit-widget-interface.h + view/view-widget.h + view/view.h + + widget/attr-widget.h + widget/button.h + widget/color-picker.h + widget/color-preview.h + widget/combo-enums.h + widget/combo-text.h + widget/dock-item.h + widget/dock.h + widget/entity-entry.h + widget/entry.h + widget/filter-effect-chooser.h + widget/handlebox.h + widget/icon-widget.h + widget/imageicon.h + widget/imagetoggler.h + widget/labelled.h + widget/layer-selector.h + widget/licensor.h + widget/notebook-page.h + widget/object-composite-settings.h + widget/page-sizer.h + widget/panel.h + widget/point.h + widget/preferences-widget.h + widget/random.h + widget/registered-enums.h + widget/registered-widget.h + widget/registry.h + widget/rendering-options.h + widget/rotateable.h + widget/ruler.h + widget/scalar-unit.h + widget/scalar.h + widget/selected-style.h + widget/spin-slider.h + widget/spinbutton.h + widget/style-subject.h + widget/style-swatch.h + widget/svg-canvas.h + widget/text.h + widget/tolerance-slider.h + widget/toolbox.h + widget/unit-menu.h + widget/zoom-status.h ) -ADD_LIBRARY(ui STATIC ${ui_SRC}) -TARGET_LINK_LIBRARIES(ui -2geom ${INKSCAPE_LIBS})
\ No newline at end of file + +if(WIN32) + list(APPEND ui_SRC + dialog/filedialogimpl-win32.cpp + ) +endif() + +# add_inkscape_lib(ui_LIB "${ui_SRC}") +add_inkscape_source("${ui_SRC}") diff --git a/src/ui/cache/CMakeLists.txt b/src/ui/cache/CMakeLists.txt deleted file mode 100644 index a78010196..000000000 --- a/src/ui/cache/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -SET(ui_cache_SRC -svg_preview_cache.cpp -) diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index a7ad1701d..f8a806a13 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -19,78 +19,55 @@ # include "config.h" #endif -#include <glib/gmem.h> +#include <glib.h> #include <gtk/gtk.h> +#include <2geom/transforms.h> #include "sp-namedview.h" #include "selection.h" #include "inkscape.h" #include "sp-rect.h" #include "document-private.h" -#include "display/nr-arena.h" -#include "display/nr-arena-item.h" +#include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/drawing.h" #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) { - NRGC gc(NULL); - +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize) +{ Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); - nr_arena_item_set_transform(root, t); + drawing.root()->setTransform(Geom::Scale(scale_factor)); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, NULL, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); - /* Item integer bbox in points */ - NRRectL ibox; - ibox.x0 = (int) floor(scale_factor * dbox.min()[Geom::X] + 0.5); - ibox.y0 = (int) floor(scale_factor * dbox.min()[Geom::Y] + 0.5); - ibox.x1 = (int) floor(scale_factor * dbox.max()[Geom::X] + 0.5); - ibox.y1 = (int) floor(scale_factor * dbox.max()[Geom::Y] + 0.5); + drawing.update(ibox); /* Find visible area */ - int width = ibox.x1 - ibox.x0; - int height = ibox.y1 - ibox.y0; + int width = ibox.width(); + int height = ibox.height(); int dx = psize; int dy = psize; dx = (dx - width)/2; // watch out for size, since 'unsigned'-'signed' can cause problems if the result is negative dy = (dy - height)/2; - NRRectL area; - area.x0 = ibox.x0 - dx; - area.y0 = ibox.y0 - dy; - area.x1 = area.x0 + psize; - area.y1 = area.y0 + psize; + Geom::IntRect area = Geom::IntRect::from_xywh( + ibox.min() - Geom::IntPoint(dx, dy), Geom::IntPoint(psize, psize)); - /* Actual renderable area */ - NRRectL ua; - ua.x0 = std::max(ibox.x0, area.x0); - ua.y0 = std::max(ibox.y0, area.y0); - ua.x1 = std::min(ibox.x1, area.x1); - ua.y1 = std::min(ibox.y1, area.y1); + /* Render */ + cairo_surface_t *s = cairo_image_surface_create( + CAIRO_FORMAT_ARGB32, psize, psize); + Inkscape::DrawingContext ct(s, area.min()); - /* Set up pixblock */ - guchar *px = g_new(guchar, 4 * psize * psize); - memset(px, 0x00, 4 * psize * psize); + drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + cairo_surface_flush(s); - /* Render */ - NRPixBlock B; - nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N, - ua.x0, ua.y0, ua.x1, ua.y1, - px + 4 * psize * (ua.y0 - area.y0) + - 4 * (ua.x0 - area.x0), - 4 * psize, FALSE, FALSE ); - nr_arena_item_invoke_render(NULL, root, &ua, &B, - NR_ARENA_ITEM_RENDER_NO_CACHE ); - nr_pixblock_release(&B); - - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(px, + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, TRUE, - 8, psize, psize, psize * 4, - (GdkPixbufDestroyNotify)g_free, - NULL); + 8, psize, psize, cairo_image_surface_get_stride(s), + ink_cairo_pixbuf_cleanup, s); + convert_pixbuf_argb32_to_normal(pixbuf); return pixbuf; } @@ -129,7 +106,7 @@ void SvgPreview::set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { _pixmap_cache[key] = px; } -GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaItem */*root*/, +GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem */*root*/, double /*scale_factor*/, unsigned int psize) { // First try looking up the cached preview in the cache map Glib::ustring key = cache_key(uri, id, psize); @@ -144,6 +121,17 @@ GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaIte return px; } -}; -}; -}; +} +} +} + +/* + 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/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 0fac94782..11d26fe22 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -1,17 +1,28 @@ -#ifndef __SVG_PREVIEW_CACHE_H__ -#define __SVG_PREVIEW_CACHE_H__ - -/** \file - * SPIcon: Generic icon widget +/** @file + * @brief Preview cache */ /* * Copyright (C) 2007 Bryce W. Harrington <bryce@bryceharrington.org> - * * Released under GNU GPL, read the file 'COPYING' for more information - * */ -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); +#ifndef SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H +#define SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H + +#include <map> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <glibmm/ustring.h> +#include <2geom/rect.h> + +namespace Inkscape { + +class Drawing; +class DrawingItem; + +} // namespace Inkscape + + +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { @@ -28,7 +39,7 @@ class SvgPreview { Glib::ustring cache_key(gchar const *uri, gchar const *name, unsigned psize) const; GdkPixbuf* get_preview_from_cache(const Glib::ustring& key); void set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px); - GdkPixbuf* get_preview(const gchar* uri, const gchar* id, NRArenaItem *root, double scale_factor, unsigned int psize); + GdkPixbuf* get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem *root, double scale_factor, unsigned int psize); }; }; // namespace Cache @@ -37,7 +48,7 @@ class SvgPreview { -#endif // __SVG_PREVIEW_CACHE_H__ +#endif // SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H /* Local Variables: mode:c++ diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 4f4f8a022..d1191cb3b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief System-wide clipboard management - implementation +/** + * @file + * System-wide clipboard management - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk@o2.pl> @@ -46,8 +47,6 @@ #include "extension/input.h" #include "extension/output.h" #include "selection-chemistry.h" -#include "libnr/nr-rect.h" -#include "libnr/nr-convert2geom.h" #include <2geom/rect.h> #include <2geom/transforms.h> #include "box3d.h" @@ -84,7 +83,7 @@ #include "snap.h" #include "persp3d.h" -/// @brief Made up mimetype to represent Gdk::Pixbuf clipboard contents +/// Made up mimetype to represent Gdk::Pixbuf clipboard contents. #define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf" #define CLIPBOARD_TEXT_TARGET "text/plain" @@ -104,7 +103,7 @@ namespace UI { /** - * @brief Default implementation of the clipboard manager + * Default implementation of the clipboard manager. */ class ClipboardManagerImpl : public ClipboardManager { public: @@ -194,7 +193,7 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {} /** - * @brief Copy selection contents to the clipboard + * Copy selection contents to the clipboard. */ void ClipboardManagerImpl::copy(SPDesktop *desktop) { @@ -274,8 +273,8 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop) /** - * @brief Copy a Live Path Effect path parameter to the clipboard - * @param pp The path parameter to store in the clipboard + * Copy a Live Path Effect path parameter to the clipboard. + * @param pp The path parameter to store in the clipboard. */ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam *pp) { @@ -301,8 +300,8 @@ void ClipboardManagerImpl::copyPathParameter(Inkscape::LivePathEffect::PathParam } /** - * @brief Paste from the system clipboard into the active desktop - * @param in_place Whether to put the contents where they were when copied + * Paste from the system clipboard into the active desktop. + * @param in_place Whether to put the contents where they were when copied. */ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) { @@ -343,7 +342,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) } /** - * @brief Returns the id of the first visible copied object + * Returns the id of the first visible copied object. */ const gchar *ClipboardManagerImpl::getFirstObjectID() { @@ -379,7 +378,7 @@ const gchar *ClipboardManagerImpl::getFirstObjectID() /** - * @brief Implements the Paste Style action + * Implements the Paste Style action. */ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) { @@ -427,7 +426,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) /** - * @brief Resize the selection or each object in the selection to match the clipboard's size + * Resize the selection or each object in the selection to match the clipboard's size. * @param separately Whether to scale each object in the selection separately * @param apply_x Whether to scale the width of objects / selection * @param apply_y Whether to scale the height of objects / selection @@ -467,7 +466,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { for (GSList *i = const_cast<GSList*>(selection->itemList()) ; i ; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect obj_size = item->getBboxDesktop(); + Geom::OptRect obj_size = item->desktopVisualBounds(); if ( !obj_size ) { continue; } @@ -476,7 +475,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } // resize the selection as a whole else { - Geom::OptRect sel_size = selection->bounds(); + Geom::OptRect sel_size = selection->visualBounds(); if ( sel_size ) { sp_selection_scale_relative(selection, sel_size->midpoint(), _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); @@ -490,7 +489,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a /** - * @brief Applies a path effect from the clipboard to the selected path + * Applies a path effect from the clipboard to the selected path. */ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) { @@ -534,7 +533,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) /** - * @brief Get LPE path data from the clipboard + * Get LPE path data from the clipboard. * @return The retrieved path data (contents of the d attribute), or "" if no path was found */ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) @@ -557,8 +556,8 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) /** - * @brief Get object id of a shape or text item from the clipboard - * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found + * Get object id of a shape or text item from the clipboard. + * @return The retrieved id string (contents of the id attribute), or "" if no shape or text item was found. */ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) { @@ -585,7 +584,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) /** - * @brief Iterate over a list of items and copy them to the clipboard. + * Iterate over a list of items and copy them to the clipboard. */ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { @@ -636,7 +635,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } } - Geom::OptRect size = selection->bounds(); + Geom::OptRect size = selection->visualBounds(); if (size) { sp_repr_set_point(_clipnode, "min", size->min()); sp_repr_set_point(_clipnode, "max", size->max()); @@ -647,7 +646,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) /** - * @brief Recursively copy all the definitions used by a given item to the clipboard defs + * Recursively copy all the definitions used by a given item to the clipboard defs. */ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) { @@ -736,7 +735,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) /** - * @brief Copy a single gradient to the clipboard's defs element + * Copy a single gradient to the clipboard's defs element. */ void ClipboardManagerImpl::_copyGradient(SPGradient *gradient) { @@ -749,7 +748,7 @@ void ClipboardManagerImpl::_copyGradient(SPGradient *gradient) /** - * @brief Copy a single pattern to the clipboard document's defs element + * Copy a single pattern to the clipboard document's defs element. */ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) { @@ -770,7 +769,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) /** - * @brief Copy a text path to the clipboard's defs element + * Copy a text path to the clipboard's defs element. */ void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp) { @@ -789,7 +788,7 @@ void ClipboardManagerImpl::_copyTextPath(SPTextPath *tp) /** - * @brief Copy a single XML node from one document to another + * Copy a single XML node from one document to another. * @param node The node to be copied * @param target_doc The document to which the node is to be copied * @param parent The node in the target document which will become the parent of the copied node @@ -805,7 +804,7 @@ Inkscape::XML::Node *ClipboardManagerImpl::_copyNode(Inkscape::XML::Node *node, /** - * @brief Paste the contents of a document into the active desktop + * Paste the contents of a document into the active desktop. * @param clipdoc The document to paste * @param in_place Whether to paste the selection where it was when copied * @pre @c clipdoc is not empty and items can be added to the current layer @@ -852,7 +851,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo target_document->ensureUpToDate(); // move selection either to original position (in_place) or to mouse pointer - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { // get offset of selection to original position of copied elements Geom::Point pos_original; @@ -884,9 +883,9 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo /** - * @brief Paste SVG defs from the document retrieved from the clipboard into the active document - * @param clipdoc The document to paste - * @pre @c clipdoc != NULL and pasting into the active document is possible + * Paste SVG defs from the document retrieved from the clipboard into the active document. + * @param clipdoc The document to paste. + * @pre @c clipdoc != NULL and pasting into the active document is possible. */ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) { @@ -894,7 +893,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) SPDocument *target_document = sp_desktop_document(desktop); Inkscape::XML::Node *root = clipdoc->getReprRoot(); Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); - Inkscape::XML::Node *target_defs = SP_DOCUMENT_DEFS(target_document)->getRepr(); + Inkscape::XML::Node *target_defs = target_document->getDefs()->getRepr(); Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@ -906,7 +905,7 @@ void ClipboardManagerImpl::_pasteDefs(SPDesktop *desktop, SPDocument *clipdoc) /** - * @brief Retrieve a bitmap image from the clipboard and paste it into the active document + * Retrieve a bitmap image from the clipboard and paste it into the active document. */ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc) { @@ -945,7 +944,7 @@ bool ClipboardManagerImpl::_pasteImage(SPDocument *doc) } /** - * @brief Paste text into the selected text object or create a new one to hold it + * Paste text into the selected text object or create a new one to hold it. */ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) { @@ -970,7 +969,7 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop) /** - * @brief Attempt to parse the passed string as a hexadecimal RGB or RGBA color + * Attempt to parse the passed string as a hexadecimal RGB or RGBA color. * @param text The Glib::ustring to parse * @return New CSS style representation if the parsing was successful, NULL otherwise */ @@ -1040,7 +1039,7 @@ SPCSSAttr *ClipboardManagerImpl::_parseColor(const Glib::ustring &text) /** - * @brief Applies a pasted path effect to a given item + * Applies a pasted path effect to a given item. */ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectstack) { @@ -1073,7 +1072,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta /** - * @brief Retrieve the clipboard contents as a document + * Retrieve the clipboard contents as a document. * @return Clipboard contents converted to SPDocument, or NULL if no suitable content was present */ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_target) @@ -1159,7 +1158,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ /** - * @brief Callback called when some other application requests data from Inkscape + * Callback called when some other application requests data from Inkscape. * * Finds a suitable output extension to save the internal clipboard document, * then saves it to memory and sets the clipboard contents. @@ -1197,7 +1196,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) gdouble dpi = PX_PER_IN; guint32 bgcolor = 0x00000000; - Geom::Point origin (SP_ROOT(_clipboardSPDoc->root)->x.computed, SP_ROOT(_clipboardSPDoc->root)->y.computed); + Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); @@ -1234,7 +1233,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) /** - * @brief Callback when someone else takes the clipboard + * Callback when someone else takes the clipboard. * * When the clipboard owner changes, this callback clears the internal clipboard document * to reduce memory usage. @@ -1247,14 +1246,14 @@ void ClipboardManagerImpl::_onClear() /** - * @brief Creates an internal clipboard document from scratch + * Creates an internal clipboard document from scratch. */ void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); - _defs = SP_DOCUMENT_DEFS(_clipboardSPDoc)->getRepr(); + _defs = _clipboardSPDoc->getDefs()->getRepr(); _doc = _clipboardSPDoc->getReprDoc(); _root = _clipboardSPDoc->getReprRoot(); @@ -1272,7 +1271,7 @@ void ClipboardManagerImpl::_createInternalClipboard() /** - * @brief Deletes the internal clipboard document + * Deletes the internal clipboard document. */ void ClipboardManagerImpl::_discardInternalClipboard() { @@ -1288,7 +1287,7 @@ void ClipboardManagerImpl::_discardInternalClipboard() /** - * @brief Get the scale to resize an item, based on the command and desktop state + * Get the scale to resize an item, based on the command and desktop state. */ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) { @@ -1317,7 +1316,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons /** - * @brief Find the most suitable clipboard target + * Find the most suitable clipboard target. */ Glib::ustring ClipboardManagerImpl::_getBestTarget() { @@ -1376,7 +1375,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() /** - * @brief Set the clipboard targets to reflect the mimetypes Inkscape can output + * Set the clipboard targets to reflect the mimetypes Inkscape can output. */ void ClipboardManagerImpl::_setClipboardTargets() { @@ -1451,7 +1450,7 @@ void ClipboardManagerImpl::_setClipboardTargets() /** - * @brief Set the string representation of a 32-bit RGBA color as the clipboard contents + * Set the string representation of a 32-bit RGBA color as the clipboard contents. */ void ClipboardManagerImpl::_setClipboardColor(guint32 color) { @@ -1462,7 +1461,7 @@ void ClipboardManagerImpl::_setClipboardColor(guint32 color) /** - * @brief Put a notification on the mesage stack + * Put a notification on the mesage stack. */ void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg) { diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp index 05fe9a459..4d2c242a6 100644 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@ -42,7 +42,7 @@ sp_object_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* Implementation */ -#include <gtk/gtkmenuitem.h> +#include <gtk/gtk.h> #include <glibmm/i18n.h> @@ -110,75 +110,75 @@ sp_item_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Object Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_properties), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Separator */ w = gtk_menu_item_new(); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Select This")); if (sp_desktop_selection(desktop)->includes(item)) { gtk_widget_set_sensitive(w, FALSE); } else { - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_select_this), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_select_this), item); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Create link */ w = gtk_menu_item_new_with_mnemonic(_("_Create Link")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_create_link), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_create_link), item); gtk_widget_set_sensitive(w, !SP_IS_ANCHOR(item)); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Set mask */ w = gtk_menu_item_new_with_mnemonic(_("Set Mask")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_mask), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_mask), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { gtk_widget_set_sensitive(w, TRUE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Release mask */ w = gtk_menu_item_new_with_mnemonic(_("Release Mask")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_mask), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_mask), item); if (item && item->mask_ref && item->mask_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { gtk_widget_set_sensitive(w, FALSE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Set Clip */ w = gtk_menu_item_new_with_mnemonic(_("Set _Clip")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_set_clip), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_set_clip), item); if ((item && item->mask_ref && item->mask_ref->getObject()) || (item->clip_ref && item->clip_ref->getObject())) { gtk_widget_set_sensitive(w, FALSE); } else { gtk_widget_set_sensitive(w, TRUE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Release Clip */ w = gtk_menu_item_new_with_mnemonic(_("Release C_lip")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_release_clip), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_release_clip), item); if (item && item->clip_ref && item->clip_ref->getObject()) { gtk_widget_set_sensitive(w, TRUE); } else { gtk_widget_set_sensitive(w, FALSE); } gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } @@ -189,7 +189,7 @@ sp_item_properties(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_desktop_selection(desktop)->set(item); @@ -205,7 +205,7 @@ sp_set_mask(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_set_mask(desktop, false, false); @@ -219,7 +219,7 @@ sp_release_mask(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_unset_mask(desktop, false); @@ -233,7 +233,7 @@ sp_set_clip(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_set_mask(desktop, true, false); @@ -247,7 +247,7 @@ sp_release_clip(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_selection_unset_mask(desktop, true); @@ -261,7 +261,7 @@ sp_item_select_this(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); sp_desktop_selection(desktop)->set(item); @@ -273,7 +273,7 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); g_assert(!SP_IS_ANCHOR(item)); - SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); @@ -311,10 +311,10 @@ sp_group_menu(SPObject *object, SPDesktop *desktop, GtkMenu *menu) /* "Ungroup" */ w = gtk_menu_item_new_with_mnemonic(_("_Ungroup")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_item_group_ungroup_activate), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_item_group_ungroup_activate), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(menu), w); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), w); } static void @@ -325,7 +325,7 @@ sp_item_group_ungroup_activate(GtkMenuItem *menuitem, SPGroup *group) g_assert(SP_IS_GROUP(group)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); children = NULL; @@ -351,21 +351,21 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Link _Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_properties), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Select item */ w = gtk_menu_item_new_with_mnemonic(_("_Follow Link")); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_follow), item); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_follow), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Reset transformations */ w = gtk_menu_item_new_with_mnemonic(_("_Remove Link")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_anchor_link_remove), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_anchor_link_remove), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } static void @@ -410,16 +410,16 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Link dialog */ w = gtk_menu_item_new_with_mnemonic(_("Image _Properties...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_properties), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_properties), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); w = gtk_menu_item_new_with_mnemonic(_("Edit Externally...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_image_image_edit), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); Inkscape::XML::Node *ir = object->getRepr(); const gchar *href = ir->attribute("xlink:href"); if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) { @@ -495,7 +495,7 @@ static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor) if ( errThing ) { g_warning("Problem launching editor (%d). %s", errThing->code, errThing->message); - SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + SPDesktop *desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, errThing->message); g_error_free(errThing); errThing = 0; @@ -511,7 +511,7 @@ sp_fill_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { @@ -533,10 +533,10 @@ sp_shape_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Item dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } /* Edit Text entry */ @@ -548,7 +548,7 @@ sp_text_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { @@ -567,7 +567,7 @@ sp_spellcheck_settings(GtkMenuItem *menuitem, SPItem *item) g_assert(SP_IS_ITEM(item)); - desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); + desktop = (SPDesktop*)g_object_get_data(G_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); if (sp_desktop_selection(desktop)->isEmpty()) { @@ -589,24 +589,24 @@ sp_text_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m) /* Fill and Stroke dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Fill and Stroke...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_fill_settings), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_fill_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Edit Text dialog */ w = gtk_menu_item_new_with_mnemonic(_("_Text and Font...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_text_settings), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_text_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); /* Spellcheck dialog */ w = gtk_menu_item_new_with_mnemonic(_("Check Spellin_g...")); - gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop); - gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_spellcheck_settings), item); + g_object_set_data(G_OBJECT(w), "desktop", desktop); + g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(sp_spellcheck_settings), item); gtk_widget_show(w); - gtk_menu_append(GTK_MENU(m), w); + gtk_menu_shell_append(GTK_MENU_SHELL(m), w); } /* Local Variables: diff --git a/src/ui/context-menu.h b/src/ui/context-menu.h index 36846edc3..39753f93f 100644 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@ -11,12 +11,15 @@ * This code is in public domain */ -#include <gtk/gtkmenu.h> +#include <gtk/gtk.h> -#include "forward.h" #include "sp-object.h" -/* Append object-specific part to context menu */ +class SPDesktop; + +/** + * Append object-specific part to context menu. + */ void sp_object_menu (SPObject *object, SPDesktop *desktop, GtkMenu *menu); #endif diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt deleted file mode 100644 index 98c4a47bb..000000000 --- a/src/ui/dialog/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -IF(WIN32) -SET(ui_dialog_WIN32_SRC -filedialogimpl-win32.cpp -) -ELSEIF(WIN32) - SET(ui_dialog_WIN32_SRC) -ENDIF(WIN32) - -SET(ui_dialog_SRC -aboutbox.cpp -align-and-distribute.cpp -color-item.cpp -debug.cpp -dialog.cpp -dialog-manager.cpp -dock-behavior.cpp -document-metadata.cpp -document-properties.cpp -extension-editor.cpp -eek-preview.cpp -ege-paint-def.cpp -filedialog.cpp -filedialogimpl-gtkmm.cpp -fill-and-stroke.cpp -filter-effects-dialog.cpp -find.cpp -floating-behavior.cpp -inkscape-preferences.cpp -input.cpp -livepatheffect-editor.cpp -memory.cpp -messages.cpp -ocaldialogs.cpp -print.cpp -scriptdialog.cpp -#session-player.cpp -tile.cpp -tracedialog.cpp -transformation.cpp -undo-history.cpp -#whiteboard-connect.cpp -#whiteboard-sharewithchat.cpp -#whiteboard-sharewithuser.cpp -${ui_dialog_WIN32_SRC} -) diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index da9be1e7c..5d6592897 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -1,15 +1,5 @@ ## Makefile.am fragment sourced by src/Makefile.am. -##if WITH_INKBOARD -## inkboard_dialogs = \ -## ui/dialog/whiteboard-connect.cpp \ -## ui/dialog/whiteboard-connect.h \ -## ui/dialog/whiteboard-sharewithchat.cpp \ -## ui/dialog/whiteboard-sharewithchat.h \ -## ui/dialog/whiteboard-sharewithuser.cpp \ -## ui/dialog/whiteboard-sharewithuser.h -##endif - ink_common_sources += \ ui/dialog/aboutbox.cpp \ ui/dialog/aboutbox.h \ diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 30ed62a4b..c8538d1fb 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape About box - implementation +/** + * @file + * Inkscape About box - implementation. */ /* Authors: * Derek P. Moore <derekm@hackunix.org> @@ -458,6 +459,7 @@ void AboutBox::initStrings() { "Francisco Xosé Vázquez Grandal <fxvazquez@arrakis.es>, 2001.\n" "Frederic Rodrigo <f.rodrigo free.fr>, 2004-2005.\n" "Ge'ez Frontier Foundation <locales@geez.org>, 2002.\n" +"George Boukeas <boukeas@gmail.com>, 2011.\n" "Hleb Valoshka <375gnu@gmail.com>, 2008-2009.\n" "Hizkuntza Politikarako Sailburuordetza <hizkpol@ej-gv.es>, 2005.\n" "Ilia Penev <lichopicho@gmail.com>, 2006.\n" @@ -514,8 +516,8 @@ void AboutBox::initStrings() { "Serdar Soytetir <sendirom@gmail.com>, 2005.\n" "shivaken <shivaken@owls-nest.net>, 2004.\n" "Shyam Krishna Bal <shyamkrishna_bal@yahoo.com>, 2006.\n" -"Simos Xenitellis <simos@hellug.gr>, 2001.\n" -"Spyros Blanas <cid_e@users.sourceforge.net>, 2006.\n" +"Simos Xenitellis <simos@hellug.gr>, 2001, 2011.\n" +"Spyros Blanas <cid_e@users.sourceforge.net>, 2006, 2011.\n" "Stefan Graubner <pflaumenmus92@gmx.net>, 2005.\n" "Supranee Thirawatthanasuk <supranee@opentle.org>, 2006.\n" "Takeshi Aihana <aihana@muc.biglobe.ne.jp>, 2000, 2001.\n" diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index f974ec6ce..708013b5d 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Align and Distribute dialog - implementation +/** + * @file + * Align and Distribute dialog - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> @@ -20,8 +21,8 @@ # include <config.h> #endif -#include <gtkmm/spinbutton.h> - +#include <2geom/transforms.h> +#include "ui/widget/spinbutton.h" #include "desktop-handles.h" #include "unclump.h" #include "document.h" @@ -43,6 +44,7 @@ #include "util/glib-list-iterators.h" #include "verbs.h" #include "widgets/icon.h" +#include "sp-root.h" #include "align-and-distribute.h" @@ -154,7 +156,7 @@ private : selected.erase(master); /*}*/ //Compute the anchor point - Geom::OptRect b = thing->getBboxDesktop (); + Geom::OptRect b = thing->desktopVisualBounds(); 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]); @@ -171,7 +173,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = static_cast<SPItem *>( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); + Geom::OptRect b = sp_desktop_document(desktop)->getRoot()->desktopVisualBounds(); 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]); @@ -183,7 +185,7 @@ private : case AlignAndDistribute::SELECTION: { - Geom::OptRect b = selection->bounds(); + Geom::OptRect b = selection->visualBounds(); 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]); @@ -210,7 +212,7 @@ private : bool changed = false; Geom::OptRect b; if (sel_as_group) - b = selection->bounds(); + b = selection->visualBounds(); //Move each item in the selected list separately for (std::list<SPItem *>::iterator it(selected.begin()); @@ -219,7 +221,7 @@ private : { sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = (*it)->getBboxDesktop(); + b = (*it)->desktopVisualBounds(); if (b) { 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]); @@ -260,7 +262,7 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[10] = { {0., 0., 1., 0., 0., 0., 0., 1.} }; -BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) : +BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd) : item(pItem), bbox (bounds) { @@ -270,7 +272,7 @@ BBoxSort::BBoxSort(const BBoxSort &rhs) : //NOTE : this copy ctor is called O(sort) when sorting the vector //this is bad. The vector should be a vector of pointers. //But I'll wait the bohem GC before doing that - item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) + item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) { } @@ -323,7 +325,7 @@ private : it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopVisualBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); } @@ -356,7 +358,7 @@ private : it < sorted.end(); it ++ ) { - if (!NR_DF_TEST_CLOSE (pos, it->bbox.min()[_orientation], 1e-6)) { + if (!Geom::are_near(pos, it->bbox.min()[_orientation], 1e-6)) { Geom::Point t(0.0, 0.0); t[_orientation] = pos - it->bbox.min()[_orientation]; sp_item_move_rel(it->item, Geom::Translate(t)); @@ -379,7 +381,7 @@ private : //new anchor position float pos = sorted.front().anchor + i * step; //Don't move if we are really close - if (!NR_DF_TEST_CLOSE (pos, it.anchor, 1e-6)) { + if (!Geom::are_near(pos, it.anchor, 1e-6)) { //Compute translation Geom::Point t(0.0, 0.0); t[_orientation] = pos - it.anchor; @@ -445,8 +447,8 @@ class ActionRemoveOverlaps : public Action { private: Gtk::Label removeOverlapXGapLabel; Gtk::Label removeOverlapYGapLabel; - Gtk::SpinButton removeOverlapXGap; - Gtk::SpinButton removeOverlapYGap; + Inkscape::UI::Widget::SpinButton removeOverlapXGap; + Inkscape::UI::Widget::SpinButton removeOverlapYGap; public: ActionRemoveOverlaps(Glib::ustring const &id, @@ -549,7 +551,7 @@ public: None, ZOrder, Clockwise - }; + }; ActionExchangePositions(Glib::ustring const &id, Glib::ustring const &tiptext, @@ -698,7 +700,7 @@ private : //Check 2 or more selected objects if (selected.size() < 2) return; - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); if (!sel_bbox) { return; } @@ -720,7 +722,7 @@ private : ++it) { sp_desktop_document (desktop)->ensureUpToDate(); - Geom::OptRect item_box = (*it)->getBboxDesktop (); + Geom::OptRect item_box = (*it)->desktopVisualBounds(); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@ -805,7 +807,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2d_affine(); + Geom::Point base = *pt * (*it)->i2dt_affine(); if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; @@ -848,7 +850,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional<Geom::Point> pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2d_affine(); + Geom::Point base = *pt * (*it)->i2dt_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; sp_item_move_rel(*it, Geom::Translate(t)); @@ -903,107 +905,107 @@ AlignAndDistribute::AlignAndDistribute() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); //Instanciate the align buttons - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-horizontal-right-to-anchor"), _("Align right edges of objects to the left edge of the anchor"), 0, 0); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT, + addAlignButton(INKSCAPE_ICON("align-horizontal-left"), _("Align left edges"), 0, 1); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER, + addAlignButton(INKSCAPE_ICON("align-horizontal-center"), _("Center on vertical axis"), 0, 2); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT, + addAlignButton(INKSCAPE_ICON("align-horizontal-right"), _("Align right sides"), 0, 3); - addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-horizontal-left-to-anchor"), _("Align left edges of objects to the right edge of the anchor"), 0, 4); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-vertical-bottom-to-anchor"), _("Align bottom edges of objects to the top edge of the anchor"), 1, 0); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP, + addAlignButton(INKSCAPE_ICON("align-vertical-top"), _("Align top edges"), 1, 1); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_CENTER, + addAlignButton(INKSCAPE_ICON("align-vertical-center"), _("Center on horizontal axis"), 1, 2); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM, + addAlignButton(INKSCAPE_ICON("align-vertical-bottom"), _("Align bottom edges"), 1, 3); - addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP_TO_ANCHOR, + addAlignButton(INKSCAPE_ICON("align-vertical-top-to-anchor"), _("Align top edges of objects to the bottom edge of the anchor"), 1, 4); //Baseline aligns - addBaselineButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("align-horizontal-baseline"), _("Align baseline anchors of texts horizontally"), 0, 5, this->align_table(), Geom::X, false); - addBaselineButton(INKSCAPE_ICON_ALIGN_VERTICAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("align-vertical-baseline"), _("Align baselines of texts"), 1, 5, this->align_table(), Geom::Y, false); //The distribute buttons - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_GAPS, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-gaps"), _("Make horizontal gaps between objects equal"), 0, 4, true, Geom::X, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_LEFT, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-left"), _("Distribute left edges equidistantly"), 0, 1, false, Geom::X, 1., 0.); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_CENTER, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-center"), _("Distribute centers equidistantly horizontally"), 0, 2, false, Geom::X, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_RIGHT, + addDistributeButton(INKSCAPE_ICON("distribute-horizontal-right"), _("Distribute right edges equidistantly"), 0, 3, false, Geom::X, 0., 1.); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_GAPS, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-gaps"), _("Make vertical gaps between objects equal"), 1, 4, true, Geom::Y, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-top"), _("Distribute top edges equidistantly"), 1, 1, false, Geom::Y, 0, 1); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-center"), _("Distribute centers equidistantly vertically"), 1, 2, false, Geom::Y, .5, .5); - addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM, + addDistributeButton(INKSCAPE_ICON("distribute-vertical-bottom"), _("Distribute bottom edges equidistantly"), 1, 3, false, Geom::Y, 1., 0.); //Baseline distribs - addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("distribute-horizontal-baseline"), _("Distribute baseline anchors of texts horizontally"), 0, 5, this->distribute_table(), Geom::X, true); - addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BASELINE, + addBaselineButton(INKSCAPE_ICON("distribute-vertical-baseline"), _("Distribute baselines of texts vertically"), 1, 5, this->distribute_table(), Geom::Y, true); // Rearrange //Graph Layout - addGraphLayoutButton(INKSCAPE_ICON_DISTRIBUTE_GRAPH, + addGraphLayoutButton(INKSCAPE_ICON("distribute-graph"), _("Nicely arrange selected connector network"), 0, 0); - addExchangePositionsButton(INKSCAPE_ICON_EXCHANGE_POSITIONS, + addExchangePositionsButton(INKSCAPE_ICON("exchange-positions"), _("Exchange positions of selected objects - selection order"), 0, 1); - addExchangePositionsByZOrderButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_ZORDER, + addExchangePositionsByZOrderButton(INKSCAPE_ICON("exchange-positions-zorder"), _("Exchange positions of selected objects - stacking order"), 0, 2); - addExchangePositionsClockwiseButton(INKSCAPE_ICON_EXCHANGE_POSITIONS_CLOCKWISE, + addExchangePositionsClockwiseButton(INKSCAPE_ICON("exchange-positions-clockwise"), _("Exchange positions of selected objects - clockwise rotate"), 0, 3); - + //Randomize & Unclump - addRandomizeButton(INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE, + addRandomizeButton(INKSCAPE_ICON("distribute-randomize"), _("Randomize centers in both dimensions"), 0, 4); - addUnclumpButton(INKSCAPE_ICON_DISTRIBUTE_UNCLUMP, + addUnclumpButton(INKSCAPE_ICON("distribute-unclump"), _("Unclump objects: try to equalize edge-to-edge distances"), 0, 5); //Remove overlaps - addRemoveOverlapsButton(INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS, + addRemoveOverlapsButton(INKSCAPE_ICON("distribute-remove-overlaps"), _("Move objects as little as possible so that their bounding boxes do not overlap"), 0, 0); @@ -1011,16 +1013,16 @@ AlignAndDistribute::AlignAndDistribute() // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common // _horizontal_ line". This is analogous to what the "align-vertical-center" icon means. // There is no doubt some ambiguity. For this reason the descriptions are different. - addNodeButton(INKSCAPE_ICON_ALIGN_VERTICAL_NODES, + addNodeButton(INKSCAPE_ICON("align-vertical-node"), _("Align selected nodes to a common horizontal line"), 0, Geom::X, false); - addNodeButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES, + addNodeButton(INKSCAPE_ICON("align-horizontal-node"), _("Align selected nodes to a common vertical line"), 1, Geom::Y, false); - addNodeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE, + addNodeButton(INKSCAPE_ICON("distribute-horizontal-node"), _("Distribute selected nodes horizontally"), 2, Geom::X, true); - addNodeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_NODE, + addNodeButton(INKSCAPE_ICON("distribute-vertical-node"), _("Distribute selected nodes vertically"), 3, Geom::Y, true); @@ -1085,7 +1087,7 @@ AlignAndDistribute::~AlignAndDistribute() for (std::list<Action *>::iterator it = _actionList.begin(); it != _actionList.end(); - it ++) + ++it) delete *it; } @@ -1243,8 +1245,8 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem case BIGGEST: { gdouble max = -1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = (*it)->getBboxDesktop (); + for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { + Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim > max) { @@ -1260,8 +1262,8 @@ std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem case SMALLEST: { gdouble max = 1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = (*it)->getBboxDesktop (); + for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { + Geom::OptRect b = (*it)->desktopVisualBounds(); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim < max) { diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 7c99d67c7..88d934f87 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -25,9 +25,6 @@ #include <gtkmm/table.h> #include <gtkmm/buttonbox.h> #include <gtkmm/label.h> -#include "libnr/nr-dim2.h" -#include "libnr/nr-rect.h" - #include "ui/widget/panel.h" #include "ui/widget/notebook-page.h" @@ -121,7 +118,7 @@ struct BBoxSort SPItem *item; float anchor; Geom::Rect bbox; - BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd); + BBoxSort(SPItem *pItem, Geom::Rect const &bounds, Geom::Dim2 orientation, double kBegin, double kEnd); BBoxSort(const BBoxSort &rhs); }; bool operator< (const BBoxSort &a, const BBoxSort &b); diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index fd7299ba2..e44b46308 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for naming calligraphic profiles +/** + * @file + * Dialog for naming calligraphic profiles. * * @note This file is in the wrong directory because of link order issues - * it is required by widgets/toolbox.cpp, and libspwidgets.a comes after diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index e9f6a8b95..f0eb0b491 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -15,7 +15,7 @@ #include <gtkmm/entry.h> #include <gtkmm/label.h> #include <gtkmm/table.h> -struct SPDesktop; +class SPDesktop; namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 9f163c00c..f245cec37 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape color swatch UI item. +/** + * @file + * Inkscape color swatch UI item. */ /* Authors: * Jon A. Cruz @@ -13,14 +14,15 @@ #include <errno.h> #include <glibmm/i18n.h> #include <gtkmm/label.h> -#include <gtk/gtkdnd.h> +#include <cairo.h> +#include <gtk/gtk.h> #include "color-item.h" #include "desktop.h" #include "desktop-handles.h" #include "desktop-style.h" -#include "display/nr-plain-stuff.h" +#include "display/cairo-utils.h" #include "document.h" #include "inkscape.h" // for SP_ACTIVE_DESKTOP #include "io/resource.h" @@ -212,17 +214,20 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin } else { GdkPixbuf* pixbuf = 0; if ( item->getGradient() ){ - guchar* px = g_new( guchar, 3 * height * width ); - nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 ); - - sp_gradient_render_vector_block_rgb( item->getGradient(), - px, width, height, 3 * width, - 0, width, TRUE ); - - pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8, - width, height, width * 3, - 0, // add delete function - 0 ); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(item->getGradient(), width); + cairo_t *ct = cairo_create(s); + cairo_set_source(ct, gradient); + cairo_paint(ct); + cairo_destroy(ct); + cairo_pattern_destroy(gradient); + cairo_surface_flush(s); + + pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), + GDK_COLORSPACE_RGB, TRUE, 8, + width, height, cairo_image_surface_get_stride(s), + ink_cairo_pixbuf_cleanup, s); + convert_pixbuf_argb32_to_normal(pixbuf); } else { Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height ); guint32 fillWith = (0xff000000 & (item->def.getR() << 24)) @@ -252,10 +257,8 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin // } -SwatchPage::SwatchPage() : - _name(), - _prefWidth(0), - _colors() +SwatchPage::SwatchPage() + : _prefWidth(0) { } @@ -265,10 +268,7 @@ SwatchPage::~SwatchPage() ColorItem::ColorItem(ege::PaintDef::ColorType type) : - Previewable(), def(type), - tips(), - _previews(), _isFill(false), _isStroke(false), _isLive(false), @@ -277,18 +277,12 @@ ColorItem::ColorItem(ege::PaintDef::ColorType type) : _linkGray(0), _linkSrc(0), _grad(0), - _pixData(0), - _pixWidth(0), - _pixHeight(0), - _listeners() + _pattern(0) { } ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) : - Previewable(), def( r, g, b, name ), - tips(), - _previews(), _isFill(false), _isStroke(false), _isLive(false), @@ -297,15 +291,15 @@ ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustr _linkGray(0), _linkSrc(0), _grad(0), - _pixData(0), - _pixWidth(0), - _pixHeight(0), - _listeners() + _pattern(0) { } ColorItem::~ColorItem() { + if (_pattern != NULL) { + cairo_pattern_destroy(_pattern); + } } ColorItem::ColorItem(ColorItem const &other) : @@ -361,18 +355,16 @@ void ColorItem::setGradient(SPGradient *grad) } } -void ColorItem::setPixData(guchar* px, int width, int height) +void ColorItem::setPattern(cairo_pattern_t *pattern) { - if (px != _pixData) { - if (_pixData) { - g_free(_pixData); - } - _pixData = px; - _pixWidth = width; - _pixHeight = height; - - _updatePreviews(); + if (pattern) { + cairo_pattern_reference(pattern); + } + if (_pattern) { + cairo_pattern_destroy(_pattern); } + _pattern = pattern; + _updatePreviews(); } void ColorItem::_dragGetColorData( GtkWidget */*widget*/, @@ -469,8 +461,8 @@ void ColorItem::_updatePreviews() for ( std::vector<SwatchPage*>::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) { SwatchPage* curr = *it2; index = 0; - for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { - if ( this == *zz ) { + for ( boost::ptr_vector<ColorItem>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { + if ( this == &*zz ) { found = true; paletteName = curr->_name; break; @@ -520,16 +512,30 @@ void ColorItem::_regenPreview(EekPreview * preview) eek_preview_set_pixbuf( preview, pixbuf ); } - else if ( !_pixData ){ + else if ( !_pattern ){ eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB() ); } else { - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( _pixData, GDK_COLORSPACE_RGB, FALSE, 8, - _pixWidth, _pixHeight, _pixWidth * 3, - 0, // add delete function - 0 ); + // These correspond to PREVIEW_PIXBUF_WIDTH and VBLOCK from swatches.cpp + // TODO: the pattern to draw should be in the widget that draws the preview, + // so the preview can be scalable + int w = 128; + int h = 16; + + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + cairo_t *ct = cairo_create(s); + cairo_set_source(ct, _pattern); + cairo_paint(ct); + cairo_destroy(ct); + cairo_surface_flush(s); + + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), + GDK_COLORSPACE_RGB, TRUE, 8, + w, h, cairo_image_surface_get_stride(s), + ink_cairo_pixbuf_cleanup, s); + convert_pixbuf_argb32_to_normal(pixbuf); eek_preview_set_pixbuf( preview, pixbuf ); } @@ -729,12 +735,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) { if ( colorSet ) { - for ( std::vector<ColorItem*>::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) + for ( boost::ptr_vector<ColorItem>::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) { - std::string::size_type pos = (*it)->def.descr.find("*{"); + std::string::size_type pos = it->def.descr.find("*{"); if ( pos != std::string::npos ) { - std::string subby = (*it)->def.descr.substr( pos + 2 ); + std::string subby = it->def.descr.substr( pos + 2 ); std::string::size_type endPos = subby.find("}*"); if ( endPos != std::string::npos ) { @@ -744,12 +750,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( subby.find('E') != std::string::npos ) { - (*it)->def.setEditable( true ); + it->def.setEditable( true ); } if ( subby.find('L') != std::string::npos ) { - (*it)->_isLive = true; + it->_isLive = true; } std::string part; @@ -759,7 +765,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( popVal( colorIndex, part ) ) { guint64 percent = 0; if ( popVal( percent, part ) ) { - (*it)->_linkTint( *(colorSet->_colors[colorIndex]), percent ); + it->_linkTint( colorSet->_colors[colorIndex], percent ); } } } @@ -774,7 +780,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( !popVal( grayLevel, part ) ) { grayLevel = 0; } - (*it)->_linkTone( *(colorSet->_colors[colorIndex]), percent, grayLevel ); + it->_linkTone( colorSet->_colors[colorIndex], percent, grayLevel ); } } } diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index a6e344ce3..d06082f2e 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -12,6 +12,7 @@ #ifndef SEEN_DIALOGS_COLOR_ITEM_H #define SEEN_DIALOGS_COLOR_ITEM_H +#include <boost/ptr_container/ptr_vector.hpp> #include <gtkmm/tooltips.h> #include "widgets/ege-paint-def.h" @@ -33,7 +34,7 @@ public: Glib::ustring _name; int _prefWidth; - std::vector<ColorItem*> _colors; + boost::ptr_vector<ColorItem> _colors; }; @@ -58,8 +59,7 @@ public: void setGradient(SPGradient *grad); SPGradient * getGradient() const { return _grad; } - - void setPixData(guchar* px, int width, int height); + void setPattern(cairo_pattern_t *pattern); void setState( bool fill, bool stroke ); bool isFill() { return _isFill; } @@ -104,9 +104,7 @@ private: int _linkGray; ColorItem* _linkSrc; SPGradient* _grad; - guchar *_pixData; - int _pixWidth; - int _pixHeight; + cairo_pattern_t *_pattern; std::vector<ColorItem*> _listeners; }; diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index 1f7539fc7..426cd5d99 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A dialog that displays log messages +/** + * @file + * A dialog that displays log messages. */ /* Authors: * Bob Jamison @@ -27,7 +28,7 @@ namespace UI { namespace Dialog { /** - * @brief A very simple dialog for displaying Inkscape messages - implementation + * A very simple dialog for displaying Inkscape messages - implementation. */ class DebugDialogImpl : public DebugDialog, public Gtk::Dialog { @@ -153,6 +154,8 @@ void DebugDialog::showInstance() { DebugDialog *debugDialog = getInstance(); debugDialog->show(); + // this is not a real memleak because getInstance() only creates a debug dialog once, and returns that instance for all subsequent calls + // cppcheck-suppress memleak } diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 4eeac74b9..42447a141 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index d73071194..0c8af66bf 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * @@ -13,7 +9,7 @@ #include <stddef.h> #include <sigc++/connection.h> -#include <glib/gtypes.h> +#include <glib.h> typedef struct _GtkWidget GtkWidget; class SPDesktop; diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 0c49690cc..cba0cf508 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Object for managing a set of dialogs, including their signals and +/** + * @file + * Object for managing a set of dialogs, including their signals and * construction/caching/destruction of them. */ /* Authors: diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h index 90e1862f1..45d8d8f66 100644 --- a/src/ui/dialog/dialog-manager.h +++ b/src/ui/dialog/dialog-manager.h @@ -14,7 +14,7 @@ #ifndef INKSCAPE_UI_DIALOG_MANAGER_H #define INKSCAPE_UI_DIALOG_MANAGER_H -#include <glib/gquark.h> +#include <glib.h> #include "dialog.h" #include <map> diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 88724a90c..3d3ea867e 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Base class for dialogs in Inkscape - implementation +/** + * @file + * Base class for dialogs in Inkscape - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 39d671cd8..cf4d36cff 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A dockable dialog implementation. +/** + * @file + * A dockable dialog implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> @@ -165,8 +166,7 @@ DockBehavior::set_title(Glib::ustring title) _dock_item.set_title(title); } -void -DockBehavior::set_sensitive(bool sensitive) +void DockBehavior::set_sensitive(bool sensitive) { // TODO check this. Seems to be bad that we ignore the parameter get_vbox()->set_sensitive(); @@ -263,7 +263,7 @@ DockBehavior::onDesktopActivated(SPDesktop *desktop) } // we're done, allow next retransientizing not sooner than after 120 msec - gtk_timeout_add (120, (GtkFunction) sp_retransientize_again, (gpointer) floating_win); + g_timeout_add (120, (GSourceFunc) sp_retransientize_again, (gpointer) floating_win); } } diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h index b865af545..98c111719 100644 --- a/src/ui/dialog/dock-behavior.h +++ b/src/ui/dialog/dock-behavior.h @@ -21,7 +21,7 @@ #include "ui/widget/dock-item.h" -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" #include "behavior.h" diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index 08479275b..2aebef997 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Document metadata dialog, Gtkmm-style +/** + * @file + * Document metadata dialog, Gtkmm-style. */ /* Authors: * bulia byak <buliabyak@users.sf.net> @@ -96,7 +97,7 @@ DocumentMetadata::~DocumentMetadata() Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++) + for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) delete (*it); } @@ -108,9 +109,8 @@ DocumentMetadata::~DocumentMetadata() * possible cases: (0,0) means insert space in first column; (0, non-0) means * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. -**/ -inline void -attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0) + */ +inline void attach_all(Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0) { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { @@ -190,8 +190,7 @@ DocumentMetadata::build_metadata() /** * Update dialog widgets from desktop. */ -void -DocumentMetadata::update() +void DocumentMetadata::update() { if (_wr.isUpdating()) return; @@ -200,7 +199,7 @@ DocumentMetadata::update() //-----------------------------------------------------------meta pages /* update the RDF entities */ - for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++) + for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) (*it)->update (SP_ACTIVE_DOCUMENT); _licensor.update (SP_ACTIVE_DOCUMENT); @@ -236,8 +235,7 @@ DocumentMetadata::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *d /** * Called when XML node attribute changed; updates dialog widgets. */ -static void -on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) +static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) { if (DocumentMetadata *dialog = static_cast<DocumentMetadata *>(data)) dialog->update(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 0c001da4b..fa392cccc 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Document properties dialog, Gtkmm-style +/** + * @file + * Document properties dialog, Gtkmm-style. */ /* Authors: * bulia byak <buliabyak@users.sf.net> @@ -43,8 +44,6 @@ #include "xml/repr.h" #if ENABLE_LCMS -#include <lcms.h> -//#include "color-profile-fns.h" #include "color-profile.h" #endif // ENABLE_LCMS @@ -75,8 +74,7 @@ static Inkscape::XML::NodeEventVector const _repr_events = { }; -DocumentProperties & -DocumentProperties::getInstance() +DocumentProperties& DocumentProperties::getInstance() { DocumentProperties &instance = *new DocumentProperties(); instance.init(); @@ -86,8 +84,13 @@ DocumentProperties::getInstance() DocumentProperties::DocumentProperties() : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW), - _page_page(1, 1, true, true), _page_guides(1, 1), - _page_snap(1, 1), _page_cms(1, 1), _page_scripting(1, 1), + _page_page(1, 1, true, true), + _page_guides(1, 1), + _page_snap(1, 1), + _page_cms(1, 1), + _page_scripting(1, 1), + _page_external_scripts(1, 1), + _page_embedded_scripts(1, 1), //--------------------------------------------------------------- _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false), _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false), @@ -99,16 +102,31 @@ DocumentProperties::DocumentProperties() //--------------------------------------------------------------- //General snap options _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr), - _rcbsng(_("_Snap guides while dragging"), _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled; only a small part of the guide near the cursor will snap)"), - "inkscape:snap-from-guide", _wr), _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr), _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr), //--------------------------------------------------------------- + _rsu_sno(_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"), + _("If set, objects only snap to another object when it's within the range specified below"), + "objecttolerance", _wr), + //Options for snapping to grids + _rsu_sn(_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"), + _("If set, objects only snap to a grid line when it's within the range specified below"), + "gridtolerance", _wr), + //Options for snapping to guides + _rsu_gusn(_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"), + _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"), + _("If set, objects only snap to a guide when it's within the range specified below"), + "guidetolerance", _wr), + //--------------------------------------------------------------- + _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr), + _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr), + //--------------------------------------------------------------- _grids_label_crea("", Gtk::ALIGN_LEFT), _grids_button_new(C_("Grid", "_New"), _("Create new grid.")), _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")), _grids_label_def("", Gtk::ALIGN_LEFT) - //--------------------------------------------------------------- { _tt.enable(); _getContents()->set_spacing (4); @@ -138,14 +156,13 @@ DocumentProperties::DocumentProperties() signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); } -void -DocumentProperties::init() +void DocumentProperties::init() { update(); Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->addListener (&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->addListener (&_repr_events, this); show_all_children(); @@ -156,7 +173,7 @@ DocumentProperties::~DocumentProperties() { Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); repr->removeListenerByData (this); - Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr(); root->removeListenerByData (this); } @@ -168,9 +185,8 @@ DocumentProperties::~DocumentProperties() * possible cases: (0,0) means insert space in first column; (0, non-0) means * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. -**/ -inline void -attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0) + */ +inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0) { for (unsigned i = 0, r = start; i < n; i += 2) { @@ -211,8 +227,7 @@ attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int st } } -void -DocumentProperties::build_page() +void DocumentProperties::build_page() { _page_page.show(); @@ -243,8 +258,7 @@ DocumentProperties::build_page() attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array)); } -void -DocumentProperties::build_guides() +void DocumentProperties::build_guides() { _page_guides.show(); @@ -256,35 +270,16 @@ DocumentProperties::build_guides() label_gui, 0, 0, &_rcb_sgui, _rcp_gui._label, &_rcp_gui, - _rcp_hgui._label, &_rcp_hgui, - 0, &_rcbsng, + _rcp_hgui._label, &_rcp_hgui }; attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array)); } -void -DocumentProperties::build_snap() +void DocumentProperties::build_snap() { _page_snap.show(); - _rsu_sno.init (_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"), - _("If set, objects only snap to another object when it's within the range specified below"), - "objecttolerance", _wr); - - //Options for snapping to grids - _rsu_sn.init (_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"), - _("If set, objects only snap to a grid line when it's within the range specified below"), - "gridtolerance", _wr); - - //Options for snapping to guides - _rsu_gusn.init (_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"), - _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"), - _("If set, objects only snap to a guide when it's within the range specified below"), - "guidetolerance", _wr); - Gtk::Label *label_o = manage (new Gtk::Label); label_o->set_markup (_("<b>Snap to objects</b>")); Gtk::Label *label_gr = manage (new Gtk::Label); @@ -296,6 +291,8 @@ DocumentProperties::build_snap() { label_o, 0, 0, _rsu_sno._vbox, + 0, &_rcb_snclp, + 0, &_rcb_snmsk, 0, 0, label_gr, 0, 0, _rsu_sn._vbox, @@ -308,53 +305,29 @@ DocumentProperties::build_snap() } #if ENABLE_LCMS -static void -lcms_profile_get_name (cmsHPROFILE profile, const gchar **name) -{ - if (profile) - { - *name = cmsTakeProductDesc (profile); - - if (! *name) - *name = cmsTakeProductName (profile); - - if (*name && ! g_utf8_validate (*name, -1, NULL)) - *name = _("(invalid UTF-8 string)"); - } - else - { - *name = _("None"); - } -} - -void -DocumentProperties::populate_available_profiles(){ +void DocumentProperties::populate_available_profiles(){ Glib::ListHandle<Gtk::Widget*> children = _menu.get_children(); for ( Glib::ListHandle<Gtk::Widget*>::iterator it2 = children.begin(); it2 != children.end(); ++it2 ) { _menu.remove(**it2); delete(*it2); } - std::list<Glib::ustring> files = ColorProfile::getProfileFiles(); - for ( std::list<Glib::ustring>::const_iterator it = files.begin(); it != files.end(); ++it ) { - cmsHPROFILE hProfile = cmsOpenProfileFromFile(it->c_str(), "r"); - if ( hProfile ){ - const gchar* name = 0; - lcms_profile_get_name(hProfile, &name); - Gtk::MenuItem* mi = manage(new Gtk::MenuItem()); - mi->set_data("filepath", g_strdup(it->c_str())); - mi->set_data("name", g_strdup(name)); - Gtk::HBox *hbox = manage(new Gtk::HBox()); - hbox->show(); - Gtk::Label* lbl = manage(new Gtk::Label(name)); - lbl->show(); - hbox->pack_start(*lbl, true, true, 0); - mi->add(*hbox); - mi->show_all(); - _menu.append(*mi); -// g_free((void*)name); - cmsCloseProfile(hProfile); - } + std::vector<std::pair<Glib::ustring, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames(); + for ( std::vector<std::pair<Glib::ustring, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) { + Glib::ustring file = it->first; + Glib::ustring name = it->second; + + Gtk::MenuItem* mi = manage(new Gtk::MenuItem()); + mi->set_data("filepath", g_strdup(file.c_str())); + mi->set_data("name", g_strdup(name.c_str())); + Gtk::HBox *hbox = manage(new Gtk::HBox()); + hbox->show(); + Gtk::Label* lbl = manage(new Gtk::Label(name)); + lbl->show(); + hbox->pack_start(*lbl, true, true, 0); + mi->add(*hbox); + mi->show_all(); + _menu.append(*mi); } _menu.show_all(); @@ -393,8 +366,7 @@ static void sanitizeName( Glib::ustring& str ) } } -void -DocumentProperties::linkSelectedProfile() +void DocumentProperties::linkSelectedProfile() { //store this profile in the SVG document (create <color-profile> element in the XML) // TODO remove use of 'active' desktop @@ -421,7 +393,7 @@ DocumentProperties::linkSelectedProfile() xml_doc->root()->addChild(defsRepr, NULL); } - g_assert(SP_ROOT(desktop->doc()->root)->defs); + g_assert(desktop->doc()->getDefs()); defsRepr->addChild(cprofRepr, NULL); // TODO check if this next line was sometimes needed. It being there caused an assertion. @@ -434,8 +406,7 @@ DocumentProperties::linkSelectedProfile() } } -void -DocumentProperties::populate_linked_profiles_box() +void DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); @@ -459,6 +430,13 @@ void DocumentProperties::external_scripts_list_button_release(GdkEventButton* ev } } +void DocumentProperties::embedded_scripts_list_button_release(GdkEventButton* event) +{ + if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { + _EmbeddedScriptsContextMenu.popup(event->button, event->time); + } +} + void DocumentProperties::linked_profiles_list_button_release(GdkEventButton* event) { if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) { @@ -476,7 +454,7 @@ void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<v } -void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) { Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); _ExternalScriptsContextMenu.append(*mi); @@ -485,6 +463,15 @@ void DocumentProperties::scripting_create_popup_menu(Gtk::Widget& parent, sigc:: _ExternalScriptsContextMenu.accelerate(parent); } +void DocumentProperties::embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem) +{ + Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE)); + _EmbeddedScriptsContextMenu.append(*mi); + mi->signal_activate().connect(rem); + mi->show(); + _EmbeddedScriptsContextMenu.accelerate(parent); +} + void DocumentProperties::removeSelectedProfile(){ Glib::ustring name; if(_LinkedProfilesList.get_selection()) { @@ -513,8 +500,7 @@ void DocumentProperties::removeSelectedProfile(){ populate_linked_profiles_box(); } -void -DocumentProperties::build_cms() +void DocumentProperties::build_cms() { _page_cms.show(); @@ -579,32 +565,40 @@ DocumentProperties::build_cms() } #endif // ENABLE_LCMS -void -DocumentProperties::build_scripting() +void DocumentProperties::build_scripting() { _page_scripting.show(); - Gtk::Label *label_script= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); - label_script->set_markup (_("<b>External script files:</b>")); + _page_scripting.set_spacing (4); + _page_scripting.pack_start(_scripting_notebook, true, true); + + _scripting_notebook.append_page(_page_external_scripts, _("External scripts")); + _scripting_notebook.append_page(_page_embedded_scripts, _("Embedded scripts")); + + //# External scripts tab + _page_external_scripts.show(); + + Gtk::Label *label_external= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_external->set_markup (_("<b>External script files:</b>")); _add_btn.set_label(_("Add")); - _page_scripting.set_spacing(4); + _page_external_scripts.set_spacing(4); gint row = 0; - label_script->set_alignment(0.0); - _page_scripting.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + label_external->set_alignment(0.0); + _page_external_scripts.table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); - spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - _page_scripting.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox()); + spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_external_scripts.table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; - _page_scripting.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_scripting.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + _page_external_scripts.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); row++; //# Set up the External Scripts box @@ -614,7 +608,58 @@ DocumentProperties::build_scripting() _ExternalScriptsList.set_headers_visible(true); // TODO restore? _ExternalScriptsList.set_fixed_height_mode(true); - populate_external_scripts_box(); + + //# Embedded scripts tab + _page_embedded_scripts.show(); + + Gtk::Label *label_embedded= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded->set_markup (_("<b>Embedded script files:</b>")); + + _new_btn.set_label(_("New")); + + _page_embedded_scripts.set_spacing(4); + row = 0; + + label_embedded->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + _page_embedded_scripts.table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox()); + spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); + _page_embedded_scripts.table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_new_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + //# Set up the Embedded Scripts box + _EmbeddedScriptsListStore = Gtk::ListStore::create(_EmbeddedScriptsListColumns); + _EmbeddedScriptsList.set_model(_EmbeddedScriptsListStore); + _EmbeddedScriptsList.append_column(_("Script id"), _EmbeddedScriptsListColumns.idColumn); + _EmbeddedScriptsList.set_headers_visible(true); +// TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true); + + //# Set up the Embedded Scripts content box + Gtk::Label *label_embedded_content= manage (new Gtk::Label("", Gtk::ALIGN_LEFT)); + label_embedded_content->set_markup (_("<b>Content:</b>")); + + label_embedded_content->set_alignment(0.0); + _page_embedded_scripts.table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + row++; + + _page_embedded_scripts.table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); + + _EmbeddedContentScroller.add(_EmbeddedContent); + _EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedContentScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _EmbeddedContentScroller.set_size_request(-1, -1); + + _EmbeddedScriptsList.signal_cursor_changed().connect(sigc::mem_fun(*this, &DocumentProperties::changeEmbeddedScript)); + _EmbeddedContent.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::editEmbeddedScript)); + + populate_script_lists(); _ExternalScriptsListScroller.add(_ExternalScriptsList); _ExternalScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); @@ -623,17 +668,28 @@ DocumentProperties::build_scripting() _add_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addExternalScript)); + _EmbeddedScriptsListScroller.add(_EmbeddedScriptsList); + _EmbeddedScriptsListScroller.set_shadow_type(Gtk::SHADOW_IN); + _EmbeddedScriptsListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS); + _EmbeddedScriptsListScroller.set_size_request(-1, 90); + + _new_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::addEmbeddedScript)); + + #if ENABLE_LCMS _ExternalScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release)); - scripting_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + external_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript)); + + _EmbeddedScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::embedded_scripts_list_button_release)); + embedded_create_popup_menu(_EmbeddedScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript)); #endif // ENABLE_LCMS //TODO: review this observers code: const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) { - _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + _scripts_observer.set(SP_OBJECT(current->data)->parent); } - _ext_scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_external_scripts_box)); + _scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_script_lists)); } @@ -652,7 +708,24 @@ void DocumentProperties::addExternalScript(){ // inform the document, so we can undo DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); - populate_external_scripts_box(); + populate_script_lists(); + } +} + +void DocumentProperties::addEmbeddedScript(){ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (!desktop){ + g_warning("No active desktop"); + } else { + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script"); + + xml_doc->root()->addChild(scriptRepr, NULL); + + // inform the document, so we can undo + DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EMBEDDED_SCRIPT, _("Add embedded script...")); + + populate_script_lists(); } } @@ -675,20 +748,138 @@ void DocumentProperties::removeExternalScript(){ if (name == script->xlinkhref){ //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(obj->getRepr()); - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + } } current = g_slist_next(current); } - populate_external_scripts_box(); + populate_script_lists(); +} + +void DocumentProperties::removeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + sp_repr_unparent(repr); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EMBEDDED_SCRIPT, _("Remove embedded script")); + } + } + current = g_slist_next(current); + } + + populate_script_lists(); } -void DocumentProperties::populate_external_scripts_box(){ +void DocumentProperties::changeEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + bool voidscript=true; + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + int count=0; + for ( SPObject *child = obj->children ; child; child = child->next ) + { + count++; + } + + if (count>1) + g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); + + //XML Tree being used directly here while it shouldn't be. + SPObject* child = obj->firstChild(); + //TODO: shouldnt we get all children instead of simply the first child? + + if (child && child->getRepr()){ + const gchar* content = child->getRepr()->content(); + if (content){ + voidscript=false; + _EmbeddedContent.get_buffer()->set_text(content); + } + } + } + current = g_slist_next(current); + } + + if (voidscript) + _EmbeddedContent.get_buffer()->set_text(""); +} + +void DocumentProperties::editEmbeddedScript(){ + Glib::ustring id; + if(_EmbeddedScriptsList.get_selection()) { + Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected(); + + if(i){ + id = (*i)[_EmbeddedScriptsListColumns.idColumn]; + } else { + return; + } + } + + Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc(); + const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); + while ( current ) { + SPObject* obj = SP_OBJECT(current->data); + if (id == obj->getId()){ + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *repr = obj->getRepr(); + if (repr){ + SPObject *child; + while (NULL != (child = obj->firstChild())) child->deleteObject(); + obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); + + //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); + + // inform the document, so we can undo + DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script")); + } + } + current = g_slist_next(current); + } +} + +void DocumentProperties::populate_script_lists(){ _ExternalScriptsListStore->clear(); + _EmbeddedScriptsListStore->clear(); const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); - if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); + if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; @@ -697,6 +888,11 @@ void DocumentProperties::populate_external_scripts_box(){ Gtk::TreeModel::Row row = *(_ExternalScriptsListStore->append()); row[_ExternalScriptsListColumns.filenameColumn] = script->xlinkhref; } + else // Embedded scripts + { + Gtk::TreeModel::Row row = *(_EmbeddedScriptsListStore->append()); + row[_EmbeddedScriptsListColumns.idColumn] = obj->getId(); + } current = g_slist_next(current); } @@ -705,8 +901,7 @@ void DocumentProperties::populate_external_scripts_box(){ /** * Called for _updating_ the dialog (e.g. when a new grid was manually added in XML) */ -void -DocumentProperties::update_gridspage() +void DocumentProperties::update_gridspage() { SPDesktop *dt = getDesktop(); SPNamedView *nv = sp_desktop_namedview(dt); @@ -747,8 +942,7 @@ DocumentProperties::update_gridspage() /** * Build grid page of dialog. */ -void -DocumentProperties::build_gridspage() +void DocumentProperties::build_gridspage() { /// \todo FIXME: gray out snapping when grid is off. /// Dissenting view: you want snapping without grid. @@ -785,8 +979,7 @@ DocumentProperties::build_gridspage() /** * Update dialog widgets from desktop. Also call updateWidget routines of the grids. */ -void -DocumentProperties::update() +void DocumentProperties::update() { if (_wr.isUpdating()) return; @@ -816,14 +1009,14 @@ DocumentProperties::update() _rcb_sgui.setActive (nv->showguides); _rcp_gui.setRgba32 (nv->guidecolor); _rcp_hgui.setRgba32 (nv->guidehicolor); - _rcbsng.setActive(nv->snap_manager.snapprefs.getSnapModeGuide()); //-----------------------------------------------------------snap page _rsu_sno.setValue (nv->snap_manager.snapprefs.getObjectTolerance()); _rsu_sn.setValue (nv->snap_manager.snapprefs.getGridTolerance()); _rsu_gusn.setValue (nv->snap_manager.snapprefs.getGuideTolerance()); - + _rcb_snclp.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_CLIP)); + _rcb_snmsk.setActive (nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_MASK)); //-----------------------------------------------------------grids page @@ -857,8 +1050,7 @@ DocumentProperties::_createPageTabLabel(const Glib::ustring& label, const char * //-------------------------------------------------------------------- -void -DocumentProperties::on_response (int id) +void DocumentProperties::on_response (int id) { if (id == Gtk::RESPONSE_DELETE_EVENT || id == Gtk::RESPONSE_CLOSE) { @@ -872,44 +1064,39 @@ DocumentProperties::on_response (int id) hide(); } -void -DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) +void DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = document->root->getRepr(); + Inkscape::XML::Node *root = document->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } -void -DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->addListener(&_repr_events, this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->addListener(&_repr_events, this); update(); } -void -DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) +void DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop) { Inkscape::XML::Node *repr = sp_desktop_namedview(desktop)->getRepr(); repr->removeListenerByData(this); - Inkscape::XML::Node *root = sp_desktop_document(desktop)->root->getRepr(); + Inkscape::XML::Node *root = sp_desktop_document(desktop)->getRoot()->getRepr(); root->removeListenerByData(this); } -static void -on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) +static void on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update_gridspage(); } -static void -on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) +static void on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update_gridspage(); @@ -920,8 +1107,7 @@ on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, /** * Called when XML node attribute changed; updates dialog widgets. */ -static void -on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) +static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data) { if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data)) dialog->update(); @@ -932,8 +1118,7 @@ on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar # BUTTON CLICK HANDLERS (callbacks) ########################################################################*/ -void -DocumentProperties::onNewGrid() +void DocumentProperties::onNewGrid() { SPDesktop *dt = getDesktop(); Inkscape::XML::Node *repr = sp_desktop_namedview(dt)->getRepr(); @@ -947,8 +1132,7 @@ DocumentProperties::onNewGrid() } -void -DocumentProperties::onRemoveGrid() +void DocumentProperties::onRemoveGrid() { gint pagenum = _grids_notebook.get_current_page(); if (pagenum == -1) // no pages diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index b88f0db26..8f922d6fd 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -64,16 +64,22 @@ protected: #endif // ENABLE_LCMS void external_scripts_list_button_release(GdkEventButton* event); - void populate_external_scripts_box(); + void embedded_scripts_list_button_release(GdkEventButton* event); + void populate_script_lists(); void addExternalScript(); + void addEmbeddedScript(); void removeExternalScript(); - void scripting_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void removeEmbeddedScript(); + void changeEmbeddedScript(); + void editEmbeddedScript(); + void external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); + void embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem); void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); void _handleActivateDesktop(Inkscape::Application *application, SPDesktop *desktop); void _handleDeactivateDesktop(Inkscape::Application *application, SPDesktop *desktop); - Inkscape::XML::SignalObserver _emb_profiles_observer, _ext_scripts_observer; + Inkscape::XML::SignalObserver _emb_profiles_observer, _scripts_observer; Gtk::Tooltips _tt; Gtk::Notebook _notebook; @@ -82,6 +88,11 @@ protected: UI::Widget::NotebookPage _page_snap; UI::Widget::NotebookPage _page_cms; UI::Widget::NotebookPage _page_scripting; + + Gtk::Notebook _scripting_notebook; + UI::Widget::NotebookPage _page_external_scripts; + UI::Widget::NotebookPage _page_embedded_scripts; + Gtk::VBox _grids_vbox; UI::Widget::Registry _wr; @@ -95,13 +106,14 @@ protected: UI::Widget::PageSizer _page_sizer; //--------------------------------------------------------------- UI::Widget::RegisteredCheckButton _rcb_sgui; - UI::Widget::RegisteredCheckButton _rcbsng; UI::Widget::RegisteredColorPicker _rcp_gui; UI::Widget::RegisteredColorPicker _rcp_hgui; //--------------------------------------------------------------- UI::Widget::ToleranceSlider _rsu_sno; UI::Widget::ToleranceSlider _rsu_sn; UI::Widget::ToleranceSlider _rsu_gusn; + UI::Widget::RegisteredCheckButton _rcb_snclp; + UI::Widget::RegisteredCheckButton _rcb_snmsk; //--------------------------------------------------------------- Gtk::Menu _menu; Gtk::OptionMenu _combo_avail; @@ -122,6 +134,7 @@ protected: //--------------------------------------------------------------- Gtk::Button _add_btn; + Gtk::Button _new_btn; class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord { public: @@ -130,11 +143,25 @@ protected: Gtk::TreeModelColumn<Glib::ustring> filenameColumn; }; ExternalScriptsColumns _ExternalScriptsListColumns; + class EmbeddedScriptsColumns : public Gtk::TreeModel::ColumnRecord + { + public: + EmbeddedScriptsColumns() + { add(idColumn); } + Gtk::TreeModelColumn<Glib::ustring> idColumn; + }; + EmbeddedScriptsColumns _EmbeddedScriptsListColumns; Glib::RefPtr<Gtk::ListStore> _ExternalScriptsListStore; + Glib::RefPtr<Gtk::ListStore> _EmbeddedScriptsListStore; Gtk::TreeView _ExternalScriptsList; + Gtk::TreeView _EmbeddedScriptsList; Gtk::ScrolledWindow _ExternalScriptsListScroller; + Gtk::ScrolledWindow _EmbeddedScriptsListScroller; Gtk::Menu _ExternalScriptsContextMenu; + Gtk::Menu _EmbeddedScriptsContextMenu; Gtk::Entry _script_entry; + Gtk::TextView _EmbeddedContent; + Gtk::ScrolledWindow _EmbeddedContentScroller; //--------------------------------------------------------------- Gtk::Notebook _grids_notebook; diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 527dfe23c..282f43a25 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Extension editor dialog +/** + * @file + * Extension editor dialog. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> @@ -33,15 +34,15 @@ namespace Inkscape { namespace UI { namespace Dialog { -/** \brief Create a new ExtensionEditor dialog - \return None - - This function creates a new extension editor dialog. The dialog - consists of two basic areas. The left side is a tree widget, which - is only used as a list. And the right side is a notebook of information - about the selected extension. A handler is set up so that when - a new extension is selected, the notebooks are changed appropriately. -*/ +/** + * Create a new ExtensionEditor dialog. + * + * This function creates a new extension editor dialog. The dialog + * consists of two basic areas. The left side is a tree widget, which + * is only used as a list. And the right side is a notebook of information + * about the selected extension. A handler is set up so that when + * a new extension is selected, the notebooks are changed appropriately. + */ ExtensionEditor::ExtensionEditor() : UI::Widget::Panel ("", "/dialogs/extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR) { @@ -92,9 +93,9 @@ ExtensionEditor::ExtensionEditor() show_all_children(); } -/** \brief Destroys the extension editor dialog - \return None -*/ +/** + * Destroys the extension editor dialog. + */ ExtensionEditor::~ExtensionEditor() { } @@ -117,15 +118,14 @@ ExtensionEditor::setExtensionIter(const Gtk::TreeModel::iterator &iter) return false; } -/** \brief Called every time a new extention is selected - \return None - - This function is set up to handle the signal for a changed extension - from the tree view in the left pane. It figure out which extension - is selected and updates the widgets to have data for that extension. -*/ -void -ExtensionEditor::on_pagelist_selection_changed (void) +/** + * Called every time a new extention is selected + * + * This function is set up to handle the signal for a changed extension + * from the tree view in the left pane. It figure out which extension + * is selected and updates the widgets to have data for that extension. + */ +void ExtensionEditor::on_pagelist_selection_changed(void) { Glib::RefPtr<Gtk::TreeSelection> selection = _page_list.get_selection(); Gtk::TreeModel::iterator iter = selection->get_selected(); @@ -179,34 +179,35 @@ ExtensionEditor::on_pagelist_selection_changed (void) return; } -/** \brief A function to pass to the iterator in the Extensions Database - \param in_plug The extension to evaluate - \param in_data A pointer to the Extension Editor class - \return None - - This function is a static function with the prototype required for - the Extension Database's foreach function. It will get called for - every extension in the database, and will then turn around and - call the more object oriented function \c add_extension in the - ExtensionEditor. -*/ -void -ExtensionEditor::dbfunc (Inkscape::Extension::Extension * in_plug, gpointer in_data) +/** + * A function to pass to the iterator in the Extensions Database. + * + * This function is a static function with the prototype required for + * the Extension Database's foreach function. It will get called for + * every extension in the database, and will then turn around and + * call the more object oriented function \c add_extension in the + * ExtensionEditor. + * + * @param in_plug The extension to evaluate. + * @param in_data A pointer to the Extension Editor class. + */ +void ExtensionEditor::dbfunc(Inkscape::Extension::Extension * in_plug, gpointer in_data) { ExtensionEditor * ee = static_cast<ExtensionEditor *>(in_data); ee->add_extension(in_plug); return; } -/** \brief Adds an extension into the tree model - \param ext The extension to add - \return The iterator representing the location in the tree model - - This function takes the data out of the extension and puts it - into the tree model for the dialog. -*/ -Gtk::TreeModel::iterator -ExtensionEditor::add_extension (Inkscape::Extension::Extension * ext) +/** + * Adds an extension into the tree model. + * + * This function takes the data out of the extension and puts it + * into the tree model for the dialog. + * + * @param ext The extension to add. + * @return The iterator representing the location in the tree model. + */ +Gtk::TreeModel::iterator ExtensionEditor::add_extension(Inkscape::Extension::Extension * ext) { Gtk::TreeModel::iterator iter; diff --git a/src/ui/dialog/extensions.cpp b/src/ui/dialog/extensions.cpp index 3c778affe..ed38860d1 100644 --- a/src/ui/dialog/extensions.cpp +++ b/src/ui/dialog/extensions.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A simple dialog with information about extensions +/** + * @file + * A simple dialog with information about extensions. */ /* Authors: * Jon A. Cruz @@ -9,11 +10,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <gtkmm/scrolledwindow.h> #include "extension/db.h" #include "extensions.h" +#include "extension/extension.h" namespace Inkscape { diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 8db390cd2..c31f7cf15 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of the file dialog interfaces defined in filedialog.h +/** + * @file + * Implementation of the file dialog interfaces defined in filedialog.h. */ /* Authors: * Bob Jamison diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 8e0b9294b..61013295a 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of the file dialog interfaces defined in filedialogimpl.h +/** + * @file + * Implementation of the file dialog interfaces defined in filedialogimpl.h. */ /* Authors: * Bob Jamison @@ -599,8 +600,9 @@ void FileDialogBaseGtk::cleanup( bool showConfirmed ) { if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if ( showConfirmed ) + if ( showConfirmed ) { prefs->setBool( preferenceBase + "/enable_preview", previewCheckbox.get_active() ); + } } } @@ -611,6 +613,9 @@ void FileDialogBaseGtk::_previewEnabledCB() set_preview_widget_active(enabled); if ( enabled ) { _updatePreviewCallback(); + } else { + // Clears out any current preview image. + svgPreview.showNoPreview(); } } @@ -622,6 +627,7 @@ void FileDialogBaseGtk::_previewEnabledCB() void FileDialogBaseGtk::_updatePreviewCallback() { Glib::ustring fileName = get_preview_filename(); + bool enabled = previewCheckbox.get_active(); #ifdef WITH_GNOME_VFS if ( fileName.empty() && gnome_vfs_initialized() ) { @@ -629,11 +635,11 @@ void FileDialogBaseGtk::_updatePreviewCallback() } #endif - if (fileName.empty()) { - return; + if ( enabled && !fileName.empty() ) { + svgPreview.set(fileName, _dialogType); + } else { + svgPreview.showNoPreview(); } - - svgPreview.set(fileName, _dialogType); } @@ -757,7 +763,7 @@ void FileOpenDialogImplGtk::createFilterMenu() Inkscape::Extension::db.get_input_list(extension_list); for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Input * imod = *current_item; @@ -1081,7 +1087,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() knownExtensions.clear(); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output * omod = *current_item; @@ -1336,7 +1342,7 @@ void FileExportDialogImpl::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output * omod = *current_item; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index af607c124..ba61d618f 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -35,11 +35,7 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include <gtk/gtkfilechooser.h> - -//Another hack -#include <gtk/gtkentry.h> -#include <gtk/gtkexpander.h> +#include <gtk/gtk.h> //Inkscape includes #include "extension/input.h" @@ -53,6 +49,9 @@ namespace Inkscape { + +class URI; + namespace UI { namespace Dialog @@ -80,7 +79,7 @@ findExpanderWidgets(Gtk::Container *parent, class FileType { public: - FileType() {} + FileType(): name(), pattern(),extension(0) {} ~FileType() {} Glib::ustring name; Glib::ustring pattern; diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index b18d5a1bc..4ed963148 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Implementation of native file dialogs for Win32 +/** + * @file + * Implementation of native file dialogs for Win32. */ /* Authors: * Joel Holdsworth @@ -29,20 +30,19 @@ //Inkscape includes #include "inkscape.h" -#include <dialogs/dialog-events.h> -#include <extension/input.h> -#include <extension/output.h> -#include <extension/db.h> - -#include <libnr/nr-pixops.h> -#include <libnr/nr-translate-scale-ops.h> -#include <display/nr-arena-item.h> -#include <display/nr-arena.h> +#include "dialogs/dialog-events.h" +#include "extension/input.h" +#include "extension/output.h" +#include "extension/db.h" + +//#include "display/drawing-item.h" +//#include "display/drawing.h" #include "sp-item.h" #include "display/canvas-arena.h" #include "filedialog.h" #include "filedialogimpl-win32.h" +#include "sp-root.h" #include <zlib.h> #include <cairomm/win32_surface.h> @@ -227,7 +227,7 @@ void FileOpenDialogImplWin32::createFilterMenu() int filter_count = 5; // 5 - one for each filter type for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Filter filter; @@ -383,7 +383,7 @@ void FileOpenDialogImplWin32::createFilterMenu() wchar_t *filterptr = _filter; for(list<Filter>::iterator filter_iterator = filter_list.begin(); - filter_iterator != filter_list.end(); filter_iterator++) + filter_iterator != filter_list.end(); ++filter_iterator) { const Filter &filter = *filter_iterator; @@ -409,7 +409,7 @@ void FileOpenDialogImplWin32::createFilterMenu() *(filterptr++) = L'\0'; _filter_count = extension_index; - _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd + _filter_index = 2; // Select the 2nd filter in the list - 2 is NOT the 3rd } void FileOpenDialogImplWin32::GetOpenFileName_thread() @@ -421,7 +421,7 @@ void FileOpenDialogImplWin32::GetOpenFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); memset(&ofn, 0, sizeof(ofn)); @@ -954,6 +954,10 @@ void FileOpenDialogImplWin32::free_preview() bool FileOpenDialogImplWin32::set_svg_preview() { + return false; + // NOTE: it's not worth the effort to fix this to use Cairo. + // Native file dialogs are unmaintainable and should be removed anyway. + #if 0 const int PreviewSize = 512; gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string, @@ -962,8 +966,10 @@ bool FileOpenDialogImplWin32::set_svg_preview() g_free(utf8string); // Check the document loaded properly - if(svgDoc == NULL) return false; - if(svgDoc->root == NULL) + if (svgDoc == NULL) { + return false; + } + if (svgDoc->getRoot() == NULL) { svgDoc->doUnref(); return false; @@ -987,16 +993,14 @@ bool FileOpenDialogImplWin32::set_svg_preview() NRRectL bbox = {0, 0, scaledSvgWidth, scaledSvgHeight}; // write object bbox to area - Geom::OptRect maybeArea(area); svgDoc->ensureUpToDate(); - static_cast<SPItem *>(svgDoc->root)->invoke_bbox( maybeArea, - static_cast<SPItem *>(svgDoc->root)->i2d_affine(), TRUE); + Geom::OptRect maybeArea = area | svgDoc->getRoot()->desktopVisualBounds(); NRArena *const arena = NRArena::create(); unsigned const key = SPItem::display_key_new(1); - NRArenaItem *root = static_cast<SPItem*>(svgDoc->root)->invoke_show( + NRArenaItem *root = svgDoc->getRoot()->invoke_show( arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); @@ -1033,7 +1037,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // Tidy up svgDoc->doUnref(); - static_cast<SPItem*>(svgDoc->root)->invoke_hide(key); + svgDoc->getRoot()->invoke_hide(key); nr_object_unref((NRObject *) arena); // Create the GDK pixbuf @@ -1052,6 +1056,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() _mutex->unlock(); return true; + #endif } void FileOpenDialogImplWin32::destroy_svg_rendering(const guint8 *buffer) @@ -1577,6 +1582,19 @@ FileSaveDialogImplWin32::FileSaveDialogImplWin32(Gtk::Window &parent, { FileSaveDialog::myDocTitle = docTitle; createFilterMenu(); + + /* The code below sets the default file name */ + myFilename = ""; + if (dir.size() > 0) { + Glib::ustring udir(dir); + Glib::ustring::size_type len = udir.length(); + // leaving a trailing backslash on the directory name leads to the infamous + // double-directory bug on win32 + if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + myFilename = udir.substr(0, udir.find_last_of( '.' ) ); // this removes the extension, or actually, removes everything past the last dot (hopefully this is what most people want) + if (1 + myFilename.find("\\\\",2)) // remove one slash if double + myFilename.replace(myFilename.find("\\\\",2), 1, ""); + } } FileSaveDialogImplWin32::~FileSaveDialogImplWin32() @@ -1598,7 +1616,7 @@ void FileSaveDialogImplWin32::createFilterMenu() int filter_length = 1; for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); current_item++) + current_item != extension_list.end(); ++current_item) { Inkscape::Extension::Output *omod = *current_item; if (omod->deactivated()) continue; @@ -1632,7 +1650,7 @@ void FileSaveDialogImplWin32::createFilterMenu() wchar_t *filterptr = _filter; for(list<Filter>::iterator filter_iterator = filter_list.begin(); - filter_iterator != filter_list.end(); filter_iterator++) + filter_iterator != filter_list.end(); ++filter_iterator) { const Filter &filter = *filter_iterator; @@ -1655,7 +1673,7 @@ void FileSaveDialogImplWin32::createFilterMenu() *(filterptr++) = 0; _filter_count = extension_index; - _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd + _filter_index = 1; // A value of 1 selects the 1st filter - NOT the 2nd } void FileSaveDialogImplWin32::GetSaveFileName_thread() @@ -1667,7 +1685,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() WCHAR* current_directory_string = (WCHAR*)g_utf8_to_utf16( _current_directory.data(), _current_directory.length(), - NULL, NULL, NULL); + NULL, NULL, NULL); // Copy the selected file name, converting from UTF-8 to UTF-16 memset(_path_string, 0, sizeof(_path_string)); @@ -1719,14 +1737,14 @@ FileSaveDialogImplWin32::show() _result = false; _main_loop = g_main_loop_new(g_main_context_default(), FALSE); - if(_main_loop != NULL) - { - if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) - g_main_loop_run(_main_loop); + if(_main_loop != NULL) + { + if(Glib::Thread::create(sigc::mem_fun(*this, &FileSaveDialogImplWin32::GetSaveFileName_thread), true)) + g_main_loop_run(_main_loop); - if(_result) - appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); - } + if(_result) + appendExtension(myFilename, (Inkscape::Extension::Output*)_extension); + } return _result; } diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 19bcadc00..91b88d3f0 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Fill and Stroke dialog - implementation +/** + * @file + * Fill and Stroke dialog - implementation. * * Based on the old sp_object_properties_dialog. */ @@ -54,9 +55,9 @@ FillAndStroke::FillAndStroke() contents->pack_start(_notebook, true, true); - _notebook.append_page(_page_fill, _createPageTabLabel(_("_Fill"), INKSCAPE_ICON_OBJECT_FILL)); - _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON_OBJECT_STROKE)); - _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON_OBJECT_STROKE_STYLE)); + _notebook.append_page(_page_fill, _createPageTabLabel(_("_Fill"), INKSCAPE_ICON("object-fill"))); + _notebook.append_page(_page_stroke_paint, _createPageTabLabel(_("Stroke _paint"), INKSCAPE_ICON("object-stroke"))); + _notebook.append_page(_page_stroke_style, _createPageTabLabel(_("Stroke st_yle"), INKSCAPE_ICON("object-stroke-style"))); _layoutPageFill(); _layoutPageStrokePaint(); diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index fe72aa31c..b4be9ce59 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -15,11 +15,9 @@ #ifndef INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H #define INKSCAPE_UI_DIALOG_FILL_AND_STROKE_H -#include <gtkmm/adjustment.h> #include <gtkmm/alignment.h> #include <gtkmm/notebook.h> #include <gtkmm/scale.h> -#include <gtkmm/spinbutton.h> #include <glibmm/i18n.h> #include "ui/widget/panel.h" diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 2699d9201..f5a5041e2 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Filter Effects dialog +/** + * @file + * Filter Effects dialog. */ /* Authors: * Nicholas Bishop <nicholasbishop@gmail.org> @@ -24,7 +25,7 @@ #include <gtkmm/paned.h> #include <gtkmm/scale.h> #include <gtkmm/scrolledwindow.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/stock.h> #include <gtkmm/tooltips.h> #include <glibmm/i18n.h> @@ -48,13 +49,13 @@ #include "filters/convolvematrix.h" #include "filters/displacementmap.h" #include "filters/distantlight.h" +#include "filters/gaussian-blur.h" #include "filters/merge.h" #include "filters/mergenode.h" #include "filters/offset.h" #include "filters/pointlight.h" #include "filters/spotlight.h" #include "sp-filter-primitive.h" -#include "sp-gaussian-blur.h" #include "style.h" #include "svg/svg-color.h" @@ -133,12 +134,12 @@ private: const Glib::ustring _true_val, _false_val; }; -class SpinButtonAttr : public Gtk::SpinButton, public AttrWidget +class SpinButtonAttr : public Inkscape::UI::Widget::SpinButton, public AttrWidget { public: SpinButtonAttr(double lower, double upper, double step_inc, double climb_rate, int digits, const SPAttributeEnum a, double def, char* tip_text) - : Gtk::SpinButton(climb_rate, digits), + : Inkscape::UI::Widget::SpinButton(climb_rate, digits), AttrWidget(a, def) { if (tip_text) _tt.set_tip(*this, tip_text); @@ -248,12 +249,12 @@ public: pack_start(_s2, false, false); } - Gtk::SpinButton& get_spinbutton1() + Inkscape::UI::Widget::SpinButton& get_spinbutton1() { return _s1; } - Gtk::SpinButton& get_spinbutton2() + Inkscape::UI::Widget::SpinButton& get_spinbutton2() { return _s2; } @@ -285,7 +286,7 @@ public: } private: - Gtk::SpinButton _s1, _s2; + Inkscape::UI::Widget::SpinButton _s1, _s2; }; class ColorButton : public Gtk::ColorButton, public AttrWidget @@ -965,10 +966,10 @@ public: _settings.add_spinslider(0, SP_ATTR_ELEVATION, _("Elevation"), 0, 360, 1, 1, 0, _("Direction angle for the light source on the YZ plane, in degrees")); _settings.type(LIGHT_POINT); - _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); + _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); _settings.type(LIGHT_SPOT); - _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); + _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_X, SP_ATTR_Y, SP_ATTR_Z, _("Location:"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); _settings.add_multispinbutton(/*default x:*/ (double) 0, /*default y:*/ (double) 0, /*default z:*/ (double) 0, SP_ATTR_POINTSATX, SP_ATTR_POINTSATY, SP_ATTR_POINTSATZ, _("Points At"), -99999, 99999, 1, 100, 0, _("X coordinate"), _("Y coordinate"), _("Z coordinate")); @@ -1378,7 +1379,8 @@ void FilterEffectsDialog::FilterModifier::rename_filter() FilterEffectsDialog::CellRendererConnection::CellRendererConnection() : Glib::ObjectBase(typeid(CellRendererConnection)), - _primitive(*this, "primitive", 0) + _primitive(*this, "primitive", 0), + _text_width(0) {} Glib::PropertyProxy<void*> FilterEffectsDialog::CellRendererConnection::property_primitive() @@ -2270,7 +2272,7 @@ void FilterEffectsDialog::init_settings_widgets() _settings->type(NR_FILTER_TURBULENCE); // _settings->add_checkbutton(false, SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch"); _settings->add_combo(TURBULENCE_TURBULENCE, SP_ATTR_TYPE, _("Type:"), TurbulenceTypeConverter, _("Indicates whether the filter primitive should perform a noise or turbulence function.")); - _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 0.4, 0.001, 0.01, 3); + _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency:"), 0, 1, 0.001, 0.01, 3); _settings->add_spinslider(1, SP_ATTR_NUMOCTAVES, _("Octaves:"), 1, 10, 1, 1, 0); _settings->add_spinslider(0, SP_ATTR_SEED, _("Seed:"), 0, 1000, 1, 1, 0, _("The starting number for the pseudo random number generator.")); } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index bdae14c62..49bdc0a30 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -1,6 +1,4 @@ -/** - * \brief Find dialog - * +/* * Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Johan Engelen <goejendaagh@zonnet.nl> @@ -50,6 +48,7 @@ #include "sp-use.h" #include "sp-image.h" #include "sp-offset.h" +#include "sp-root.h" #include "xml/repr.h" diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 35cc88090..5215ec167 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Floating dialog implementation. +/** + * @file + * Floating dialog implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> @@ -54,15 +55,16 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : } #if GTK_VERSION_GE(2, 12) -/** \brief A function called when the window gets focus - - This function gets called on a focus event. It figures out how much - time is required for a transition, and the number of steps that'll take, - and sets up the _trans_timer function to do the work. If the transition - time is set to 0 ms it just calls _trans_timer once with _steps equal to - zero so that the transition happens instantaneously. This occurs on - windows as opacity changes cause flicker there. -*/ +/** + * A function called when the window gets focus. + * + * This function gets called on a focus event. It figures out how much + * time is required for a transition, and the number of steps that'll take, + * and sets up the _trans_timer function to do the work. If the transition + * time is set to 0 ms it just calls _trans_timer once with _steps equal to + * zero so that the transition happens instantaneously. This occurs on + * windows as opacity changes cause flicker there. + */ void FloatingBehavior::_focus_event (void) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -89,13 +91,14 @@ void FloatingBehavior::_focus_event (void) return; } -/** \brief Move the opacity of a window towards our goal - - This is a timer function that is set up by _focus_event to slightly - move the opacity of the window along in an animated fashion. It moves - the opacity half way to the goal until it runs out of steps, and then - it just forces the goal. -*/ +/** + * Move the opacity of a window towards our goal. + * + * This is a timer function that is set up by _focus_event to slightly + * move the opacity of the window along in an animated fashion. It moves + * the opacity half way to the goal until it runs out of steps, and then + * it just forces the goal. + */ bool FloatingBehavior::_trans_timer (void) { // printf("Go go gadget timer: %d\n", _steps); if (_steps == 0) { @@ -220,7 +223,7 @@ FloatingBehavior::onDesktopActivated (SPDesktop *desktop) } // we're done, allow next retransientizing not sooner than after 120 msec - gtk_timeout_add (120, (GtkFunction) sp_retransientize_again, (gpointer) _d); + g_timeout_add (120, (GSourceFunc) sp_retransientize_again, (gpointer) _d); } diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index f3d7ed971..6d823e6de 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * Abhishek Sharma @@ -22,9 +18,7 @@ #include <gtkmm/treemodelcolumn.h> #include <gtkmm/widget.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkversion.h> +#include <gtk/gtk.h> #include "glyphs.h" @@ -48,7 +42,6 @@ GlyphsPanel &GlyphsPanel::getInstance() } -#if GLIB_CHECK_VERSION(2,14,0) static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() { static bool init = false; @@ -123,8 +116,6 @@ static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() mappings[G_UNICODE_SCRIPT_PHOENICIAN] = _("Phoenician"); mappings[G_UNICODE_SCRIPT_PHAGS_PA] = _("Phags-pa"); mappings[G_UNICODE_SCRIPT_NKO] = _("N'Ko"); - -#if GLIB_CHECK_VERSION(2,14,0) mappings[G_UNICODE_SCRIPT_KAYAH_LI] = _("Kayah Li"); mappings[G_UNICODE_SCRIPT_LEPCHA] = _("Lepcha"); mappings[G_UNICODE_SCRIPT_REJANG] = _("Rejang"); @@ -136,11 +127,9 @@ static std::map<GUnicodeScript, Glib::ustring> & getScriptToName() mappings[G_UNICODE_SCRIPT_CARIAN] = _("Carian"); mappings[G_UNICODE_SCRIPT_LYCIAN] = _("Lycian"); mappings[G_UNICODE_SCRIPT_LYDIAN] = _("Lydian"); -#endif // GLIB_CHECK_VERSION(2,14,0) } return mappings; } -#endif // GLIB_CHECK_VERSION(2,14,0) typedef std::pair<gunichar, gunichar> Range; typedef std::pair<Range, Glib::ustring> NamedRange; @@ -337,9 +326,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : entry(0), label(0), insertBtn(0), -#if GLIB_CHECK_VERSION(2,14,0) scriptCombo(0), -#endif // GLIB_CHECK_VERSION(2,14,0) fsel(0), targetDesktop(0), deskTrack(), @@ -366,7 +353,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- -#if GLIB_CHECK_VERSION(2,14,0) { Gtk::Label *label = new Gtk::Label(_("Script: ")); table->attach( *Gtk::manage(label), @@ -391,7 +377,6 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : } row++; -#endif // GLIB_CHECK_VERSION(2,14,0) // ------------------------------- @@ -464,10 +449,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn = new Gtk::Button(_("Append")); conn = insertBtn->signal_clicked().connect(sigc::mem_fun(*this, &GlyphsPanel::insertText)); instanceConns.push_back(conn); -#if GTK_CHECK_VERSION(2,18,0) - //gtkmm 2.18 insertBtn->set_can_default(); -#endif insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); @@ -607,13 +589,11 @@ void GlyphsPanel::glyphSelectionChanged() Glib::ustring scriptName; -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = g_unichar_get_script(ch); std::map<GUnicodeScript, Glib::ustring> mappings = getScriptToName(); if (mappings.find(script) != mappings.end()) { scriptName = mappings[script]; } -#endif gchar * tmp = g_strdup_printf("U+%04X %s", ch, scriptName.c_str()); label->set_text(tmp); } @@ -680,7 +660,6 @@ void GlyphsPanel::rebuild() if (font) { //double sp_font_selector_get_size (SPFontSelector *fsel); -#if GLIB_CHECK_VERSION(2,14,0) GUnicodeScript script = G_UNICODE_SCRIPT_INVALID_CODE; Glib::ustring scriptName = scriptCombo->get_active_text(); std::map<GUnicodeScript, Glib::ustring> items = getScriptToName(); @@ -690,7 +669,6 @@ void GlyphsPanel::rebuild() break; } } -#endif // GLIB_CHECK_VERSION(2,14,0) // Disconnect the model while we update it. Simple work-around for 5x+ performance boost. Glib::RefPtr<Gtk::ListStore> tmp = Gtk::ListStore::create(*getColumns()); @@ -707,13 +685,9 @@ void GlyphsPanel::rebuild() for (gunichar ch = lower; ch <= upper; ch++) { int glyphId = font->MapUnicodeChar(ch); if (glyphId > 0) { -#if GLIB_CHECK_VERSION(2,14,0) if ((script == G_UNICODE_SCRIPT_INVALID_CODE) || (script == g_unichar_get_script(ch))) { present.push_back(ch); } -#else - present.push_back(ch); -#endif } } diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index d6c731dda..5dbfb9af5 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -1,7 +1,3 @@ -/** - * Glyph selector dialog. - */ - /* Authors: * Jon A. Cruz * @@ -40,7 +36,6 @@ class GlyphColumns; /** * A panel that displays character glyphs. */ - class GlyphsPanel : public Inkscape::UI::Widget::Panel { public: @@ -77,9 +72,7 @@ private: Gtk::Entry *entry; Gtk::Label *label; Gtk::Button *insertBtn; -#if GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *scriptCombo; -#endif //GLIB_CHECK_VERSION(2,14,0) Gtk::ComboBoxText *rangeCombo; SPFontSelector *fsel; SPDesktop *targetDesktop; diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index bd9777048..e353178ed 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Simple guideline dialog +/** + * @file + * Simple guideline dialog. */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> @@ -15,9 +16,9 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif +#include "guides.h" + #include "display/guideline.h" -#include "helper/unit-menu.h" -#include "helper/units.h" #include "desktop.h" #include "document.h" #include "sp-guide.h" @@ -25,14 +26,13 @@ #include "desktop-handles.h" #include "event-context.h" #include "widgets/desktop-widget.h" -#include "sp-metrics.h" #include <glibmm/i18n.h> #include "dialogs/dialog-events.h" #include "message-context.h" #include "xml/repr.h" + #include <2geom/point.h> #include <2geom/angle.h> -#include "guides.h" namespace Inkscape { namespace UI { @@ -40,19 +40,22 @@ namespace Dialogs { GuidelinePropertiesDialog::GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop) : _desktop(desktop), _guide(guide), - _label_units(_("Unit:")), - _label_X(_("X:")), - _label_Y(_("Y:")), - _label_degrees(_("Angle (degrees):")), _relative_toggle(_("Rela_tive change"), _("Move and/or rotate the guide relative to current settings")), - _adjustment_x(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adjustment_y(0.0, -1e6, 1e6, 1.0, 10.0, 10.0), - _adj_angle(0.0, -360, 360, 1.0, 10.0, 10.0), - _unit_selector(NULL), _mode(true), _oldpos(0.,0.), _oldangle(0.0) + _spin_button_x(_("_X:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _spin_button_y(_("_Y:"), "", UNIT_TYPE_LINEAR, "", "", &_unit_menu), + _label_entry(_("_Label:"), _("Optionally give this guideline a name")), + _spin_angle(_("_Angle:"), "", UNIT_TYPE_RADIAL), + _mode(true), _oldpos(0.,0.), _oldangle(0.0) { } +bool GuidelinePropertiesDialog::_relative_toggle_status = false; // initialize relative checkbox status for when this dialog is opened for first time +Glib::ustring GuidelinePropertiesDialog::_angle_unit_status = "deg"; // initialize angle unit status + GuidelinePropertiesDialog::~GuidelinePropertiesDialog() { + // save current status + _relative_toggle_status = _relative_toggle.get_active(); + _angle_unit_status = _spin_angle.getUnit().abbr; } void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { @@ -61,30 +64,35 @@ void GuidelinePropertiesDialog::showDialog(SPGuide *guide, SPDesktop *desktop) { dialog.run(); } +void GuidelinePropertiesDialog::_colorChanged() +{ + const Gdk::Color c = _color.get_color(); + char r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; + //TODO: why 257? verify this! + sp_guide_set_color(*_guide, r, g, b, true); +} + void GuidelinePropertiesDialog::_modeChanged() { _mode = !_relative_toggle.get_active(); if (!_mode) { // relative - _spin_angle.set_value(0); + _spin_angle.setValue(0); - _spin_button_y.set_value(0); - _spin_button_x.set_value(0); + _spin_button_y.setValue(0); + _spin_button_x.setValue(0); } else { // absolute - _spin_angle.set_value(_oldangle); + _spin_angle.setValueKeepUnit(_oldangle, "deg"); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const val_y = sp_pixels_get_units(_oldpos[Geom::Y], unit); - _spin_button_y.set_value(val_y); - gdouble const val_x = sp_pixels_get_units(_oldpos[Geom::X], unit); - _spin_button_x.set_value(val_x); + _spin_button_x.setValueKeepUnit(_oldpos[Geom::X], "px"); + _spin_button_y.setValueKeepUnit(_oldpos[Geom::Y], "px"); } } void GuidelinePropertiesDialog::_onApply() { - double deg_angle = _spin_angle.get_value(); + double deg_angle = _spin_angle.getValue("deg"); if (!_mode) deg_angle += _oldangle; Geom::Point normal; @@ -98,17 +106,17 @@ void GuidelinePropertiesDialog::_onApply() } sp_guide_set_normal(*_guide, normal, true); - SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(_unit_selector->gobj())); - gdouble const raw_dist_x = _spin_button_x.get_value(); - gdouble const points_x = sp_units_get_pixels(raw_dist_x, unit); - gdouble const raw_dist_y = _spin_button_y.get_value(); - gdouble const points_y = sp_units_get_pixels(raw_dist_y, unit); + double const points_x = _spin_button_x.getValue("px"); + double const points_y = _spin_button_y.getValue("px"); Geom::Point newpos(points_x, points_y); if (!_mode) newpos += _oldpos; sp_guide_moveto(*_guide, newpos, true); + const gchar* name = _label_entry.getEntry()->get_text().c_str(); + sp_guide_set_label(*_guide, name, true); + DocumentUndo::done(_guide->document, SP_VERB_NONE, _("Set guide properties")); } @@ -172,52 +180,61 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_alignment(0, 0.5); // indent - _layout_table.attach(*manage(new Gtk::Label(" ")), - 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); +// _layout_table.attach(*manage(new Gtk::Label(" ")), +// 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 10); - // mode radio button - _layout_table.attach(_relative_toggle, - 1, 3, 9, 10, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _layout_table.attach(_label_entry, + 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + + _layout_table.attach(_color, + 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _color.signal_color_set().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_colorChanged)); - // unitmenu + + // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ - GtkWidget *unit_selector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); - sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unit_selector), _desktop->namedview->doc_units); - _unit_selector = Gtk::manage(Glib::wrap(unit_selector)); + _unit_menu.setUnitType(UNIT_TYPE_LINEAR); + _unit_menu.setUnit("px"); + if (_desktop->namedview->doc_units) { + _unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); + } + _spin_angle.setUnit(_angle_unit_status); // position spinbuttons - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_x.gobj())); - sp_unit_selector_add_adjustment(SP_UNIT_SELECTOR(unit_selector), GTK_ADJUSTMENT(_adjustment_y.gobj())); - _spin_button_x.configure(_adjustment_x, 1.0 , 3); - _spin_button_x.set_numeric(); - _spin_button_y.configure(_adjustment_y, 1.0 , 3); - _spin_button_y.set_numeric(); - _layout_table.attach(_label_X, - 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_button_x.setDigits(3); + _spin_button_x.setIncrements(1.0, 10.0); + _spin_button_x.setRange(-1e6, 1e6); + _spin_button_y.setDigits(3); + _spin_button_y.setIncrements(1.0, 10.0); + _spin_button_y.setRange(-1e6, 1e6); _layout_table.attach(_spin_button_x, - 2, 3, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_Y, - 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); _layout_table.attach(_spin_button_y, - 2, 3, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - gtk_signal_connect_object(GTK_OBJECT(_spin_button_x.gobj()), "activate", - GTK_SIGNAL_FUNC(gtk_window_activate_default), - gobj()); + 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_label_units, - 1, 2, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(*_unit_selector, - 2, 3, 6, 7, Gtk::FILL, Gtk::FILL); + _layout_table.attach(_unit_menu, + 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); // angle spinbutton - _spin_angle.configure(_adj_angle, 5.0 , 3); - _spin_angle.set_numeric(); - _spin_angle.show(); - _layout_table.attach(_label_degrees, - 1, 2, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _spin_angle.setDigits(3); + _spin_angle.setIncrements(1.0, 10.0); + _spin_angle.setRange(-3600., 3600.); _layout_table.attach(_spin_angle, - 2, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + + // mode radio button + _layout_table.attach(_relative_toggle, + 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); + _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); + _relative_toggle.set_active(_relative_toggle_status); + + // don't know what this exactly does, but it results in that the dialog closes when entering a value and pressing enter (see LP bug 484187) + g_signal_connect_swapped(G_OBJECT(_spin_button_x.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_button_y.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); + g_signal_connect_swapped(G_OBJECT(_spin_angle.getWidget()->gobj()), "activate", + G_CALLBACK(gtk_window_activate_default), gobj()); // dialog @@ -249,17 +266,20 @@ void GuidelinePropertiesDialog::_setup() { g_free(label); } + // init name entry + _label_entry.getEntry()->set_text(_guide->label ? _guide->label : ""); + Gdk::Color c; + c.set_rgb_p(((_guide->color>>24)&0xff) / 255.0, ((_guide->color>>16)&0xff) / 255.0, ((_guide->color>>8)&0xff) / 255.0); + _color.set_color(c); + _modeChanged(); // sets values of spinboxes. if ( _oldangle == 90. || _oldangle == 270. || _oldangle == -90. || _oldangle == -270.) { - _spin_button_x.grab_focus(); - _spin_button_x.select_region(0, 20); + _spin_button_x.grabFocusAndSelectEntry(); } else if ( _oldangle == 0. || _oldangle == 180. || _oldangle == -180.) { - _spin_button_y.grab_focus(); - _spin_button_y.select_region(0, 20); + _spin_button_y.grabFocusAndSelectEntry(); } else { - _spin_angle.grab_focus(); - _spin_angle.select_region(0, 20); + _spin_angle.grabFocusAndSelectEntry(); } set_position(Gtk::WIN_POS_MOUSE); diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 2817e2644..20136fbff 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -1,7 +1,4 @@ -/** - * - * \brief Dialog for modifying guidelines - * +/* * Author: * Andrius R. <knutux@gmail.com> * Johan Engelen @@ -20,13 +17,29 @@ #include <gtkmm/label.h> #include <gtkmm/stock.h> #include <gtkmm/adjustment.h> +#include <gtkmm/colorbutton.h> #include "ui/widget/button.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/unit-menu.h" +#include "ui/widget/scalar-unit.h" +#include "ui/widget/entry.h" #include <2geom/point.h> +class SPGuide; +class SPDesktop; + namespace Inkscape { namespace UI { + +namespace Widget { + class UnitMenu; +}; + namespace Dialogs { +/** + * Dialog for modifying guidelines. + */ class GuidelinePropertiesDialog : public Gtk::Dialog { public: GuidelinePropertiesDialog(SPGuide *guide, SPDesktop *desktop); @@ -45,6 +58,7 @@ protected: void _response(gint response); void _modeChanged(); + void _colorChanged(); private: GuidelinePropertiesDialog(GuidelinePropertiesDialog const &); // no copy @@ -55,20 +69,17 @@ private: Gtk::Table _layout_table; Gtk::Label _label_name; Gtk::Label _label_descr; - Gtk::Label _label_units; - Gtk::Label _label_X; - Gtk::Label _label_Y; - Gtk::Label _label_degrees; Inkscape::UI::Widget::CheckButton _relative_toggle; - Gtk::Adjustment _adjustment_x; - Gtk::SpinButton _spin_button_x; - Gtk::Adjustment _adjustment_y; - Gtk::SpinButton _spin_button_y; + static bool _relative_toggle_status; // remember the status of the _relative_toggle_status button across instances + Inkscape::UI::Widget::UnitMenu _unit_menu; + Inkscape::UI::Widget::ScalarUnit _spin_button_x; + Inkscape::UI::Widget::ScalarUnit _spin_button_y; + Inkscape::UI::Widget::Entry _label_entry; + Gtk::ColorButton _color; - Gtk::Adjustment _adj_angle; - Gtk::SpinButton _spin_angle; + Inkscape::UI::Widget::ScalarUnit _spin_angle; + static Glib::ustring _angle_unit_status; // remember the status of the _relative_toggle_status button across instances - Gtk::Widget *_unit_selector; bool _mode; Geom::Point _oldpos; gdouble _oldangle; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index bb566fb7f..a2b952677 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A simple dialog for previewing icon representation. +/** + * @file + * A simple dialog for previewing icon representation. */ /* Authors: * Jon A. Cruz @@ -16,8 +17,9 @@ # include <config.h> #endif +#include <boost/scoped_ptr.hpp> #include <gtk/gtk.h> -#include <glib/gmem.h> +#include <glib.h> #include <glibmm/i18n.h> #include <gtkmm/alignment.h> #include <gtkmm/buttonbox.h> @@ -25,7 +27,7 @@ #include "desktop.h" #include "desktop-handles.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "document.h" #include "inkscape.h" #include "preferences.h" @@ -36,10 +38,11 @@ #include "icon-preview.h" extern "C" { -// takes doc, root, icon, and icon name to produce pixels +// takes doc, drawing, icon, and icon name to produce pixels +// this is defined in widgets/icon.cpp guchar * -sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, - const gchar *name, unsigned int psize ); +sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, + const gchar *name, unsigned int psize, unsigned &stride); } #define noICON_VERBOSE 1 @@ -167,10 +170,11 @@ IconPreviewPanel::IconPreviewPanel() : int previous = 0; int avail = 0; for ( int i = numEntries - 1; i >= 0; --i ) { - pixMem[i] = new guchar[4 * sizes[i] * sizes[i]]; - memset( pixMem[i], 0x00, 4 * sizes[i] * sizes[i] ); + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); + pixMem[i] = new guchar[sizes[i] * stride]; + memset( pixMem[i], 0x00, sizes[i] * stride ); - GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], sizes[i] * 4, /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL ); + GdkPixbuf *pb = gdk_pixbuf_new_from_data( pixMem[i], GDK_COLORSPACE_RGB, TRUE, 8, sizes[i], sizes[i], stride, /*(GdkPixbufDestroyNotify)g_free*/NULL, NULL ); GtkImage* img = GTK_IMAGE( gtk_image_new_from_pixbuf( pb ) ); images[i] = Glib::wrap(img); Glib::ustring label(*labels[i]); @@ -355,11 +359,10 @@ void IconPreviewPanel::refreshPreview() GSList const *items = sel->itemList(); while ( items && !target ) { SPItem* item = SP_ITEM( items->data ); - SPObject * obj = item; - gchar const *id = obj->getId(); + gchar const *id = item->getId(); if ( id ) { targetId = id; - target = obj; + target = item; } items = g_slist_next(items); @@ -438,32 +441,29 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id ); #endif // ICON_VERBOSE - NRArenaItem *root = NULL; - - /* Create new arena */ - NRArena *arena = NRArena::create(); + Inkscape::Drawing drawing; - /* Create ArenaItem and set transform */ + /* Create drawing items and set transform */ unsigned int visionkey = SPItem::display_key_new(1); - - root = SP_ITEM( doc->getRoot() )->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + drawing.setRoot(doc->getRoot()->invoke_show( drawing, visionkey, SP_ITEM_SHOW_DISPLAY )); for ( int i = 0; i < numEntries; i++ ) { - guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] ); + unsigned unused; + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); + guchar * px = sp_icon_doc_icon( doc, drawing, id, sizes[i], unused); // g_message( " size %d %s", sizes[i], (px ? "worked" : "failed") ); if ( px ) { - memcpy( pixMem[i], px, sizes[i] * sizes[i] * 4 ); + memcpy( pixMem[i], px, sizes[i] * stride ); g_free( px ); px = 0; } else { - memset( pixMem[i], 0, sizes[i] * sizes[i] * 4 ); + memset( pixMem[i], 0, sizes[i] * stride ); } images[i]->queue_draw(); } updateMagnify(); - SP_ITEM(doc->getRoot())->invoke_hide(visionkey); - nr_object_unref((NRObject *) arena); + doc->getRoot()->invoke_hide(visionkey); renderTimer->stop(); minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); #if ICON_VERBOSE diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 9c10eb89b..ec4b3cac4 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -26,7 +26,7 @@ #include "ui/widget/panel.h" #include "desktop-tracker.h" -struct SPObject; +class SPObject; namespace Glib { class Timer; } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d10902722..cb4d2b755 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Inkscape Preferences dialog - implementation +/** + * @file + * Inkscape Preferences dialog - implementation. */ /* Authors: * Carl Hetherington @@ -7,7 +8,7 @@ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bruno Dilly <bruno.dilly@gmail.com> * - * Copyright (C) 2004-2007 Authors + * Copyright (C) 2004-2011 Authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -21,7 +22,7 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/alignment.h> -#include <gtk/gtkicontheme.h> +#include <gtk/gtk.h> #include "preferences.h" #include "inkscape-preferences.h" @@ -38,9 +39,10 @@ #include "selection-chemistry.h" #include "xml/repr.h" #include "ui/widget/style-swatch.h" +#include "ui/widget/spinbutton.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" -#include "color-profile-fns.h" +#include "cms-system.h" #include "color-profile.h" #include "display/canvas-grid.h" #include "path-prefix.h" @@ -61,6 +63,7 @@ using Inkscape::UI::Widget::PrefCheckButton; using Inkscape::UI::Widget::PrefRadioButton; using Inkscape::UI::Widget::PrefSpinButton; using Inkscape::UI::Widget::StyleSwatch; +using Inkscape::CMSSystem; InkscapePreferences::InkscapePreferences() @@ -70,7 +73,7 @@ InkscapePreferences::InkscapePreferences() _current_page(0) { //get the width of a spinbutton - Gtk::SpinButton* sb = new Gtk::SpinButton; + Inkscape::UI::Widget::SpinButton* sb = new Inkscape::UI::Widget::SpinButton; sb->set_width_chars(6); _getContents()->add(*sb); show_all_children(); @@ -122,7 +125,7 @@ InkscapePreferences::InkscapePreferences() initPageTransforms(); initPageClones(); initPageMasks(); - initPageFilters(); + initPageRendering(); initPageBitmaps(); initPageCMS(); initPageGrids(); @@ -248,17 +251,17 @@ void InkscapePreferences::initPageSteps() { this->AddPage(_page_steps, _("Steps"), PREFS_PAGE_STEPS); - _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _steps_arrow.init ( "/options/nudgedistance/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //nudgedistance is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, _("px"), - _("Pressing an arrow key moves selected object(s) or node(s) by this distance (in px units)"), false); - _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false); + _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, "", + _("Pressing an arrow key moves selected object(s) or node(s) by this distance"), false); + _steps_scale.init ( "/options/defaultscale/value", 0.0, 1000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); //defaultscale is limited to 1000 in select-context.cpp: use the same limit here - _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, _("px"), - _("Pressing > or < scales selection up or down by this increment (in px units)"), false); - _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false); - _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, _("px"), - _("Inset and Outset commands displace the path by this distance (in px units)"), false); + _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, "", + _("Pressing > or < scales selection up or down by this increment"), false); + _steps_inset.init ( "/options/defaultoffsetwidth/value", 0.0, 3000.0, 0.01, 2.0, UNIT_TYPE_LINEAR, "px"); + _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, "", + _("Inset and Outset commands displace the path by this distance"), false); _steps_compass.init ( _("Compass-like display of angles"), "/options/compassangledisplay/value", true); _page_steps.add_line( false, "", _steps_compass, "", _("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise")); @@ -269,6 +272,9 @@ void InkscapePreferences::initPageSteps() _steps_rot_snap.init("/options/rotationsnapsperpi/value", labels, values, num_items, 12); _page_steps.add_line( false, _("Rotation snaps every:"), _steps_rot_snap, _("degrees"), _("Rotating with Ctrl pressed snaps every that much degrees; also, pressing [ or ] rotates by this amount"), false); + _steps_rot_relative.init ( _("Relative snapping of guideline angles"), "/options/relativeguiderotationsnap/value", false); + _page_steps.add_line( false, "", _steps_rot_relative, "", + _("When on, the snap angles when rotating a guideline will be relative to the original angle")); _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true); _page_steps.add_line( false, _("Zoom in/out by:"), _steps_zoom, _("%"), _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); @@ -393,7 +399,7 @@ void InkscapePreferences::initPageTools() Gtk::TreeModel::iterator iter_tools = this->AddPage(_page_tools, _("Tools"), PREFS_PAGE_TOOLS); _path_tools = _page_list.get_model()->get_path(iter_tools); - _page_tools.add_group_header( _("Bounding box to use:")); + _page_tools.add_group_header( _("Bounding box to use")); _t_bbox_visual.init ( _("Visual bounding box"), "/tools/bounding_box", 0, false, 0); // 0 means visual _page_tools.add_line( true, "", _t_bbox_visual, "", _("This bounding box includes stroke width, markers, filter margins, etc.")); @@ -401,7 +407,7 @@ void InkscapePreferences::initPageTools() _page_tools.add_line( true, "", _t_bbox_geometric, "", _("This bounding box includes only the bare path")); - _page_tools.add_group_header( _("Conversion to guides:")); + _page_tools.add_group_header( _("Conversion to guides")); _t_cvg_keep_objects.init ( _("Keep objects after conversion to guides"), "/tools/cvg_keep_objects", false); _page_tools.add_line( true, "", _t_cvg_keep_objects, "", _("When converting an object to guides, don't delete the object after the conversion")); @@ -418,14 +424,14 @@ void InkscapePreferences::initPageTools() this->AddPage(_page_selector, _("Selector"), iter_tools, PREFS_PAGE_TOOLS_SELECTOR); AddSelcueCheckbox(_page_selector, "/tools/select", false); - _page_selector.add_group_header( _("When transforming, show:")); + _page_selector.add_group_header( _("When transforming, show")); _t_sel_trans_obj.init ( _("Objects"), "/tools/select/show", "content", true, 0); _page_selector.add_line( true, "", _t_sel_trans_obj, "", _("Show the actual objects when moving or transforming")); _t_sel_trans_outl.init ( _("Box outline"), "/tools/select/show", "outline", false, &_t_sel_trans_obj); _page_selector.add_line( true, "", _t_sel_trans_outl, "", _("Show only a box outline of the objects when moving or transforming")); - _page_selector.add_group_header( _("Per-object selection cue:")); + _page_selector.add_group_header( _("Per-object selection cue")); _t_sel_cue_none.init ( _("None"), "/options/selcue/value", Inkscape::SelCue::NONE, false, 0); _page_selector.add_line( true, "", _t_sel_cue_none, "", _("No per-object selection indication")); @@ -479,6 +485,12 @@ void InkscapePreferences::initPageTools() AddSelcueCheckbox(_page_zoom, "/tools/zoom", true); AddGradientCheckbox(_page_zoom, "/tools/zoom", false); + //Measure + this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); + PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); + cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); + _page_measure.add_line( false, "", *cb, "", _("The start and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); + //Shapes Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES); _path_shapes = _page_list.get_model()->get_path(iter_shapes); @@ -646,20 +658,20 @@ void InkscapePreferences::initPageClones() _clone_option_delete.init ( _("Are deleted"), "/options/cloneorphans/value", SP_CLONE_ORPHANS_DELETE, false, &_clone_option_unlink); - _page_clones.add_group_header( _("When the original moves, its clones and linked offsets:")); + _page_clones.add_group_header( _("Moving original: clones and linked offsets")); _page_clones.add_line( true, "", _clone_option_parallel, "", _("Clones are translated by the same vector as their original")); _page_clones.add_line( true, "", _clone_option_stay, "", _("Clones preserve their positions when their original is moved")); _page_clones.add_line( true, "", _clone_option_transform, "", _("Each clone moves according to the value of its transform= attribute; for example, a rotated clone will move in a different direction than its original")); - _page_clones.add_group_header( _("When the original is deleted, its clones:")); + _page_clones.add_group_header( _("Deleting original: clones")); _page_clones.add_line( true, "", _clone_option_unlink, "", _("Orphaned clones are converted to regular objects")); _page_clones.add_line( true, "", _clone_option_delete, "", _("Orphaned clones are deleted along with their original")); - _page_clones.add_group_header( _("When duplicating original+clones:")); + _page_clones.add_group_header( _("Duplicating original+clones/linked offset")); _clone_relink_on_duplicate.init ( _("Relink duplicated clones"), "/options/relinkclonesonduplicate/value", false); _page_clones.add_line(true, "", _clone_relink_on_duplicate, "", @@ -728,8 +740,22 @@ void InkscapePreferences::initPageTransforms() this->AddPage(_page_transforms, _("Transforms"), PREFS_PAGE_TRANSFORMS); } -void InkscapePreferences::initPageFilters() +void InkscapePreferences::initPageRendering() { + /* show infobox */ + _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); + _page_rendering.add_line(true, "", _show_filters_info_box, "", + _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); + + /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded + _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); + _page_rendering.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), + _("Configure number of processors/threads to use when rendering filters"), false); + + // rendering cache + _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 64.0, true, false); + _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); + /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", BLUR_QUALITY_BEST, false, 0); @@ -742,16 +768,16 @@ void InkscapePreferences::initPageFilters() _blur_quality_worst.init ( _("Lowest quality (fastest)"), "/options/blurquality/value", BLUR_QUALITY_WORST, false, &_blur_quality_best); - _page_filters.add_group_header( _("Gaussian blur quality for display")); - _page_filters.add_line( true, "", _blur_quality_best, "", + _page_rendering.add_group_header( _("Gaussian blur quality for display")); + _page_rendering.add_line( true, "", _blur_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _blur_quality_better, "", + _page_rendering.add_line( true, "", _blur_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _blur_quality_normal, "", + _page_rendering.add_line( true, "", _blur_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _blur_quality_worse, "", + _page_rendering.add_line( true, "", _blur_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _blur_quality_worst, "", + _page_rendering.add_line( true, "", _blur_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); /* filter quality */ @@ -766,29 +792,19 @@ void InkscapePreferences::initPageFilters() _filter_quality_worst.init ( _("Lowest quality (fastest)"), "/options/filterquality/value", Inkscape::Filters::FILTER_QUALITY_WORST, false, &_filter_quality_best); - _page_filters.add_group_header( _("Filter effects quality for display")); - _page_filters.add_line( true, "", _filter_quality_best, "", + _page_rendering.add_group_header( _("Filter effects quality for display")); + _page_rendering.add_line( true, "", _filter_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _filter_quality_better, "", + _page_rendering.add_line( true, "", _filter_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _filter_quality_normal, "", + _page_rendering.add_line( true, "", _filter_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _filter_quality_worse, "", + _page_rendering.add_line( true, "", _filter_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _filter_quality_worst, "", + _page_rendering.add_line( true, "", _filter_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); - /* show infobox */ - _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); - _page_filters.add_line(true, "", _show_filters_info_box, "", - _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); - - /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded - _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); - _page_filters.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), - _("Configure number of processors/threads to use with rendering of gaussian blur"), false); - - this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS); + this->AddPage(_page_rendering, _("Rendering"), PREFS_PAGE_RENDERING); } @@ -848,7 +864,7 @@ static void profileComboChanged( Gtk::ComboBoxText* combo ) } else { Glib::ustring active = combo->get_active_text(); - Glib::ustring path = get_path_for_profile(active); + Glib::ustring path = CMSSystem::getPathForProfile(active); if ( !path.empty() ) { prefs->setString("/options/displayprofile/uri", path); } @@ -858,7 +874,7 @@ static void profileComboChanged( Gtk::ComboBoxText* combo ) static void proofComboChanged( Gtk::ComboBoxText* combo ) { Glib::ustring active = combo->get_active_text(); - Glib::ustring path = get_path_for_profile(active); + Glib::ustring path = CMSSystem::getPathForProfile(active); if ( !path.empty() ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -896,8 +912,8 @@ void InkscapePreferences::initPageCMS() _page_cms.add_group_header( _("Display adjustment")); Glib::ustring tmpStr; - std::list<Glib::ustring> sources = ColorProfile::getBaseProfileDirs(); - for ( std::list<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) { + std::vector<Glib::ustring> sources = ColorProfile::getBaseProfileDirs(); + for ( std::vector<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) { gchar* part = g_strdup_printf( "\n%s", it->c_str() ); tmpStr += part; g_free(part); @@ -965,7 +981,7 @@ void InkscapePreferences::initPageCMS() #if ENABLE_LCMS { - std::vector<Glib::ustring> names = ::Inkscape::colorprofile_get_display_names(); + std::vector<Glib::ustring> names = ::Inkscape::CMSSystem::getDisplayNames(); Glib::ustring current = prefs->getString( "/options/displayprofile/uri" ); gint index = 0; @@ -973,7 +989,7 @@ void InkscapePreferences::initPageCMS() index++; for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) { _cms_display_profile.append_text( *it ); - Glib::ustring path = get_path_for_profile(*it); + Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_display_profile.set_active(index); } @@ -983,12 +999,12 @@ void InkscapePreferences::initPageCMS() _cms_display_profile.set_active(0); } - names = ::Inkscape::colorprofile_get_softproof_names(); + names = ::Inkscape::CMSSystem::getSoftproofNames(); current = prefs->getString("/options/softproof/uri"); index = 0; for ( std::vector<Glib::ustring>::iterator it = names.begin(); it != names.end(); ++it ) { _cms_proof_profile.append_text( *it ); - Glib::ustring path = get_path_for_profile(*it); + Glib::ustring path = CMSSystem::getPathForProfile(*it); if ( !path.empty() && path == current ) { _cms_proof_profile.set_active(index); } @@ -1033,10 +1049,14 @@ void InkscapePreferences::initPageGrids() _grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false); _grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); _grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); + _grids_xy_origin_x.set_digits(5); + _grids_xy_origin_y.set_digits(5); _grids_xy.add_line( false, _("Origin X:"), _grids_xy_origin_x, "", _("X coordinate of grid origin"), false); _grids_xy.add_line( false, _("Origin Y:"), _grids_xy_origin_y, "", _("Y coordinate of grid origin"), false); _grids_xy_spacing_x.init("/options/grids/xy/spacing_x", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); _grids_xy_spacing_y.init("/options/grids/xy/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); + _grids_xy_spacing_x.set_digits(5); + _grids_xy_spacing_y.set_digits(5); _grids_xy.add_line( false, _("Spacing X:"), _grids_xy_spacing_x, "", _("Distance between vertical grid lines"), false); _grids_xy.add_line( false, _("Spacing Y:"), _grids_xy_spacing_y, "", _("Distance between horizontal grid lines"), false); @@ -1054,9 +1074,12 @@ void InkscapePreferences::initPageGrids() _grids_axonom.add_line( false, _("Grid units:"), _grids_axonom_units, "", "", false); _grids_axonom_origin_x.init("/options/grids/axonom/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); _grids_axonom_origin_y.init("/options/grids/axonom/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false); + _grids_axonom_origin_x.set_digits(5); + _grids_axonom_origin_y.set_digits(5); _grids_axonom.add_line( false, _("Origin X:"), _grids_axonom_origin_x, "", _("X coordinate of grid origin"), false); _grids_axonom.add_line( false, _("Origin Y:"), _grids_axonom_origin_y, "", _("Y coordinate of grid origin"), false); _grids_axonom_spacing_y.init("/options/grids/axonom/spacing_y", -10000.0, 10000.0, 0.1, 1.0, 1.0, false, false); + _grids_axonom_spacing_y.set_digits(5); _grids_axonom.add_line( false, _("Spacing Y:"), _grids_axonom_spacing_y, "", _("Base length of z-axis"), false); _grids_axonom_angle_x.init("/options/grids/axonom/angle_x", -360.0, 360.0, 1.0, 10.0, 30.0, false, false); _grids_axonom_angle_z.init("/options/grids/axonom/angle_z", -360.0, 360.0, 1.0, 10.0, 30.0, false, false); @@ -1101,6 +1124,42 @@ void InkscapePreferences::initPageSVGOutput() _svgoutput_minimumexponent.init("/options/svgoutput/minimumexponent", -32.0, -1, 1.0, 2.0, -8.0, true, false); _page_svgoutput.add_line( false, _("Minimum exponent:"), _svgoutput_minimumexponent, "", _("The smallest number written to SVG is 10 to the power of this exponent; anything smaller is written as zero"), false); + /* Code to add controls for attribute checking options */ + + /* Add incorrect style properties options */ + _page_svgoutput.add_group_header( _("Improper Attributes Actions")); + + _svgoutput_attrwarn.init( _("Print warnings"), "/options/svgoutput/incorrect_attributes_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_attrwarn, "", _("Print warning if invalid or non-useful attributes found. Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_attrremove.init( _("Remove attributes"), "/options/svgoutput/incorrect_attributes_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_attrremove, "", _("Delete invalid or non-useful attributes from element tag."), false); + + /* Add incorrect style properties options */ + _page_svgoutput.add_group_header( _("Inappropriate Style Properties Actions")); + + _svgoutput_stylepropwarn.init( _("Print warnings"), "/options/svgoutput/incorrect_style_properties_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_stylepropwarn, "", _("Print warning if inappropriate style properties found (i.e. 'font-family' set on a <rect>). Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_stylepropremove.init( _("Remove style properties"), "/options/svgoutput/incorrect_style_properties_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_stylepropremove, "", _("Delete inappropriate style properties."), false); + + /* Add default or inherited style properties options */ + _page_svgoutput.add_group_header( _("Non-useful Style Properties Actions")); + + _svgoutput_styledefaultswarn.init( _("Print warnings"), "/options/svgoutput/style_defaults_warn", true); + _page_svgoutput.add_line( false, "", _svgoutput_styledefaultswarn, "", _("Print warning if redundant style properties found (i.e. if a property has the default value and a different value is not inherited or if value is the same as would be inherited). Database files located in inkscape_data_dir/attributes."), false); + _svgoutput_styledefaultsremove.init( _("Remove style properties"), "/options/svgoutput/style_defaults_remove", false); + _page_svgoutput.add_line( false, "", _svgoutput_styledefaultsremove, "", _("Delete redundant style properties."), false); + + _page_svgoutput.add_group_header( _("Check Attributes and Style Properties on:")); + + _svgoutput_check_reading.init( _("Reading"), "/options/svgoutput/check_on_reading", false); + _page_svgoutput.add_line( false, "", _svgoutput_check_reading, "", _("Check attributes and style properties on reading in SVG files (including those internal to Inkscape which will slow down startup)."), false); + _svgoutput_check_editing.init( _("Editing"), "/options/svgoutput/check_on_editing", false); + _page_svgoutput.add_line( false, "", _svgoutput_check_editing, "", _("Check attributes and style properties while editing SVG files (may slow down Inkscape, mostly useful for debugging)."), false); + _svgoutput_check_writing.init( _("Writing"), "/options/svgoutput/check_on_writing", true); + _page_svgoutput.add_line( false, "", _svgoutput_check_writing, "", _("Check attributes and style properties on writing out SVG files."), false); + + this->AddPage(_page_svgoutput, _("SVG output"), PREFS_PAGE_SVGOUTPUT); } @@ -1123,6 +1182,31 @@ void InkscapePreferences::initPageUI() "gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "mk", "mn", "ne", "nb", "nn", "pa", "pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "te_IN", "th", "tr", "uk", "vi" }; + { + // sorting languages according to translated name + int i = 0; + int j = 0; + int n = sizeof( languages ) / sizeof( Glib::ustring ); + Glib::ustring key_language; + Glib::ustring key_langValue; + for ( j = 1 ; j < n ; j++ ) { + key_language = languages[j]; + key_langValue = langValues[j]; + i = j-1; + while ( i >= 0 + && ( ( languages[i] > key_language + && langValues[i] != "" ) + || key_langValue == "" ) ) + { + languages[i+1] = languages[i]; + langValues[i+1] = langValues[i]; + i--; + } + languages[i+1] = key_language; + langValues[i+1] = key_langValue; + } + } + _ui_languages.init( "/ui/language", languages, langValues, G_N_ELEMENTS(languages), languages[0]); _page_ui.add_line( false, _("Language (requires restart):"), _ui_languages, "", _("Set the language for menus and number formats"), false); @@ -1177,7 +1261,7 @@ void InkscapePreferences::initPageSave() { _save_use_current_dir.init( _("Use current directory for \"Save As ...\""), "/dialogs/save_as/use_current_dir", true); _page_save.add_line( false, "", _save_use_current_dir, "", - _("When this option is on, the \"Save as...\" dialog will always open in the directory where the currently open document is; when it's off, it will open in the directory where you last saved a file using that dialog"), true); + _("When this option is on, the \"Save as...\" and \"Save a Copy\" dialogs will always open in the directory where the currently open document is; when it's off, each will open in the directory where you last saved a file using it"), true); // Autosave options diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index a20278551..a72b74203 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -44,8 +44,9 @@ enum { PREFS_PAGE_TOOLS_SELECTOR, PREFS_PAGE_TOOLS_NODE, PREFS_PAGE_TOOLS_TWEAK, - PREFS_PAGE_TOOLS_SPRAY, + PREFS_PAGE_TOOLS_SPRAY, PREFS_PAGE_TOOLS_ZOOM, + PREFS_PAGE_TOOLS_MEASURE, PREFS_PAGE_TOOLS_SHAPES, PREFS_PAGE_TOOLS_SHAPES_RECT, PREFS_PAGE_TOOLS_SHAPES_3DBOX, @@ -66,7 +67,7 @@ enum { PREFS_PAGE_TRANSFORMS, PREFS_PAGE_CLONES, PREFS_PAGE_MASKS, - PREFS_PAGE_FILTERS, + PREFS_PAGE_RENDERING, PREFS_PAGE_BITMAPS, PREFS_PAGE_CMS, PREFS_PAGE_GRIDS, @@ -123,7 +124,7 @@ protected: UI::Widget::DialogPage _page_clones; UI::Widget::DialogPage _page_mask; UI::Widget::DialogPage _page_transforms; - UI::Widget::DialogPage _page_filters; + UI::Widget::DialogPage _page_rendering; UI::Widget::DialogPage _page_select; UI::Widget::DialogPage _page_importexport; UI::Widget::DialogPage _page_cms; @@ -140,6 +141,7 @@ protected: UI::Widget::DialogPage _page_tweak; UI::Widget::DialogPage _page_spray; UI::Widget::DialogPage _page_zoom; + UI::Widget::DialogPage _page_measure; UI::Widget::DialogPage _page_shapes; UI::Widget::DialogPage _page_pencil; UI::Widget::DialogPage _page_pen; @@ -177,11 +179,12 @@ protected: UI::Widget::PrefCheckButton _snap_mouse_pointer; UI::Widget::PrefCombo _steps_rot_snap; + UI::Widget::PrefCheckButton _steps_rot_relative; UI::Widget::PrefCheckButton _steps_compass; - UI::Widget::PrefSpinButton _steps_arrow; - UI::Widget::PrefSpinButton _steps_scale; - UI::Widget::PrefSpinButton _steps_inset; - UI::Widget::PrefSpinButton _steps_zoom; + UI::Widget::PrefSpinUnit _steps_arrow; + UI::Widget::PrefSpinUnit _steps_scale; + UI::Widget::PrefSpinUnit _steps_inset; + UI::Widget::PrefSpinButton _steps_zoom; UI::Widget::PrefRadioButton _t_sel_trans_obj; UI::Widget::PrefRadioButton _t_sel_trans_outl; @@ -251,6 +254,7 @@ protected: UI::Widget::PrefRadioButton _filter_quality_worse; UI::Widget::PrefRadioButton _filter_quality_worst; UI::Widget::PrefCheckButton _show_filters_info_box; + UI::Widget::PrefSpinButton _rendering_cache_size; UI::Widget::PrefSpinButton _filter_multi_threaded; UI::Widget::PrefCheckButton _trans_scale_stroke; @@ -354,6 +358,17 @@ protected: UI::Widget::PrefCheckButton _svgoutput_allowrelativecoordinates; UI::Widget::PrefCheckButton _svgoutput_forcerepeatcommands; + // Attribute Checking controls for SVG Output page: + UI::Widget::PrefCheckButton _svgoutput_attrwarn; + UI::Widget::PrefCheckButton _svgoutput_attrremove; + UI::Widget::PrefCheckButton _svgoutput_stylepropwarn; + UI::Widget::PrefCheckButton _svgoutput_stylepropremove; + UI::Widget::PrefCheckButton _svgoutput_styledefaultswarn; + UI::Widget::PrefCheckButton _svgoutput_styledefaultsremove; + UI::Widget::PrefCheckButton _svgoutput_check_reading; + UI::Widget::PrefCheckButton _svgoutput_check_editing; + UI::Widget::PrefCheckButton _svgoutput_check_writing; + UI::Widget::PrefEntryButtonHBox _importexport_ocal_url; UI::Widget::PrefEntry _importexport_ocal_username; UI::Widget::PrefEntry _importexport_ocal_password; @@ -371,6 +386,7 @@ protected: static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddFirstAndLastCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); @@ -385,7 +401,7 @@ protected: void initPageClones(); void initPageMasks(); void initPageTransforms(); - void initPageFilters(); + void initPageRendering(); void initPageSelecting(); void initPageImportExport(); void initPageCMS(); diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 6869aa97b..e80f581c1 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Input devices dialog (new) - implementation +/** + * @file + * Input devices dialog (new) - implementation. */ /* Author: * Jon A. Cruz diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index bf15bcd76..eeef12b88 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for renaming layers +/** + * @file + * Dialog for renaming layers. */ /* Author: * Bryce W. Harrington <bryce@bryceharrington.com> diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 0eca5bbca..340a1921c 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -13,8 +13,7 @@ # include <config.h> #endif -#include <gtk/gtkstock.h> -#include <gtk/gtkmain.h> +#include <gtk/gtk.h> #include <gtkmm/widget.h> #include <gtkmm/icontheme.h> #include <glibmm/i18n.h> @@ -35,6 +34,7 @@ #include "verbs.h" #include "widgets/icon.h" #include "xml/repr.h" +#include "sp-root.h" #include "layers.h" @@ -293,7 +293,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre } void LayersPanel::_selectLayer( SPObject *layer ) { - if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->root)) ) { + if ( !layer || (_desktop && _desktop->doc() && (layer == _desktop->doc()->getRoot())) ) { if ( _tree.get_selection()->count_selected_rows() != 0 ) { _tree.get_selection()->unselect_all(); } @@ -328,7 +328,7 @@ void LayersPanel::_layersChanged() // g_message("_layersChanged()"); if (_desktop) { SPDocument* document = _desktop->doc(); - SPObject* root = document->root; + SPRoot* root = document->getRoot(); if ( root ) { _selectedConnection.block(); if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) { @@ -402,7 +402,7 @@ void LayersPanel::_pushTreeSelectionToCurrent() _desktop->layer_manager->setCurrentLayer( inTree ); } } else { - _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root ); + _desktop->layer_manager->setCurrentLayer( _desktop->doc()->getRoot() ); } } } @@ -582,7 +582,7 @@ LayersPanel::LayersPanel() : _tree.set_headers_visible(false); Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1; eyeRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) ); @@ -593,7 +593,7 @@ LayersPanel::LayersPanel() : } Inkscape::UI::Widget::ImageToggler * renderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_LOCKED, INKSCAPE_ICON_OBJECT_UNLOCKED) ); + INKSCAPE_ICON("object-locked"), INKSCAPE_ICON("object-unlocked")) ); int lockedColNum = _tree.append_column("lock", *renderer) - 1; renderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) ); renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) ); diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index b7e81480c..018357425 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -19,7 +19,7 @@ #include <gtkmm/scrolledwindow.h> #include <gtkmm/box.h> #include <gtkmm/buttonbox.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/notebook.h> //#include "ui/previewholder.h" @@ -117,7 +117,7 @@ private: Gtk::HButtonBox _buttonsRow; Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; - Gtk::SpinButton _spinBtn; + Inkscape::UI::Widget::SpinButton _spinBtn; Gtk::VBox _layersPage; UI::Widget::StyleSubject::CurrentLayer _subject; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index bf60fe059..b48022360 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Live Path Effect editing dialog - implementation +/** + * @file + * Live Path Effect editing dialog - implementation. */ /* Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> @@ -138,7 +139,7 @@ LivePathEffectEditor::LivePathEffectEditor() //Add the visibility icon column: Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler( - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) ); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden")) ); int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1; eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) ); eyeRenderer->property_activatable() = true; @@ -245,7 +246,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) // this was triggered by selecting a row in the list, so skip reloading lpe_list_locked = false; return; - } + } effectlist_store->clear(); current_lpeitem = NULL; @@ -265,7 +266,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); if (lpe) { showParams(*lpe); - lpe_list_locked = true; + lpe_list_locked = true; selectInList(lpe); } else { showText(_("Unknown effect is applied")); @@ -298,7 +299,7 @@ LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem) PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); PathEffectList::iterator it; - for( it = effectlist.begin() ; it!=effectlist.end(); it++ ) + for( it = effectlist.begin() ; it!=effectlist.end(); ++it) { if ( !(*it)->lpeobject ) { continue; diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index 7f5c5cefa..8229929e5 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Memory statistics dialog +/** + * @file + * Memory statistics dialog. */ /* Authors: * MenTaLguY <mental@rydia.net> diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp index 654117704..022e6ac2c 100644 --- a/src/ui/dialog/messages.cpp +++ b/src/ui/dialog/messages.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Messages dialog - implementation +/** + * @file + * Messages dialog - implementation. */ /* Authors: * Bob Jamison diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index f9c0e7212..db3d1272a 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Open Clip Art Library integration dialogs - implementation +/** + * @file + * Open Clip Art Library integration dialogs - implementation. */ /* Authors: * Bruno Dilly @@ -635,7 +636,7 @@ void ImportDialog::on_list_results_selection_changed() pathlist = list_results->get_selection()->get_selected_rows(); std::vector<int> posArray(1); - printf("%s", "on_list_results_selection_changed"); + printf("%s", "on_list_results_selection_changed\n"); posArray = pathlist[0].get_indices(); int row = posArray[0]; @@ -652,7 +653,7 @@ void ImportDialog::on_button_import_clicked() { pathlist = list_results->get_selection()->get_selected_rows(); std::vector<int> posArray(1); - printf("%s", "on_button_import_clicked"); + printf("%s", "on_button_import_clicked\n"); posArray = pathlist[0].get_indices(); int row = posArray[0]; @@ -673,7 +674,7 @@ void ImportDialog::on_list_results_cursor_changed() pathlist = list_results->get_selection()->get_selected_rows(); std::vector<int> posArray(1); - printf("%s", "on_list_results_cursor_changed"); + printf("%s", "on_list_results_cursor_changed\n"); posArray = pathlist[0].get_indices(); int row = posArray[0]; @@ -1077,6 +1078,7 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types const Glib::ustring &title) : FileDialogBase(title, parent_window) { + printf("%s\n", "Hi!"); // Initalize to Autodetect extension = NULL; // No filename to start out with diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 2ca71d5f7..4d6997fc5 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -34,11 +34,9 @@ //Temporary ugly hack //Remove this after the get_filter() calls in //show() on both classes are fixed -#include <gtk/gtkfilechooser.h> +#include <gtk/gtk.h> //Another hack -#include <gtk/gtkentry.h> -#include <gtk/gtkexpander.h> #ifdef WITH_GNOME_VFS #include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized #include<libgnomevfs/gnome-vfs.h> diff --git a/src/ui/dialog/print-colors-preview-dialog.cpp b/src/ui/dialog/print-colors-preview-dialog.cpp index 1f999f692..ef5c1b6f6 100644 --- a/src/ui/dialog/print-colors-preview-dialog.cpp +++ b/src/ui/dialog/print-colors-preview-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Print Colors Preview dialog - implementation +/** + * @file + * Print Colors Preview dialog - implementation. */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index a56cbfd9d..8da31b813 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Print dialog +/** + * @file + * Print dialog. */ /* Authors: * Kees Cook <kees@outflux.net> diff --git a/src/ui/dialog/print.h b/src/ui/dialog/print.h index cc27955cb..0184bc783 100644 --- a/src/ui/dialog/print.h +++ b/src/ui/dialog/print.h @@ -13,7 +13,7 @@ #include <glibmm/i18n.h> #include <gtkmm/printoperation.h> // GtkMM -#include <gtk/gtkprintoperation.h> // Gtk +#include <gtk/gtk.h> // Gtk #include "desktop.h" #include "sp-item.h" diff --git a/src/ui/dialog/scriptdialog.cpp b/src/ui/dialog/scriptdialog.cpp index c7f828067..b775c74a1 100644 --- a/src/ui/dialog/scriptdialog.cpp +++ b/src/ui/dialog/scriptdialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Dialog for executing and monitoring script execution +/** + * @file + * Dialog for executing and monitoring script execution. */ /* Author: * Bob Jamison @@ -151,9 +152,7 @@ void ScriptDialogImpl::clear() /** * Execute the script in the dialog */ -void -ScriptDialogImpl::execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage -lang) +void ScriptDialogImpl::execute(Inkscape::Extension::Script::InkscapeScript::ScriptLanguage lang) { Glib::ustring script = scriptText.get_buffer()->get_text(true); Glib::ustring output; diff --git a/src/ui/dialog/scriptdialog.h b/src/ui/dialog/scriptdialog.h index 0b26f169a..a54f865f8 100644 --- a/src/ui/dialog/scriptdialog.h +++ b/src/ui/dialog/scriptdialog.h @@ -51,12 +51,6 @@ class ScriptDialog : public UI::Widget::Panel */ virtual ~ScriptDialog() {}; - - private: - int _max_dialog_width; - int _max_dialog_height; - - }; // class ScriptDialog diff --git a/src/ui/dialog/session-player.cpp b/src/ui/dialog/session-player.cpp deleted file mode 100644 index d8ff8ca56..000000000 --- a/src/ui/dialog/session-player.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/** @file - * @brief Whiteboard session playback control dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Abhishek Sharma - * - * Copyright (c) 2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <glibmm.h> -#include <glibmm/i18n.h> -#include <gtk/gtkdialog.h> -#include <gtkmm.h> - -#include "inkscape.h" -#include "path-prefix.h" - -#include "desktop.h" -#include "desktop-handles.h" -#include "document.h" - -#include "jabber_whiteboard/node-tracker.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/session-file-player.h" - -#include "ui/dialog/session-player.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -SessionPlaybackDialog* -SessionPlaybackDialog::create() -{ - return new SessionPlaybackDialogImpl(); -} - -SessionPlaybackDialogImpl::SessionPlaybackDialogImpl() - : _delay(100, 1, 5000, 10, 100), _delayentry(_delay) -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - this->_sfp = this->_sm->session_player(); - this->_openfile.set_text(this->_sfp->filename()); - - this->_construct(); - this->get_vbox()->show_all_children(); -} - -SessionPlaybackDialogImpl::~SessionPlaybackDialogImpl() -{ - -} - -void -SessionPlaybackDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Dialog organization - this->_filemanager.set_label(_("Session file")); - this->_playback.set_label(_("Playback controls")); - this->_currentmsgbox.set_label(_("Message information")); - - this->_filemanager.set_border_width(4); - this->_playback.set_border_width(4); - this->_fm.set_border_width(4); - this->_toolbarbox.set_border_width(4); - - // Active session file display - // fixme: Does this mean the active file for the session, or the file for the active session? - // Please indicate which with a TRANSLATORS comment. - this->_labels[0].set_text(_("Active session file:")); - this->_labels[1].set_text(_("Delay (milliseconds):")); - - this->_openfile.set_editable(false); - - this->_filebox.pack_start(this->_labels[0], true, false, 8); - this->_filebox.pack_end(this->_openfile, true, true, 0); - - // Unload/load buttons - this->_close.set_label(_("Close file")); - this->_open.set_label(_("Open new file")); - this->_setdelay.set_label(_("Set delay")); - - // Attach callbacks - this->_close.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), CLOSE_FILE)); - this->_open.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), OPEN_FILE)); - this->_setdelay.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), RESET_DELAY)); - - // Button box - this->_filebuttons.pack_start(this->_close, true, false, 0); - this->_filebuttons.pack_start(this->_open, true, false, 0); - - // Message information box - this->_currentmsgbuffer = Gtk::TextBuffer::create(); - this->_currentmsgview.set_buffer(this->_currentmsgbuffer); - this->_currentmsgview.set_editable(false); - this->_currentmsgview.set_cursor_visible(false); - this->_currentmsgview.set_wrap_mode(Gtk::WRAP_WORD); - this->_currentmsgscroller.add(this->_currentmsgview); - this->_currentmsgbox.add(this->_currentmsgscroller); - this->_sfp->setMessageOutputWidget(this->_currentmsgbuffer); - - // Delay setting - // parameters: initial lower upper single-incr page-incr - this->_delayentry.set_numeric(true); - - // Playback controls - this->_playbackcontrols.set_show_arrow(false); - - this->_controls[0].set_label("Rewind"); - this->_controls[1].set_label("Go back one"); - this->_controls[2].set_label("Pause"); - this->_controls[3].set_label("Go forward one"); - this->_controls[4].set_label("Play"); - - this->_controls[0].set_tooltip(this->_tooltips, _("Rewind")); - this->_controls[1].set_tooltip(this->_tooltips, _("Go back one change")); - this->_controls[2].set_tooltip(this->_tooltips, _("Pause")); - this->_controls[3].set_tooltip(this->_tooltips, _("Go forward one change")); - this->_controls[4].set_tooltip(this->_tooltips, _("Play")); - - for(int i = 0; i < 5; i++) { - this->_playbackcontrols.append(this->_controls[i], sigc::bind< 0 >(sigc::mem_fun(*this, &SessionPlaybackDialogImpl::_respCallback), TOOLBAR_BASE + i)); - } - - this->_delaybox.pack_start(this->_labels[1]); - this->_delaybox.pack_start(this->_delayentry); - this->_delaybox.pack_end(this->_setdelay); - - this->_toolbarbox.pack_start(this->_delaybox); - this->_toolbarbox.pack_end(this->_playbackcontrols); - - // Pack widgets into frames - this->_fm.pack_start(this->_filebox); - this->_fm.pack_end(this->_filebuttons); - - this->_filemanager.add(this->_fm); - this->_playback.add(this->_toolbarbox); - - // Pack widgets into main vbox - main->pack_start(this->_filemanager); - main->pack_start(this->_playback); - main->pack_end(this->_currentmsgbox); -} - -void -SessionPlaybackDialogImpl::_respCallback(int resp) -{ - g_log(NULL, G_LOG_LEVEL_DEBUG, "_respCallback: %u", resp); - switch(resp) { - case CLOSE_FILE: - this->_sfp->unload(); - break; - case OPEN_FILE: { - Gtk::FileChooserDialog sessionfiledlg(_("Open session file"), Gtk::FILE_CHOOSER_ACTION_OPEN); - sessionfiledlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - sessionfiledlg.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - - int result = sessionfiledlg.run(); - switch (result) { - case Gtk::RESPONSE_OK: - this->_sm->clearDocument(); - SPDocumentUndo::done(sp_desktop_document(this->_desktop), SP_VERB_NONE, - /* TODO: annotate */ "session-player.cpp:186"); - this->_sm->loadSessionFile(sessionfiledlg.get_filename()); - this->_openfile.set_text(this->_sfp->filename()); - break; - default: - break; - } - break; - } - case RESET_DELAY: - this->_sfp->setDelay(this->_delayentry.get_value_as_int()); - break; - case REWIND: - if (this->_sfp->_playing) { - this->_sfp->stop(); - } - this->_sfp->_curdir = Whiteboard::SessionFilePlayer::BACKWARD; - this->_sfp->start(); - break; - case STEP_REWIND: - this->_sfp->step(Whiteboard::SessionFilePlayer::BACKWARD); - break; - case PAUSE: - this->_sfp->stop(); - break; - case STEP_PLAY: - this->_sfp->step(Whiteboard::SessionFilePlayer::FORWARD); - break; - case PLAY: - if (this->_sfp->_playing) { - this->_sfp->stop(); - } - this->_sfp->_curdir = Whiteboard::SessionFilePlayer::FORWARD; - this->_sfp->start(); - break; - default: - break; - } -} - -} - -} - -} - -/* - 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/ui/dialog/session-player.h b/src/ui/dialog/session-player.h deleted file mode 100644 index 9c10f264f..000000000 --- a/src/ui/dialog/session-player.h +++ /dev/null @@ -1,134 +0,0 @@ -/** @file - * @brief Whiteboard session playback control dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * - * Copyright (c) 2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __SESSION_PLAYBACK_DIALOG_H__ -#define __SESSION_PLAYBACK_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include "gtkmm/toolbutton.h" -#include "gtkmm/toolbar.h" -#include "gtkmm/expander.h" - -#include "ui/widget/icon-widget.h" - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; -class SessionFilePlayer; - -} - -namespace UI { - -namespace Dialog { - -class SessionPlaybackDialog : public Dialog { -public: - SessionPlaybackDialog() : Dialog("/dialogs/session_playback", SP_VERB_DIALOG_WHITEBOARD_SESSIONPLAYBACK) - { - - } - - static SessionPlaybackDialog* create(); - - virtual ~SessionPlaybackDialog() - { - - } -private: - SessionPlaybackDialog(SessionPlaybackDialog const& dlg); // no copy - void operator=(SessionPlaybackDialog const& dlg); // no assign -}; - -class SessionPlaybackDialogImpl : public SessionPlaybackDialog { -public: - SessionPlaybackDialogImpl(); - ~SessionPlaybackDialogImpl(); - -private: - // GTK+ widgets - Gtk::HBox _filebox; - Gtk::HBox _filebuttons; - Gtk::HBox _toolbarbox; - Gtk::HBox _delaybox; - - Gtk::Entry _openfile; - - Gtk::Label _labels[2]; - Gtk::ToolButton _controls[5]; - - Gtk::Button _close, _open, _setdelay; - - Gtk::Tooltips _tooltips; - Gtk::Toolbar _playbackcontrols; - Gtk::Adjustment _delay; - Gtk::SpinButton _delayentry; - - Gtk::Frame _filemanager; - Gtk::VBox _fm; - - Gtk::Frame _playback; - - Gtk::Expander _currentmsgbox; - Glib::RefPtr<Gtk::TextBuffer> _currentmsgbuffer; - Gtk::TextView _currentmsgview; - Gtk::ScrolledWindow _currentmsgscroller; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; - Whiteboard::SessionFilePlayer* _sfp; - - // button values - static unsigned short const CLOSE_FILE = 0; - static unsigned short const OPEN_FILE = 1; - static unsigned short const RESET_DELAY = 2; - - static unsigned short const TOOLBAR_BASE = 10; - static unsigned short const REWIND = TOOLBAR_BASE + 0; - static unsigned short const STEP_REWIND = TOOLBAR_BASE + 1; - static unsigned short const PAUSE = TOOLBAR_BASE + 2; - static unsigned short const STEP_PLAY = TOOLBAR_BASE + 3; - static unsigned short const PLAY = TOOLBAR_BASE + 4; - - - // noncopyable - SessionPlaybackDialogImpl(SessionPlaybackDialogImpl const& dlg); // no copy - void operator=(SessionPlaybackDialogImpl const& dlg); // no assign -}; - -} - -} - -} - -#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/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 2d1b5ae39..658ef6613 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief SVG Fonts dialog - implementation +/** + * @file + * SVG Fonts dialog - implementation. */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> @@ -16,7 +17,6 @@ #ifdef ENABLE_SVG_FONTS -#include <2geom/pathvector.h> #include "document-private.h" #include <gtkmm/notebook.h> #include <glibmm/i18n.h> @@ -28,24 +28,27 @@ #include "xml/node.h" #include "xml/repr.h" -SvgFontDrawingArea::SvgFontDrawingArea(){ - this->text = ""; - this->svgfont = NULL; +SvgFontDrawingArea::SvgFontDrawingArea(): + _x(0), + _y(0), + _svgfont(0), + _text() +{ } void SvgFontDrawingArea::set_svgfont(SvgFont* svgfont){ - this->svgfont = svgfont; + _svgfont = svgfont; } void SvgFontDrawingArea::set_text(Glib::ustring text){ - this->text = text; + _text = text; redraw(); } void SvgFontDrawingArea::set_size(int x, int y){ - this->x = x; - this->y = y; - ((Gtk::Widget*) this)->set_size_request(x, y); + _x = x; + _y = y; + ((Gtk::Widget*) this)->set_size_request(_x, _y); } void SvgFontDrawingArea::redraw(){ @@ -53,13 +56,13 @@ void SvgFontDrawingArea::redraw(){ } bool SvgFontDrawingArea::on_expose_event (GdkEventExpose */*event*/){ - if (this->svgfont){ + if (_svgfont){ Glib::RefPtr<Gdk::Window> window = get_window(); Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); - cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) ); - cr->set_font_size (this->y-20); + cr->set_font_face( Cairo::RefPtr<Cairo::FontFace>(new Cairo::FontFace(_svgfont->get_font_face(), false /* does not have reference */)) ); + cr->set_font_size (_y-20); cr->move_to (10, 10); - cr->show_text (this->text.c_str()); + cr->show_text (_text.c_str()); } return TRUE; } @@ -137,7 +140,7 @@ Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/) Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); - hbox->add(* Gtk::manage(new Gtk::SpinBox()) ); + hbox->add(* Gtk::manage(new Inkscape::UI::Widget::SpinBox()) ); hbox->show_all(); return hbox; }*/ @@ -162,7 +165,10 @@ void GlyphComboBox::update(SPFont* spfont){ } void SvgFontsDialog::on_kerning_value_changed(){ - if (!this->kerning_pair) return; + if (!get_selected_kerning_pair()) { + return; + } + SPDocument* document = sp_desktop_document(this->getDesktop()); //TODO: I am unsure whether this is the correct way of calling SPDocumentUndo::maybe_done @@ -471,6 +477,24 @@ void SvgFontsDialog::add_glyph(){ update_glyphs(); } +Geom::PathVector +SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ + double units_per_em = 1000; + SPObject* obj; + for (obj = get_selected_spfont()->children; obj; obj=obj->next){ + if (SP_IS_FONTFACE(obj)){ + //XML Tree being directly used here while it shouldn't be. + sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em); + } + } + + double baseline_offset = units_per_em - get_selected_spfont()->horiz_origin_y; + + //This matrix flips y-axis and places the origin at baseline + Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset)); + return pathv*m; +} + void SvgFontsDialog::set_glyph_description_from_selected_path(){ SPDesktop* desktop = this->getDesktop(); if (!desktop) { @@ -495,22 +519,17 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } //TODO: //Is there a better way to tell it to to the user? - Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - SPGlyph* glyph = get_selected_glyph(); if (!glyph){ char *msg = _("No glyph selected in the SVGFonts dialog."); msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } + + Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); + //XML Tree being directly used here while it shouldn't be. - glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); @@ -542,19 +561,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - //This matrix flips the glyph vertically - Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(0)); - pathv*=m; - //then we offset it -// pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(get_selected_spfont()->horiz_adv_x)); - pathv+=Geom::Point(Geom::Coord(0),Geom::Coord(1000));//TODO: use here the units-per-em attribute? - SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (flip_coordinate_system(pathv))); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@ -786,7 +798,7 @@ SPFont *new_font(SPDocument *document) { g_return_val_if_fail(document != NULL, NULL); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + SPDefs *defs = document->getDefs(); Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -903,7 +915,7 @@ SvgFontsDialog::SvgFontsDialog() _FontsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &SvgFontsDialog::fonts_list_button_release)); create_fonts_popup_menu(_FontsList, sigc::mem_fun(*this, &SvgFontsDialog::remove_selected_font)); - _defs_observer.set(SP_DOCUMENT_DEFS(sp_desktop_document(this->getDesktop()))); + _defs_observer.set(sp_desktop_document(this->getDesktop())->getDefs()); _defs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_fonts)); _getContents()->show_all(); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index e819187a1..41bd6ecc8 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -11,7 +11,9 @@ #ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H #define INKSCAPE_UI_DIALOG_SVG_FONTS_H +#include <2geom/pathvector.h> #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" #include "sp-font.h" #include "sp-font-face.h" #include "verbs.h" @@ -37,9 +39,9 @@ public: void set_size(int x, int y); void redraw(); private: - int x,y; - SvgFont* svgfont; - Glib::ustring text; + int _x,_y; + SvgFont* _svgfont; + Glib::ustring _text; bool on_expose_event (GdkEventExpose *event); }; @@ -77,6 +79,7 @@ public: void on_kerning_value_changed(); void on_setwidth_changed(); void add_font(); + Geom::PathVector flip_coordinate_system(Geom::PathVector pathv); //TODO: AttrEntry is currently unused. Should we remove it? class AttrEntry : public Gtk::HBox @@ -206,7 +209,7 @@ private: SvgFontDrawingArea _font_da, kerning_preview; GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; - Gtk::SpinButton setwidth_spin; + Inkscape::UI::Widget::SpinButton setwidth_spin; Gtk::HScale kerning_slider; class EntryWidget : public Gtk::HBox diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index b2b1b26da..50f8a90aa 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -1,6 +1,6 @@ - -/** @file - * @brief Color swatches dialog +/** + * @file + * Color swatches dialog. */ /* Authors: * Jon A. Cruz @@ -17,12 +17,9 @@ #include <map> #include <algorithm> -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types -#include <gtk/gtkdnd.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkseparatormenuitem.h> +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> +#include <glibmm/main.h> #include <gdkmm/pixbuf.h> #include "color-item.h" @@ -49,7 +46,7 @@ #include "widgets/desktop-widget.h" #include "widgets/gradient-vector.h" #include "widgets/eek-preview.h" -#include "display/nr-plain-stuff.h" +#include "display/cairo-utils.h" #include "sp-gradient-reference.h" #include "dialog-manager.h" @@ -63,8 +60,6 @@ namespace Dialogs { void _loadPaletteFile( gchar const *filename ); -class DocTrack; - std::vector<SwatchPage*> possible; static std::map<SPDocument*, SwatchPage*> docPalettes; static std::vector<DocTrack*> docTrackings; @@ -625,7 +620,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : int i = 0; std::vector<SwatchPage*> swatchSets = _getSwatchSets(); - for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); it++ ) { + for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); ++it) { SwatchPage* curr = *it; Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name)); if ( curr == first ) { @@ -715,14 +710,31 @@ class DocTrack public: DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) : doc(doc), + updatePending(false), + lastGradientUpdate(0.0), gradientRsrcChanged(gradientRsrcChanged), defsChanged(defsChanged), defsModified(defsModified) { + if ( !timer ) { + timer = new Glib::Timer(); + refreshTimer = Glib::signal_timeout().connect( sigc::ptr_fun(handleTimerCB), 33 ); + } + timerRefCount++; } ~DocTrack() { + timerRefCount--; + if ( timerRefCount <= 0 ) { + refreshTimer.disconnect(); + timerRefCount = 0; + if ( timer ) { + timer->stop(); + delete timer; + timer = 0; + } + } if (doc) { gradientRsrcChanged.disconnect(); defsChanged.disconnect(); @@ -730,7 +742,22 @@ public: } } + static bool handleTimerCB(); + + /** + * Checks if update should be queued or executed immediately. + * + * @return true if the update was queued and should not be immediately executed. + */ + static bool queueUpdateIfNeeded(SPDocument *doc); + + static Glib::Timer *timer; + static int timerRefCount; + static sigc::connection refreshTimer; + SPDocument *doc; + bool updatePending; + double lastGradientUpdate; sigc::connection gradientRsrcChanged; sigc::connection defsChanged; sigc::connection defsModified; @@ -740,6 +767,58 @@ private: DocTrack &operator=(DocTrack const &); // no assign }; +Glib::Timer *DocTrack::timer = 0; +int DocTrack::timerRefCount = 0; +sigc::connection DocTrack::refreshTimer; + +static const double DOC_UPDATE_THREASHOLD = 0.090; + +bool DocTrack::handleTimerCB() +{ + double now = timer->elapsed(); + + std::vector<DocTrack *> needCallback; + for (std::vector<DocTrack *>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->updatePending && ( (now - track->lastGradientUpdate) >= DOC_UPDATE_THREASHOLD) ) { + needCallback.push_back(track); + } + } + + for (std::vector<DocTrack *>::iterator it = needCallback.begin(); it != needCallback.end(); ++it) { + DocTrack *track = *it; + if ( std::find(docTrackings.begin(), docTrackings.end(), track) != docTrackings.end() ) { // Just in case one gets deleted while we are looping + // Note: calling handleDefsModified will call queueUpdateIfNeeded and thus update the time and flag. + SwatchesPanel::handleDefsModified(track->doc); + } + } + + return true; +} + +bool DocTrack::queueUpdateIfNeeded( SPDocument *doc ) +{ + bool deferProcessing = false; + for (std::vector<DocTrack*>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it) { + DocTrack *track = *it; + if ( track->doc == doc ) { + double now = timer->elapsed(); + double elapsed = now - track->lastGradientUpdate; + + if ( elapsed < DOC_UPDATE_THREASHOLD ) { + deferProcessing = true; + track->updatePending = true; + } else { + track->lastGradientUpdate = now; + track->updatePending = false; + } + + break; + } + } + return deferProcessing; +} + void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) { SPDocument *oldDoc = 0; @@ -775,8 +854,8 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) docPerPanel[panel] = document; if (!found) { sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); - sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); - sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); + sigc::connection conn2 = document->getDefs()->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); + sigc::connection conn3 = document->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); DocTrack *dt = new DocTrack(document, conn1, conn2, conn3); docTrackings.push_back(dt); @@ -806,8 +885,8 @@ void SwatchesPanel::_setDocument( SPDocument *document ) } static void recalcSwatchContents(SPDocument* doc, - std::vector<ColorItem*> &tmpColors, - std::map<ColorItem*, guchar*> &previewMappings, + boost::ptr_vector<ColorItem> &tmpColors, + std::map<ColorItem*, cairo_pattern_t*> &previewMappings, std::map<ColorItem*, SPGradient*> &gradMappings) { std::vector<SPGradient*> newList; @@ -825,30 +904,29 @@ static void recalcSwatchContents(SPDocument* doc, for ( std::vector<SPGradient*>::iterator it = newList.begin(); it != newList.end(); ++it ) { SPGradient* grad = *it; - grad->ensureVector(); - SPGradientStop first = grad->vector.stops[0]; - SPColor color = first.color; - guint32 together = color.toRGBA32(first.opacity); - SPGradientStop second = (*it)->vector.stops[1]; - SPColor color2 = second.color; + cairo_surface_t *preview = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + PREVIEW_PIXBUF_WIDTH, VBLOCK); + cairo_t *ct = cairo_create(preview); Glib::ustring name( grad->getId() ); - unsigned int r = SP_RGBA32_R_U(together); - unsigned int g = SP_RGBA32_G_U(together); - unsigned int b = SP_RGBA32_B_U(together); - ColorItem* item = new ColorItem( r, g, b, name ); + ColorItem* item = new ColorItem( 0, 0, 0, name ); - gint width = PREVIEW_PIXBUF_WIDTH; - gint height = VBLOCK; - guchar* px = g_new( guchar, 3 * height * width ); - nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 ); + cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard(); + cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(grad, PREVIEW_PIXBUF_WIDTH); + cairo_set_source(ct, check); + cairo_paint(ct); + cairo_set_source(ct, gradient); + cairo_paint(ct); - sp_gradient_render_vector_block_rgb( grad, - px, width, height, 3 * width, - 0, width, TRUE ); + cairo_destroy(ct); + cairo_pattern_destroy(gradient); + cairo_pattern_destroy(check); - previewMappings[item] = px; + cairo_pattern_t *prevpat = cairo_pattern_create_for_surface(preview); + cairo_surface_destroy(preview); + + previewMappings[item] = prevpat; tmpColors.push_back(item); gradMappings[item] = grad; @@ -860,13 +938,14 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette) { - std::vector<ColorItem*> tmpColors; - std::map<ColorItem*, guchar*> tmpPrevs; + boost::ptr_vector<ColorItem> tmpColors; + std::map<ColorItem*, cairo_pattern_t*> tmpPrevs; std::map<ColorItem*, SPGradient*> tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); - for (std::map<ColorItem*, guchar*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { - it->first->setPixData(it->second, PREVIEW_PIXBUF_WIDTH, VBLOCK); + for (std::map<ColorItem*, cairo_pattern_t*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { + it->first->setPattern(it->second); + cairo_pattern_destroy(it->second); } for (std::map<ColorItem*, SPGradient*>::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) { @@ -874,10 +953,6 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) } docPalette->_colors.swap(tmpColors); - for (std::vector<ColorItem*>::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { - delete *it; - } - // Figure out which SwatchesPanel instances are affected and update them. @@ -897,9 +972,9 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) void SwatchesPanel::handleDefsModified(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; - if (docPalette) { - std::vector<ColorItem*> tmpColors; - std::map<ColorItem*, guchar*> tmpPrevs; + if (docPalette && !DocTrack::queueUpdateIfNeeded(document) ) { + boost::ptr_vector<ColorItem> tmpColors; + std::map<ColorItem*, cairo_pattern_t*> tmpPrevs; std::map<ColorItem*, SPGradient*> tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -908,8 +983,8 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } else { int cap = std::min(docPalette->_colors.size(), tmpColors.size()); for (int i = 0; i < cap; i++) { - ColorItem* newColor = tmpColors[i]; - ColorItem* oldColor = docPalette->_colors[i]; + ColorItem *newColor = &tmpColors[i]; + ColorItem *oldColor = &docPalette->_colors[i]; if ( (newColor->def.getType() != oldColor->def.getType()) || (newColor->def.getR() != oldColor->def.getR()) || (newColor->def.getG() != oldColor->def.getG()) || @@ -920,10 +995,14 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) oldColor->setGradient(tmpGrads[newColor]); } if ( tmpPrevs.find(newColor) != tmpPrevs.end() ) { - oldColor->setPixData(tmpPrevs[newColor], PREVIEW_PIXBUF_WIDTH, VBLOCK); + oldColor->setPattern(tmpPrevs[newColor]); } } } + + for (std::map<ColorItem*, cairo_pattern_t*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { + cairo_pattern_destroy(it->second); + } } } @@ -1013,8 +1092,8 @@ void SwatchesPanel::_updateFromSelection() } sp_style_unref(tmpStyle); - for ( std::vector<ColorItem*>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { - ColorItem* item = *it; + for ( boost::ptr_vector<ColorItem>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { + ColorItem* item = &*it; bool isFill = (fillId == item->def.descr); bool isStroke = (strokeId == item->def.descr); item->setState( isFill, isStroke ); @@ -1055,8 +1134,8 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { - _holder->addPreview(*it); + for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { + _holder->addPreview(&*it); } _holder->thawUpdates(); } diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index f9f3daf91..95d7acb00 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -23,6 +23,7 @@ namespace Dialogs { class ColorItem; class SwatchPage; +class DocTrack; /** * A panel that displays paint swatches. @@ -68,6 +69,8 @@ private: sigc::connection _documentConnection; sigc::connection _selChanged; + + friend class DocTrack; }; } //namespace Dialogs diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index b0a39bd0e..9d1e314f7 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -18,10 +18,10 @@ # include <config.h> #endif -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types -#include <gtk/gtksizegroup.h> +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include <gtkmm/stock.h> +#include <2geom/transforms.h> #include "verbs.h" #include "preferences.h" @@ -47,8 +47,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using Geom::X; using Geom::Y; - Geom::OptRect a = first->getBounds(first->i2doc_affine()); - Geom::OptRect b = second->getBounds(second->i2doc_affine()); + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); if ( !a || !b ) { // FIXME? @@ -87,8 +87,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - Geom::OptRect a = first->getBounds(first->i2doc_affine()); - Geom::OptRect b = second->getBounds(second->i2doc_affine()); + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); if ( !a || !b ) { // FIXME? @@ -136,8 +136,8 @@ void TileDialog::Grid_Arrange () on_row_spinbutton_changed(); // set padding to manual values - paddingx = XPadSpinner.get_value(); - paddingy = YPadSpinner.get_value(); + paddingx = XPadding.getValue("px"); + paddingy = YPadding.getValue("px"); std::vector<double> row_heights; std::vector<double> col_widths; @@ -167,7 +167,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); if (!b) { continue; } @@ -210,7 +210,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; height = b->dimensions()[Geom::Y]; @@ -267,7 +267,7 @@ void TileDialog::Grid_Arrange () } - Geom::OptRect sel_bbox = selection->bounds(); + Geom::OptRect sel_bbox = selection->visualBounds(); // Fit to bbox, calculate padding between rows accordingly. if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ #ifdef DEBUG_GRID_ARRANGE @@ -317,7 +317,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = item->getRepr(); - Geom::OptRect b = item->getBounds(item->i2doc_affine()); + Geom::OptRect b = item->documentVisualBounds(); Geom::Point min; if (b) { width = b->dimensions()[Geom::X]; @@ -337,7 +337,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); - item->set_i2d_affine(item->i2d_affine() * affine); + item->set_i2d_affine(item->i2dt_affine() * affine); item->doWriteTransform(repr, item->transform, NULL); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; @@ -422,7 +422,7 @@ void TileDialog::on_col_spinbutton_changed() void TileDialog::on_xpad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/XPad", XPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); } @@ -432,7 +432,7 @@ void TileDialog::on_xpad_spinbutton_changed() void TileDialog::on_ypad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/YPad", YPadSpinner.get_value()); + prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); } @@ -512,7 +512,8 @@ void TileDialog::Spacing_button_changed() prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); } - SizesHBox.set_sensitive ( SpaceManualRadioButton.get_active()); + XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); + YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); } /** @@ -614,7 +615,9 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap * Constructor */ TileDialog::TileDialog() - : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE) + : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), + XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), + YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -662,7 +665,7 @@ TileDialog::TileDialog() NoOfRowsSpinner.set_digits(0); NoOfRowsSpinner.set_increments(1, 0); - NoOfRowsSpinner.set_range(1.0, 100.0); + NoOfRowsSpinner.set_range(1.0, 10000.0); NoOfRowsSpinner.set_value(PerCol); NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_col_spinbutton_changed)); tips.set_tip(NoOfRowsSpinner, _("Number of rows")); @@ -734,7 +737,7 @@ TileDialog::TileDialog() NoOfColsSpinner.set_digits(0); NoOfColsSpinner.set_increments(1, 0); - NoOfColsSpinner.set_range(1.0, 100.0); + NoOfColsSpinner.set_range(1.0, 10000.0); NoOfColsSpinner.set_value(PerRow); NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_row_spinbutton_changed)); tips.set_tip(NoOfColsSpinner, _("Number of columns")); @@ -814,51 +817,25 @@ TileDialog::TileDialog() } { - /*#### Y Padding ####*/ + /*#### Padding ####*/ - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-rows"); - YPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); + YPadding.setDigits(5); + YPadding.setIncrements(0.2, 0); + YPadding.setRange(-10000, 10000); + double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); + YPadding.setValue(yPad, "px"); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - YPadSpinner.set_digits(1); - YPadSpinner.set_increments(0.2, 0); - YPadSpinner.set_range(-10000, 10000); - double YPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); - YPadSpinner.set_value(YPad); - YPadBox.pack_start(YPadSpinner, true, true, MARGIN); - tips.set_tip(YPadSpinner, _("Vertical spacing between rows (px units)")); - YPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); - gtk_size_group_add_widget(_col1, (GtkWidget *) YPadBox.gobj()); + XPadding.setDigits(5); + XPadding.setIncrements(0.2, 0); + XPadding.setRange(-10000, 10000); + double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); + XPadding.setValue(xPad, "px"); - SizesHBox.pack_start(YPadBox, false, false, MARGIN); + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); } - - { - Gtk::HBox *spacer = new Gtk::HBox; - SizesHBox.pack_start(*spacer, false, false, 0); - gtk_size_group_add_widget(_col2, (GtkWidget *) spacer->gobj()); - } - - { - /*#### X padding ####*/ - - GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_MENU, "object-columns"); - XPadBox.pack_start (*(Glib::wrap(i)), false, false, MARGIN); - - XPadSpinner.set_digits(1); - XPadSpinner.set_increments(0.2, 0); - XPadSpinner.set_range(-10000, 10000); - double XPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); - XPadSpinner.set_value(XPad); - XPadBox.pack_start(XPadSpinner, true, true, MARGIN); - tips.set_tip(XPadSpinner, _("Horizontal spacing between columns (px units)")); - XPadSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); - gtk_size_group_add_widget(_col3, (GtkWidget *) XPadBox.gobj()); - - SizesHBox.pack_start(XPadBox, false, false, MARGIN); - } - - - TileBox.pack_start(SizesHBox, false, false, MARGIN); + TileBox.pack_start(XPadding, false, false, MARGIN); + TileBox.pack_start(YPadding, false, false, MARGIN); contents->pack_start(TileBox); @@ -870,7 +847,8 @@ TileDialog::TileDialog() } SpaceManualRadioButton.set_active(ManualSpacing); SpaceByBBoxRadioButton.set_active(!ManualSpacing); - SizesHBox.set_sensitive (ManualSpacing); + XPadding.set_sensitive (ManualSpacing); + YPadding.set_sensitive (ManualSpacing); //## The OK button TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 16ae3e4f8..fe77a9098 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -24,6 +24,8 @@ #include <gtkmm/radiobutton.h> #include "ui/widget/panel.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -88,12 +90,11 @@ private: Gtk::HBox AlignHBox; Gtk::HBox SpinsHBox; - Gtk::HBox SizesHBox; // Number per Row Gtk::VBox NoOfColsBox; Gtk::Label NoOfColsLabel; - Gtk::SpinButton NoOfColsSpinner; + Inkscape::UI::Widget::SpinButton NoOfColsSpinner; bool AutoRowSize; Gtk::CheckButton RowHeightButton; @@ -104,7 +105,7 @@ private: // Number per Column Gtk::VBox NoOfRowsBox; Gtk::Label NoOfRowsLabel; - Gtk::SpinButton NoOfRowsSpinner; + Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; bool AutoColSize; Gtk::CheckButton ColumnWidthButton; @@ -128,15 +129,8 @@ private: Gtk::RadioButton HorizRightRadioButton; double HorizAlign; - // padding in x - Gtk::VBox XPadBox; - Gtk::Label XPadLabel; - Gtk::SpinButton XPadSpinner; - - // padding in y - Gtk::VBox YPadBox; - Gtk::Label YPadLabel; - Gtk::SpinButton YPadSpinner; + Inkscape::UI::Widget::ScalarUnit XPadding; + Inkscape::UI::Widget::ScalarUnit YPadding; // BBox or manual spacing Gtk::VBox SpacingVBox; @@ -145,19 +139,17 @@ private: Gtk::RadioButton SpaceManualRadioButton; bool ManualSpacing; - - // Row height Gtk::VBox RowHeightVBox; Gtk::HBox RowHeightBox; Gtk::Label RowHeightLabel; - Gtk::SpinButton RowHeightSpinner; + Inkscape::UI::Widget::SpinButton RowHeightSpinner; // Column width Gtk::VBox ColumnWidthVBox; Gtk::HBox ColumnWidthBox; Gtk::Label ColumnWidthLabel; - Gtk::SpinButton ColumnWidthSpinner; + Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; }; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index f6dd6cb28..597c9a217 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Bitmap tracing settings dialog - implementation +/** + * @file + * Bitmap tracing settings dialog - implementation. */ /* Authors: * Bob Jamison <rjamison@titan.com> @@ -16,10 +17,10 @@ #include <gtkmm/notebook.h> #include <gtkmm/frame.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/stock.h> -#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types +#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include "desktop.h" @@ -109,7 +110,7 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox modeBrightnessBox; Gtk::RadioButton modeBrightnessRadioButton; Gtk::Label modeBrightnessSpinnerLabel; - Gtk::SpinButton modeBrightnessSpinner; + Inkscape::UI::Widget::SpinButton modeBrightnessSpinner; //edge detection Gtk::Frame modeCannyFrame; Gtk::HBox modeCannyBox; @@ -117,16 +118,16 @@ class TraceDialogImpl : public TraceDialog Gtk::RadioButton modeCannyRadioButton; //Gtk::HSeparator modeCannySeparator; //Gtk::Label modeCannyLoSpinnerLabel; - //Gtk::SpinButton modeCannyLoSpinner; + //Inkscape::UI::Widget::SpinButton modeCannyLoSpinner; Gtk::Label modeCannyHiSpinnerLabel; - Gtk::SpinButton modeCannyHiSpinner; + Inkscape::UI::Widget::SpinButton modeCannyHiSpinner; //quantization Gtk::Frame modeQuantFrame; Gtk::HBox modeQuantBox; Gtk::VBox modeQuantVBox; Gtk::RadioButton modeQuantRadioButton; Gtk::Label modeQuantNrColorLabel; - Gtk::SpinButton modeQuantNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeQuantNrColorSpinner; //params Gtk::CheckButton modeInvertButton; Gtk::HBox modeInvertBox; @@ -137,7 +138,7 @@ class TraceDialogImpl : public TraceDialog //brightness Gtk::HBox modeMultiScanHBox1; Gtk::RadioButton modeMultiScanBrightnessRadioButton; - Gtk::SpinButton modeMultiScanNrColorSpinner; + Inkscape::UI::Widget::SpinButton modeMultiScanNrColorSpinner; //colors Gtk::HBox modeMultiScanHBox2; Gtk::RadioButton modeMultiScanColorRadioButton; @@ -162,15 +163,15 @@ class TraceDialogImpl : public TraceDialog Gtk::HBox optionsSpecklesBox; Gtk::CheckButton optionsSpecklesButton; Gtk::Label optionsSpecklesSizeLabel; - Gtk::SpinButton optionsSpecklesSizeSpinner; + Inkscape::UI::Widget::SpinButton optionsSpecklesSizeSpinner; Gtk::HBox optionsCornersBox; Gtk::CheckButton optionsCornersButton; Gtk::Label optionsCornersThresholdLabel; - Gtk::SpinButton optionsCornersThresholdSpinner; + Inkscape::UI::Widget::SpinButton optionsCornersThresholdSpinner; Gtk::HBox optionsOptimBox; Gtk::CheckButton optionsOptimButton; Gtk::Label optionsOptimToleranceLabel; - Gtk::SpinButton optionsOptimToleranceSpinner; + Inkscape::UI::Widget::SpinButton optionsOptimToleranceSpinner; //#### Credits @@ -403,8 +404,9 @@ TraceDialogImpl::TraceDialogImpl() : // brightness - modeBrightnessRadioButton.set_label(_("Brightness cutoff")); + modeBrightnessRadioButton.set_label(_("_Brightness cutoff")); modeGroup = modeBrightnessRadioButton.get_group(); + modeBrightnessRadioButton.set_use_underline(true); modeBrightnessBox.pack_start(modeBrightnessRadioButton, false, false, MARGIN); tips.set_tip(modeBrightnessRadioButton, _("Trace by a given brightness level")); @@ -417,7 +419,9 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeBrightnessSpinner, _("Brightness cutoff for black/white")); - modeBrightnessSpinnerLabel.set_label(_("Threshold:")); + modeBrightnessSpinnerLabel.set_label(_("_Threshold:")); + modeBrightnessSpinnerLabel.set_use_underline(true); + modeBrightnessSpinnerLabel.set_mnemonic_widget(modeBrightnessSpinner); modeBrightnessBox.pack_end(modeBrightnessSpinnerLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeBrightnessBox, false, false, MARGIN); @@ -427,8 +431,9 @@ TraceDialogImpl::TraceDialogImpl() : // canny edge detection // TRANSLATORS: "Canny" is the name of the inventor of this edge detection method - modeCannyRadioButton.set_label(_("Edge detection")); + modeCannyRadioButton.set_label(_("_Edge detection")); modeCannyRadioButton.set_group(modeGroup); + modeCannyRadioButton.set_use_underline(true); modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN); tips.set_tip(modeCannyRadioButton, _("Trace with optimal edge detection by J. Canny's algorithm")); @@ -450,7 +455,9 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeCannyHiSpinner, _("Brightness cutoff for adjacent pixels (determines edge thickness)")); - modeCannyHiSpinnerLabel.set_label(_("Threshold:")); + modeCannyHiSpinnerLabel.set_label(_("T_hreshold:")); + modeCannyHiSpinnerLabel.set_use_underline(true); + modeCannyHiSpinnerLabel.set_mnemonic_widget(modeCannyHiSpinner); modeCannyBox.pack_end(modeCannyHiSpinnerLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeCannyBox, false, false, MARGIN); @@ -460,8 +467,9 @@ TraceDialogImpl::TraceDialogImpl() : // of colors in an image by selecting an optimized set of representative // colors and then re-applying this reduced set to the original image. - modeQuantRadioButton.set_label(_("Color quantization")); + modeQuantRadioButton.set_label(_("Color _quantization")); modeQuantRadioButton.set_group(modeGroup); + modeQuantRadioButton.set_use_underline(true); modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN); tips.set_tip(modeQuantRadioButton, _("Trace along the boundaries of reduced colors")); @@ -474,14 +482,17 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(modeQuantNrColorSpinner, _("The number of reduced colors")); - modeQuantNrColorLabel.set_label(_("Colors:")); + modeQuantNrColorLabel.set_label(_("_Colors:")); + modeQuantNrColorLabel.set_mnemonic_widget(modeQuantNrColorSpinner); + modeQuantNrColorLabel.set_use_underline(true); modeQuantBox.pack_end(modeQuantNrColorLabel, false, false, MARGIN); modeBrightnessVBox.pack_start(modeQuantBox, false, false, MARGIN); // swap black and white - modeInvertButton.set_label(_("Invert image")); + modeInvertButton.set_label(_("_Invert image")); modeInvertButton.set_active(false); + modeInvertButton.set_use_underline(true); modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN); modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN); tips.set_tip(modeInvertButton, @@ -494,8 +505,9 @@ TraceDialogImpl::TraceDialogImpl() : //# begin multiple scan - modeMultiScanBrightnessRadioButton.set_label(_("Brightness steps")); + modeMultiScanBrightnessRadioButton.set_label(_("B_rightness steps")); modeMultiScanBrightnessRadioButton.set_group(modeGroup); + modeMultiScanBrightnessRadioButton.set_use_underline(true); modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanBrightnessRadioButton, _("Trace the given number of brightness levels")); @@ -505,23 +517,27 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanNrColorSpinner.set_range(2.0, 256.0); modeMultiScanNrColorSpinner.set_value(8.0); modeMultiScanHBox1.pack_end(modeMultiScanNrColorSpinner, false, false, MARGIN); - modeMultiScanNrColorLabel.set_label(_("Scans:")); + modeMultiScanNrColorLabel.set_label(_("Sc_ans:")); + modeMultiScanNrColorLabel.set_use_underline(true); + modeMultiScanNrColorLabel.set_mnemonic_widget(modeMultiScanNrColorSpinner); modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN); tips.set_tip(modeMultiScanNrColorSpinner, _("The desired number of scans")); modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN); - modeMultiScanColorRadioButton.set_label(_("Colors")); + modeMultiScanColorRadioButton.set_label(_("Co_lors")); modeMultiScanColorRadioButton.set_group(modeGroup); + modeMultiScanColorRadioButton.set_use_underline(true); modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanColorRadioButton, _("Trace the given number of reduced colors")); modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN); - modeMultiScanMonoRadioButton.set_label(_("Grays")); + modeMultiScanMonoRadioButton.set_label(_("_Grays")); modeMultiScanMonoRadioButton.set_group(modeGroup); + modeMultiScanMonoRadioButton.set_use_underline(true); modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN); tips.set_tip(modeMultiScanMonoRadioButton, _("Same as Colors, but the result is converted to grayscale")); @@ -529,20 +545,23 @@ TraceDialogImpl::TraceDialogImpl() : modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN); // TRANSLATORS: "Smooth" is a verb here - modeMultiScanSmoothButton.set_label(_("Smooth")); + modeMultiScanSmoothButton.set_label(_("S_mooth")); + modeMultiScanSmoothButton.set_use_underline(true); modeMultiScanSmoothButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN); tips.set_tip(modeMultiScanSmoothButton, _("Apply Gaussian blur to the bitmap before tracing")); // TRANSLATORS: "Stack" is a verb here - modeMultiScanStackButton.set_label(_("Stack scans")); + modeMultiScanStackButton.set_label(_("Stac_k scans")); + modeMultiScanStackButton.set_use_underline(true); modeMultiScanStackButton.set_active(true); modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN); tips.set_tip(modeMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)")); - modeMultiScanBackgroundButton.set_label(_("Remove background")); + modeMultiScanBackgroundButton.set_label(_("Remo_ve background")); + modeMultiScanBackgroundButton.set_use_underline(true); modeMultiScanBackgroundButton.set_active(false); modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN); // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan @@ -560,13 +579,14 @@ TraceDialogImpl::TraceDialogImpl() : //## end mode page - notebook.append_page(modePageBox, _("Mode")); + notebook.append_page(modePageBox, _("_Mode"), true); //## begin option page //# potrace parameters - optionsSpecklesButton.set_label(_("Suppress speckles")); + optionsSpecklesButton.set_label(_("Suppress _speckles")); + optionsSpecklesButton.set_use_underline(true); tips.set_tip(optionsSpecklesButton, _("Ignore small spots (speckles) in the bitmap")); optionsSpecklesButton.set_active(true); @@ -578,10 +598,13 @@ TraceDialogImpl::TraceDialogImpl() : tips.set_tip(optionsSpecklesSizeSpinner, _("Speckles of up to this many pixels will be suppressed")); optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN); - optionsSpecklesSizeLabel.set_label(_("Size:")); + optionsSpecklesSizeLabel.set_label(_("S_ize:")); + optionsSpecklesSizeLabel.set_use_underline(true); + optionsSpecklesSizeLabel.set_mnemonic_widget(optionsSpecklesSizeSpinner); optionsSpecklesBox.pack_end(optionsSpecklesSizeLabel, false, false, MARGIN); - optionsCornersButton.set_label(_("Smooth corners")); + optionsCornersButton.set_label(_("Smooth _corners")); + optionsCornersButton.set_use_underline(true); tips.set_tip(optionsCornersButton, _("Smooth out sharp corners of the trace")); optionsCornersButton.set_active(true); @@ -593,10 +616,13 @@ TraceDialogImpl::TraceDialogImpl() : optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN); tips.set_tip(optionsCornersThresholdSpinner, _("Increase this to smooth corners more")); - optionsCornersThresholdLabel.set_label(_("Threshold:")); + optionsCornersThresholdLabel.set_label(_("_Threshold:")); + optionsCornersThresholdLabel.set_use_underline(true); + optionsCornersThresholdLabel.set_mnemonic_widget(optionsCornersThresholdSpinner); optionsCornersBox.pack_end(optionsCornersThresholdLabel, false, false, MARGIN); - optionsOptimButton.set_label(_("Optimize paths")); + optionsOptimButton.set_label(_("Optimize p_aths")); + optionsOptimButton.set_use_underline(true); optionsOptimButton.set_active(true); tips.set_tip(optionsOptimButton, _("Try to optimize paths by joining adjacent Bezier curve segments")); @@ -608,7 +634,9 @@ TraceDialogImpl::TraceDialogImpl() : optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN); tips.set_tip(optionsOptimToleranceSpinner, _("Increase this to reduce the number of nodes in the trace by more aggressive optimization")); - optionsOptimToleranceLabel.set_label(_("Tolerance:")); + optionsOptimToleranceLabel.set_label(_("To_lerance:")); + optionsOptimToleranceLabel.set_use_underline(true); + optionsOptimToleranceLabel.set_mnemonic_widget(optionsOptimToleranceSpinner); optionsOptimBox.pack_end(optionsOptimToleranceLabel, false, false, MARGIN); optionsVBox.pack_start(optionsSpecklesBox, false, false, MARGIN); @@ -620,7 +648,7 @@ TraceDialogImpl::TraceDialogImpl() : //## end option page - notebook.append_page(optionsPageBox, _("Options")); + notebook.append_page(optionsPageBox, _("O_ptions"), true); //### credits @@ -641,7 +669,8 @@ TraceDialogImpl::TraceDialogImpl() : //## SIOX - sioxButton.set_label(_("SIOX foreground selection")); + sioxButton.set_label(_("SIOX _foreground selection")); + sioxButton.set_use_underline(true); sioxBox.pack_start(sioxButton, false, false, MARGIN); tips.set_tip(sioxButton, _("Cover the area you want to select as the foreground")); @@ -649,7 +678,8 @@ TraceDialogImpl::TraceDialogImpl() : //## preview - previewButton.set_label(_("Update")); + previewButton.set_label(_("_Update")); + previewButton.set_use_underline(true); previewButton.signal_clicked().connect( sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) ); previewVBox.pack_end(previewButton, false, false, 0); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 38664fd3a..570120bcd 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -1,5 +1,6 @@ -/** @file - * \brief Transform dialog - implementation +/** + * @file + * Transform dialog - implementation. */ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> @@ -16,12 +17,12 @@ #include <gtkmm/stock.h> #include <gtkmm/dialog.h> +#include <2geom/transforms.h> #include "document.h" #include "desktop-handles.h" #include "transformation.h" #include "align-and-distribute.h" -#include "libnr/nr-matrix-ops.h" #include "inkscape.h" #include "selection.h" #include "selection-chemistry.h" @@ -467,7 +468,7 @@ Transformation::updatePageMove(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (!_check_move_relative.get_active()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double x = bbox->min()[Geom::X]; double y = bbox->min()[Geom::Y]; @@ -489,7 +490,7 @@ void Transformation::updatePageScale(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -519,7 +520,7 @@ void Transformation::updatePageSkew(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { double w = bbox->dimensions()[Geom::X]; double h = bbox->dimensions()[Geom::Y]; @@ -616,7 +617,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { sp_selection_move_relative(selection, x, y); } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -637,7 +638,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -661,7 +662,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->getBboxDesktop(); + Geom::OptRect bbox = (*it)->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -680,7 +681,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) } } } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { sp_selection_move_relative(selection, x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); @@ -699,49 +700,54 @@ Transformation::applyPageScale(Inkscape::Selection *selection) double scaleY = _scalar_scale_vertical.getValue("px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; if (prefs->getBool("/dialogs/transformation/applyseparately")) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - Geom::Scale scale (0,0); - // the values are increments! - if (_units_scale.isAbsolute()) { - Geom::OptRect bbox(item->getBboxDesktop()); - if (bbox) { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / bbox->dimensions()[Geom::X], new_height / bbox->dimensions()[Geom::Y]); - } - } else { + Geom::OptRect bbox_pref = item->desktopPreferredBounds(); + Geom::OptRect bbox_geom = item->desktopGeometricBounds(); + if (bbox_pref && bbox_geom) { double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; double new_height = scaleY; + // the values are increments! + if (!_units_scale.isAbsolute()) { // Relative scaling, i.e in percent + new_width = scaleX/100 * bbox_pref->width(); + new_height = scaleY/100 * bbox_pref->height(); + } + if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / 100.0, new_height / 100.0); + + double x0 = bbox_pref->midpoint()[Geom::X] - new_width/2; + double y0 = bbox_pref->midpoint()[Geom::Y] - new_height/2; + double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; + double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; + + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + item->set_i2d_affine(item->i2dt_affine() * scaler); + item->doWriteTransform(item->getRepr(), item->transform); } - sp_item_scale_rel (item, scale); } } else { - Geom::OptRect bbox(selection->bounds()); - if (bbox) { - Geom::Point center(bbox->midpoint()); // use rotation center? - Geom::Scale scale (0,0); + Geom::OptRect bbox_pref = selection->preferredBounds(); + Geom::OptRect bbox_geom = selection->geometricBounds(); + if (bbox_pref && bbox_geom) { // the values are increments! - if (_units_scale.isAbsolute()) { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / bbox->dimensions()[Geom::X], new_height / bbox->dimensions()[Geom::Y]); - } else { - double new_width = scaleX; - if (fabs(new_width) < 1e-6) new_width = 1e-6; - double new_height = scaleY; - if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = Geom::Scale(new_width / 100.0, new_height / 100.0); + double new_width = scaleX; + double new_height = scaleY; + if (!_units_scale.isAbsolute()) { // Relative scaling, i.e in percent + new_width = scaleX/100 * bbox_pref->width(); + new_height = scaleY/100 * bbox_pref->height(); } - sp_selection_scale_relative(selection, center, scale); + if (fabs(new_width) < 1e-6) new_width = 1e-6; + if (fabs(new_height) < 1e-6) new_height = 1e-6; + + double x0 = bbox_pref->midpoint()[Geom::X] - new_width/2; + double y0 = bbox_pref->midpoint()[Geom::Y] - new_height/2; + double x1 = bbox_pref->midpoint()[Geom::X] + new_width/2; + double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; + Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, x0, y0, x1, y1); + + sp_selection_apply_affine(selection, scaler); } } @@ -792,7 +798,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); - Geom::OptRect bbox(item->getBboxDesktop()); + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; @@ -801,7 +807,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } } else { // transform whole selection - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); boost::optional<Geom::Point> center = selection->center(); if ( bbox && center ) { @@ -886,7 +892,7 @@ Transformation::onMoveRelativeToggled() //g_message("onMoveRelativeToggled: %f, %f px\n", x, y); - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { if (_check_move_relative.get_active()) { @@ -1026,7 +1032,7 @@ Transformation::onClear() _scalar_move_horizontal.setValue(0); _scalar_move_vertical.setValue(0); } else { - Geom::OptRect bbox = selection->bounds(); + Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { _scalar_move_horizontal.setValue(bbox->min()[Geom::X], "px"); _scalar_move_vertical.setValue(bbox->min()[Geom::Y], "px"); diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index e6f113e48..74de33b27 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Undo History dialog - implementation +/** + * @file + * Undo History dialog - implementation. */ /* Author: * Gustav Broberg <broberg@kth.se> @@ -14,7 +15,7 @@ #endif #include <glibmm/i18n.h> -#include <gtk/gtkimage.h> +#include <gtk/gtk.h> #include <stddef.h> #include <sigc++/sigc++.h> diff --git a/src/ui/dialog/whiteboard-connect.cpp b/src/ui/dialog/whiteboard-connect.cpp deleted file mode 100644 index 0555281d4..000000000 --- a/src/ui/dialog/whiteboard-connect.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/** @file - * @brief Whiteboard connection dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> -#include <gtk/gtkdialog.h> -#include <gtkmm/entry.h> -#include <gtkmm/checkbutton.h> -#include <gtkmm/table.h> - -#include "inkscape.h" -#include "desktop.h" -#include "message-stack.h" -#include "preferences.h" - -#include "jabber_whiteboard/session-manager.h" - -#include "message-context.h" -#include "ui/dialog/whiteboard-connect.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -WhiteboardConnectDialog* -WhiteboardConnectDialog::create() -{ - return new WhiteboardConnectDialogImpl(); -} - -WhiteboardConnectDialogImpl::WhiteboardConnectDialogImpl() : - _layout(4, 4, false), _usessl(_("_Use SSL"), true), _register(_("_Register"), true) -{ - this->setSessionManager(); - this->_construct(); - //this->set_resize_mode(Gtk::RESIZE_IMMEDIATE); - this->set_resizable(false); - this->get_vbox()->show_all_children(); -} - -WhiteboardConnectDialogImpl::~WhiteboardConnectDialogImpl() -{ -} - -void WhiteboardConnectDialogImpl::present() -{ - Dialog::present(); -} - -void -WhiteboardConnectDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); -} - -void -WhiteboardConnectDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct dialog interface - this->_labels[0].set_markup_with_mnemonic(_("_Server:")); - this->_labels[1].set_markup_with_mnemonic(_("_Username:")); - this->_labels[2].set_markup_with_mnemonic(_("_Password:")); - this->_labels[3].set_markup_with_mnemonic(_("P_ort:")); - - this->_labels[0].set_mnemonic_widget(this->_server); - this->_labels[1].set_mnemonic_widget(this->_username); - this->_labels[2].set_mnemonic_widget(this->_password); - this->_labels[3].set_mnemonic_widget(this->_port); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - this->_server.set_text(prefs->getString("/whiteboard/server/name")); - /// @todo Convert port to an integer preference? - this->_port.set_text(prefs->getString("/whiteboard/server/port")); - this->_username.set_text(prefs->getString("/whiteboard/server/username")); - this->_usessl.set_active(prefs->getBool("/whiteboard/server/ssl", false); - - this->_layout.attach(this->_labels[0], 0, 1, 0, 1); - this->_layout.attach(this->_labels[1], 0, 1, 1, 2); - this->_layout.attach(this->_labels[2], 0, 1, 2, 3); - this->_layout.attach(this->_labels[3], 2, 3, 0, 1); - - this->_layout.attach(this->_server, 1, 2, 0, 1); - this->_layout.attach(this->_port, 3, 4, 0, 1); - this->_layout.attach(this->_username, 1, 4, 1, 2); - this->_layout.attach(this->_password, 1, 4, 2, 3); - - this->_checkboxes.attach(this->_blank,0,1,0,1); - this->_checkboxes.attach(this->_blank,0,1,1,2); - - this->_checkboxes.attach(this->_usessl, 1, 4, 0, 1); - this->_checkboxes.attach(this->_register, 1, 5, 1, 2); - - this->_layout.set_col_spacings(1); - this->_layout.set_row_spacings(1); - - this->_password.set_visibility(false); - this->_password.set_invisible_char('*'); - - // Buttons - this->_ok.set_label(_("Connect")); - this->_cancel.set_label(_("Cancel")); - - this->_ok.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_OK)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_respCallback), GTK_RESPONSE_CANCEL)); - - this->_register.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_registerCallback)); - this->_usessl.signal_clicked().connect(sigc::mem_fun(*this, &WhiteboardConnectDialogImpl::_useSSLClickedCallback)); - - this->_buttons.pack_start(this->_cancel, true, true, 0); - this->_buttons.pack_end(this->_ok, true, true, 0); - - // Pack widgets into main vbox - main->pack_start(this->_layout,Gtk::PACK_SHRINK); - main->pack_start(this->_checkboxes,Gtk::PACK_SHRINK); - main->pack_end(this->_buttons,Gtk::PACK_SHRINK); -} - - -void -WhiteboardConnectDialogImpl::_registerCallback() -{ - if (this->_register.get_active()) - { - Glib::ustring server, port; - bool usessl; - - server = this->_server.get_text(); - port = this->_port.get_text(); - usessl = this->_usessl.get_active(); - - Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - if(this->_sm->initializeConnection(server,port,usessl) == CONNECT_SUCCESS) - { - - std::vector<Glib::ustring> entries = this->_sm->getRegistrationInfo(); - - for(unsigned i = 0; i<entries.size();i++) - { - - Gtk::Entry *entry = manage (new Gtk::Entry); - Gtk::Label *label = manage (new Gtk::Label); - - Glib::ustring::size_type zero=0,one=1; - Glib::ustring LabelText = entries[i].replace(zero,one,one,Glib::Unicode::toupper(entries[i].at(0))); - - (*label).set_markup_with_mnemonic(LabelText.c_str()); - (*label).set_mnemonic_widget(*entry); - - this->_layout.attach (*label, 0, 1, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0); - this->_layout.attach (*entry, 1, 4, i+3, i+4, Gtk::FILL|Gtk::EXPAND|Gtk::SHRINK, (Gtk::AttachOptions)0,0,0); - - this->registerlabels.push_back(label); - this->registerentries.push_back(entry); - } - }else{ - Glib::ustring msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - } - - }else{ - - for(unsigned i = 0; i<registerlabels.size();i++) - { - this->_layout.remove(*registerlabels[i]); - this->_layout.remove(*registerentries[i]); - - delete registerlabels[i]; - delete registerentries[i]; - } - - registerentries.erase(registerentries.begin(), registerentries.end()); - registerlabels.erase(registerlabels.begin(), registerlabels.end()); - } - - this->get_vbox()->show_all_children(); - //this->reshow_with_initial_size(); -} - -void -WhiteboardConnectDialogImpl::_respCallback(int resp) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (resp == GTK_RESPONSE_OK) - { - Glib::ustring server, port, username, password; - bool usessl; - - server = this->_server.get_text(); - port = this->_port.get_text(); - username = this->_username.get_text(); - password = this->_password.get_text(); - usessl = this->_usessl.get_active(); - - Glib::ustring msg = String::ucompose(_("Establishing connection to Jabber server <b>%1</b> as user <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - if (!this->_register.get_active()) - { - switch (this->_sm->connectToServer(server, port, username, password, usessl)) { - case FAILED_TO_CONNECT: - msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case INVALID_AUTH: - msg = String::ucompose(_("Authentication failed on Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case SSL_INITIALIZATION_ERROR: - msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - - case CONNECT_SUCCESS: - msg = String::ucompose(_("Connected to Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - // Save preferences - prefs->setString(this->_prefs_path + "/server", this->_server.get_text()); - break; - default: - break; - } - }else{ - - std::vector<Glib::ustring> key,val; - - for(unsigned i = 0; i<registerlabels.size();i++) - { - key.push_back((*registerlabels[i]).get_text()); - val.push_back((*registerentries[i]).get_text()); - } - - switch (this->_sm->registerWithServer(username, password, key, val)) - { - case FAILED_TO_CONNECT: - msg = String::ucompose(_("Failed to establish connection to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case INVALID_AUTH: - msg = String::ucompose(_("Registration failed on Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - case SSL_INITIALIZATION_ERROR: - msg = String::ucompose(_("SSL initialization failed when connecting to Jabber server <b>%1</b>"), server); - this->_desktop->messageStack()->flash(WARNING_MESSAGE, msg.data()); - this->_sm->connectionError(msg); - break; - - case CONNECT_SUCCESS: - msg = String::ucompose(_("Connected to Jabber server <b>%1</b> as <b>%2</b>"), server, username); - this->_desktop->messageStack()->flash(INFORMATION_MESSAGE, msg.data()); - - // Save preferences - prefs->setString(this->_prefs_path + "/server", this->_server.get_text()); - break; - default: - break; - } - } - } - - this->_password.set_text(""); - this->hide(); -} - -void -WhiteboardConnectDialogImpl::_useSSLClickedCallback() -{ - if (this->_usessl.get_active()) { - this->_port.set_text("5223"); - - // String::ucompose seems to format numbers according to locale; unfortunately, - // I'm not yet sure how to turn that off - //this->_port.set_text(String::ucompose("%1", LM_CONNECTION_DEFAULT_PORT_SSL)); - } else { - this->_port.set_text("5222"); - } -} - -} // namespace Dialog - -} // namespace UI - -} // 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:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/whiteboard-connect.h b/src/ui/dialog/whiteboard-connect.h deleted file mode 100644 index 8b34215f9..000000000 --- a/src/ui/dialog/whiteboard-connect.h +++ /dev/null @@ -1,99 +0,0 @@ -/** @file - * @brief Whiteboard connection dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_CONNECT_DIALOG_H__ -#define __WHITEBOARD_CONNECT_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include <vector> - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; - -} - -namespace UI { - -namespace Dialog { - -class WhiteboardConnectDialog : public Dialog { -public: - WhiteboardConnectDialog() : Dialog("/dialogs/whiteboard_connect", SP_VERB_DIALOG_WHITEBOARD_CONNECT) - { - - } - - static WhiteboardConnectDialog* create(); - - virtual ~WhiteboardConnectDialog() - { - - } -}; - -class WhiteboardConnectDialogImpl : public WhiteboardConnectDialog { -public: - WhiteboardConnectDialogImpl(); - ~WhiteboardConnectDialogImpl(); - void present(); - void setSessionManager(); - -private: - - // GTK+ widgets - std::vector<Gtk::Label*> registerlabels; - std::vector<Gtk::Entry*> registerentries; - - Gtk::Table _layout,_checkboxes; - Gtk::HBox _buttons; - - Gtk::Entry _server; - Gtk::Entry _username; - Gtk::Entry _password; - Gtk::Entry _port; - - Gtk::Label _labels[4],_blank; - - Gtk::CheckButton _usessl,_register; - - Gtk::Button _ok, _cancel; - - // Construction and callbacks - void _construct(); - void _respCallback(int resp); - - void _registerCallback(); - void _useSSLClickedCallback(); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - - -} - -} - -} - -#endif diff --git a/src/ui/dialog/whiteboard-sharewithchat.cpp b/src/ui/dialog/whiteboard-sharewithchat.cpp deleted file mode 100644 index 3315a7029..000000000 --- a/src/ui/dialog/whiteboard-sharewithchat.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/** @file - * @brief Whiteboard share with chatroom dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include <sigc++/sigc++.h> -#include <gtk/gtkdialog.h> - -#include "message-stack.h" -#include "message-context.h" -#include "inkscape.h" -#include "desktop.h" - -#include "preferences.h" - -#include "jabber_whiteboard/typedefs.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/buddy-list-manager.h" - -#include "jabber_whiteboard/session-file-selector.h" - -#include "ui/dialog/whiteboard-sharewithchat.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { -namespace UI { -namespace Dialog { - -WhiteboardShareWithChatroomDialog* -WhiteboardShareWithChatroomDialog::create() -{ - return new WhiteboardShareWithChatroomDialogImpl(); -} - -WhiteboardShareWithChatroomDialogImpl::WhiteboardShareWithChatroomDialogImpl() : - _layout(4, 2, false) -{ - this->setSessionManager(); - this->_construct(); - this->get_vbox()->show_all_children(); -} - -WhiteboardShareWithChatroomDialogImpl::~WhiteboardShareWithChatroomDialogImpl() -{ - -} - -void -WhiteboardShareWithChatroomDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - -} - - -void -WhiteboardShareWithChatroomDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct labels - this->_labels[0].set_markup_with_mnemonic(_("Chatroom _name:")); - this->_labels[1].set_markup_with_mnemonic(_("Chatroom _server:")); - this->_labels[2].set_markup_with_mnemonic(_("Chatroom _password:")); - this->_labels[3].set_markup_with_mnemonic(_("Chatroom _handle:")); - - this->_labels[0].set_mnemonic_widget(this->_roomname); - this->_labels[1].set_mnemonic_widget(this->_confserver); - this->_labels[2].set_mnemonic_widget(this->_roompass); - this->_labels[3].set_mnemonic_widget(this->_handle); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - this->_roomname.set_text(prefs->getString("/whiteboard/room/name")); - this->_confserver.set_text(prefs->getString("/whiteboard/room/server")); - this->_handle.set_text(prefs->getString("/whiteboard/server/username")); - - // Pack table - this->_layout.attach(this->_labels[0], 0, 1, 0, 1); - this->_layout.attach(this->_labels[1], 0, 1, 1, 2); - this->_layout.attach(this->_labels[2], 0, 1, 2, 3); - this->_layout.attach(this->_labels[3], 0, 1, 3, 4); - - this->_layout.attach(this->_roomname, 1, 2, 0, 1); - this->_layout.attach(this->_confserver, 1, 2, 1, 2); - this->_layout.attach(this->_roompass, 1, 2, 2, 3); - this->_layout.attach(this->_handle, 1, 2, 3, 4); - - // Button setup and callback registration - this->_share.set_label(_("Connect to chatroom")); - this->_cancel.set_label(_("Cancel")); - this->_share.set_use_underline(true); - this->_cancel.set_use_underline(true); - - this->_share.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::SHARE)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithChatroomDialogImpl::_respCallback), WhiteboardShareWithChatroomDialogImpl::CANCEL)); - - // Pack buttons - this->_buttonsbox.pack_start(this->_cancel); - this->_buttonsbox.pack_start(this->_share); - - // Set default values - Glib::ustring jid = this->_sm->session_data->jid; - Glib::ustring nick = jid.substr(0, jid.find_first_of('@')); - this->_handle.set_text(nick); - this->_roomname.set_text("inkboard"); - - // Pack into main box - main->pack_start(this->_layout); - main->pack_end(this->_buttonsbox); -} - -void -WhiteboardShareWithChatroomDialogImpl::_respCallback(int resp) -{ - switch (resp) { - case SHARE: - { - Glib::ustring chatroom, server, handle, password; - chatroom = this->_roomname.get_text(); - server = this->_confserver.get_text(); - password = this->_roompass.get_text(); - handle = this->_handle.get_text(); - - Glib::ustring msg = String::ucompose(_("Synchronizing with chatroom <b>%1@%2</b> using the handle <b>%3</b>"), chatroom, server, handle); - - this->_desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.data()); - - this->_desktop->whiteboard_session_manager()->sendRequestToChatroom(server, chatroom, handle, password); - } - case CANCEL: - default: - this->hide(); - break; - } -} - -} // namespace Dialog -} // namespace UI -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/dialog/whiteboard-sharewithchat.h b/src/ui/dialog/whiteboard-sharewithchat.h deleted file mode 100644 index 4a6c2fc89..000000000 --- a/src/ui/dialog/whiteboard-sharewithchat.h +++ /dev/null @@ -1,96 +0,0 @@ -/** @file - * @brief Whiteboard share with chatroom dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal - * Jonas Collaros - * Stephen Montgomery - * Brandi Soggs - * Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_SHAREWITHCHAT_DIALOG_H__ -#define __WHITEBOARD_SHAREWITHCHAT_DIALOG_H__ - -#include "verbs.h" -#include "dialog.h" - -#include <gtkmm/table.h> -#include "jabber_whiteboard/session-file-selector.h" - -struct SPDesktop; - -namespace Inkscape { - -namespace Whiteboard { - -class SessionManager; - -} - -namespace UI { - -namespace Dialog { - -class WhiteboardShareWithChatroomDialog : public Dialog { -public: - WhiteboardShareWithChatroomDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER) - { - - } - - static WhiteboardShareWithChatroomDialog* create(); - - virtual ~WhiteboardShareWithChatroomDialog() - { - - } -}; - - -class WhiteboardShareWithChatroomDialogImpl : public WhiteboardShareWithChatroomDialog { -public: - WhiteboardShareWithChatroomDialogImpl(); - ~WhiteboardShareWithChatroomDialogImpl(); - void setSessionManager(); - -private: - // Response flags - static unsigned int const SHARE = 0; - static unsigned int const CANCEL = 2; - - // GTK+ widgets - Gtk::Table _layout; - - Gtk::HBox _buttonsbox; - Whiteboard::SessionFileSelectorBox _sfsbox; - - Gtk::Entry _roomname; - Gtk::Entry _roompass; - Gtk::Entry _confserver; - Gtk::Entry _handle; - - Gtk::Label _labels[4]; - - Gtk::Button _share, _cancel; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - -} - -} - -} - -#endif diff --git a/src/ui/dialog/whiteboard-sharewithuser.cpp b/src/ui/dialog/whiteboard-sharewithuser.cpp deleted file mode 100644 index 6d905b684..000000000 --- a/src/ui/dialog/whiteboard-sharewithuser.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/** @file - * Whiteboard share with user dialog - implementation - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glibmm/i18n.h> - -#include <sigc++/sigc++.h> -#include <gtk/gtkdialog.h> - -#include "message-stack.h" -#include "message-context.h" -#include "inkscape.h" -#include "desktop.h" - -#include "jabber_whiteboard/typedefs.h" -#include "jabber_whiteboard/session-manager.h" -#include "jabber_whiteboard/buddy-list-manager.h" - -#include "jabber_whiteboard/session-file-selector.h" - -#include "ui/dialog/whiteboard-sharewithuser.h" - -#include "util/ucompose.hpp" - -namespace Inkscape { - -namespace UI { - -namespace Dialog { - -WhiteboardShareWithUserDialog* -WhiteboardShareWithUserDialog::create() -{ - return new WhiteboardShareWithUserDialogImpl(); -} - -WhiteboardShareWithUserDialogImpl::WhiteboardShareWithUserDialogImpl() -{ - this->setSessionManager(); - this->_construct(); - this->get_vbox()->show_all_children(); - - this->_sm->session_data->buddyList.addInsertListener(sigc::mem_fun(this, &WhiteboardShareWithUserDialogImpl::_insertBuddy)); - this->_sm->session_data->buddyList.addEraseListener(sigc::mem_fun(this, &WhiteboardShareWithUserDialogImpl::_eraseBuddy)); - -} - -WhiteboardShareWithUserDialogImpl::~WhiteboardShareWithUserDialogImpl() -{ - -} - -void -WhiteboardShareWithUserDialogImpl::setSessionManager() -{ - this->_desktop = this->getDesktop(); - this->_sm = this->_desktop->whiteboard_session_manager(); - -} - - -void -WhiteboardShareWithUserDialogImpl::_construct() -{ - Gtk::VBox* main = this->get_vbox(); - - // Construct dialog interface - this->_labels[0].set_markup_with_mnemonic(_("_User's Jabber ID:")); - this->_labels[0].set_mnemonic_widget(this->_jid); - - // Buttons - this->_share.set_label(_("_Invite user")); - this->_cancel.set_label(_("_Cancel")); - this->_share.set_use_underline(true); - this->_cancel.set_use_underline(true); - - // Button callbacks - this->_share.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_respCallback), SHARE)); - this->_cancel.signal_clicked().connect(sigc::bind< 0 >(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_respCallback), CANCEL)); - - // Construct ListStore for buddy list information - this->_buddylistdata = Gtk::ListStore::create(this->_blm); - this->_buddylist.set_model(this->_buddylistdata); - this->_buddylist.append_column(_("Buddy List"), this->_blm.jid); - - // Fill buddy list - this->_fillBuddyList(); - - // Buddy list onclick callback - this->_buddylist.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &WhiteboardShareWithUserDialogImpl::_listCallback)); - - // Pack widgets into boxes - this->_listwindow.add(this->_buddylist); - this->_listwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - this->_buddylistbox.pack_start(this->_listwindow); - - this->_connecttojidbox.pack_start(this->_labels[0]); - this->_connecttojidbox.pack_end(this->_jid); - - this->_buttons.pack_start(this->_cancel); - this->_buttons.pack_end(this->_share); - - // Pack boxes into main box - main->pack_start(this->_buddylistbox); - main->pack_start(this->_connecttojidbox); - main->pack_start(this->_sfsbox); - main->pack_end(this->_buttons); -} - - -void -WhiteboardShareWithUserDialogImpl::_fillBuddyList() -{ - Whiteboard::BuddyList& bl = this->_sm->session_data->buddyList.getList(); - - for(Whiteboard::BuddyList::iterator i = bl.begin(); i != bl.end(); i++) { - this->_insertBuddy(*i); - } -// std::for_each(bl.begin(), bl.end(), std::mem_fun(&WhiteboardShareWithUserDialogImpl::_insertBuddy)); -} - -void -WhiteboardShareWithUserDialogImpl::_insertBuddy(std::string const& jid) -{ - // FIXME: need a better way to avoid inserting duplicate rows in the case - // of duplicate Jabber presence messages - typedef Gtk::TreeModel::Children type_children; - type_children children = this->_buddylistdata->children(); - for(type_children::iterator i = children.begin(); i != children.end(); i++) { - if ((*i).get_value(this->_blm.jid) == jid) { - return; - } - } - - Gtk::TreeModel::Row row = *(this->_buddylistdata->append()); - row[this->_blm.jid] = jid; -} - -void -WhiteboardShareWithUserDialogImpl::_eraseBuddy(std::string const& jid) -{ - // FIXME: Doesn't gtkmm provide a better way to erase rows from a ListStore? - typedef Gtk::TreeModel::Children type_children; - type_children children = this->_buddylistdata->children(); - for(type_children::iterator i = children.begin(); i != children.end(); i++) { - if ((*i).get_value(this->_blm.jid) == jid) { - this->_buddylistdata->erase(i); - return; - } - } -} - -void -WhiteboardShareWithUserDialogImpl::_respCallback(int resp) -{ - switch (resp) { - case SHARE: - { - Glib::ustring jid = this->_jid.get_text(); - - // Check that the JID is in the format user@host/resource - if (jid.find("@", 0) == Glib::ustring::npos) { - jid += "@"; - jid += lm_connection_get_server(this->_sm->session_data->connection); - } - - if (jid.find("/", 0) == Glib::ustring::npos) { - jid += "/" + static_cast< Glib::ustring >(RESOURCE_NAME); - } - - g_log(NULL, G_LOG_LEVEL_DEBUG, "Full JID is %s", jid.c_str()); - - Glib::ustring msg = String::ucompose(_("Sending whiteboard invitation to <b>%1</b>"), jid); - this->_sm->desktop()->messageStack()->flash(Inkscape::NORMAL_MESSAGE, msg.data()); - if (this->_sfsbox.isSelected()) { - this->_sm->session_data->sessionFile = this->_sfsbox.getFilename(); - } else { - this->_sm->session_data->sessionFile.clear(); - } - this->_sm->sendRequestToUser(jid); - this->hide(); - break; - } - - case CANCEL: - this->hide(); - break; - - default: - break; - } -} - -void -WhiteboardShareWithUserDialogImpl::_listCallback() -{ - Glib::RefPtr< Gtk::TreeSelection > sel = this->_buddylist.get_selection(); - - typedef Gtk::TreeModel::Children type_children; - type_children::iterator row = sel->get_selected(); - this->_jid.set_text((*row).get_value(this->_blm.jid)); -} - -} - -} - -} - -/* - 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/ui/dialog/whiteboard-sharewithuser.h b/src/ui/dialog/whiteboard-sharewithuser.h deleted file mode 100644 index 24ec91be5..000000000 --- a/src/ui/dialog/whiteboard-sharewithuser.h +++ /dev/null @@ -1,110 +0,0 @@ -/** @file - * @brief Whiteboard share with user dialog - */ -/* Authors: - * David Yip <yipdw@rose-hulman.edu> - * Jason Segal, Jonas Collaros, Stephen Montgomery, Brandi Soggs, Matthew Weinstock (original C/Gtk version) - * - * Copyright (c) 2004-2005 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef __WHITEBOARD_SHAREWITHUSER_DIALOG_H__ -#define __WHITEBOARD_SHAREWITHUSER_DIALOG_H__ - -#include <gtkmm/liststore.h> -#include <gtkmm/treeview.h> -#include <gtkmm/scrolledwindow.h> - -#include "verbs.h" -#include "ui/dialog/dialog.h" -#include "jabber_whiteboard/session-file-selector.h" - - -struct SPDesktop; - -namespace Inkscape { - namespace Whiteboard { - class SessionManager; - } - namespace UI { - namespace Dialog { - -class WhiteboardShareWithUserDialog : public Dialog { -public: - WhiteboardShareWithUserDialog() : Dialog("/dialogs/whiteboard_sharewithuser", SP_VERB_DIALOG_WHITEBOARD_SHAREWITHUSER) - { - - } - - static WhiteboardShareWithUserDialog* create(); - - virtual ~WhiteboardShareWithUserDialog() - { - - } -}; - -class WhiteboardShareWithUserDialogImpl : public WhiteboardShareWithUserDialog { -public: - WhiteboardShareWithUserDialogImpl(); - ~WhiteboardShareWithUserDialogImpl(); - void setSessionManager(); - -private: - // Response flags - static unsigned int const SHARE = 0; - static unsigned int const CANCEL = 2; - - // GTK+ widgets - Gtk::HBox _connecttojidbox; - Gtk::HBox _buddylistbox; - Gtk::HBox _buttons; - - Whiteboard::SessionFileSelectorBox _sfsbox; - - Gtk::Entry _jid; - - // more or less shamelessly stolen from gtkmm tutorial book - Glib::RefPtr< Gtk::ListStore > _buddylistdata; - Gtk::TreeView _buddylist; - class BuddyListModel : public Gtk::TreeModel::ColumnRecord { - public: - BuddyListModel() - { - add(jid); - } - - Gtk::TreeModelColumn< std::string > jid; - }; - BuddyListModel _blm; - - Gtk::Label _labels[2]; - Gtk::ScrolledWindow _listwindow; - - Gtk::Button _share, _cancel; - - // Construction and callback - void _construct(); - void _respCallback(int resp); - void _listCallback(); - - // Buddy list management - void _fillBuddyList(); - void _insertBuddy(std::string const& jid); - void _eraseBuddy(std::string const& jid); - - // SessionManager and SPDesktop pointers - ::SPDesktop* _desktop; - Whiteboard::SessionManager* _sm; -}; - - -} - -} - -} - -#endif diff --git a/src/ui/icon-names.h b/src/ui/icon-names.h index 2ec03c5cc..f83d42174 100644 --- a/src/ui/icon-names.h +++ b/src/ui/icon-names.h @@ -1,10 +1,5 @@ /** @file * @brief Macro for icon names used in Inkscape - * - * This file exists for several reasons: firstly, it contains all the icon names - * in Inkscape, so it can serve as a reference to themers. Secondly, using - * macros instead of strings avoids typos. Thirdly, we can change names - * to conform to external icon sets / specifications without changing any code. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -16,568 +11,11 @@ #ifndef SEEN_INKSCAPE_ICON_NAMES_H #define SEEN_INKSCAPE_ICON_NAMES_H -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_BASELINE \ - "align-horizontal-baseline" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER \ - "align-horizontal-center" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT \ - "align-horizontal-left" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR \ - "align-horizontal-left-to-anchor" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES \ - "align-horizontal-node" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT \ - "align-horizontal-right" -#define INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR \ - "align-horizontal-right-to-anchor" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BASELINE \ - "align-vertical-baseline" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM \ - "align-vertical-bottom" -#define INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR \ - "align-vertical-bottom-to-anchor" -#define INKSCAPE_ICON_ALIGN_VERTICAL_CENTER \ - "align-vertical-center" -#define INKSCAPE_ICON_ALIGN_VERTICAL_NODES \ - "align-vertical-node" -#define INKSCAPE_ICON_ALIGN_VERTICAL_TOP \ - "align-vertical-top" -#define INKSCAPE_ICON_ALIGN_VERTICAL_TOP_TO_ANCHOR \ - "align-vertical-top-to-anchor" -#define INKSCAPE_ICON_BITMAP_TRACE \ - "bitmap-trace" -#define INKSCAPE_ICON_COLOR_FILL \ - "color-fill" -#define INKSCAPE_ICON_COLOR_GRADIENT \ - "color-gradient" -#define INKSCAPE_ICON_COLOR_MANAGEMENT \ - "color-management" -#define INKSCAPE_ICON_COLOR_PICKER \ - "color-picker" -#define INKSCAPE_ICON_COLOR_REMOVE \ - "color-remove" -#define INKSCAPE_ICON_CONNECTOR_EDIT \ - "connector-edit" -#define INKSCAPE_ICON_CONNECTOR_AVOID \ - "connector-avoid" -#define INKSCAPE_ICON_CONNECTOR_IGNORE \ - "connector-ignore" -#define INKSCAPE_ICON_CONNECTOR_ORTHOGONAL \ - "connector-orthogonal" -#define INKSCAPE_ICON_CONNECTOR_NEW_CONNPOINT \ - "connector-new-connpoint" -#define INKSCAPE_ICON_CONNECTOR_REMOVE_CONNPOINT \ - "connector-remove-connpoint" -#define INKSCAPE_ICON_DIALOG_ALIGN_AND_DISTRIBUTE \ - "dialog-align-and-distribute" -#define INKSCAPE_ICON_DIALOG_FILL_AND_STROKE \ - "dialog-fill-and-stroke" -#define INKSCAPE_ICON_DIALOG_ICON_PREVIEW \ - "dialog-icon-preview" -#define INKSCAPE_ICON_DIALOG_INPUT_DEVICES \ - "dialog-input-devices" -#define INKSCAPE_ICON_DIALOG_LAYERS \ - "dialog-layers" -#define INKSCAPE_ICON_DIALOG_MEMORY \ - "dialog-memory" -#define INKSCAPE_ICON_DIALOG_MESSAGES \ - "dialog-messages" -#define INKSCAPE_ICON_DIALOG_OBJECT_PROPERTIES \ - "dialog-object-properties" -#define INKSCAPE_ICON_DIALOG_ROWS_AND_COLUMNS \ - "dialog-rows-and-columns" -#define INKSCAPE_ICON_DIALOG_SCRIPTS \ - "dialog-scripts" -#define INKSCAPE_ICON_DIALOG_TEXT_AND_FONT \ - "dialog-text-and-font" -#define INKSCAPE_ICON_DIALOG_TILE_CLONES \ - "dialog-tile-clones" -#define INKSCAPE_ICON_DIALOG_TRANSFORM \ - "dialog-transform" -#define INKSCAPE_ICON_DIALOG_XML_EDITOR \ - "dialog-xml-editor" -#define INKSCAPE_ICON_DISTRIBUTE_GRAPH \ - "distribute-graph" -#define INKSCAPE_ICON_DISTRIBUTE_GRAPH_DIRECTED \ - "distribute-graph-directed" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE \ - "distribute-horizontal-baseline" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_CENTER \ - "distribute-horizontal-center" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_GAPS \ - "distribute-horizontal-gaps" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_LEFT \ - "distribute-horizontal-left" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE \ - "distribute-horizontal-node" -#define INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_RIGHT \ - "distribute-horizontal-right" -#define INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE \ - "distribute-randomize" -#define INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS \ - "distribute-remove-overlaps" -#define INKSCAPE_ICON_DISTRIBUTE_UNCLUMP \ - "distribute-unclump" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BASELINE \ - "distribute-vertical-baseline" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM \ - "distribute-vertical-bottom" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER \ - "distribute-vertical-center" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_GAPS \ - "distribute-vertical-gaps" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_NODE \ - "distribute-vertical-node" -#define INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP \ - "distribute-vertical-top" -#define INKSCAPE_ICON_DOCUMENT_CLEANUP \ - "document-cleanup" -#define INKSCAPE_ICON_DOCUMENT_EXPORT \ - "document-export" -#define INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL \ - "document-export-ocal" -#define INKSCAPE_ICON_DOCUMENT_IMPORT \ - "document-import" -#define INKSCAPE_ICON_DOCUMENT_IMPORT_OCAL \ - "document-import-ocal" -#define INKSCAPE_ICON_DOCUMENT_METADATA \ - "document-metadata" -#define INKSCAPE_ICON_DOCUMENT_OPEN_RECENT \ - "document-open-recent" -#define INKSCAPE_ICON_DRAW_CALLIGRAPHIC \ - "draw-calligraphic" -#define INKSCAPE_ICON_DRAW_CONNECTOR \ - "draw-connector" -#define INKSCAPE_ICON_DRAW_CUBOID \ - "draw-cuboid" -#define INKSCAPE_ICON_DRAW_ELLIPSE \ - "draw-ellipse" -#define INKSCAPE_ICON_DRAW_ELLIPSE_ARC \ - "draw-ellipse-arc" -#define INKSCAPE_ICON_DRAW_ELLIPSE_SEGMENT \ - "draw-ellipse-segment" -#define INKSCAPE_ICON_DRAW_ELLIPSE_WHOLE \ - "draw-ellipse-whole" -#define INKSCAPE_ICON_DRAW_ERASER \ - "draw-eraser" -#define INKSCAPE_ICON_DRAW_ERASER_DELETE_OBJECTS \ - "draw-eraser-delete-objects" -#define INKSCAPE_ICON_DRAW_FREEHAND \ - "draw-freehand" -#define INKSCAPE_ICON_DRAW_PATH \ - "draw-path" -#define INKSCAPE_ICON_DRAW_POLYGON \ - "draw-polygon" -#define INKSCAPE_ICON_DRAW_POLYGON_STAR \ - "draw-polygon-star" -#define INKSCAPE_ICON_DRAW_RECTANGLE \ - "draw-rectangle" -#define INKSCAPE_ICON_DRAW_SPIRAL \ - "draw-spiral" -#define INKSCAPE_ICON_DRAW_STAR \ - "draw-star" -#define INKSCAPE_ICON_DRAW_TEXT \ - "draw-text" -#define INKSCAPE_ICON_DRAW_TRACE_BACKGROUND \ - "draw-trace-background" -#define INKSCAPE_ICON_DRAW_USE_PRESSURE \ - "draw-use-pressure" -#define INKSCAPE_ICON_DRAW_USE_TILT \ - "draw-use-tilt" -#define INKSCAPE_ICON_EDIT_CLONE \ - "edit-clone" -#define INKSCAPE_ICON_EDIT_CLONE_UNLINK \ - "edit-clone-unlink" -#define INKSCAPE_ICON_EDIT_DUPLICATE \ - "edit-duplicate" -#define INKSCAPE_ICON_EDIT_PASTE_IN_PLACE \ - "edit-paste-in-place" -#define INKSCAPE_ICON_EDIT_PASTE_STYLE \ - "edit-paste-style" -#define INKSCAPE_ICON_EDIT_SELECT_ALL \ - "edit-select-all" -#define INKSCAPE_ICON_EDIT_SELECT_ALL_LAYERS \ - "edit-select-all-layers" -#define INKSCAPE_ICON_EDIT_SELECT_INVERT \ - "edit-select-invert" -#define INKSCAPE_ICON_EDIT_SELECT_NONE \ - "edit-select-none" -#define INKSCAPE_ICON_EDIT_SELECT_ORIGINAL \ - "edit-select-original" -#define INKSCAPE_ICON_EDIT_UNDO_HISTORY \ - "edit-undo-history" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS \ - "exchange-positions" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS_ZORDER \ - "exchange-positions-zorder" -#define INKSCAPE_ICON_EXCHANGE_POSITIONS_CLOCKWISE \ - "exchange-positions-clockwise" -#define INKSCAPE_ICON_FILL_RULE_EVEN_ODD \ - "fill-rule-even-odd" -#define INKSCAPE_ICON_FILL_RULE_NONZERO \ - "fill-rule-nonzero" -#define INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL \ - "format-text-direction-horizontal" -#define INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL \ - "format-text-direction-vertical" -#define INKSCAPE_ICON_GRID_AXONOMETRIC \ - "grid-axonometric" -#define INKSCAPE_ICON_GRID_RECTANGULAR \ - "grid-rectangular" -#define INKSCAPE_ICON_GUIDES \ - "guides" -#define INKSCAPE_ICON_HELP_CONTENTS \ - "help-contents" -#define INKSCAPE_ICON_HELP_KEYBOARD_SHORTCUTS \ - "help-keyboard-shortcuts" -#define INKSCAPE_ICON_IMAGE_FILTER_BLEND \ - "image-filter-blend" -#define INKSCAPE_ICON_IMAGE_FILTER_COLOR_MATRIX \ - "image-filter-color-matrix" -#define INKSCAPE_ICON_IMAGE_FILTER_DIFFUSE_LIGHTING \ - "image-filter-diffuse-lighting" -#define INKSCAPE_ICON_IMAGE_FILTER_DISPLACEMENT_MAP \ - "image-filter-displacement-map" -#define INKSCAPE_ICON_IMAGE_FILTER_FLOOD \ - "image-filter-flood" -#define INKSCAPE_ICON_IMAGE_FILTER_GAUSSIAN_BLUR \ - "image-filter-gaussian-blur" -#define INKSCAPE_ICON_IMAGE_FILTER_MORPHOLOGY \ - "image-filter-morphology" -#define INKSCAPE_ICON_IMAGE_FILTER_OFFSET \ - "image-filter-offset" -#define INKSCAPE_ICON_IMAGE_FILTER_TURBULENCE \ - "image-filter-turbulence" -#define INKSCAPE_ICON_INKSCAPE \ - "inkscape-logo" -#define INKSCAPE_ICON_LAYER_BOTTOM \ - "layer-bottom" -#define INKSCAPE_ICON_LAYER_DELETE \ - "layer-delete" -#define INKSCAPE_ICON_LAYER_LOWER \ - "layer-lower" -#define INKSCAPE_ICON_LAYER_NEW \ - "layer-new" -#define INKSCAPE_ICON_LAYER_NEXT \ - "layer-next" -#define INKSCAPE_ICON_LAYER_PREVIOUS \ - "layer-previous" -#define INKSCAPE_ICON_LAYER_RAISE \ - "layer-raise" -#define INKSCAPE_ICON_LAYER_RENAME \ - "layer-rename" -#define INKSCAPE_ICON_LAYER_TOP \ - "layer-top" -#define INKSCAPE_ICON_NODE_ADD \ - "node-add" -#define INKSCAPE_ICON_NODE_BREAK \ - "node-break" -#define INKSCAPE_ICON_NODE_DELETE \ - "node-delete" -#define INKSCAPE_ICON_NODE_DELETE_SEGMENT \ - "node-delete-segment" -#define INKSCAPE_ICON_NODE_DISTRIBUTE_HORIZONTAL \ - "distribute-horizontal-node" -#define INKSCAPE_ICON_NODE_DISTRIBUTE_VERTICAL \ - "distribute-vertical-node" -#define INKSCAPE_ICON_NODE_JOIN \ - "node-join" -#define INKSCAPE_ICON_NODE_JOIN_SEGMENT \ - "node-join-segment" -#define INKSCAPE_ICON_NODE_SEGMENT_CURVE \ - "node-segment-curve" -#define INKSCAPE_ICON_NODE_SEGMENT_LINE \ - "node-segment-line" -#define INKSCAPE_ICON_NODE_TYPE_AUTO_SMOOTH \ - "node-type-auto-smooth" -#define INKSCAPE_ICON_NODE_TYPE_CUSP \ - "node-type-cusp" -#define INKSCAPE_ICON_NODE_TYPE_SMOOTH \ - "node-type-smooth" -#define INKSCAPE_ICON_NODE_TYPE_SYMMETRIC \ - "node-type-symmetric" -#define INKSCAPE_ICON_OBJECT_COLUMNS \ - "object-columns" -#define INKSCAPE_ICON_OBJECT_FILL \ - "object-fill" -#define INKSCAPE_ICON_OBJECT_FLIP_HORIZONTAL \ - "object-flip-horizontal" -#define INKSCAPE_ICON_OBJECT_FLIP_VERTICAL \ - "object-flip-vertical" -#define INKSCAPE_ICON_OBJECT_GROUP \ - "object-group" -#define INKSCAPE_ICON_OBJECT_HIDDEN \ - "object-hidden" -#define INKSCAPE_ICON_OBJECT_LOCKED \ - "object-locked" -#define INKSCAPE_ICON_OBJECT_ROTATE_LEFT \ - "object-rotate-left" -#define INKSCAPE_ICON_OBJECT_ROTATE_RIGHT \ - "object-rotate-right" -#define INKSCAPE_ICON_OBJECT_ROWS \ - "object-rows" -#define INKSCAPE_ICON_OBJECT_STROKE \ - "object-stroke" -#define INKSCAPE_ICON_OBJECT_STROKE_STYLE \ - "object-stroke-style" -#define INKSCAPE_ICON_OBJECT_TO_PATH \ - "object-to-path" -#define INKSCAPE_ICON_OBJECT_TWEAK_ATTRACT \ - "object-tweak-attract" -#define INKSCAPE_ICON_OBJECT_TWEAK_BLUR \ - "object-tweak-blur" -#define INKSCAPE_ICON_OBJECT_TWEAK_DUPLICATE \ - "object-tweak-duplicate" -#define INKSCAPE_ICON_OBJECT_TWEAK_JITTER_COLOR \ - "object-tweak-jitter-color" -#define INKSCAPE_ICON_OBJECT_TWEAK_PAINT \ - "object-tweak-paint" -#define INKSCAPE_ICON_OBJECT_TWEAK_PUSH \ - "object-tweak-push" -#define INKSCAPE_ICON_OBJECT_TWEAK_RANDOMIZE \ - "object-tweak-randomize" -#define INKSCAPE_ICON_OBJECT_TWEAK_ROTATE \ - "object-tweak-rotate" -#define INKSCAPE_ICON_OBJECT_TWEAK_SHRINK \ - "object-tweak-shrink" -#define INKSCAPE_ICON_OBJECT_UNGROUP \ - "object-ungroup" -#define INKSCAPE_ICON_OBJECT_UNLOCKED \ - "object-unlocked" -#define INKSCAPE_ICON_OBJECT_VISIBLE \ - "object-visible" -#define INKSCAPE_ICON_PAINT_GRADIENT_LINEAR \ - "paint-gradient-linear" -#define INKSCAPE_ICON_PAINT_GRADIENT_RADIAL \ - "paint-gradient-radial" -#define INKSCAPE_ICON_PAINT_NONE \ - "paint-none" -#define INKSCAPE_ICON_PAINT_PATTERN \ - "paint-pattern" -#define INKSCAPE_ICON_PAINT_SOLID \ - "paint-solid" -#define INKSCAPE_ICON_PAINT_SWATCH \ - "paint-swatch" -#define INKSCAPE_ICON_PAINT_UNKNOWN \ - "paint-unknown" -#define INKSCAPE_ICON_PATH_BREAK_APART \ - "path-break-apart" -#define INKSCAPE_ICON_PATH_CLIP_EDIT \ - "path-clip-edit" -#define INKSCAPE_ICON_PATH_COMBINE \ - "path-combine" -#define INKSCAPE_ICON_PATH_CUT \ - "path-cut" -#define INKSCAPE_ICON_PATH_DIFFERENCE \ - "path-difference" -#define INKSCAPE_ICON_PATH_DIVISION \ - "path-division" -#define INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT \ - "path-effect-parameter-next" -#define INKSCAPE_ICON_PATH_EXCLUSION \ - "path-exclusion" -#define INKSCAPE_ICON_PATH_INSET \ - "path-inset" -#define INKSCAPE_ICON_PATH_INTERSECTION \ - "path-intersection" -#define INKSCAPE_ICON_PATH_MASK_EDIT \ - "path-mask-edit" -#define INKSCAPE_ICON_PATH_MODE_BEZIER \ - "path-mode-bezier" -#define INKSCAPE_ICON_PATH_MODE_POLYLINE \ - "path-mode-polyline" -#define INKSCAPE_ICON_PATH_MODE_POLYLINE_PARAXIAL \ - "path-mode-polyline-paraxial" -#define INKSCAPE_ICON_PATH_MODE_SPIRO \ - "path-mode-spiro" -#define INKSCAPE_ICON_PATH_OFFSET_DYNAMIC \ - "path-offset-dynamic" -#define INKSCAPE_ICON_PATH_OFFSET_LINKED \ - "path-offset-linked" -#define INKSCAPE_ICON_PATH_OUTSET \ - "path-outset" -#define INKSCAPE_ICON_PATH_REVERSE \ - "path-reverse" -#define INKSCAPE_ICON_PATH_SIMPLIFY \ - "path-simplify" -#define INKSCAPE_ICON_PATH_TWEAK_ATTRACT \ - "path-tweak-attract" -#define INKSCAPE_ICON_PATH_TWEAK_GROW \ - "path-tweak-grow" -#define INKSCAPE_ICON_PATH_TWEAK_PUSH \ - "path-tweak-push" -#define INKSCAPE_ICON_PATH_TWEAK_ROUGHEN \ - "path-tweak-roughen" -#define INKSCAPE_ICON_PATH_TWEAK_SHRINK \ - "path-tweak-shrink" -#define INKSCAPE_ICON_PATH_UNION \ - "path-union" -#define INKSCAPE_ICON_PERSPECTIVE_PARALLEL \ - "perspective-parallel" -#define INKSCAPE_ICON_RECTANGLE_MAKE_CORNERS_SHARP \ - "rectangle-make-corners-sharp" -#define INKSCAPE_ICON_SELECTION_BOTTOM \ - "selection-bottom" -#define INKSCAPE_ICON_SELECTION_LOWER \ - "selection-lower" -#define INKSCAPE_ICON_SELECTION_MAKE_BITMAP_COPY \ - "selection-make-bitmap-copy" -#define INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_ABOVE \ - "selection-move-to-layer-above" -#define INKSCAPE_ICON_SELECTION_MOVE_TO_LAYER_BELOW \ - "selection-move-to-layer-below" -#define INKSCAPE_ICON_SELECTION_RAISE \ - "selection-raise" -#define INKSCAPE_ICON_SELECTION_TOP \ - "selection-top" -#define INKSCAPE_ICON_SHOW_DIALOGS \ - "show-dialogs" -#define INKSCAPE_ICON_SHOW_GRID \ - "show-grid" -#define INKSCAPE_ICON_SHOW_GUIDES \ - "show-guides" -#define INKSCAPE_ICON_SHOW_NODE_HANDLES \ - "show-node-handles" -#define INKSCAPE_ICON_SHOW_PATH_OUTLINE \ - "show-path-outline" -#define INKSCAPE_ICON_SNAP \ - "snap" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX \ - "snap-bounding-box" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER \ - "snap-bounding-box-center" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS \ - "snap-bounding-box-corners" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES \ - "snap-bounding-box-edges" -#define INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS \ - "snap-bounding-box-midpoints" -#define INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS \ - "snap-grid-guide-intersections" -#define INKSCAPE_ICON_SNAP_NODES \ - "snap-nodes" -#define INKSCAPE_ICON_SNAP_NODES_CENTER \ - "snap-nodes-center" -#define INKSCAPE_ICON_SNAP_NODES_CUSP \ - "snap-nodes-cusp" -#define INKSCAPE_ICON_SNAP_NODES_INTERSECTION \ - "snap-nodes-intersection" -#define INKSCAPE_ICON_SNAP_NODES_MIDPOINT \ - "snap-nodes-midpoint" -#define INKSCAPE_ICON_SNAP_NODES_PATH \ - "snap-nodes-path" -#define INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER \ - "snap-nodes-rotation-center" -#define INKSCAPE_ICON_SNAP_NODES_SMOOTH \ - "snap-nodes-smooth" -#define INKSCAPE_ICON_SNAP_PAGE \ - "snap-page" -#define INKSCAPE_ICON_SPRAY_COPY_MODE \ - "spray-copy-mode" -#define INKSCAPE_ICON_SPRAY_CLONE_MODE \ - "spray-clone-mode" -#define INKSCAPE_ICON_SPRAY_UNION_MODE \ - "spray-union-mode" -#define INKSCAPE_ICON_DIALOG_SPRAY_OPTIONS \ - "dialog-spray-options" -#define INKSCAPE_ICON_STROKE_CAP_BUTT \ - "stroke-cap-butt" -#define INKSCAPE_ICON_STROKE_CAP_ROUND \ - "stroke-cap-round" -#define INKSCAPE_ICON_STROKE_CAP_SQUARE \ - "stroke-cap-square" -#define INKSCAPE_ICON_STROKE_JOIN_BEVEL \ - "stroke-join-bevel" -#define INKSCAPE_ICON_STROKE_JOIN_MITER \ - "stroke-join-miter" -#define INKSCAPE_ICON_STROKE_JOIN_ROUND \ - "stroke-join-round" -#define INKSCAPE_ICON_STROKE_TO_PATH \ - "stroke-to-path" -#define INKSCAPE_ICON_TEXT_CONVERT_TO_REGULAR \ - "text-convert-to-regular" -#define INKSCAPE_ICON_TEXT_FLOW_INTO_FRAME \ - "text-flow-into-frame" -#define INKSCAPE_ICON_TEXT_PUT_ON_PATH \ - "text-put-on-path" -#define INKSCAPE_ICON_TEXT_REMOVE_FROM_PATH \ - "text-remove-from-path" -#define INKSCAPE_ICON_TEXT_UNFLOW \ - "text-unflow" -#define INKSCAPE_ICON_TEXT_UNKERN \ - "text-unkern" -#define INKSCAPE_ICON_TOOL_NODE_EDITOR \ - "tool-node-editor" -#define INKSCAPE_ICON_TOOL_POINTER \ - "tool-pointer" -#define INKSCAPE_ICON_TOOL_TWEAK \ - "tool-tweak" -#define INKSCAPE_ICON_TOOL_SPRAY \ - "tool-spray" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_GRADIENT \ - "transform-affect-gradient" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_PATTERN \ - "transform-affect-pattern" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_ROUNDED_CORNERS \ - "transform-affect-rounded-corners" -#define INKSCAPE_ICON_TRANSFORM_AFFECT_STROKE \ - "transform-affect-stroke" -#define INKSCAPE_ICON_TRANSFORM_MOVE_HORIZONTAL \ - "transform-move-horizontal" -#define INKSCAPE_ICON_TRANSFORM_MOVE_VERTICAL \ - "transform-move-vertical" -#define INKSCAPE_ICON_TRANSFORM_ROTATE \ - "transform-rotate" -#define INKSCAPE_ICON_TRANSFORM_SCALE_HORIZONTAL \ - "transform-scale-horizontal" -#define INKSCAPE_ICON_TRANSFORM_SCALE_VERTICAL \ - "transform-scale-vertical" -#define INKSCAPE_ICON_TRANSFORM_SKEW_HORIZONTAL \ - "transform-skew-horizontal" -#define INKSCAPE_ICON_TRANSFORM_SKEW_VERTICAL \ - "transform-skew-vertical" -#define INKSCAPE_ICON_VIEW_FULLSCREEN \ - "view-fullscreen" -#define INKSCAPE_ICON_WINDOW_NEW \ - "window-new" -#define INKSCAPE_ICON_WINDOW_NEXT \ - "window-next" -#define INKSCAPE_ICON_WINDOW_PREVIOUS \ - "window-previous" -#define INKSCAPE_ICON_XML_ATTRIBUTE_DELETE \ - "xml-attribute-delete" -#define INKSCAPE_ICON_XML_ELEMENT_NEW \ - "xml-element-new" -#define INKSCAPE_ICON_XML_NODE_DELETE \ - "xml-node-delete" -#define INKSCAPE_ICON_XML_NODE_DUPLICATE \ - "xml-node-duplicate" -#define INKSCAPE_ICON_XML_TEXT_NEW \ - "xml-text-new" -#define INKSCAPE_ICON_ZOOM \ - "zoom" -#define INKSCAPE_ICON_ZOOM_DOUBLE_SIZE \ - "zoom-double-size" -#define INKSCAPE_ICON_ZOOM_FIT_DRAWING \ - "zoom-fit-drawing" -#define INKSCAPE_ICON_ZOOM_FIT_PAGE \ - "zoom-fit-page" -#define INKSCAPE_ICON_ZOOM_FIT_SELECTION \ - "zoom-fit-selection" -#define INKSCAPE_ICON_ZOOM_FIT_WIDTH \ - "zoom-fit-width" -#define INKSCAPE_ICON_ZOOM_HALF_SIZE \ - "zoom-half-size" -#define INKSCAPE_ICON_ZOOM_IN \ - "zoom-in" -#define INKSCAPE_ICON_ZOOM_NEXT \ - "zoom-next" -#define INKSCAPE_ICON_ZOOM_ORIGINAL \ - "zoom-original" -#define INKSCAPE_ICON_ZOOM_OUT \ - "zoom-out" -#define INKSCAPE_ICON_ZOOM_PREVIOUS \ - "zoom-previous" +/** @brief Icon name annotation. + * Use this macro to mark strings which are used as icon names. + * This greatly simplifies tasks such as obtaining a full list of icons + * used by Inkscape. */ +#define INKSCAPE_ICON(icon) icon #endif /* ifdef SEEN_INKSCAPE_ICON_NAMES_H */ diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index 1fb98d78f..308359c33 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -1,5 +1,6 @@ -/** @file - * Node selection - implementation +/** + * @file + * Node selection - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -16,13 +17,14 @@ #include "ui/tool/event-utils.h" #include "ui/tool/selectable-control-point.h" #include "ui/tool/transform-handle-set.h" +#include "ui/tool/node.h" namespace Inkscape { namespace UI { /** * @class ControlPointSelection - * @brief Group of selected control points. + * Group of selected control points. * * Some operations can be performed on all selected points regardless of their type, therefore * this class is also a Manipulator. It handles the transformations of points using @@ -432,7 +434,7 @@ bool ControlPointSelection::_keyboardMove(GdkEventKey const &event, Geom::Point delta /= _desktop->current_zoom(); } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); + double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); delta *= nudge; } @@ -445,8 +447,10 @@ bool ControlPointSelection::_keyboardMove(GdkEventKey const &event, Geom::Point return true; } -/** @brief Computes the distance to the farthest corner of the bounding box. - * Used to determine what it means to "rotate by one pixel". */ +/** + * Computes the distance to the farthest corner of the bounding box. + * Used to determine what it means to "rotate by one pixel". + */ double ControlPointSelection::_rotationRadius(Geom::Point const &rc) { if (empty()) return 1.0; // some safe value @@ -459,7 +463,8 @@ double ControlPointSelection::_rotationRadius(Geom::Point const &rc) return maxlen; } -/** Rotates the selected points in the given direction according to the modifier state +/** + * Rotates the selected points in the given direction according to the modifier state * from the supplied event. * @param event Key event to take modifier state from * @param dir Direction of rotation (math convention: 1 = counterclockwise, -1 = clockwise) @@ -533,7 +538,7 @@ bool ControlPointSelection::_keyboardScale(GdkEventKey const &event, int dir) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } double scale = (maxext + length_change) / maxext; @@ -642,13 +647,24 @@ bool ControlPointSelection::event(GdkEvent *event) return false; } -std::vector<Inkscape::SnapCandidatePoint> ControlPointSelection::getOriginalPoints() +void ControlPointSelection::getOriginalPoints(std::vector<Inkscape::SnapCandidatePoint> &pts) { - std::vector<Inkscape::SnapCandidatePoint> points; + pts.clear(); for (iterator i = _points.begin(); i != _points.end(); ++i) { - points.push_back(Inkscape::SnapCandidatePoint(_original_positions[*i], SNAPSOURCE_NODE_HANDLE)); + pts.push_back(Inkscape::SnapCandidatePoint(_original_positions[*i], SNAPSOURCE_NODE_HANDLE)); + } +} + +void ControlPointSelection::getUnselectedPoints(std::vector<Inkscape::SnapCandidatePoint> &pts) +{ + pts.clear(); + ControlPointSelection::Set &nodes = this->allPoints(); + for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + if (!(*i)->selected()) { + Node *n = static_cast<Node*>(*i); + pts.push_back(n->snapCandidatePoint()); + } } - return points; } void ControlPointSelection::setOriginalPoints() @@ -659,7 +675,6 @@ void ControlPointSelection::setOriginalPoints() } } - } // namespace UI } // namespace Inkscape diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index 7e09d50f5..67bd07644 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -111,7 +111,8 @@ public: sigc::signal<void, SelectableControlPoint *, bool> signal_point_changed; sigc::signal<void, CommitEvent> signal_commit; - std::vector<Inkscape::SnapCandidatePoint> getOriginalPoints(); + void getOriginalPoints(std::vector<Inkscape::SnapCandidatePoint> &pts); + void getUnselectedPoints(std::vector<Inkscape::SnapCandidatePoint> &pts); void setOriginalPoints(); private: diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index bece1324b..79d70d453 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -1,5 +1,6 @@ -/** @file - * Desktop-bound visual control object - implementation +/** + * @file + * Desktop-bound visual control object - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -21,6 +22,7 @@ #include "preferences.h" #include "ui/tool/control-point.h" #include "ui/tool/event-utils.h" +#include "ui/tool/transform-handle-set.h" namespace Inkscape { namespace UI { @@ -29,7 +31,7 @@ namespace UI { /** * @class ControlPoint - * @brief Draggable point, the workhorse of on-canvas editing. + * Draggable point, the workhorse of on-canvas editing. * * Control points (formerly known as knots) are graphical representations of some significant * point in the drawing. The drawing can be changed by dragging the point and the things that are @@ -436,6 +438,32 @@ bool ControlPoint::_eventHandler(GdkEvent *event) // update tips on modifier state change // TODO add ESC keybinding as drag cancel case GDK_KEY_PRESS: + switch (get_group0_keyval(&event->key)) + { + case GDK_Tab: + {// Downcast from ControlPoint to TransformHandle, if possible + // This is an ugly hack; we should have the transform handle intercept the keystrokes itself + TransformHandle *th = dynamic_cast<TransformHandle*>(this); + if (th) { + th->getNextClosestPoint(false); + return true; + } + break; + } + case GDK_ISO_Left_Tab: + {// Downcast from ControlPoint to TransformHandle, if possible + // This is an ugly hack; we should have the transform handle intercept the keystrokes itself + TransformHandle *th = dynamic_cast<TransformHandle*>(this); + if (th) { + th->getNextClosestPoint(true); + return true; + } + break; + } + default: + break; + } + // Do not break here, to allow for updating tooltips and such case GDK_KEY_RELEASE: if (mouseovered_point != this) return false; if (_drag_initiated) { @@ -537,7 +565,7 @@ void ControlPoint::transferGrab(ControlPoint *prev_point, GdkEventMotion *event) } /** - * @brief Change the state of the knot + * Change the state of the knot. * Alters the appearance of the knot to match one of the states: normal, mouseover * or clicked. */ diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index 9f62fca42..72106403e 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -18,10 +18,11 @@ #include <gtkmm.h> #include <2geom/point.h> -#include "forward.h" #include "util/accumulators.h" #include "display/sodipodi-ctrl.h" +class SPDesktop; + namespace Inkscape { namespace UI { diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index a3fb5aa6e..8dafb55d7 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -153,7 +153,7 @@ void CurveDragPoint::_insertNode(bool take_selection) } _pm._selection.insert(inserted.ptr()); - _pm.update(); + _pm.update(true); _pm._commit(_("Add node")); } diff --git a/src/ui/tool/manipulator.h b/src/ui/tool/manipulator.h index 6866ec9dd..474ccd8f3 100644 --- a/src/ui/tool/manipulator.h +++ b/src/ui/tool/manipulator.h @@ -40,7 +40,6 @@ public: /// Handle input event. Returns true if handled. virtual bool event(GdkEvent *)=0; -protected: SPDesktop *const _desktop; }; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 082ac194b..2316058ed 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -1,5 +1,6 @@ -/** @file - * Multi path manipulator - implementation +/** + * @file + * Multi path manipulator - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -149,9 +150,11 @@ void MultiPathManipulator::cleanup() } } -/** @brief Change the set of items to edit. +/** + * Change the set of items to edit. * - * This method attempts to preserve as much of the state as possible. */ + * This method attempts to preserve as much of the state as possible. + */ void MultiPathManipulator::setItems(std::set<ShapeRecord> const &s) { std::set<ShapeRecord> shapes(s); @@ -399,21 +402,21 @@ void MultiPathManipulator::joinNodes() invokeForAll(&PathManipulator::weldNodes, preserve_pos); } - _doneWithCleanup(_("Join nodes")); + _doneWithCleanup(_("Join nodes"), true); } void MultiPathManipulator::breakNodes() { if (_selection.empty()) return; invokeForAll(&PathManipulator::breakNodes); - _done(_("Break nodes")); + _done(_("Break nodes"), true); } void MultiPathManipulator::deleteNodes(bool keep_shape) { if (_selection.empty()) return; invokeForAll(&PathManipulator::deleteNodes, keep_shape); - _doneWithCleanup(_("Delete nodes")); + _doneWithCleanup(_("Delete nodes"), true); } /** Join selected endpoints to create segments. */ @@ -439,14 +442,14 @@ void MultiPathManipulator::joinSegments() if (joins.empty()) { invokeForAll(&PathManipulator::weldSegments); } - _doneWithCleanup("Join segments"); + _doneWithCleanup("Join segments", true); } void MultiPathManipulator::deleteSegments() { if (_selection.empty()) return; invokeForAll(&PathManipulator::deleteSegments); - _doneWithCleanup("Delete segments"); + _doneWithCleanup("Delete segments", true); } void MultiPathManipulator::alignNodes(Geom::Dim2 d) @@ -507,20 +510,24 @@ void MultiPathManipulator::showPathDirection(bool show) _show_path_direction = show; } -/** @brief Set live outline update status +/** + * Set live outline update status. * When set to true, outline will be updated continuously when dragging * or transforming nodes. Otherwise it will only update when changes are committed - * to XML. */ + * to XML. + */ void MultiPathManipulator::setLiveOutline(bool set) { invokeForAll(&PathManipulator::setLiveOutline, set); _live_outline = set; } -/** @brief Set live object update status +/** + * Set live object update status. * When set to true, objects will be updated continuously when dragging * or transforming nodes. Otherwise they will only update when changes are committed - * to XML. */ + * to XML. + */ void MultiPathManipulator::setLiveObjects(bool set) { invokeForAll(&PathManipulator::setLiveObjects, set); @@ -794,17 +801,17 @@ void MultiPathManipulator::_commit(CommitEvent cps) } /** Commits changes to XML and adds undo stack entry. */ -void MultiPathManipulator::_done(gchar const *reason) { - invokeForAll(&PathManipulator::update); +void MultiPathManipulator::_done(gchar const *reason, bool alert_LPE) { + invokeForAll(&PathManipulator::update, alert_LPE); invokeForAll(&PathManipulator::writeXML); DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); signal_coords_changed.emit(); } /** Commits changes to XML, adds undo stack entry and removes empty manipulators. */ -void MultiPathManipulator::_doneWithCleanup(gchar const *reason) { +void MultiPathManipulator::_doneWithCleanup(gchar const *reason, bool alert_LPE) { _changed.block(); - _done(reason); + _done(reason, alert_LPE); cleanup(); _changed.unblock(); } diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h index c25719790..6b5686139 100644 --- a/src/ui/tool/multi-path-manipulator.h +++ b/src/ui/tool/multi-path-manipulator.h @@ -13,7 +13,6 @@ #include <stddef.h> #include <sigc++/connection.h> -#include "forward.h" #include "ui/tool/commit-events.h" #include "ui/tool/manipulator.h" #include "ui/tool/modifier-tracker.h" @@ -103,8 +102,8 @@ private: } void _commit(CommitEvent cps); - void _done(gchar const *); - void _doneWithCleanup(gchar const *); + void _done(gchar const *reason, bool alert_LPE = false); + void _doneWithCleanup(gchar const *reason, bool alert_LPE = false); guint32 _getOutlineColor(ShapeRole role); MapType _mmap; diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index e75f31370..33020982e 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief New node tool - implementation +/** + * @file + * New node tool - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk@gmail.com> @@ -480,11 +481,12 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) nt->flash_tempitem = NULL; nt->flashed_item = NULL; } - if (!SP_IS_PATH(over_item)) break; // for now, handle only paths + if (!SP_IS_SHAPE(over_item)) break; // for now, handle only shapes nt->flashed_item = over_item; - SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(over_item)); - c->transform(over_item->i2d_affine()); + SPCurve *c = SP_SHAPE(over_item)->getCurveBeforeLPE(); + if (!c) break; // break out when curve doesn't exist + c->transform(over_item->i2dt_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index d005a0bdf..6f7ab01d4 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -17,14 +17,13 @@ #include <stddef.h> #include <sigc++/sigc++.h> #include "event-context.h" -#include "forward.h" #include "ui/tool/node-types.h" #define INK_TYPE_NODE_TOOL (ink_node_tool_get_type ()) -#define INK_NODE_TOOL(obj) (GTK_CHECK_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) -#define INK_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) -#define INK_IS_NODE_TOOL(obj) (GTK_CHECK_TYPE ((obj), INK_TYPE_NODE_TOOL)) -#define INK_IS_NODE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) +#define INK_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_TYPE_NODE_TOOL, InkNodeTool)) +#define INK_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_TYPE_NODE_TOOL, InkNodeToolClass)) +#define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) +#define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) class InkNodeTool; class InkNodeToolClass; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8e3da266b..d268a9f14 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1,5 +1,6 @@ -/** @file - * Editable node - implementation +/** + * @file + * Editable node - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -70,13 +71,11 @@ static Geom::Point direction(Geom::Point const &first, Geom::Point const &second } /** - * @class Handle - * @brief Control point of a cubic Bezier curve in a path. + * Control point of a cubic Bezier curve in a path. * * Handle keeps the node type invariant only for the opposite handle of the same node. * Keeping the invariant on node moves is left to the %Node class. */ - Geom::Point Handle::_saved_other_pos(0, 0); double Handle::_saved_length = 0.0; bool Handle::_drag_out = false; @@ -307,12 +306,10 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) std::vector<Inkscape::SnapCandidatePoint> unselected; if (snap) { - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); + for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast<Node*>(*i); - Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); - unselected.push_back(p); + unselected.push_back(n->snapCandidatePoint()); } sm.setupIgnoreSelection(_desktop, true, &unselected); @@ -326,7 +323,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } else if (ctrl_constraint) { // NOTE: this is subtly wrong. // We should get all possible constraints and snap along them using - // multipleConstrainedSnaps, instead of first snapping to angle and the to objects + // multipleConstrainedSnaps, instead of first snapping to angle and then to objects Inkscape::SnappedPoint p; p = sm.constrainedSnap(Inkscape::SnapCandidatePoint(new_pos, SNAPSOURCE_NODE_HANDLE), *ctrl_constraint); new_pos = p.getPoint(); @@ -469,12 +466,10 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) } /** - * @class Node - * @brief Curve endpoint in an editable path. + * Curve endpoint in an editable path. * * The method move() keeps node type invariants during translations. */ - Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : SelectableControlPoint(data.desktop, initial_pos, Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_DIAMOND, 9.0, *data.selection, &node_colors, data.node_group) @@ -1118,8 +1113,15 @@ Inkscape::SnapTargetType Node::_snapTargetType() return SNAPTARGET_NODE_CUSP; } -/** @brief Gets the handle that faces the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +Inkscape::SnapCandidatePoint Node::snapCandidatePoint() +{ + return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); +} + +/** + * Gets the handle that faces the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleToward(Node *to) { if (_next() == to) { @@ -1131,8 +1133,10 @@ Handle *Node::handleToward(Node *to) g_error("Node::handleToward(): second node is not adjacent!"); } -/** @brief Gets the node in the direction of the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction of the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeToward(Handle *dir) { if (front() == dir) { @@ -1144,8 +1148,10 @@ Node *Node::nodeToward(Handle *dir) g_error("Node::nodeToward(): handle is not a child of this node!"); } -/** @brief Gets the handle that goes in the direction opposite to the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +/** + * Gets the handle that goes in the direction opposite to the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleAwayFrom(Node *to) { if (_next() == to) { @@ -1157,8 +1163,10 @@ Handle *Node::handleAwayFrom(Node *to) g_error("Node::handleAwayFrom(): second node is not adjacent!"); } -/** @brief Gets the node in the direction opposite to the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction opposite to the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeAwayFrom(Handle *h) { if (front() == h) { @@ -1259,14 +1267,12 @@ SPCtrlShapeType Node::_node_type_to_shape(NodeType type) /** - * @class NodeList - * @brief An editable list of nodes representing a subpath. + * An editable list of nodes representing a subpath. * * It can optionally be cyclic to represent a closed path. * The list has iterators that act like plain node iterators, but can also be used * to obtain shared pointers to nodes. */ - NodeList::NodeList(SubpathList &splist) : _list(splist) , _closed(false) @@ -1427,7 +1433,7 @@ NodeList &NodeList::get(iterator const &i) { /** * @class SubpathList - * @brief Editable path composed of one or more subpaths + * Editable path composed of one or more subpaths. */ } // namespace UI diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index b7145790b..f3416ed1c 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -151,6 +151,7 @@ public: static char const *node_type_to_localized_string(NodeType type); // temporarily public virtual bool _eventHandler(GdkEvent *event); + Inkscape::SnapCandidatePoint snapCandidatePoint(); protected: virtual void dragged(Geom::Point &, GdkEventMotion *); virtual bool grabbed(GdkEventMotion *); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7c2013872..96b3a1bb1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1,5 +1,6 @@ -/** @file - * Path manipulator - implementation +/** + * @file + * Path manipulator - implementation. */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> @@ -29,7 +30,9 @@ #include "document.h" #include "live_effects/effect.h" #include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" +#include "live_effects/lpe-powerstroke.h" #include "sp-path.h" #include "helper/geom.h" #include "preferences.h" @@ -120,7 +123,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _lpe_key(lpe_key) { if (_lpe_key.empty()) { - _i2d_transform = SP_ITEM(path)->i2d_affine(); + _i2d_transform = path->i2dt_affine(); } else { _i2d_transform = Geom::identity(); } @@ -136,7 +139,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(_outline), 0, SP_WIND_RULE_NONZERO); _selection.signal_update.connect( - sigc::mem_fun(*this, &PathManipulator::update)); + sigc::bind(sigc::mem_fun(*this, &PathManipulator::update), false)); _selection.signal_point_changed.connect( sigc::mem_fun(*this, &PathManipulator::_selectionChanged)); _desktop->signal_zoom_changed.connect( @@ -174,10 +177,12 @@ bool PathManipulator::empty() { return !_path || _subpaths.empty(); } -/** Update the display and the outline of the path. */ -void PathManipulator::update() +/** Update the display and the outline of the path. + * \param alert_LPE if true, alerts an applied LPE to what the path is going to be changed to, so it can adjust its parameters for nicer user interfacing + */ +void PathManipulator::update(bool alert_LPE) { - _createGeometryFromControlPoints(); + _createGeometryFromControlPoints(alert_LPE); } /** Store the changes to the path in XML. */ @@ -534,13 +539,15 @@ void PathManipulator::deleteNodes(bool keep_shape) } } -/** @brief Delete nodes between the two iterators. +/** + * Delete nodes between the two iterators. * The given range can cross the beginning of the subpath in closed subpaths. * @param start Beginning of the range to delete * @param end End of the range * @param keep_shape Whether to fit the handles at surrounding nodes to approximate * the shape before deletion - * @return Number of deleted nodes */ + * @return Number of deleted nodes + */ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::iterator end, bool keep_shape) { unsigned const samples_per_segment = 10; @@ -727,7 +734,7 @@ void PathManipulator::scaleHandle(Node *n, int which, int dir, bool pixel) length_change = 1.0 / _desktop->current_zoom() * dir; } else { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000); + length_change = prefs->getDoubleLimited("/options/defaultscale/value", 2, 1, 1000, "px"); length_change *= dir; } @@ -976,7 +983,7 @@ void PathManipulator::_externalChange(unsigned type) } break; case PATH_CHANGE_TRANSFORM: { Geom::Affine i2d_change = _d2i_transform; - _i2d_transform = SP_ITEM(_path)->i2d_affine(); + _i2d_transform = _path->i2dt_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { @@ -1003,7 +1010,7 @@ void PathManipulator::_createControlPointsFromGeometry() // When we erase an element, the next one slides into position, // so we do not increment the iterator even though it is theoretically invalidated. if (i->empty()) { - pathv.erase(i); + i = pathv.erase(i); } else { ++i; } @@ -1091,8 +1098,10 @@ void PathManipulator::_createControlPointsFromGeometry() } /** Construct the geometric representation of nodes and handles, update the outline - * and display */ -void PathManipulator::_createGeometryFromControlPoints() + * and display + * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it + */ +void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; for (std::list<SubpathPtr>::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { @@ -1120,7 +1129,18 @@ void PathManipulator::_createGeometryFromControlPoints() ++spi; } builder.finish(); - _spcurve->set_pathvector(builder.peek() * (_edit_transform * _i2d_transform).inverse()); + Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); + _spcurve->set_pathvector(pathv); + if (alert_LPE) { + if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast<LivePathEffect::LPEPowerStroke*>( effect_list.front()->lpeobject->get_lpe() ); + if (lpe_pwr) { + lpe_pwr->adjustForNewPath(pathv); + } + } + } + if (_live_outline) _updateOutline(); if (_live_objects) @@ -1278,8 +1298,9 @@ bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event) } if (!empty()) { - update(); + update(true); } + // We need to call MPM's method because it could have been our last node _multi_path_manipulator._doneWithCleanup(_("Delete node")); diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 27a83f06b..e3b724e37 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -17,12 +17,12 @@ #include <2geom/affine.h> #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> -#include "forward.h" #include "ui/tool/node.h" #include "ui/tool/manipulator.h" struct SPCanvasItem; struct SPCurve; +struct SPPath; namespace Inkscape { namespace XML { class Node; } @@ -60,7 +60,7 @@ public: bool empty(); void writeXML(); - void update(); // update display, but don't commit + void update(bool alert_LPE = false); // update display, but don't commit void clear(); // remove all nodes from manipulator SPPath *item() { return _path; } @@ -102,7 +102,7 @@ private: typedef boost::shared_ptr<NodeList> SubpathPtr; void _createControlPointsFromGeometry(); - void _createGeometryFromControlPoints(); + void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); void _updateOutline(); diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 26263c26b..7a12f4fbd 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -28,6 +28,8 @@ #include "ui/tool/event-utils.h" #include "ui/tool/transform-handle-set.h" #include "ui/tool/node-tool.h" +#include "ui/tool/node.h" +#include "seltrans.h" // FIXME BRAIN DAMAGE WARNING: this is a global variable in select-context.cpp // It should be moved to a header @@ -82,70 +84,101 @@ ControlPoint::ColorSet center_cset = { } // anonymous namespace /** Base class for node transform handles to simplify implementation */ -class TransformHandle : public ControlPoint { -public: - TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb) - : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, - th._transform_handle_group) - , _th(th) - { - setVisible(false); +TransformHandle::TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb) + : ControlPoint(th._desktop, Geom::Point(), anchor, pb, &thandle_cset, + th._transform_handle_group) + , _th(th) +{ + setVisible(false); +} + +void TransformHandle::getNextClosestPoint(bool reverse) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/options/snapclosestonly/value", false)) { + if (!_all_snap_sources_sorted.empty()) { + if (reverse) { // Shift-tab will find a closer point + if (_all_snap_sources_iter == _all_snap_sources_sorted.begin()) { + _all_snap_sources_iter = _all_snap_sources_sorted.end(); + } + --_all_snap_sources_iter; + } else { // Tab will find a point further away + ++_all_snap_sources_iter; + if (_all_snap_sources_iter == _all_snap_sources_sorted.end()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + } + } + + _snap_points.clear(); + _snap_points.push_back(*_all_snap_sources_iter); + + } } -protected: - virtual void startTransform() {} - virtual void endTransform() {} - virtual Geom::Affine computeTransform(Geom::Point const &pos, GdkEventMotion *event) = 0; - virtual CommitEvent getCommitEvent() = 0; +} - Geom::Affine _last_transform; - Geom::Point _origin; - TransformHandleSet &_th; - std::vector<Inkscape::SnapCandidatePoint> _snap_points; +bool TransformHandle::grabbed(GdkEventMotion *) +{ + _origin = position(); + _last_transform.setIdentity(); + startTransform(); -private: - virtual bool grabbed(GdkEventMotion *) { - _origin = position(); - _last_transform.setIdentity(); - startTransform(); - - _th._setActiveHandle(this); - _cset = &invisible_cset; - _setState(_state); - - // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SnapManager &m = desktop->namedview->snap_manager; - InkNodeTool *nt = INK_NODE_TOOL(_desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); - - _snap_points = selection->getOriginalPoints(); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getBool("/options/snapclosestonly/value", false)) { - m.keepClosestPointOnly(_snap_points, _origin); + _th._setActiveHandle(this); + _cset = &invisible_cset; + _setState(_state); + + // Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector. + InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context); + ControlPointSelection *selection = nt->_selected_nodes.get(); + + selection->setOriginalPoints(); + selection->getOriginalPoints(_snap_points); + selection->getUnselectedPoints(_unselected_points); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/options/snapclosestonly/value", false)) { + // Find the closest snap source candidate + _all_snap_sources_sorted = _snap_points; + + // Calculate and store the distance to the reference point for each snap candidate point + for(std::vector<Inkscape::SnapCandidatePoint>::iterator i = _all_snap_sources_sorted.begin(); i != _all_snap_sources_sorted.end(); ++i) { + (*i).setDistance(Geom::L2((*i).getPoint() - _origin)); } - return false; - } - virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event) - { - Geom::Affine t = computeTransform(new_pos, event); - // protect against degeneracies - if (t.isSingular()) return; - Geom::Affine incr = _last_transform.inverse() * t; - if (incr.isSingular()) return; - _th.signal_transform.emit(incr); - _last_transform = t; - } - virtual void ungrabbed(GdkEventButton *) { + // Sort them ascending, using the distance calculated above as the single criteria + std::sort(_all_snap_sources_sorted.begin(), _all_snap_sources_sorted.end()); + + // Now get the closest snap source _snap_points.clear(); - _th._clearActiveHandle(); - _cset = &thandle_cset; - _setState(_state); - endTransform(); - _th.signal_commit.emit(getCommitEvent()); + if (!_all_snap_sources_sorted.empty()) { + _all_snap_sources_iter = _all_snap_sources_sorted.begin(); + _snap_points.push_back(_all_snap_sources_sorted.front()); + } } -}; + + return false; +} + +void TransformHandle::dragged(Geom::Point &new_pos, GdkEventMotion *event) +{ + Geom::Affine t = computeTransform(new_pos, event); + // protect against degeneracies + if (t.isSingular()) return; + Geom::Affine incr = _last_transform.inverse() * t; + if (incr.isSingular()) return; + _th.signal_transform.emit(incr); + _last_transform = t; +} + +void TransformHandle::ungrabbed(GdkEventButton *) +{ + _snap_points.clear(); + _th._clearActiveHandle(); + _cset = &thandle_cset; + _setState(_state); + endTransform(); + _th.signal_commit.emit(getCommitEvent()); +} + class ScaleHandle : public TransformHandle { public: @@ -198,9 +231,6 @@ protected: _sc_center = _th.rotationCenter(); _sc_opposite = _th.bounds().corner(_corner + 2); _last_scale_x = _last_scale_y = 1.0; - InkNodeTool *nt = INK_NODE_TOOL(_desktop->event_context); - ControlPointSelection *selection = nt->_selected_nodes.get(); - selection->setOriginalPoints(); } virtual Geom::Affine computeTransform(Geom::Point const &new_pos, GdkEventMotion *event) { Geom::Point scc = held_shift(*event) ? _sc_center : _sc_opposite; @@ -214,30 +244,15 @@ protected: if (held_alt(*event)) { for (unsigned i = 0; i < 2; ++i) { - if (scale[i] >= 1.0) scale[i] = round(scale[i]); - else scale[i] = 1.0 / round(1.0 / scale[i]); + if (fabs(scale[i]) >= 1.0) { + scale[i] = round(scale[i]); + } else { + scale[i] = 1.0 / round(1.0 / MIN(scale[i],10)); + } } } else { - //SPDesktop *desktop = _th._desktop; // Won't work as _desktop is protected - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SnapManager &m = desktop->namedview->snap_manager; - - // The lines below have been copied from Handle::dragged() in node.cpp, and need to be - // activated if we want to snap to unselected (i.e. stationary) nodes and stationary pieces of paths of the - // path that's currently being edited - /* - std::vector<Inkscape::SnapCandidatePoint> unselected; - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast<Node*>(*i); - Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); - unselected.push_back(p); - } - m.setupIgnoreSelection(_desktop, true, &unselected); - */ - - m.setupIgnoreSelection(_desktop); + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); Inkscape::SnappedPoint sp; if (held_control(*event)) { @@ -306,10 +321,30 @@ protected: vs[d1] = (new_pos - scc)[d1] / (_origin - scc)[d1]; if (held_alt(*event)) { - if (vs[d1] >= 1.0) vs[d1] = round(vs[d1]); - else vs[d1] = 1.0 / round(1.0 / vs[d1]); + if (fabs(vs[d1]) >= 1.0) { + vs[d1] = round(vs[d1]); + } else { + vs[d1] = 1.0 / round(1.0 / MIN(vs[d1],10)); + } + vs[d2] = 1.0; + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + + bool uniform = held_control(*event); + Inkscape::SnappedPoint sp = m.constrainedSnapStretch(_snap_points, _origin, vs[d1], scc, d1, uniform); + m.unSetup(); + + if (sp.getSnapped()) { + Geom::Point result = sp.getTransformation(); + vs[d1] = result[d1]; + vs[d2] = result[d2]; + } else { + // on ctrl, apply uniform scaling instead of stretching + // Preserve aspect ratio, but never flip in the dimension not being edited (by using fabs()) + vs[d2] = uniform ? fabs(vs[d1]) : 1.0; + } } - vs[d2] = held_control(*event) ? vs[d1] : 1.0; _last_scale_x = vs[Geom::X]; _last_scale_y = vs[Geom::Y]; @@ -357,7 +392,17 @@ protected: double angle = Geom::angle_between(_origin - rotc, new_pos - rotc); if (held_control(*event)) { angle = snap_angle(angle); + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + Inkscape::SnappedPoint sp = m.constrainedSnapRotate(_snap_points, _origin, angle, rotc); + m.unSetup(); + + if (sp.getSnapped()) { + angle = sp.getTransformation()[0]; + } } + _last_angle = angle; Geom::Affine t = Geom::Translate(-rotc) * Geom::Rotate(angle) @@ -428,44 +473,76 @@ protected: virtual Geom::Affine computeTransform(Geom::Point const &new_pos, GdkEventMotion *event) { Geom::Point scc = held_shift(*event) ? _skew_center : _skew_opposite; - // d1 and d2 are reversed with respect to ScaleSideHandle - Geom::Dim2 d1 = static_cast<Geom::Dim2>(_side % 2); - Geom::Dim2 d2 = static_cast<Geom::Dim2>((_side + 1) % 2); - Geom::Point proj, scale(1.0, 1.0); + Geom::Dim2 d1 = static_cast<Geom::Dim2>((_side + 1) % 2); + Geom::Dim2 d2 = static_cast<Geom::Dim2>(_side % 2); + + Geom::Point const initial_delta = _origin - scc; + + if (fabs(initial_delta[d1]) < 1e-15) { + return Geom::Affine(); + } + + // Calculate the scale factors, which can be either visual or geometric + // depending on which type of bbox is currently being used (see preferences -> selector tool) + Geom::Scale scale = calcScaleFactors(_origin, new_pos, scc, false); + Geom::Scale skew = calcScaleFactors(_origin, new_pos, scc, true); + scale[d2] = 1; + skew[d2] = 1; // Skew handles allow scaling up to integer multiples of the original size // in the second direction; prevent explosions - // TODO should the scaling part be only active with Alt? - if (!Geom::are_near(_origin[d2], scc[d2])) { - scale[d2] = (new_pos - scc)[d2] / (_origin - scc)[d2]; - } - if (scale[d2] < 1.0) { - scale[d2] = copysign(1.0, scale[d2]); + if (fabs(scale[d1]) < 1) { + // Prevent shrinking of the selected object, while allowing mirroring + scale[d1] = copysign(1.0, scale[d1]); } else { - scale[d2] = floor(scale[d2]); + // Allow expanding of the selected object by integer multiples + scale[d1] = floor(scale[d1] + 0.5); } - // Calculate skew angle. The angle is calculated with regards to the point obtained - // by projecting the handle position on the relevant side of the bounding box. - // This avoids degeneracies when moving the skew angle over the rotation center - proj[d1] = new_pos[d1]; - proj[d2] = scc[d2] + (_origin[d2] - scc[d2]) * scale[d2]; - double angle = 0; - if (!Geom::are_near(proj[d2], scc[d2])) - angle = Geom::angle_between(_origin - scc, proj - scc); - if (held_control(*event)) angle = snap_angle(angle); - - // skew matrix has the from [[1, k],[0, 1]] for horizontal skew - // and [[1,0],[k,1]] for vertical skew. - Geom::Affine skew = Geom::identity(); - // correct the sign of the tangent - skew[d2 + 1] = (d1 == Geom::X ? -1.0 : 1.0) * tan(angle); + double angle = atan(skew[d1] / scale[d1]); + + if (held_control(*event)) { + angle = snap_angle(angle); + skew[d1] = tan(angle) * scale[d1]; + } else { + SnapManager &m = _th._desktop->namedview->snap_manager; + m.setupIgnoreSelection(_th._desktop, true, &_unselected_points); + + Geom::Point cvec; cvec[d2] = 1.0; + Inkscape::Snapper::SnapConstraint const constraint(cvec); + Inkscape::SnappedPoint sp = m.constrainedSnapSkew(_snap_points, _origin, constraint, Geom::Point(skew[d1], scale[d1]), scc, d2); + m.unSetup(); + + if (sp.getSnapped()) { + skew[d1] = sp.getTransformation()[0]; + } + } _last_angle = angle; + + // Update the handle position + Geom::Point new_new_pos; + new_new_pos[d2] = initial_delta[d1] * skew[d1] + _origin[d2]; + new_new_pos[d1] = initial_delta[d1] * scale[d1] + scc[d1]; + + // Calculate the relative affine + Geom::Affine relative_affine = Geom::identity(); + relative_affine[2*d1 + d1] = (new_new_pos[d1] - scc[d1]) / initial_delta[d1]; + relative_affine[2*d1 + (d2)] = (new_new_pos[d2] - _origin[d2]) / initial_delta[d1]; + relative_affine[2*(d2) + (d1)] = 0; + relative_affine[2*(d2) + (d2)] = 1; + + for (int i = 0; i < 2; i++) { + if (fabs(relative_affine[3*i]) < 1e-15) { + relative_affine[3*i] = 1e-15; + } + } + Geom::Affine t = Geom::Translate(-scc) - * Geom::Scale(scale) * skew + * relative_affine * Geom::Translate(scc); + return t; } @@ -537,8 +614,8 @@ public: protected: virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event) { - SnapManager &sm = _desktop->namedview->snap_manager; - sm.setup(_desktop); + SnapManager &sm = _th._desktop->namedview->snap_manager; + sm.setup(_th._desktop); bool snap = !held_shift(*event) && sm.someSnapperMightSnap(); if (held_control(*event)) { // constrain to axes diff --git a/src/ui/tool/transform-handle-set.h b/src/ui/tool/transform-handle-set.h index 0557b1278..8ce7011c5 100644 --- a/src/ui/tool/transform-handle-set.h +++ b/src/ui/tool/transform-handle-set.h @@ -78,6 +78,32 @@ private: friend class RotationCenter; }; +/** Base class for node transform handles to simplify implementation */ +class TransformHandle : public ControlPoint { +public: + TransformHandle(TransformHandleSet &th, Gtk::AnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pb); + void getNextClosestPoint(bool reverse); + +protected: + virtual void startTransform() {} + virtual void endTransform() {} + virtual Geom::Affine computeTransform(Geom::Point const &pos, GdkEventMotion *event) = 0; + virtual CommitEvent getCommitEvent() = 0; + + Geom::Affine _last_transform; + Geom::Point _origin; + TransformHandleSet &_th; + std::vector<Inkscape::SnapCandidatePoint> _snap_points; + std::vector<Inkscape::SnapCandidatePoint> _unselected_points; + std::vector<Inkscape::SnapCandidatePoint> _all_snap_sources_sorted; + std::vector<Inkscape::SnapCandidatePoint>::iterator _all_snap_sources_iter; + +private: + virtual bool grabbed(GdkEventMotion *); + virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); + virtual void ungrabbed(GdkEventButton *); +}; + } // namespace UI } // namespace Inkscape diff --git a/src/ui/view/CMakeLists.txt b/src/ui/view/CMakeLists.txt deleted file mode 100644 index 5c96bc40e..000000000 --- a/src/ui/view/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -SET(ui_view_SRC -desktop.cpp -desktop-events.cpp -desktop-handles.cpp -desktop-style.cpp -edit.cpp -edit-widget.cpp -view.cpp -view-widget.cpp -) diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 919b570dd..ba29d6225 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -1,8 +1,4 @@ -/** - * \file - * - * Abstract base class for all EditWidget implementations. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * John Bintz <jcoswell@coswellproductions.org> @@ -16,9 +12,9 @@ #ifndef INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H #define INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H -#include "libnr/nr-point.h" #include "message.h" #include <gtkmm/window.h> +#include <2geom/point.h> namespace Inkscape { namespace UI { namespace Widget { class Dock; } } } @@ -26,6 +22,9 @@ namespace Inkscape { namespace UI { namespace View { +/** + * Abstract base class for all EditWidget implementations. + */ struct EditWidgetInterface { EditWidgetInterface() {} @@ -137,6 +136,10 @@ struct EditWidgetInterface /// Message widget will get no content virtual void setMessage (Inkscape::MessageType type, gchar const* msg) = 0; + + /** Show an info dialog with the given message */ + virtual bool showInfoDialog( Glib::ustring const &message ) = 0; + /// Open yes/no dialog with warning text and confirmation question. virtual bool warnDialog (gchar*) = 0; diff --git a/src/ui/view/view-widget.cpp b/src/ui/view/view-widget.cpp index cf0f55f2c..7876928f7 100644 --- a/src/ui/view/view-widget.cpp +++ b/src/ui/view/view-widget.cpp @@ -1,6 +1,4 @@ -/** \file - * SPViewWidget implementation. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -16,7 +14,7 @@ //using namespace Inkscape::UI::View; -/* SPViewWidget */ +// SPViewWidget static void sp_view_widget_class_init(SPViewWidgetClass *vwc); static void sp_view_widget_init(SPViewWidget *widget); @@ -24,25 +22,21 @@ static void sp_view_widget_destroy(GtkObject *object); static GtkEventBoxClass *widget_parent_class; -/** - * Registers the SPViewWidget class with Glib and returns its type number. - */ -GtkType sp_view_widget_get_type(void) +GType sp_view_widget_get_type(void) { - static GtkType type = 0; - //TODO: switch to GObject - // GtkType and such calls were deprecated a while back with the - // introduction of GObject as a separate layer, with GType instead. --JonCruz + static GType type = 0; if (!type) { - GtkTypeInfo info = { - (gchar*) "SPViewWidget", - sizeof(SPViewWidget), + GTypeInfo info = { sizeof(SPViewWidgetClass), - (GtkClassInitFunc) sp_view_widget_class_init, - (GtkObjectInitFunc) sp_view_widget_init, - NULL, NULL, NULL - }; - type = gtk_type_unique(GTK_TYPE_EVENT_BOX, &info); + NULL, NULL, + (GClassInitFunc) sp_view_widget_class_init, + NULL, NULL, + sizeof(SPViewWidget), + 0, + (GInstanceInitFunc) sp_view_widget_init, + NULL + }; + type = g_type_register_static (GTK_TYPE_EVENT_BOX, "SPViewWidget", &info, (GTypeFlags)0); } return type; @@ -55,7 +49,7 @@ static void sp_view_widget_class_init(SPViewWidgetClass *vwc) { GtkObjectClass *object_class = GTK_OBJECT_CLASS(vwc); - widget_parent_class = (GtkEventBoxClass*) gtk_type_class(GTK_TYPE_EVENT_BOX); + widget_parent_class = (GtkEventBoxClass*) g_type_class_peek_parent(vwc); object_class->destroy = sp_view_widget_destroy; } @@ -90,10 +84,6 @@ static void sp_view_widget_destroy(GtkObject *object) Inkscape::GC::request_early_collection(); } -/** - * Connects widget to view's 'resized' signal and calls virtual set_view() - * function. - */ void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view) { g_return_if_fail(vw != NULL); @@ -110,9 +100,6 @@ void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view) } } -/** - * Calls the virtual shutdown() function of the SPViewWidget. - */ bool sp_view_widget_shutdown(SPViewWidget *vw) { g_return_val_if_fail(vw != NULL, TRUE); diff --git a/src/ui/view/view-widget.h b/src/ui/view/view-widget.h index 9b5e9c4a8..668f9d19a 100644 --- a/src/ui/view/view-widget.h +++ b/src/ui/view/view-widget.h @@ -1,9 +1,7 @@ #ifndef INKSCAPE_UI_VIEW_VIEWWIDGET_H #define INKSCAPE_UI_VIEW_VIEWWIDGET_H -/** \file - * A widget is the UI context for a document view. - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -14,33 +12,48 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtkeventbox.h> +#include <gtk/gtk.h> namespace Inkscape { - namespace UI { - namespace View { - class View; - }}} +namespace UI { +namespace View { +class View; +} // namespace View +} // namespace UI +} // namespace Inkscape + class SPViewWidget; class SPNamedView; #define SP_TYPE_VIEW_WIDGET (sp_view_widget_get_type ()) -#define SP_VIEW_WIDGET(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) -#define SP_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) -#define SP_IS_VIEW_WIDGET(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) -#define SP_IS_VIEW_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) +#define SP_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VIEW_WIDGET, SPViewWidget)) +#define SP_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VIEW_WIDGET, SPViewWidgetClass)) +#define SP_IS_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VIEW_WIDGET)) +#define SP_IS_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VIEW_WIDGET)) #define SP_VIEW_WIDGET_VIEW(w) (SP_VIEW_WIDGET (w)->view) #define SP_VIEW_WIDGET_DOCUMENT(w) (SP_VIEW_WIDGET (w)->view ? ((SPViewWidget *) (w))->view->doc : NULL) -GType sp_view_widget_get_type (void); +/** + * Registers the SPViewWidget class with Glib and returns its type number. + */ +GType sp_view_widget_get_type(void); -void sp_view_widget_set_view (SPViewWidget *vw, Inkscape::UI::View::View *view); +/** + * Connects widget to view's 'resized' signal and calls virtual set_view() + * function. + */ +void sp_view_widget_set_view(SPViewWidget *vw, Inkscape::UI::View::View *view); -/// Allows presenting 'save changes' dialog, FALSE - continue, TRUE - cancel -bool sp_view_widget_shutdown (SPViewWidget *vw); +/** + * Allows presenting 'save changes' dialog, FALSE - continue, TRUE - cancel. + * Calls the virtual shutdown() function of the SPViewWidget. + */ +bool sp_view_widget_shutdown(SPViewWidget *vw); -/// Create a new SPViewWidget (which happens to be a SPDesktopWidget). -SPViewWidget *sp_desktop_widget_new (SPNamedView *namedview); +/** + * Create a new SPViewWidget (which happens to be a SPDesktopWidget). + */ +SPViewWidget *sp_desktop_widget_new(SPNamedView *namedview); /** * SPViewWidget is a GUI widget that contain a single View. It is also diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index f05e024d1..e13976cc4 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -1,6 +1,4 @@ -/** \file - * View implementation - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -16,7 +14,7 @@ # include "config.h" #endif -#include "libnr/nr-point.h" +#include <2geom/point.h> #include "document.h" #include "view.h" #include "message-stack.h" @@ -78,9 +76,6 @@ View::View() _message_changed_connection = _message_stack->connectChanged (sigc::bind (sigc::ptr_fun (&_onStatusMessage), this)); } -/** - * Deletes and nulls all View message stacks and disconnects it from signals. - */ View::~View() { _close(); @@ -127,15 +122,6 @@ void View::requestRedraw() _redraw_requested_signal.emit(); } -/** - * Disconnects the view from the document signals, connects the view - * to a new one, and emits the _document_set_signal on the view. - * - * This is code comon to all subclasses and called from their - * setDocument() methods after they are done. - * - * \param doc The new document to connect the view to. - */ void View::setDocument(SPDocument *doc) { g_return_if_fail(doc != NULL); diff --git a/src/ui/view/view.h b/src/ui/view/view.h index e6853555f..6ed9f476c 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -1,9 +1,6 @@ #ifndef INKSCAPE_UI_VIEW_VIEW_H #define INKSCAPE_UI_VIEW_VIEW_H - -/** \file - * Abstract base class for all SVG document views - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -14,14 +11,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gdk/gdktypes.h> +#include <gdk/gdk.h> #include <stddef.h> #include <sigc++/connection.h> #include "message.h" #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include <libnr/nr-forward.h> #include <2geom/forward.h> /** @@ -65,7 +61,7 @@ namespace Inkscape { /** * View is an abstract base class of all UI document views. This * includes both the editing window and the SVG preview, but does not - * include the non-UI RGBA buffer-based NRArena nor the XML editor or + * include the non-UI RGBA buffer-based Inkscape::Drawing nor the XML editor or * similar views. The View base class has very little functionality of * its own. */ @@ -76,6 +72,10 @@ class View : public GC::Managed<>, public: View(); + + /** + * Deletes and nulls all View message stacks and disconnects it from signals. + */ virtual ~View(); void close() { _close(); } @@ -114,6 +114,16 @@ protected: Inkscape::MessageContext *_tips_message_context; virtual void _close(); + + /** + * Disconnects the view from the document signals, connects the view + * to a new one, and emits the _document_set_signal on the view. + * + * This is code comon to all subclasses and called from their + * setDocument() methods after they are done. + * + * @param doc The new document to connect the view to. + */ virtual void setDocument(SPDocument *doc); sigc::signal<void,double,double> _position_set_signal; diff --git a/src/ui/widget/CMakeLists.txt b/src/ui/widget/CMakeLists.txt deleted file mode 100644 index ffc94c299..000000000 --- a/src/ui/widget/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -SET(ui_widget_SRC -button.cpp -color-picker.cpp -color-preview.cpp -combo-text.cpp -dock.cpp -dock-item.cpp -entity-entry.cpp -entry.cpp -filter-effect-chooser.cpp -handlebox.cpp -icon-widget.cpp -imageicon.cpp -imagetoggler.cpp -labelled.cpp -licensor.cpp -notebook-page.cpp -object-composite-settings.cpp -page-sizer.cpp -panel.cpp -point.cpp -preferences-widget.cpp -random.cpp -registered-widget.cpp -registry.cpp -rendering-options.cpp -rotateable.cpp -ruler.cpp -scalar.cpp -scalar-unit.cpp -selected-style.cpp -spin-slider.cpp -style-subject.cpp -style-swatch.cpp -svg-canvas.cpp -tolerance-slider.cpp -toolbox.cpp -unit-menu.cpp -zoom-status.cpp -) diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index b6069631b..bd23b6782 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -66,6 +66,8 @@ ink_common_sources += \ ui/widget/scalar.h \ ui/widget/selected-style.h \ ui/widget/selected-style.cpp \ + ui/widget/spinbutton.h \ + ui/widget/spinbutton.cpp \ ui/widget/spin-slider.h \ ui/widget/spin-slider.cpp \ ui/widget/style-subject.h \ diff --git a/src/ui/widget/attr-widget.h b/src/ui/widget/attr-widget.h index 7b9c35ab7..94906c8e8 100644 --- a/src/ui/widget/attr-widget.h +++ b/src/ui/widget/attr-widget.h @@ -1,6 +1,4 @@ -/** - * \brief Very basic interface for classes that control attributes - * +/* * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> * Rodrigo Kumpera <kumpera@gmail.com> @@ -32,6 +30,9 @@ enum DefaultValueType T_CHARPTR }; +/** + * Very basic interface for classes that control attributes. + */ class DefaultValueHolder { DefaultValueType type; diff --git a/src/ui/widget/button.cpp b/src/ui/widget/button.cpp index 19c69ba44..ae1dbbe98 100644 --- a/src/ui/widget/button.cpp +++ b/src/ui/widget/button.cpp @@ -1,6 +1,4 @@ -/** - * \brief Button and CheckButton widgets - * +/* * Author: * buliabyak@gmail.com * diff --git a/src/ui/widget/button.h b/src/ui/widget/button.h index 7e942b324..1ed88a2da 100644 --- a/src/ui/widget/button.h +++ b/src/ui/widget/button.h @@ -1,6 +1,4 @@ -/** - * \brief Button and CheckButton widgets - * +/* * Author: * buliabyak@gmail.com * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Button widget. + */ class Button : public Gtk::Button { public: @@ -29,6 +30,9 @@ protected: Gtk::Tooltips _tooltips; }; +/** + * CheckButton widget. + */ class CheckButton : public Gtk::CheckButton { public: diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 650ed10f6..f32e25885 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -1,6 +1,4 @@ -/** \file - * \brief Color picker button & window - * +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index add596444..22ca1ebe0 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -1,6 +1,4 @@ -/** \file - * Implemenmtation of a simple color preview widget - * +/* * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -11,8 +9,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-plain-stuff-gdk.h" -#include "color-preview.h" +#include "ui/widget/color-preview.h" +#include "display/cairo-utils.h" #define SPCP_DEFAULT_WIDTH 32 #define SPCP_DEFAULT_HEIGHT 12 @@ -76,6 +74,9 @@ ColorPreview::paint (GdkRectangle *area) if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return; + GtkWidget *widget = GTK_WIDGET(this->gobj()); + cairo_t *ct = gdk_cairo_create(widget->window); + /* Transparent area */ w2 = warea.width / 2; @@ -86,11 +87,15 @@ ColorPreview::paint (GdkRectangle *area) carea.height = warea.height; if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (get_window()->gobj(), - get_style()->get_black_gc()->gobj(), - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - _rgba); + cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard(); + + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + cairo_set_source(ct, checkers); + cairo_fill_preserve(ct); + ink_cairo_set_source_rgba32(ct, _rgba); + cairo_fill(ct); + + cairo_pattern_destroy(checkers); } /* Solid area */ @@ -101,12 +106,12 @@ ColorPreview::paint (GdkRectangle *area) carea.height = warea.height; if (gdk_rectangle_intersect (area, &carea, &cpaint)) { - nr_gdk_draw_rgba32_solid (get_window()->gobj(), - get_style()->get_black_gc()->gobj(), - cpaint.x, cpaint.y, - cpaint.width, cpaint.height, - _rgba | 0xff); + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + ink_cairo_set_source_rgba32(ct, _rgba | 0xff); + cairo_fill(ct); } + + cairo_destroy(ct); } }}} diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index 424c58665..aa4c7e11d 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -1,9 +1,6 @@ -#ifndef __COLOR_PREVIEW_H__ -#define __COLOR_PREVIEW_H__ - -/** \file - * A simple color preview widget, mainly used within a picker button. - * +#ifndef SEEN_COLOR_PREVIEW_H +#define SEEN_COLOR_PREVIEW_H +/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> @@ -17,9 +14,12 @@ #include <gtkmm/eventbox.h> namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * A simple color preview widget, mainly used within a picker button. + */ class ColorPreview : public Gtk::Widget { public: ColorPreview (guint32 rgba); @@ -34,9 +34,11 @@ protected: guint32 _rgba; }; -}}} +} // namespace Widget +} // namespace UI +} // namespace Inkscape -#endif +#endif // SEEN_COLOR_PREVIEW_H /* Local Variables: diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h index d9044daa6..9dfb920a5 100644 --- a/src/ui/widget/combo-enums.h +++ b/src/ui/widget/combo-enums.h @@ -1,6 +1,4 @@ -/** - * \brief Simplified management of enumerations in the UI as combobox. - * +/* * Authors: * Nicholas Bishop <nicholasbishop@gmail.com> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> @@ -23,6 +21,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class ComboBoxEnum : public Gtk::ComboBox, public AttrWidget { private: @@ -176,6 +177,9 @@ private: }; +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class LabelledComboBoxEnum : public Labelled { public: diff --git a/src/ui/widget/combo-text.cpp b/src/ui/widget/combo-text.cpp index 7706f7c29..43428adb8 100644 --- a/src/ui/widget/combo-text.cpp +++ b/src/ui/widget/combo-text.cpp @@ -23,7 +23,7 @@ #endif #include "combo-text.h" -#include <gtk/gtkcombobox.h> +#include <gtk/gtk.h> ComboText::ComboText() : Gtk::ComboBox() diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 72a20c385..14b219110 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -1,6 +1,4 @@ -/** - * \brief A custom Inkscape wrapper around gdl_dock_item - * +/* * Author: * Gustav Broberg <broberg@kth.se> * @@ -262,7 +260,7 @@ DockItem::present() void DockItem::grab_focus() { - if (GTK_WIDGET_REALIZED (_gdl_dock_item)) { + if (gtk_widget_get_realized (_gdl_dock_item)) { // make sure the window we're in is present Gtk::Widget *toplevel = getWidget().get_toplevel(); diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 79d69d862..48cd71846 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -1,6 +1,4 @@ -/** - * \brief A custom wrapper around gdl-dock-item - * +/* * Author: * Gustav Broberg <broberg@kth.se> * @@ -19,7 +17,7 @@ #include <gtkmm/paned.h> #include <gtkmm/window.h> -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" namespace Inkscape { namespace UI { @@ -27,6 +25,9 @@ namespace Widget { class Dock; +/** + * A custom wrapper around gdl-dock-item. + */ class DockItem { public: diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 02e1f2b41..627b01e27 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief A desktop dock pane to dock dialogs. +/** + * @file + * A desktop dock pane to dock dialogs. */ /* Author: * Gustav Broberg <broberg@kth.se> diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 5836cf83f..bd5685348 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -20,7 +20,7 @@ #include "ui/widget/dock-item.h" -#include "libgdl/libgdl.h" +#include "libgdl/gdl.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index e191a9360..aaf67a7a2 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -1,5 +1,4 @@ -/** \file - * +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Bryce W. Harrington <bryce@bryceharrington.org> @@ -25,6 +24,7 @@ #include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" +#include "sp-root.h" #include "entity-entry.h" @@ -87,8 +87,8 @@ void EntityLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's <title> and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); @@ -133,8 +133,8 @@ void EntityMultiLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); // If RDF title is not set, get the document's <title> and set the RDF: - if ( !text && !strcmp(_entity->name, "title") && doc->root ) { - text = doc->root->title(); + if ( !text && !strcmp(_entity->name, "title") && doc->getRoot() ) { + text = doc->getRoot()->title(); rdf_set_work_entity(doc, _entity, text); } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); diff --git a/src/ui/widget/entity-entry.h b/src/ui/widget/entity-entry.h index 5bdee9a90..c96f3351d 100644 --- a/src/ui/widget/entity-entry.h +++ b/src/ui/widget/entity-entry.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index 7b19ac861..7ac8532fb 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -1,7 +1,4 @@ -/** \file - * - * \brief Helperclass for Gtk::Entry widgets - * +/* * Authors: * Johan Engelen <goejendaagh@zonnet.nl> * diff --git a/src/ui/widget/entry.h b/src/ui/widget/entry.h index bb6c1321a..3338f0888 100644 --- a/src/ui/widget/entry.h +++ b/src/ui/widget/entry.h @@ -1,7 +1,4 @@ -/** \file - * - * \brief Helperclass for Gtk::Entry widgets - * +/* * Authors: * Johan Engelen <goejendaagh@zonnet.nl> * @@ -23,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Helperclass for Gtk::Entry widgets. + */ class Entry : public Labelled { public: diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index aba3a18e8..52ce0b5bc 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -22,10 +22,10 @@ namespace UI { namespace Widget { SimpleFilterModifier::SimpleFilterModifier(int flags) - : _lb_blend(_("_Blend mode:")), + : _lb_blend(_("Blend mode:")), _lb_blur(_("_Blur:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, true), _blend(BlendModeConverter, SP_ATTR_INVALID, false), - _blur(0, 0, 100, 1, 0.01, 1) + _blur(0, 0, 100, 1, 0.01, 2) { _flags = flags; diff --git a/src/ui/widget/handlebox.cpp b/src/ui/widget/handlebox.cpp index b82b715bb..0ac84ef3a 100644 --- a/src/ui/widget/handlebox.cpp +++ b/src/ui/widget/handlebox.cpp @@ -1,10 +1,4 @@ -/** - * \brief HandleBox Widget - Adds a detachment handle to another widget. - * - * This work really doesn't amount to much more than a convenience constructor - * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as - * Gtkmm provides several convenience constructors for other widgets as well. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * diff --git a/src/ui/widget/handlebox.h b/src/ui/widget/handlebox.h index 41a993e9d..db384552b 100644 --- a/src/ui/widget/handlebox.h +++ b/src/ui/widget/handlebox.h @@ -1,9 +1,4 @@ -/** - * \brief HandleBox Widget - Adds a detachment handle to another widget. - * - * This work really doesn't amount to much more than a convenience constructor - * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as - * Gtkmm provides several convenience constructors for other widgets as well. +/* * * Author: * Derek P. Moore <derekm@hackunix.org> @@ -22,6 +17,13 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Adds a detachment handle to another widget. + * + * This work really doesn't amount to much more than a convenience constructor + * for Gtk::HandleBox. Maybe this could be contributed back to Gtkmm, as + * Gtkmm provides several convenience constructors for other widgets as well. + */ class HandleBox : public Gtk::HandleBox { public: diff --git a/src/ui/widget/icon-widget.cpp b/src/ui/widget/icon-widget.cpp index 64415f421..d04f89b15 100644 --- a/src/ui/widget/icon-widget.cpp +++ b/src/ui/widget/icon-widget.cpp @@ -1,6 +1,4 @@ -/** - * \brief Icon Widget - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -14,28 +12,23 @@ # include <config.h> #endif -#include <glib/gmem.h> +#include <glib.h> #include "icon-widget.h" namespace Inkscape { namespace UI { namespace Widget { -/** - * General purpose icon widget, supporting SVG, etc. icon loading - * - * \param ... - * - * An icon widget is a ... - */ - -IconWidget::IconWidget() +IconWidget::IconWidget() : + _pb(0), + _size(0), + _do_bitmap_icons(false) { - _pb = NULL; - _size = 0; } -IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) +IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) : + _pb(0), + _do_bitmap_icons(false) { _size = std::max((int unsigned)128, std::min(size, (int unsigned)1)); @@ -45,7 +38,7 @@ IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) if (pixels == NULL) { g_warning("Couldn't find matching icon for %s - has this application been installed?", name); - _pb = NULL; + //_pb = NULL; } else { /* TODO _pb = gdk_pixbuf_new_from_data(pixels, GDK_COLORSPACE_RGB, @@ -55,7 +48,9 @@ IconWidget::IconWidget(int unsigned size, int unsigned scale, gchar const *name) } } -IconWidget::IconWidget(int unsigned size, guchar const */*px*/) +IconWidget::IconWidget(int unsigned size, guchar const */*px*/) : + _pb(0), + _do_bitmap_icons(false) { _size = std::max((int unsigned)128, std::min(size, (int unsigned)1)); diff --git a/src/ui/widget/icon-widget.h b/src/ui/widget/icon-widget.h index 3ca461b33..329702f2e 100644 --- a/src/ui/widget/icon-widget.h +++ b/src/ui/widget/icon-widget.h @@ -1,6 +1,4 @@ -/** - * \brief Icon Widget - General image widget (including SVG icons) - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -19,6 +17,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Icon Widget - General image widget (including SVG icons). + */ class IconWidget : public Gtk::Widget { public: diff --git a/src/ui/widget/labelled.cpp b/src/ui/widget/labelled.cpp index c55b57616..0a13d6347 100644 --- a/src/ui/widget/labelled.cpp +++ b/src/ui/widget/labelled.cpp @@ -1,7 +1,4 @@ -/** - * \brief Labelled Widget - Adds a label with optional icon or suffix to - * another widget. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -24,18 +21,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Labelled Widget. - * - * \param label Label. - * \param widget Widget to label; should be allocated with new, as it will - * be passed to Gtk::manage(). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the text - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &suffix, @@ -60,9 +45,6 @@ Labelled::Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, } -/** - * Allow the setting of the width of the labelled widget - */ void Labelled::setWidgetSizeRequest(int width, int height) { if (_widget) diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h index a8b00ebb6..8c2ec8939 100644 --- a/src/ui/widget/labelled.h +++ b/src/ui/widget/labelled.h @@ -1,7 +1,4 @@ -/** - * \brief Labelled Widget - Adds a label with optional icon or suffix to - * another widget. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -23,9 +20,25 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Adds a label with optional icon or suffix to another widget. + */ class Labelled : public Gtk::HBox { public: + + /** + * Construct a Labelled Widget. + * + * @param label Label. + * @param widget Widget to label; should be allocated with new, as it will + * be passed to Gtk::manage(). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the text + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Widget *widget, Glib::ustring const &suffix = "", diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 7111e17be..de482fb74 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -95,7 +95,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) AlternateIcons *label; label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN)); + INKSCAPE_ICON("object-visible"), INKSCAPE_ICON("object-hidden"))); _visibility_toggle.add(*label); _visibility_toggle.signal_toggled().connect( sigc::compose( @@ -116,7 +116,7 @@ LayerSelector::LayerSelector(SPDesktop *desktop) pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING); label = Gtk::manage(new AlternateIcons(Inkscape::ICON_SIZE_DECORATION, - INKSCAPE_ICON_OBJECT_UNLOCKED, INKSCAPE_ICON_OBJECT_LOCKED)); + INKSCAPE_ICON("object-unlocked"), INKSCAPE_ICON("object-locked"))); _lock_toggle.add(*label); _lock_toggle.signal_toggled().connect( sigc::compose( @@ -236,6 +236,8 @@ void LayerSelector::_selectLayer(SPObject *layer) { using Inkscape::Util::reverse_list; _selection_changed_connection.block(); + _visibility_toggled_connection.block(); + _lock_toggled_connection.block(); while (!_layer_model->children().empty()) { Gtk::ListStore::iterator first_row(_layer_model->children().begin()); @@ -285,6 +287,8 @@ void LayerSelector::_selectLayer(SPObject *layer) { _lock_toggle.set_active(( SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false )); } + _lock_toggled_connection.unblock(); + _visibility_toggled_connection.unblock(); _selection_changed_connection.unblock(); } diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index c9550bb27..7caf732a4 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -1,5 +1,4 @@ -/** \file - * +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Bryce W. Harrington <bryce@bryceharrington.org> @@ -58,8 +57,7 @@ LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* enti } /// \pre it is assumed that the license URI entry is a Gtk::Entry -void -LicenseItem::on_toggled() +void LicenseItem::on_toggled() { if (_wr.isUpdating()) return; @@ -84,8 +82,7 @@ Licensor::~Licensor() if (_eentry) delete _eentry; } -void -Licensor::init (Gtk::Tooltips& tt, Registry& wr) +void Licensor::init (Gtk::Tooltips& tt, Registry& wr) { /* add license-specific metadata entry areas */ rdf_work_entity_t* entity = rdf_find_entity ( "license_uri" ); @@ -119,8 +116,7 @@ Licensor::init (Gtk::Tooltips& tt, Registry& wr) show_all_children(); } -void -Licensor::update (SPDocument *doc) +void Licensor::update (SPDocument *doc) { /* identify the license info */ struct rdf_license_t * license = rdf_get_license (doc); diff --git a/src/ui/widget/licensor.h b/src/ui/widget/licensor.h index 9f41a6d0d..3c503b5ba 100644 --- a/src/ui/widget/licensor.h +++ b/src/ui/widget/licensor.h @@ -1,7 +1,4 @@ -/** \file - * \brief Widget for specifying a document's license; part of document - * preferences dialog. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -10,8 +7,8 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#ifndef INKSCAPE_UI_WIDGET_LICENSOR__H -#define INKSCAPE_UI_WIDGET_LICENSOR__H +#ifndef INKSCAPE_UI_WIDGET_LICENSOR_H +#define INKSCAPE_UI_WIDGET_LICENSOR_H #include <gtkmm/box.h> @@ -29,6 +26,10 @@ class EntityEntry; class Registry; +/** + * Widget for specifying a document's license; part of document + * preferences dialog. + */ class Licensor : public Gtk::VBox { public: Licensor(); @@ -45,7 +46,7 @@ protected: } // namespace UI } // namespace Inkscape -#endif // INKSCAPE_UI_WIDGET_LICENSOR__H +#endif // INKSCAPE_UI_WIDGET_LICENSOR_H /* Local Variables: diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index 47035ce2f..92bcb6937 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -1,5 +1,5 @@ -/** - * \brief Notebook page widget +/* + * Notebook page widget. * * Author: * Bryce Harrington <bryce@bryceharrington.org> @@ -19,12 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a NotebookPage - * - * \param label Label. - */ - NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding) :_table(n_rows, n_columns) { diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index 38c13005e..a541f3ba0 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -1,6 +1,4 @@ -/** - * \brief Notebook Page Widget - A tabbed notebook page for dialogs. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -20,10 +18,18 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A tabbed notebook page for dialogs. + */ class NotebookPage : public Gtk::VBox { public: + NotebookPage(); + + /** + * Construct a NotebookPage. + */ NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0); Gtk::Table& table() { return _table; } diff --git a/src/ui/widget/object-composite-settings.h b/src/ui/widget/object-composite-settings.h index 76538d6a7..8ef31a889 100644 --- a/src/ui/widget/object-composite-settings.h +++ b/src/ui/widget/object-composite-settings.h @@ -17,7 +17,7 @@ #include <gtkmm/alignment.h> #include <gtkmm/adjustment.h> #include <gtkmm/label.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/scale.h> #include <glibmm/ustring.h> @@ -47,7 +47,7 @@ private: Gtk::Label _opacity_label; Gtk::Adjustment _opacity_adjustment; Gtk::HScale _opacity_hscale; - Gtk::SpinButton _opacity_spin_button; + Inkscape::UI::Widget::SpinButton _opacity_spin_button; StyleSubject *_subject; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index f306b9eea..0b18f1039 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -1,7 +1,9 @@ -/** \file +/** + * @file * * Paper-size widget and helper functions - * + */ +/* * Authors: * bulia byak <buliabyak@users.sf.net> * Lauris Kaplinski <lauris@kaplinski.com> @@ -24,6 +26,7 @@ #include <string> #include <string.h> #include <vector> +#include <2geom/transforms.h> #include "desktop-handles.h" #include "document.h" @@ -235,9 +238,17 @@ PageSizer::PageSizer(Registry & _wr) _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr), _marginBottom( _("Botto_m:"), _("Bottom margin"), "fit-margin-bottom", _wr), - + _lockMarginUpdate(false), _widgetRegistry(&_wr) { + // set precision of scalar entry boxes + _dimensionWidth.setDigits(5); + _dimensionHeight.setDigits(5); + _marginTop.setDigits(5); + _marginLeft.setDigits(5); + _marginRight.setDigits(5); + _marginBottom.setDigits(5); + //# Set up the Paper Size combo box _paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns); _paperSizeList.set_model(_paperSizeListStore); @@ -422,7 +433,7 @@ PageSizer::setDim (double w, double h, bool changeList) // The origin for the user is in the lower left corner; this point should remain stationary when // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); - SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); + doc->getRoot()->translateChildItems(vert_offset); DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } @@ -464,18 +475,20 @@ PageSizer::setDim (double w, double h, bool changeList) void PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) { - double value = 0.0; - if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) { - _marginTop.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) { - _marginLeft.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) { - _marginRight.setValue(value); - } - if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) { - _marginBottom.setValue(value); + if (!_lockMarginUpdate) { + double value = 0.0; + if (sp_repr_get_double(nv_repr, "fit-margin-top", &value)) { + _marginTop.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-left", &value)) { + _marginLeft.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-right", &value)) { + _marginRight.setValue(value); + } + if (sp_repr_get_double(nv_repr, "fit-margin-bottom", &value)) { + _marginBottom.setValue(value); + } } } @@ -498,7 +511,7 @@ PageSizer::find_paper_size (double w, double h) const std::map<Glib::ustring, PaperSize>::const_iterator iter; for (iter = _paperSizeTable.begin() ; - iter != _paperSizeTable.end() ; iter++) { + iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; SPUnit const &i_unit = sp_unit_get_by_id(paper.unit); double smallX = sp_units_get_pixels(paper.smaller, i_unit); @@ -512,7 +525,7 @@ PageSizer::find_paper_size (double w, double h) const // We need to search paperSizeListStore explicitly for the // specified paper size because it is sorted in a different // way than paperSizeTable (which is sorted alphabetically) - for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); p++) { + for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) { if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) { return p; } @@ -537,14 +550,18 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() SPDocument *doc; SPNamedView *nv; Inkscape::XML::Node *nv_repr; + if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP)) && (nv = sp_document_namedview(doc, 0)) && (nv_repr = nv->getRepr())) { + _lockMarginUpdate = true; sp_repr_set_svg_double(nv_repr, "fit-margin-top", _marginTop.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-left", _marginLeft.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-right", _marginRight.getValue()); sp_repr_set_svg_double(nv_repr, "fit-margin-bottom", _marginBottom.getValue()); + _lockMarginUpdate = false; } + Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); if (verb) { SPAction *action = verb->get_action(dt); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 2072aeccd..7f165266c 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -1,6 +1,4 @@ -/** \file - * \brief Widget for specifying page size; part of Document Preferences dialog. - * +/* * Author: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -9,8 +7,8 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER__H -#define INKSCAPE_UI_WIDGET_PAGE_SIZER__H +#ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER_H +#define INKSCAPE_UI_WIDGET_PAGE_SIZER_H #include <gtkmm.h> #include <stddef.h> @@ -219,6 +217,7 @@ protected: RegisteredScalar _marginBottom; Gtk::Alignment _fitPageButtonAlign; Gtk::Button _fitPageButton; + bool _lockMarginUpdate; //callback void on_value_changed(); @@ -237,7 +236,7 @@ protected: } // namespace Inkscape -#endif /* INKSCAPE_UI_WIDGET_PAGE_SIZER__H */ +#endif // INKSCAPE_UI_WIDGET_PAGE_SIZER_H /* Local Variables: diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index b3c8ce376..8c8603640 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -1,6 +1,4 @@ -/** - * \brief Panel widget - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Jon A. Cruz <jon@joncruz.org> @@ -22,7 +20,7 @@ #include <gtkmm/dialog.h> // for Gtk::RESPONSE_* #include <gtkmm/stock.h> -#include <gtk/gtkiconfactory.h> +#include <gtk/gtk.h> #include "panel.h" #include "icon-size.h" @@ -54,10 +52,6 @@ void Panel::prep() { eek_preview_set_size_mappings( G_N_ELEMENTS(sizes), sizes ); } -/** - * Construct a Panel - */ - Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, int verb_num, Glib::ustring const &apply_label, bool menu_desired) : diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index fe3e226b4..d51d942dd 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -1,6 +1,4 @@ -/** - * \brief Generic Panel widget - A generic dockable container. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Jon A. Cruz <jon@joncruz.org> @@ -35,16 +33,23 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A generic dockable container. + */ class Panel : public Gtk::VBox { public: static void prep(); - virtual ~Panel(); + /** + * Construct a Panel. + */ Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0, int verb_num = 0, Glib::ustring const &apply_label = "", bool menu_desired = false); + virtual ~Panel(); + gchar const *getPrefsPath() const; void setLabel(Glib::ustring const &label); Glib::ustring const &getLabel() const; diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index ca7f7a501..385b60122 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -1,7 +1,4 @@ -/** - * \brief Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Carl Hetherington <inkscape@carlh.net> @@ -28,16 +25,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Point Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -51,17 +38,6 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** - * Construct a Point Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, @@ -76,18 +52,6 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** - * Construct a Point Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, @@ -103,131 +67,105 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, static_cast<Gtk::VBox*>(_widget)->show_all_children(); } -/** Fetches the precision of the spin buton */ -unsigned -Point::getDigits() const +unsigned Point::getDigits() const { return xwidget.getDigits(); } -/** Gets the current step ingrement used by the spin button */ -double -Point::getStep() const +double Point::getStep() const { return xwidget.getStep(); } -/** Gets the current page increment used by the spin button */ -double -Point::getPage() const +double Point::getPage() const { return xwidget.getPage(); } -/** Gets the minimum range value allowed for the spin button */ -double -Point::getRangeMin() const +double Point::getRangeMin() const { return xwidget.getRangeMin(); } -/** Gets the maximum range value allowed for the spin button */ -double -Point::getRangeMax() const +double Point::getRangeMax() const { return xwidget.getRangeMax(); } -/** Get the value in the spin_button . */ -double -Point::getXValue() const +double Point::getXValue() const { return xwidget.getValue(); } -double -Point::getYValue() const + +double Point::getYValue() const { return ywidget.getValue(); } -Geom::Point -Point::getValue() const + +Geom::Point Point::getValue() const { return Geom::Point( getXValue() , getYValue() ); } -/** Get the value spin_button represented as an integer. */ -int -Point::getXValueAsInt() const +int Point::getXValueAsInt() const { return xwidget.getValueAsInt(); } -int -Point::getYValueAsInt() const + +int Point::getYValueAsInt() const { return ywidget.getValueAsInt(); } -/** Sets the precision to be displayed by the spin button */ -void -Point::setDigits(unsigned digits) +void Point::setDigits(unsigned digits) { xwidget.setDigits(digits); ywidget.setDigits(digits); } -/** Sets the step and page increments for the spin button */ -void -Point::setIncrements(double step, double page) +void Point::setIncrements(double step, double page) { xwidget.setIncrements(step, page); ywidget.setIncrements(step, page); } -/** Sets the minimum and maximum range allowed for the spin button */ -void -Point::setRange(double min, double max) +void Point::setRange(double min, double max) { xwidget.setRange(min, max); ywidget.setRange(min, max); } -/** Sets the value of the spin button */ -void -Point::setValue(Geom::Point const & p) +void Point::setValue(Geom::Point const & p) { xwidget.setValue(p[0]); ywidget.setValue(p[1]); } -/** Manually forces an update of the spin button */ -void -Point::update() { +void Point::update() +{ xwidget.update(); ywidget.update(); } -/** Check 'setProgrammatically' of both scalar widgets. False if value is changed by user by clicking the widget. */ -bool -Point::setProgrammatically() { +bool Point::setProgrammatically() +{ return (xwidget.setProgrammatically || ywidget.setProgrammatically); } -void -Point::clearProgrammatically() { +void Point::clearProgrammatically() +{ xwidget.setProgrammatically = false; ywidget.setProgrammatically = false; } -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Point::signal_x_value_changed() +Glib::SignalProxy0<void> Point::signal_x_value_changed() { return xwidget.signal_value_changed(); } -Glib::SignalProxy0<void> -Point::signal_y_value_changed() + +Glib::SignalProxy0<void> Point::signal_y_value_changed() { return ywidget.signal_value_changed(); } diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 68d2f4c9d..ced43c47a 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -1,7 +1,4 @@ -/** - * \brief Point Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary coordinate values. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Carl Hetherington <inkscape@carlh.net> @@ -13,7 +10,6 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef INKSCAPE_UI_WIDGET_POINT_H #define INKSCAPE_UI_WIDGET_POINT_H @@ -27,20 +23,61 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional icon or suffix, for + * entering arbitrary coordinate values. + */ class Point : public Labelled { public: + + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Point Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -49,35 +86,93 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Fetches the precision of the spin buton. + */ unsigned getDigits() const; + + /** + * Gets the current step ingrement used by the spin button. + */ double getStep() const; + + /** + * Gets the current page increment used by the spin button. + */ double getPage() const; + + /** + * Gets the minimum range value allowed for the spin button. + */ double getRangeMin() const; + + /** + * Gets the maximum range value allowed for the spin button. + */ double getRangeMax() const; + bool getSnapToTicks() const; + + /** + * Get the value in the spin_button. + */ double getXValue() const; + double getYValue() const; + Geom::Point getValue() const; + + /** + * Get the value spin_button represented as an integer. + */ int getXValueAsInt() const; + int getYValueAsInt() const; + /** + * Sets the precision to be displayed by the spin button. + */ void setDigits(unsigned digits); + + /** + * Sets the step and page increments for the spin button. + */ void setIncrements(double step, double page); + + /** + * Sets the minimum and maximum range allowed for the spin button. + */ void setRange(double min, double max); + + /** + * Sets the value of the spin button. + */ void setValue(Geom::Point const & p); + /** + * Manually forces an update of the spin button. + */ void update(); + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_x_value_changed(); + Glib::SignalProxy0<void> signal_y_value_changed(); - bool setProgrammatically(); // true if the value was set by setValue, not changed by the user; - // if a callback checks it, it must reset it back to false + /** + * Check 'setProgrammatically' of both scalar widgets. False if value is changed by user by clicking the widget. + * true if the value was set by setValue, not changed by the user; + * if a callback checks it, it must reset it back to false. + */ + bool setProgrammatically(); + void clearProgrammatically(); protected: - Scalar xwidget, ywidget; - + Scalar xwidget; + Scalar ywidget; }; } // namespace Widget diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index afcaa338e..001d2277d 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -1,5 +1,5 @@ -/** - * \brief Inkscape Preferences dialog +/* + * Inkscape Preferences dialog. * * Authors: * Marco Scholten @@ -227,7 +227,6 @@ void PrefSpinButton::init(Glib::ustring const &prefs_path, this->set_range (lower, upper); this->set_increments (step_increment, 0); - this->set_numeric(); this->set_value (value); this->set_width_chars(6); if (is_int) @@ -256,6 +255,45 @@ void PrefSpinButton::on_value_changed() } } +void PrefSpinUnit::init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, UnitType unit_type, Glib::ustring const &default_unit) +{ + _prefs_path = prefs_path; + _is_percent = (unit_type == UNIT_TYPE_DIMENSIONLESS); + + resetUnitType(unit_type); + setUnit(default_unit); + setRange (lower, upper); /// @fixme this disregards changes of units + setIncrements (step_increment, 0); + if (step_increment < 0.1) { + setDigits(4); + } else { + setDigits(2); + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper); + Glib::ustring unitstr = prefs->getUnit(prefs_path); + if (unitstr.length() == 0) { + unitstr = default_unit; + // write the assumed unit to preferences: + prefs->setDoubleUnit(_prefs_path, value, unitstr); + } + setValue(value, unitstr); + + signal_value_changed().connect_notify(sigc::mem_fun(*this, &PrefSpinUnit::on_my_value_changed)); +} + +void PrefSpinUnit::on_my_value_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (getWidget()->is_visible()) //only take action if user changed value + { + prefs->setDoubleUnit(_prefs_path, getValue(getUnit().abbr), getUnit().abbr); + } +} + const double ZoomCorrRuler::textsize = 7; const double ZoomCorrRuler::textpadding = 5; @@ -545,10 +583,6 @@ void PrefCombo::init(Glib::ustring const &prefs_path, this->set_active(row); } -/** - initialize a combo box - second form uses strings as key values -*/ void PrefCombo::init(Glib::ustring const &prefs_path, Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value) { diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 6c7f9ce4a..ea5c377a3 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -1,6 +1,8 @@ /** - * \brief Inkscape Preferences dialog - * + * @file + * Widgets for Inkscape Preferences dialog. + */ +/* * Authors: * Marco Scholten * Bruno Dilly <bruno.dilly@gmail.com> @@ -17,7 +19,7 @@ #include <vector> #include <gtkmm/table.h> #include <gtkmm/comboboxtext.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <gtkmm/tooltips.h> #include <gtkmm/treeview.h> #include <gtkmm/radiobutton.h> @@ -32,6 +34,8 @@ #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" +#include "ui/widget/spinbutton.h" +#include "ui/widget/scalar-unit.h" namespace Inkscape { namespace UI { @@ -68,7 +72,7 @@ protected: void on_toggled(); }; -class PrefSpinButton : public Gtk::SpinButton +class PrefSpinButton : public SpinButton { public: void init(Glib::ustring const &prefs_path, @@ -81,6 +85,21 @@ protected: void on_value_changed(); }; +class PrefSpinUnit : public ScalarUnit +{ +public: + PrefSpinUnit() : ScalarUnit("", "") {}; + + void init(Glib::ustring const &prefs_path, + double lower, double upper, double step_increment, + double default_value, + UnitType unit_type, Glib::ustring const &default_unit); +protected: + Glib::ustring _prefs_path; + bool _is_percent; + void on_my_value_changed(); +}; + class ZoomCorrRuler : public Gtk::DrawingArea { public: ZoomCorrRuler(int width = 100, int height = 20); @@ -116,7 +135,7 @@ private: void on_spinbutton_value_changed(); void on_unit_changed(); - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; Gtk::HScale _slider; ZoomCorrRuler _ruler; @@ -134,7 +153,7 @@ private: void on_spinbutton_value_changed(); Glib::ustring _prefs_path; - Gtk::SpinButton _sb; + Inkscape::UI::Widget::SpinButton _sb; Gtk::HScale _slider; bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -145,6 +164,11 @@ class PrefCombo : public Gtk::ComboBoxText public: void init(Glib::ustring const &prefs_path, Glib::ustring labels[], int values[], int num_items, int default_value); + + /** + * Initialize a combo box. + * second form uses strings as key values. + */ void init(Glib::ustring const &prefs_path, Glib::ustring labels[], Glib::ustring values[], int num_items, Glib::ustring default_value); protected: diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 02201be12..03cea7d5a 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -1,10 +1,4 @@ -/** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. It adds an extra - * number called "startseed", that is not UI edittable, but should be put in SVG. - * This does NOT generate a random number, but provides merely the saving of - * the startseed value. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -25,20 +19,12 @@ #include <glibmm/i18n.h> +#include <gtkmm/button.h> + namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Random scalar Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -49,17 +35,6 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** - * Construct a Random Scalar Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, @@ -71,18 +46,6 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** - * Construct a Random Scalar Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, @@ -95,23 +58,17 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, addReseedButton(); } -/** Gets the startseed */ -long -Random::getStartSeed() const +long Random::getStartSeed() const { return startseed; } -/** Sets the startseed number */ -void -Random::setStartSeed(long newseed) +void Random::setStartSeed(long newseed) { startseed = newseed; } -/** Add reseed button to the widget */ -void -Random::addReseedButton() +void Random::addReseedButton() { Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "randomize", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index 71cc8d1e5..cb8c223dc 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -1,7 +1,4 @@ -/** - * \brief Random Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values and generating a random number from it. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * @@ -19,20 +16,63 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values. It adds an extra + * number called "startseed", that is not UI edittable, but should be put in SVG. + * This does NOT generate a random number, but provides merely the saving of + * the startseed value. + */ class Random : public Scalar { public: + + /** + * Construct a Random scalar Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Random Scalar Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Random Scalar Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -41,7 +81,14 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Gets the startseed. + */ long getStartSeed() const; + + /** + * Sets the startseed number. + */ void setStartSeed(long newseed); sigc::signal <void> signal_reseeded; @@ -50,7 +97,12 @@ protected: long startseed; private: + + /** + * Add reseed button to the widget. + */ void addReseedButton(); + void onReseedButtonClick(); }; diff --git a/src/ui/widget/registered-enums.h b/src/ui/widget/registered-enums.h index 056a09fed..9e1682c7d 100644 --- a/src/ui/widget/registered-enums.h +++ b/src/ui/widget/registered-enums.h @@ -1,6 +1,4 @@ -/** - * \brief Simplified management of enumerations in the UI as combobox. - * +/* * Authors: * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * @@ -19,6 +17,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Simplified management of enumerations in the UI as combobox. + */ template<typename E> class RegisteredEnum : public RegisteredWidget< LabelledComboBoxEnum<E> > { public: diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index c2580013a..f923a7c9c 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -1,6 +1,4 @@ -/** \file - * - * +/* * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * bulia byak <buliabyak@users.sf.net> @@ -72,7 +70,7 @@ RegisteredCheckButton::setActive (bool b) setProgrammatically = true; set_active (b); //The slave button is greyed out if the master button is unchecked - for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); i++) { + for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { (*i)->set_sensitive(b); } setProgrammatically = false; @@ -92,7 +90,7 @@ RegisteredCheckButton::on_toggled() write_to_xml(get_active() ? "true" : "false"); //The slave button is greyed out if the master button is unchecked - for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); i++) { + for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { (*i)->set_sensitive(get_active()); } @@ -632,13 +630,7 @@ RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin) _origin = origin; } -/** - * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector. - * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length. - * After changing the coords type (polar/non-polar), the value has to be reset (setValue). - */ -void -RegisteredVector::setPolarCoords(bool polar_coords) +void RegisteredVector::setPolarCoords(bool polar_coords) { _polar_coords = polar_coords; if (polar_coords) { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 560c63dd4..df2377464 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Johan Engelen <j.b.c.engelen@utwente.nl> @@ -62,9 +60,6 @@ public: bool is_updating() {if (_wr) return _wr->isUpdating(); else return false;} - // provide automatic 'upcast' for ease of use. (do it 'dynamic_cast' instead of 'static' because who knows what W is) - operator const Gtk::Widget () { return dynamic_cast<Gtk::Widget*>(this); } - protected: RegisteredWidget() : W() { construct(); } template< typename A > @@ -350,6 +345,12 @@ public: // redefine setValue, because transform must be applied void setValue(Geom::Point const & p); void setValue(Geom::Point const & p, Geom::Point const & origin); + + /** + * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector. + * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length. + * After changing the coords type (polar/non-polar), the value has to be reset (setValue). + */ void setPolarCoords(bool polar_coords = true); protected: diff --git a/src/ui/widget/registry.cpp b/src/ui/widget/registry.cpp index aa92e6ecb..725e52791 100644 --- a/src/ui/widget/registry.cpp +++ b/src/ui/widget/registry.cpp @@ -1,6 +1,4 @@ -/** \file - * - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * diff --git a/src/ui/widget/registry.h b/src/ui/widget/registry.h index 4d7ad3068..ed1281d79 100644 --- a/src/ui/widget/registry.h +++ b/src/ui/widget/registry.h @@ -1,6 +1,4 @@ -/** \file - * \brief - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -8,7 +6,6 @@ * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef INKSCAPE_UI_WIDGET_REGISTRY__H #define INKSCAPE_UI_WIDGET_REGISTRY__H diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index 48e257af7..bbc0a0039 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -1,6 +1,4 @@ -/** - * \brief Rendering options widget - * +/* * Author: * Kees Cook <kees@outflux.net> * @@ -23,17 +21,11 @@ namespace Inkscape { namespace UI { namespace Widget { -void -RenderingOptions::_toggled() +void RenderingOptions::_toggled() { _frame_bitmap.set_sensitive(as_bitmap()); } -/** - * Construct a Rendering Options widget - * - */ - RenderingOptions::RenderingOptions () : Gtk::VBox (), _frame_backends ( Glib::ustring(_("Backend")) ), diff --git a/src/ui/widget/rendering-options.h b/src/ui/widget/rendering-options.h index 8e047e682..241683fe6 100644 --- a/src/ui/widget/rendering-options.h +++ b/src/ui/widget/rendering-options.h @@ -1,6 +1,4 @@ -/** - * \brief Rendering Options Widget - A container for selecting rendering options - * +/* * Author: * Kees Cook <kees@outflux.net> * @@ -20,9 +18,16 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A container for selecting rendering options. + */ class RenderingOptions : public Gtk::VBox { public: + + /** + * Construct a Rendering Options widget. + */ RenderingOptions(); bool as_bitmap(); // should we render as a bitmap? diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 396280aee..c31e6f529 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -1,6 +1,4 @@ -/** - * \brief widget adjustable by dragging it to rotate away from a zero-change axis - * +/* * Authors: * buliabyak@gmail.com * @@ -9,13 +7,12 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#include "event-context.h" -#include "rotateable.h" -#include "libnr/nr-point.h" -#include "libnr/nr-point-fns.h" #include <gtkmm/box.h> #include <gtkmm/eventbox.h> #include <glibmm/i18n.h> +#include <2geom/point.h> +#include "event-context.h" +#include "rotateable.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h index 79a6daa5b..15e0bf71c 100644 --- a/src/ui/widget/rotateable.h +++ b/src/ui/widget/rotateable.h @@ -1,6 +1,4 @@ -/** - * \brief widget adjustable by dragging it to rotate away from a zero-change axis - * +/* * Authors: * buliabyak@gmail.com * @@ -20,6 +18,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * Widget adjustable by dragging it to rotate away from a zero-change axis. + */ class Rotateable: public Gtk::EventBox { public: diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index a220a54ad..c6ac3a381 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -108,7 +108,7 @@ Ruler::on_button_press_event(GdkEventButton *evb) _dragging = true; sp_repr_set_boolean(repr, "showguides", TRUE); sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE); - _guide = sp_guideline_new(_dt->guides, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); + _guide = sp_guideline_new(_dt->guides, NULL, event_dt, _horiz_f ? Geom::Point(0.,1.) : Geom::Point(1.,0.)); sp_guideline_set_color(SP_GUIDELINE(_guide), _dt->namedview->guidehicolor); (void) get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK | diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index c315418d8..1a455a325 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -1,9 +1,7 @@ -#ifndef __UI_WIDGET_RULER_H__ -#define __UI_WIDGET_RULER_H__ +#ifndef SEEN_UI_WIDGET_RULER_H +#define SEEN_UI_WIDGET_RULER_H -/** \file - * Gtkmm facade/wrapper around sp_rulers. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -13,10 +11,10 @@ */ #include <gtkmm/eventbox.h> -#include "libnr/nr-point.h" +#include <2geom/point.h> struct SPCanvasItem; -struct SPDesktop; +class SPDesktop; namespace Glib { class ustring; } @@ -24,9 +22,12 @@ namespace Gtk { class Ruler; } namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * Gtkmm facade/wrapper around sp_rulers. + */ class Ruler : public Gtk::EventBox { public: @@ -52,7 +53,9 @@ private: Geom::Point get_event_dt(); }; -/// Horizontal ruler +/** + * Horizontal ruler gtkmm wrapper. + */ class HRuler : public Ruler { public: @@ -60,7 +63,9 @@ public: ~HRuler(); }; -/// Vertical ruler +/** + * Vertical ruler gtkmm wrapper. + */ class VRuler : public Ruler { public: @@ -73,7 +78,7 @@ public: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_RULER_H /* diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 6209d40e0..99ff70846 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -1,17 +1,4 @@ -/** - * \brief Scalar Unit Widget - A labelled text box, with spin buttons and - * optional icon or suffix, for entering the values of various unit - * types. - * - * A ScalarUnit is a control for entering, viewing, or manipulating - * numbers with units. This differs from ordinary numbers like 2 or - * 3.14 because the number portion of a scalar *only* has meaning - * when considered with its unit type. For instance, 12 m and 12 in - * have very different actual values, but 1 m and 100 cm have the same - * value. The ScalarUnit allows us to abstract the presentation of - * the scalar to the user from the internal representations used by - * the program. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Derek P. Moore <derekm@hackunix.org> @@ -27,24 +14,12 @@ #endif #include "scalar-unit.h" +#include "spinbutton.h" namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a ScalarUnit - * - * \param label Label. - * \param unit_type Unit type (defaults to UNIT_TYPE_LINEAR). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param unit_menu UnitMenu drop down; if not specified, one will be created - * and displayed after the widget (defaults to NULL). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, UnitType unit_type, Glib::ustring const &suffix, @@ -65,14 +40,33 @@ ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, } _unit_menu->signal_changed() .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast<SpinButton*>(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); } -/** - * Initializes the scalar based on the settings in _unit_menu. - * Requires that _unit_menu has already been initialized. - */ -void -ScalarUnit::initScalar(double min_value, double max_value) +ScalarUnit::ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + : Scalar(label, tooltip, suffix, icon, mnemonic), + _unit_menu(take_unitmenu._unit_menu), + _hundred_percent(0), + _absolute_is_increment(false), + _percentage_is_increment(false) +{ + _unit_menu->signal_changed() + .connect_notify(sigc::mem_fun(*this, &ScalarUnit::on_unit_changed)); + + static_cast<SpinButton*>(_widget)->setUnitMenu(_unit_menu); + + lastUnits = _unit_menu->getUnitAbbr(); +} + + +void ScalarUnit::initScalar(double min_value, double max_value) { g_assert(_unit_menu != NULL); Scalar::setDigits(_unit_menu->getDefaultDigits()); @@ -81,9 +75,8 @@ ScalarUnit::initScalar(double min_value, double max_value) Scalar::setRange(min_value, max_value); } -/** Sets the unit for the ScalarUnit widget */ -bool -ScalarUnit::setUnit(Glib::ustring const &unit) { +bool ScalarUnit::setUnit(Glib::ustring const &unit) +{ g_assert(_unit_menu != NULL); // First set the unit if (!_unit_menu->setUnit(unit)) { @@ -93,37 +86,58 @@ ScalarUnit::setUnit(Glib::ustring const &unit) { return true; } -/** Gets the object for the currently selected unit */ -Unit -ScalarUnit::getUnit() const { +void ScalarUnit::setUnitType(UnitType unit_type) +{ + g_assert(_unit_menu != NULL); + _unit_menu->setUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + +void ScalarUnit::resetUnitType(UnitType unit_type) +{ + g_assert(_unit_menu != NULL); + _unit_menu->resetUnitType(unit_type); + lastUnits = _unit_menu->getUnitAbbr(); +} + +Unit ScalarUnit::getUnit() const +{ g_assert(_unit_menu != NULL); return _unit_menu->getUnit(); } -/** Gets the UnitType ID for the unit */ -UnitType -ScalarUnit::getUnitType() const { +UnitType ScalarUnit::getUnitType() const +{ g_assert(_unit_menu); return _unit_menu->getUnitType(); } -/** Sets the number and unit system */ -void -ScalarUnit::setValue(double number, Glib::ustring const &units) { +void ScalarUnit::setValue(double number, Glib::ustring const &units) +{ g_assert(_unit_menu != NULL); _unit_menu->setUnit(units); Scalar::setValue(number); } -/** Sets the number only */ -void -ScalarUnit::setValue(double number) { +void ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) +{ + g_assert(_unit_menu != NULL); + if (units == "") { + // set the value in the default units + Scalar::setValue(number); + } else { + double conversion = _unit_menu->getConversion(units); + Scalar::setValue(number / conversion); + } +} + +void ScalarUnit::setValue(double number) +{ Scalar::setValue(number); } -/** Returns the value in the given unit system */ -double -ScalarUnit::getValue(Glib::ustring const &unit_name) const { +double ScalarUnit::getValue(Glib::ustring const &unit_name) const +{ g_assert(_unit_menu != NULL); if (unit_name == "") { // Return the value in the default units @@ -134,27 +148,29 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const { } } -void -ScalarUnit::setHundredPercent(double number) +void ScalarUnit::grabFocusAndSelectEntry() +{ + _widget->grab_focus(); + static_cast<SpinButton*>(_widget)->select_region(0, 20); +} + + +void ScalarUnit::setHundredPercent(double number) { _hundred_percent = number; } -void -ScalarUnit::setAbsoluteIsIncrement(bool value) +void ScalarUnit::setAbsoluteIsIncrement(bool value) { _absolute_is_increment = value; } -void -ScalarUnit::setPercentageIsIncrement(bool value) +void ScalarUnit::setPercentageIsIncrement(bool value) { _percentage_is_increment = value; } -/** Convert value from % to absolute, using _hundred_percent and *_is_increment flags */ -double -ScalarUnit::PercentageToAbsolute(double value) +double ScalarUnit::PercentageToAbsolute(double value) { // convert from percent to absolute double convertedVal = 0; @@ -168,9 +184,7 @@ ScalarUnit::PercentageToAbsolute(double value) return convertedVal; } -/** Convert value from absolute to %, using _hundred_percent and *_is_increment flags */ -double -ScalarUnit::AbsoluteToPercentage(double value) +double ScalarUnit::AbsoluteToPercentage(double value) { double convertedVal = 0; // convert from absolute to percent @@ -191,27 +205,21 @@ ScalarUnit::AbsoluteToPercentage(double value) return convertedVal; } -/** Assuming the current unit is absolute, get the corresponding % value */ -double -ScalarUnit::getAsPercentage() +double ScalarUnit::getAsPercentage() { double convertedVal = AbsoluteToPercentage(Scalar::getValue()); return convertedVal; } -/** Assuming the current unit is absolute, set the value corresponding to a given % */ -void -ScalarUnit::setFromPercentage(double value) +void ScalarUnit::setFromPercentage(double value) { double absolute = PercentageToAbsolute(value); Scalar::setValue(absolute); } -/** Signal handler for updating the value and suffix label when unit is changed */ -void -ScalarUnit::on_unit_changed() +void ScalarUnit::on_unit_changed() { g_assert(_unit_menu != NULL); diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index d8b2edbd5..4f22f438c 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -1,8 +1,4 @@ -/** - * \brief Scalar Unit Widget - A labelled text box, with spin buttons and - * optional icon or suffix, for entering the values of various unit - * types. - * +/* * Authors: * Bryce Harrington <bryce@bryceharrington.org> * Derek P. Moore <derekm@hackunix.org> @@ -23,9 +19,35 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional icon or suffix, for + * entering the values of various unit types. + * + * A ScalarUnit is a control for entering, viewing, or manipulating + * numbers with units. This differs from ordinary numbers like 2 or + * 3.14 because the number portion of a scalar *only* has meaning + * when considered with its unit type. For instance, 12 m and 12 in + * have very different actual values, but 1 m and 100 cm have the same + * value. The ScalarUnit allows us to abstract the presentation of + * the scalar to the user from the internal representations used by + * the program. + */ class ScalarUnit : public Scalar { public: + /** + * Construct a ScalarUnit. + * + * @param label Label. + * @param unit_type Unit type (defaults to UNIT_TYPE_LINEAR). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param unit_menu UnitMenu drop down; if not specified, one will be created + * and displayed after the widget (defaults to NULL). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, UnitType unit_type = UNIT_TYPE_LINEAR, Glib::ustring const &suffix = "", @@ -33,26 +55,109 @@ public: UnitMenu *unit_menu = NULL, bool mnemonic = true); + /** + * Construct a ScalarUnit. + * + * @param label Label. + * @param tooltip Tooltip text. + * @param take_unitmenu Use the unitmenu from this parameter. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ + ScalarUnit(Glib::ustring const &label, Glib::ustring const &tooltip, + ScalarUnit &take_unitmenu, + Glib::ustring const &suffix = "", + Glib::ustring const &icon = "", + bool mnemonic = true); + + /** + * Initializes the scalar based on the settings in _unit_menu. + * Requires that _unit_menu has already been initialized. + */ void initScalar(double min_value, double max_value); + /** + * Gets the object for the currently selected unit. + */ Unit getUnit() const; + + /** + * Gets the UnitType ID for the unit. + */ UnitType getUnitType() const; + + /** + * Returns the value in the given unit system. + */ double getValue(Glib::ustring const &units) const; + /** + * Sets the unit for the ScalarUnit widget. + */ bool setUnit(Glib::ustring const &units); + + /** + * Adds the unit type to the ScalarUnit widget. + */ + void setUnitType(UnitType unit_type); + + /** + * Resets the unit type for the ScalarUnit widget. + */ + void resetUnitType(UnitType unit_type); + + /** + * Sets the number and unit system. + */ void setValue(double number, Glib::ustring const &units); + + /** + * Convert and sets the number only and keeps the current unit. + */ + void setValueKeepUnit(double number, Glib::ustring const &units); + + /** + * Sets the number only. + */ void setValue(double number); + /** + * Grab focus, and select the text that is in the entry field. + */ + void grabFocusAndSelectEntry(); + void setHundredPercent(double number); + void setAbsoluteIsIncrement(bool value); + void setPercentageIsIncrement(bool value); + /** + * Convert value from % to absolute, using _hundred_percent and *_is_increment flags. + */ double PercentageToAbsolute(double value); + + /** + * Convert value from absolute to %, using _hundred_percent and *_is_increment flags. + */ double AbsoluteToPercentage(double value); + /** + * Assuming the current unit is absolute, get the corresponding % value. + */ double getAsPercentage(); + + /** + * Assuming the current unit is absolute, set the value corresponding to a given %. + */ void setFromPercentage(double value); + /** + * Signal handler for updating the value and suffix label when unit is changed. + */ void on_unit_changed(); protected: diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 26a1f6541..cc051599c 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -1,13 +1,11 @@ -/** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> * Bryce Harrington <bryce@bryceharrington.org> + * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl> * - * Copyright (C) 2004 Carl Hetherington + * Copyright (C) 2004-2011 authors * * Released under GNU GPL. Read the file 'COPYING' for more information. */ @@ -18,191 +16,135 @@ #include "scalar.h" +#include "spinbutton.h" +#include <gtkmm/scale.h> namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param digits Number of decimal digits to display. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } -/** - * Construct a Scalar Widget. - * - * \param label Label. - * \param adjust Adjustment to use for the SpinButton. - * \param digits Number of decimal digits to display (defaults to 0). - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to true). - */ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, bool mnemonic) - : Labelled(label, tooltip, new Gtk::SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), + : Labelled(label, tooltip, new SpinButton(adjust, 0.0, digits), suffix, icon, mnemonic), setProgrammatically(false) { - static_cast<Gtk::SpinButton*>(_widget)->set_numeric(); } -/** Fetches the precision of the spin buton */ -unsigned -Scalar::getDigits() const +unsigned Scalar::getDigits() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_digits(); + return static_cast<SpinButton*>(_widget)->get_digits(); } -/** Gets the current step ingrement used by the spin button */ -double -Scalar::getStep() const +double Scalar::getStep() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return step; } -/** Gets the current page increment used by the spin button */ -double -Scalar::getPage() const +double Scalar::getPage() const { g_assert(_widget != NULL); double step, page; - static_cast<Gtk::SpinButton*>(_widget)->get_increments(step, page); + static_cast<SpinButton*>(_widget)->get_increments(step, page); return page; } -/** Gets the minimum range value allowed for the spin button */ -double -Scalar::getRangeMin() const +double Scalar::getRangeMin() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return min; } -/** Gets the maximum range value allowed for the spin button */ -double -Scalar::getRangeMax() const +double Scalar::getRangeMax() const { g_assert(_widget != NULL); double min, max; - static_cast<Gtk::SpinButton*>(_widget)->get_range(min, max); + static_cast<SpinButton*>(_widget)->get_range(min, max); return max; } -/** Get the value in the spin_button . */ -double -Scalar::getValue() const +double Scalar::getValue() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value(); + return static_cast<SpinButton*>(_widget)->get_value(); } -/** Get the value spin_button represented as an integer. */ -int -Scalar::getValueAsInt() const +int Scalar::getValueAsInt() const { g_assert(_widget != NULL); - return static_cast<Gtk::SpinButton*>(_widget)->get_value_as_int(); + return static_cast<SpinButton*>(_widget)->get_value_as_int(); } -/** Sets the precision to be displayed by the spin button */ -void -Scalar::setDigits(unsigned digits) +void Scalar::setDigits(unsigned digits) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_digits(digits); + static_cast<SpinButton*>(_widget)->set_digits(digits); } -/** Sets the step and page increments for the spin button - * @todo Remove the second parameter - deprecated - */ -void -Scalar::setIncrements(double step, double /*page*/) +void Scalar::setIncrements(double step, double /*page*/) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_increments(step, 0); + static_cast<SpinButton*>(_widget)->set_increments(step, 0); } -/** Sets the minimum and maximum range allowed for the spin button */ -void -Scalar::setRange(double min, double max) +void Scalar::setRange(double min, double max) { g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->set_range(min, max); + static_cast<SpinButton*>(_widget)->set_range(min, max); } -/** Sets the value of the spin button */ -void -Scalar::setValue(double value) +void Scalar::setValue(double value) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares - static_cast<Gtk::SpinButton*>(_widget)->set_value(value); + static_cast<SpinButton*>(_widget)->set_value(value); } -/** Manually forces an update of the spin button */ -void -Scalar::update() { +void Scalar::update() +{ g_assert(_widget != NULL); - static_cast<Gtk::SpinButton*>(_widget)->update(); + static_cast<SpinButton*>(_widget)->update(); } +void Scalar::addSlider() +{ + Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() ); + scale->set_draw_value(false); + add (*manage (scale)); +} - -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Scalar::signal_value_changed() +Glib::SignalProxy0<void> Scalar::signal_value_changed() { - return static_cast<Gtk::SpinButton*>(_widget)->signal_value_changed(); + return static_cast<SpinButton*>(_widget)->signal_value_changed(); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 6de128edb..19ccb7ae0 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -1,7 +1,4 @@ -/** - * \brief Scalar Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Derek P. Moore <derekm@hackunix.org> @@ -15,29 +12,65 @@ #ifndef INKSCAPE_UI_WIDGET_SCALAR_H #define INKSCAPE_UI_WIDGET_SCALAR_H -#include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> - #include "labelled.h" namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with spin buttons and optional + * icon or suffix, for entering arbitrary number values. + */ class Scalar : public Labelled { public: + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param digits Number of decimal digits to display. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, unsigned digits, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + + /** + * Construct a Scalar Widget. + * + * @param label Label. + * @param adjust Adjustment to use for the SpinButton. + * @param digits Number of decimal digits to display (defaults to 0). + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to true). + */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, Gtk::Adjustment &adjust, @@ -46,26 +79,84 @@ public: Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Fetches the precision of the spin buton. + */ unsigned getDigits() const; + + /** + * Gets the current step ingrement used by the spin button. + */ double getStep() const; + + /** + * Gets the current page increment used by the spin button. + */ double getPage() const; + + /** + * Gets the minimum range value allowed for the spin button. + */ double getRangeMin() const; + + /** + * Gets the maximum range value allowed for the spin button. + */ double getRangeMax() const; + bool getSnapToTicks() const; + + /** + * Get the value in the spin_button. + */ double getValue() const; + + /** + * Get the value spin_button represented as an integer. + */ int getValueAsInt() const; + /** + * Sets the precision to be displayed by the spin button. + */ void setDigits(unsigned digits); + + /** + * Sets the step and page increments for the spin button. + * @todo Remove the second parameter - deprecated + */ void setIncrements(double step, double page); + + /** + * Sets the minimum and maximum range allowed for the spin button. + */ void setRange(double min, double max); + + /** + * Sets the value of the spin button. + */ void setValue(double value); + /** + * Manually forces an update of the spin button. + */ void update(); + /** + * Adds a slider (HScale) to the left of the spinbox. + */ + void addSlider(); + + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_value_changed(); - bool setProgrammatically; // true if the value was set by setValue, not changed by the user; - // if a callback checks it, it must reset it back to false + /** + * true if the value was set by setValue, not changed by the user; + * if a callback checks it, it must reset it back to false. + */ + bool setProgrammatically; }; } // namespace Widget diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 50476dc65..b6722f4cf 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1,6 +1,4 @@ -/** - * \brief Selected style indicator (fill, stroke, opacity) - * +/* * Author: * buliabyak@gmail.com * Abhishek Sharma @@ -14,7 +12,7 @@ # include <config.h> #endif -#include <gtk/gtkdnd.h> +#include <gtk/gtk.h> #include "selected-style.h" @@ -412,7 +410,7 @@ void SelectedStyle::setDesktop(SPDesktop *desktop) { _desktop = desktop; - gtk_object_set_data (GTK_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas); + g_object_set_data (G_OBJECT(_opacity_sb.gobj()), "dtw", _desktop->canvas); Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -1092,7 +1090,7 @@ void SelectedStyle::opacity_1(void) {_opacity_sb.set_value(100);} void SelectedStyle::on_opacity_menu (Gtk::Menu *menu) { Glib::ListHandle<Gtk::Widget *> children = menu->get_children(); - for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); iter++) { + for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); ++iter) { menu->remove(*(*iter)); } diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index e74d5b1ae..916cbe6d1 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -1,6 +1,4 @@ -/** - * \brief Selected style indicator (fill, stroke, opacity) - * +/* * Authors: * buliabyak@gmail.com * scislac@users.sf.net @@ -21,7 +19,7 @@ #include <gtkmm/menu.h> #include <gtkmm/menuitem.h> #include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" #include <stddef.h> #include <sigc++/sigc++.h> @@ -103,6 +101,9 @@ private: bool cr_set; }; +/** + * Selected style indicator (fill, stroke, opacity). + */ class SelectedStyle : public Gtk::HBox { public: @@ -138,7 +139,7 @@ protected: Gtk::EventBox _opacity_place; Gtk::Adjustment _opacity_adjustment; - Gtk::SpinButton _opacity_sb; + Inkscape::UI::Widget::SpinButton _opacity_sb; Gtk::Label _na[2]; Glib::ustring __na[2]; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index faafc63b4..d159ecc15 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -1,6 +1,4 @@ -/** - * \brief Groups an HScale and a SpinButton together using the same Adjustment - * +/* * Author: * Nicholas Bishop <nicholasbishop@gmail.com> * Felipe C. da S. Sanches <juca@members.fsf.org> @@ -20,7 +18,7 @@ namespace UI { namespace Widget { SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc, - double climb_rate, int digits, const SPAttributeEnum a, char* tip_text) + double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value), _adjustment(value, lower, upper, step_inc), _scale(_adjustment), _spin(_adjustment, climb_rate, digits) { @@ -90,11 +88,11 @@ Gtk::HScale& SpinSlider::get_scale() return _scale; } -const Gtk::SpinButton& SpinSlider::get_spin_button() const +const Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() const { return _spin; } -Gtk::SpinButton& SpinSlider::get_spin_button() +Inkscape::UI::Widget::SpinButton& SpinSlider::get_spin_button() { return _spin; } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index a4d0aa9d6..d2f41603a 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -1,6 +1,4 @@ -/** - * \brief Groups an HScale and a SpinButton together using the same Adjustment - * +/* * Author: * Nicholas Bishop <nicholasbishop@gmail.com> * @@ -15,18 +13,21 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> #include <gtkmm/scale.h> -#include <gtkmm/spinbutton.h> +#include "spinbutton.h" #include "attr-widget.h" namespace Inkscape { namespace UI { namespace Widget { +/** + * Groups an HScale and a SpinButton together using the same Adjustment. + */ class SpinSlider : public Gtk::HBox, public AttrWidget { public: SpinSlider(double value, double lower, double upper, double step_inc, - double climb_rate, int digits, const SPAttributeEnum a = SP_ATTR_INVALID, char* tip_text = NULL); + double climb_rate, int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); virtual Glib::ustring get_as_attribute() const; virtual void set_from_attribute(SPObject*); @@ -42,8 +43,8 @@ public: const Gtk::HScale& get_scale() const; Gtk::HScale& get_scale(); - const Gtk::SpinButton& get_spin_button() const; - Gtk::SpinButton& get_spin_button(); + const Inkscape::UI::Widget::SpinButton& get_spin_button() const; + Inkscape::UI::Widget::SpinButton& get_spin_button(); void set_update_policy(const Gtk::UpdateType); @@ -52,10 +53,14 @@ public: private: Gtk::Adjustment _adjustment; Gtk::HScale _scale; - Gtk::SpinButton _spin; + Inkscape::UI::Widget::SpinButton _spin; }; -// Contains two SpinSliders for controlling number-opt-number attributes +/** + * Contains two SpinSliders for controlling number-opt-number attributes. + * + * @see SpinSlider + */ class DualSpinSlider : public Gtk::HBox, public AttrWidget { public: diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp new file mode 100644 index 000000000..60b7856f6 --- /dev/null +++ b/src/ui/widget/spinbutton.cpp @@ -0,0 +1,104 @@ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "spinbutton.h" + +#include "unit-menu.h" +#include "util/expression-evaluator.h" +#include "event-context.h" + +namespace Inkscape { +namespace UI { +namespace Widget { + + +void +SpinButton::connect_signals() { + signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input)); + signal_focus_in_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_focus_in_event)); + signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event)); +}; + +int SpinButton::on_input(double* newvalue) +{ + try { + Inkscape::Util::GimpEevlQuantity result; + if (_unit_menu) { + Unit unit = _unit_menu->getUnit(); + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + // check if output dimension corresponds to input unit + if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { + throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); + } + } else { + result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); + } + + *newvalue = result.value; + } + catch(Inkscape::Util::EvaluatorException &e) { + g_message ("%s", e.what()); + + return false; + } + + return true; +} + +bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) +{ + on_focus_in_value = get_value(); + return false; // do not consume the event +} + +bool SpinButton::on_my_key_press_event(GdkEventKey* event) +{ + switch (get_group0_keyval (event)) { + case GDK_Escape: + undo(); + return true; // I consumed the event + break; + case GDK_z: + case GDK_Z: + if (event->state & GDK_CONTROL_MASK) { + undo(); + return true; // I consumed the event + } + break; + default: + break; + } + + return false; // do not consume the event +} + +void SpinButton::undo() +{ + set_value(on_focus_in_value); +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h new file mode 100644 index 000000000..b7764d979 --- /dev/null +++ b/src/ui/widget/spinbutton.h @@ -0,0 +1,104 @@ +/* + * Author: + * Johan B. C. Engelen + * + * Copyright (C) 2011 Author + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_SPINBUTTON_H +#define INKSCAPE_UI_WIDGET_SPINBUTTON_H + +#include <gtkmm/spinbutton.h> + +namespace Inkscape { +namespace UI { +namespace Widget { + +class UnitMenu; + +/** + * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), + * and allows entry of both '.' and ',' for the decimal, even when in numeric mode. + * + * Calling "set_numeric()" effectively disables the expression parsing. If no unit menu is linked, all unitlike characters are ignored. + */ +class SpinButton : public Gtk::SpinButton +{ +public: + SpinButton(double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(climb_rate, digits), + _unit_menu(NULL) + { + connect_signals(); + }; + explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) + : Gtk::SpinButton(adjustment, climb_rate, digits), + _unit_menu(NULL) + { + connect_signals(); + }; + + virtual ~SpinButton() {}; + + void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + +protected: + UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + + void connect_signals(); + + /** + * This callback function should try to convert the entered text to a number and write it to newvalue. + * It calls a method to evaluate the (potential) mathematical expression. + * + * @retval false No conversion done, continue with default handler. + * @retval true Conversion successful, don't call default handler. + */ + int on_input(double* newvalue); + + /** + * When focus is obtained, save the value to enable undo later. + * @retval false continue with default handler. + * @retval true don't call default handler. + */ + bool on_my_focus_in_event(GdkEventFocus* event); + + /** + * Handle specific keypress events, like Ctrl+Z. + * + * @retval false continue with default handler. + * @retval true don't call default handler. + */ + bool on_my_key_press_event(GdkEventKey* event); + + /** + * Undo the editing, by resetting the value upon when the spinbutton got focus. + */ + void undo(); + + double on_focus_in_value; + +private: + // noncopyable + SpinButton(const SpinButton&); + SpinButton& operator=(const SpinButton&); +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_SPINBUTTON_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index f4780896b..d9bf7e2aa 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -1,6 +1,4 @@ -/** - * \brief Abstraction for different style widget operands - * +/* * Copyright (C) 2007 MenTaLguY <mental@rydia.net> * Abhishek Sharma * @@ -147,7 +145,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() { Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { SPObject *layer = _getLayer(); if (layer && SP_IS_ITEM(layer)) { - return SP_ITEM(layer)->getBboxDesktop(type); + return SP_ITEM(layer)->desktopBounds(type); } else { return Geom::OptRect(); } diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h index 6d5c96350..47da91732 100644 --- a/src/ui/widget/style-subject.h +++ b/src/ui/widget/style-subject.h @@ -1,17 +1,17 @@ /** - * \brief Abstraction for different style widget operands - * + * @file + * Abstraction for different style widget operands. + */ +/* * Copyright (C) 2007 MenTaLguY <mental@rydia.net> * * Released under GNU GPL. Read the file 'COPYING' for more information. */ - #ifndef SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H #define SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H #include "util/glib-list-iterators.h" #include <boost/optional.hpp> -#include "libnr/nr-rect.h" #include <2geom/rect.h> #include "sp-item.h" #include <stddef.h> @@ -45,7 +45,7 @@ public: virtual iterator begin() = 0; virtual iterator end() { return iterator(NULL); } - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0; + virtual Geom::OptRect getBounds(SPItem::BBoxType type) = 0; virtual int queryStyle(SPStyle *query, int property) = 0; virtual void setCSS(SPCSSAttr *css) = 0; @@ -68,7 +68,7 @@ public: ~Selection(); virtual iterator begin(); - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); @@ -89,7 +89,7 @@ public: ~CurrentLayer(); virtual iterator begin(); - virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); @@ -111,7 +111,7 @@ private: } } -#endif +#endif // SEEN_INKSCAPE_UI_WIDGET_STYLE_SUBJECT_H /* Local Variables: diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 47f6292e3..41366f749 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -1,5 +1,6 @@ -/** @file - * @brief Static style swatch (fill, stroke, opacity) +/** + * @file + * Static style swatch (fill, stroke, opacity). */ /* Authors: * buliabyak@gmail.com @@ -43,7 +44,7 @@ namespace UI { namespace Widget { /** - * @brief Watches whether the tool uses the current style + * Watches whether the tool uses the current style. */ class StyleSwatch::ToolObserver : public Inkscape::Preferences::Observer { public: @@ -57,7 +58,7 @@ private: }; /** - * @brief Watches for changes in the observed style pref + * Watches for changes in the observed style pref. */ class StyleSwatch::StyleObserver : public Inkscape::Preferences::Observer { public: diff --git a/src/ui/widget/svg-canvas.cpp b/src/ui/widget/svg-canvas.cpp index 7d37ec355..d3d9f70f2 100644 --- a/src/ui/widget/svg-canvas.cpp +++ b/src/ui/widget/svg-canvas.cpp @@ -1,6 +1,4 @@ -/** \file - * Gtkmm facade/wrapper around SPCanvas. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -22,7 +20,7 @@ namespace Widget { SVGCanvas::SVGCanvas() { - void *canvas = gtk_type_new (sp_canvas_get_type ()); + void *canvas = g_object_new (sp_canvas_get_type (), NULL); _spcanvas = static_cast<SPCanvas*>(canvas); _widget = Glib::wrap (static_cast<GtkWidget*> (canvas)); _dt = 0; diff --git a/src/ui/widget/svg-canvas.h b/src/ui/widget/svg-canvas.h index cb8dc4013..c513bcf26 100644 --- a/src/ui/widget/svg-canvas.h +++ b/src/ui/widget/svg-canvas.h @@ -1,9 +1,7 @@ -#ifndef __UI_WIDGET_SVGCANVAS_H__ -#define __UI_WIDGET_SVGCANVAS_H__ +#ifndef SEEN_UI_WIDGET_SVGCANVAS_H +#define SEEN_UI_WIDGET_SVGCANVAS_H -/** \file - * Gtkmm facade/wrapper around SPCanvas. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -16,9 +14,12 @@ struct SPCanvas; struct SPDesktop; namespace Gtk { class Widget; } namespace Inkscape { - namespace UI { - namespace Widget { +namespace UI { +namespace Widget { +/** + * Gtkmm facade/wrapper around SPCanvas. + */ class SVGCanvas { public: @@ -41,7 +42,7 @@ protected: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_SVGCANVAS_H /* diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index 581491f0e..b79bea067 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -1,7 +1,4 @@ -/** - * \brief Text Widget - A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Maximilian Albert <maximilian.albert@gmail.com> @@ -22,16 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a Text Widget. - * - * \param label Label. - * \param suffix Suffix, placed after the widget (defaults to ""). - * \param icon Icon filename, placed before the label (defaults to ""). - * \param mnemonic Mnemonic toggle; if true, an underscore (_) in the label - * indicates the next character should be used for the - * mnemonic accelerator key (defaults to false). - */ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -41,26 +28,20 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, { } -/** Get the text in the entry */ -const char * -Text::getText() const +const char *Text::getText() const { g_assert(_widget != NULL); return static_cast<Gtk::Entry*>(_widget)->get_text().c_str(); } -/** Sets the text of the text entry */ -void -Text::setText(const char* text) +void Text::setText(const char* text) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares static_cast<Gtk::Entry*>(_widget)->set_text(text); // FIXME: set correctly } -/** Signal raised when the spin button's value changes */ -Glib::SignalProxy0<void> -Text::signal_activate() +Glib::SignalProxy0<void> Text::signal_activate() { return static_cast<Gtk::Entry*>(_widget)->signal_activate(); } diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index 0dcfc5cc6..0f6efd01f 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -1,7 +1,4 @@ -/** - * \brief Text Widget - A labelled text box, with optional icon or - * suffix, for entering arbitrary number values. - * +/* * Authors: * Carl Hetherington <inkscape@carlh.net> * Maximilian Albert <maximilian.albert@gmail.com> @@ -23,21 +20,44 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A labelled text box, with optional icon or suffix, for entering arbitrary number values. + */ class Text : public Labelled { public: + + /** + * Construct a Text Widget. + * + * @param label Label. + * @param suffix Suffix, placed after the widget (defaults to ""). + * @param icon Icon filename, placed before the label (defaults to ""). + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label + * indicates the next character should be used for the + * mnemonic accelerator key (defaults to false). + */ Text(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); + /** + * Get the text in the entry. + */ const char* getText() const; + /** + * Sets the text of the text entry. + */ void setText(const char* text); void update(); + /** + * Signal raised when the spin button's value changes. + */ Glib::SignalProxy0<void> signal_activate(); bool setProgrammatically; // true if the value was set by setValue, not changed by the user; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 51e0a262f..aa749fb39 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -1,7 +1,4 @@ -/** \file - * - Implementation of tolerance slider widget. - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Abhishek Sharma @@ -43,9 +40,10 @@ namespace Widget { //==================================================== -ToleranceSlider::ToleranceSlider() +ToleranceSlider::ToleranceSlider(const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) : _vbox(0) { + init(label1, label2, label3, tip1, tip2, tip3, key, wr); } ToleranceSlider::~ToleranceSlider() @@ -54,8 +52,7 @@ ToleranceSlider::~ToleranceSlider() _scale_changed_connection.disconnect(); } -void -ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) +void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr) { // hbox = label + slider // @@ -112,8 +109,7 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, _vbox->show_all_children(); } -void -ToleranceSlider::setValue (double val) +void ToleranceSlider::setValue (double val) { Gtk::Adjustment *adj = _hscale->get_adjustment(); @@ -138,21 +134,18 @@ ToleranceSlider::setValue (double val) _hbox->show_all(); } -void -ToleranceSlider::setLimits (double theMin, double theMax) +void ToleranceSlider::setLimits (double theMin, double theMax) { _hscale->set_range (theMin, theMax); _hscale->get_adjustment()->set_step_increment (1); } -void -ToleranceSlider::on_scale_changed() +void ToleranceSlider::on_scale_changed() { update (_hscale->get_value()); } -void -ToleranceSlider::on_toggled() +void ToleranceSlider::on_toggled() { if (!_button2->get_active()) { @@ -171,8 +164,7 @@ ToleranceSlider::on_toggled() } } -void -ToleranceSlider::update (double val) +void ToleranceSlider::update (double val) { if (_wr->isUpdating()) return; diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 22c04d361..6865ec769 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -1,8 +1,3 @@ -/** \file - * \brief - * - * This widget is part of the Document properties dialog. - */ /* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> @@ -27,11 +22,13 @@ namespace Widget { class Registry; +/** + * Implementation of tolerance slider widget. + * This widget is part of the Document properties dialog. + */ class ToleranceSlider { public: - ToleranceSlider(); - ~ToleranceSlider(); - void init (const Glib::ustring& label1, + ToleranceSlider(const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& label3, const Glib::ustring& tip1, @@ -39,9 +36,19 @@ public: const Glib::ustring& tip3, const Glib::ustring& key, Registry& wr); + ~ToleranceSlider(); void setValue (double); void setLimits (double, double); Gtk::VBox* _vbox; +private: + void init (const Glib::ustring& label1, + const Glib::ustring& label2, + const Glib::ustring& label3, + const Glib::ustring& tip1, + const Glib::ustring& tip2, + const Glib::ustring& tip3, + const Glib::ustring& key, + Registry& wr); protected: void on_scale_changed(); diff --git a/src/ui/widget/toolbox.cpp b/src/ui/widget/toolbox.cpp index e90a58b6e..99891fc44 100644 --- a/src/ui/widget/toolbox.cpp +++ b/src/ui/widget/toolbox.cpp @@ -1,6 +1,4 @@ -/** - * \brief Toolbox Widget - A detachable toolbar for buttons and other widgets. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * @@ -14,7 +12,7 @@ #endif #include <gtkmm/radioaction.h> -#include <gtk/gtkmain.h> +#include <gtk/gtk.h> #include "ui/widget/toolbox.h" #include "path-prefix.h" diff --git a/src/ui/widget/toolbox.h b/src/ui/widget/toolbox.h index 9c4e18909..f721bef8a 100644 --- a/src/ui/widget/toolbox.h +++ b/src/ui/widget/toolbox.h @@ -1,6 +1,4 @@ -/** - * \brief Toolbox Widget - A detachable toolbar for buttons and other widgets. - * +/* * Author: * Derek P. Moore <derekm@hackunix.org> * @@ -22,6 +20,9 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A detachable toolbar for buttons and other widgets. + */ class Toolbox : public HandleBox { public: diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index b4271762c..085783481 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -1,6 +1,4 @@ -/** - * \brief Unit Menu Widget - A drop down menu for choosing unit types. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -21,10 +19,6 @@ namespace Inkscape { namespace UI { namespace Widget { -/** - * Construct a UnitMenu - * - */ UnitMenu::UnitMenu() : _type(UNIT_TYPE_NONE) { set_active(0); @@ -33,14 +27,9 @@ UnitMenu::UnitMenu() : _type(UNIT_TYPE_NONE) UnitMenu::~UnitMenu() { } -/** Adds the unit type to the widget. This extracts the corresponding - units from the unit map matching the given type, and appends them - to the dropdown widget. It causes the primary unit for the given - unit_type to be selected. */ -bool -UnitMenu::setUnitType(UnitType unit_type) +bool UnitMenu::setUnitType(UnitType unit_type) { - /* Expand the unit widget with unit entries from the unit table */ + // Expand the unit widget with unit entries from the unit table UnitTable::UnitMap m = _unit_table.units(unit_type); UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { @@ -54,10 +43,21 @@ UnitMenu::setUnitType(UnitType unit_type) return true; } -/** Returns the Unit object corresponding to the current selection - in the dropdown widget */ -Unit -UnitMenu::getUnit() const { +bool UnitMenu::resetUnitType(UnitType unit_type) +{ + clear_text(); + + return setUnitType(unit_type); +} + +void UnitMenu::addUnit(Unit const& u) +{ + _unit_table.addUnit(u, false); + append_text(u.abbr); +} + +Unit UnitMenu::getUnit() const +{ if (get_active_text() == "") { g_assert(_type != UNIT_TYPE_NONE); return _unit_table.getUnit(_unit_table.primary(_type)); @@ -65,11 +65,8 @@ UnitMenu::getUnit() const { return _unit_table.getUnit(get_active_text()); } -/** Sets the dropdown widget to the given unit abbreviation. - Returns true if the unit was selectable, false if not - (i.e., if the unit was not present in the widget) */ -bool -UnitMenu::setUnit(Glib::ustring const & unit) { +bool UnitMenu::setUnit(Glib::ustring const & unit) +{ // TODO: Determine if 'unit' is available in the dropdown. // If not, return false @@ -77,63 +74,41 @@ UnitMenu::setUnit(Glib::ustring const & unit) { return true; } -/** Returns the abbreviated unit name of the selected unit */ -Glib::ustring -UnitMenu::getUnitAbbr() const { +Glib::ustring UnitMenu::getUnitAbbr() const +{ if (get_active_text() == "") { return ""; } return getUnit().abbr; } -/** Returns the UnitType of the selected unit */ -UnitType -UnitMenu::getUnitType() const { +UnitType UnitMenu::getUnitType() const +{ return getUnit().type; } -/** Returns the unit factor for the selected unit */ -double -UnitMenu::getUnitFactor() const +double UnitMenu::getUnitFactor() const { return getUnit().factor; } -/** Returns the recommended number of digits for displaying - * numbers of this unit type. - */ -int -UnitMenu::getDefaultDigits() const +int UnitMenu::getDefaultDigits() const { return getUnit().defaultDigits(); } -/** Returns the recommended step size in spin buttons - * displaying units of this type - */ -double -UnitMenu::getDefaultStep() const +double UnitMenu::getDefaultStep() const { int factor_digits = -1*int(log10(getUnit().factor)); return pow(10.0, factor_digits); } -/** Returns the recommended page size (when hitting pgup/pgdn) - * in spin buttons displaying units of this type - */ -double -UnitMenu::getDefaultPage() const +double UnitMenu::getDefaultPage() const { return 10 * getDefaultStep(); } -/** - * Returns the conversion factor required to convert values - * of the currently selected unit into units of type - * new_unit_abbr. - */ -double -UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const +double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr) const { double old_factor = getUnit().factor; if (old_unit_abbr != "no_unit") @@ -150,18 +125,13 @@ UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const return old_factor / new_unit.factor; } -/** Returns true if the selected unit is not dimensionless - * (false for %, true for px, pt, cm, etc) - */ -bool -UnitMenu::isAbsolute() const { +bool UnitMenu::isAbsolute() const +{ return getUnitType() != UNIT_TYPE_DIMENSIONLESS; } -/** Returns true if the selected unit is radial (deg or rad) - */ -bool -UnitMenu::isRadial() const { +bool UnitMenu::isRadial() const +{ return getUnitType() == UNIT_TYPE_RADIAL; } diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 60a9702b4..61e93bd65 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -1,6 +1,4 @@ -/** - * \brief Unit Menu Widget - A drop down menu for choosing unit types. - * +/* * Author: * Bryce Harrington <bryce@bryceharrington.org> * @@ -21,28 +19,104 @@ namespace Inkscape { namespace UI { namespace Widget { +/** + * A drop down menu for choosing unit types. + */ class UnitMenu : public ComboText { public: + + /** + * Construct a UnitMenu + */ UnitMenu(); + virtual ~UnitMenu(); + /** + * Adds the unit type to the widget. This extracts the corresponding + * units from the unit map matching the given type, and appends them + * to the dropdown widget. It causes the primary unit for the given + * unit_type to be selected. + */ bool setUnitType(UnitType unit_type); + /** + * Removes all unit entries, then adds the unit type to the widget. + * This extracts the corresponding + * units from the unit map matching the given type, and appends them + * to the dropdown widget. It causes the primary unit for the given + * unit_type to be selected. + */ + bool resetUnitType(UnitType unit_type); + + /** + * Adds a unit, possibly user-defined, to the menu. + */ + void addUnit(Unit const& u); + + /** + * Sets the dropdown widget to the given unit abbreviation. + * Returns true if the unit was selectable, false if not + * (i.e., if the unit was not present in the widget). + */ bool setUnit(Glib::ustring const &unit); + /** + * Returns the Unit object corresponding to the current selection + * in the dropdown widget. + */ Unit getUnit() const; + + /** + * Returns the abbreviated unit name of the selected unit. + */ Glib::ustring getUnitAbbr() const; + + /** + * Returns the UnitType of the selected unit. + */ UnitType getUnitType() const; + + /** + * Returns the unit factor for the selected unit. + */ double getUnitFactor() const; + /** + * Returns the recommended number of digits for displaying + * numbers of this unit type. + */ int getDefaultDigits() const; + + /** + * Returns the recommended step size in spin buttons + * displaying units of this type. + */ double getDefaultStep() const; + + /** + * Returns the recommended page size (when hitting pgup/pgdn) + * in spin buttons displaying units of this type. + */ double getDefaultPage() const; + /** + * Returns the conversion factor required to convert values + * of the currently selected unit into units of type + * new_unit_abbr. + */ double getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring const &old_unit_abbr = "no_unit") const; + /** + * Returns true if the selected unit is not dimensionless + * (false for %, true for px, pt, cm, etc). + */ bool isAbsolute() const; + + /** + * Returns true if the selected unit is radial (deg or rad). + */ bool isRadial() const; UnitTable &getUnitTable() {return _unit_table;} diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index 9322aa803..fa8191671 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -1,7 +1,4 @@ -/** \file - * Gtkmm facade/wrapper around zoom_status code that formerly lived - * in desktop-widget.cpp - * +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Lauris Kaplinski <lauris@kaplinski.com> @@ -20,7 +17,6 @@ #include "desktop.h" #include "desktop-handles.h" #include "widgets/spw-utilities.h" -#include "libnr/nr-convert2geom.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/zoom-status.h b/src/ui/widget/zoom-status.h index 58d595329..b9373589f 100644 --- a/src/ui/widget/zoom-status.h +++ b/src/ui/widget/zoom-status.h @@ -1,9 +1,6 @@ -#ifndef __UI_WIDGET_ZOOMSTATUS_H__ -#define __UI_WIDGET_ZOOMSTATUS_H__ - -/** \file - * Enhanced spinbutton. - * +#ifndef SEEN_UI_WIDGET_ZOOMSTATUS_H +#define SEEN_UI_WIDGET_ZOOMSTATUS_H +/* * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * @@ -13,7 +10,7 @@ */ #include <gtkmm/adjustment.h> -#include <gtkmm/spinbutton.h> +#include "ui/widget/spinbutton.h" struct SPDesktop; @@ -22,7 +19,10 @@ namespace Inkscape { namespace UI { namespace Widget { -class ZoomStatus : public Gtk::SpinButton +/** + * Enhanced spinbutton. + */ +class ZoomStatus : public Inkscape::UI::Widget::SpinButton { public: ZoomStatus(); @@ -46,7 +46,7 @@ protected: } // namespace Inkscape -#endif +#endif // SEEN_UI_WIDGET_ZOOMSTATUS_H /* |
