diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-08-30 15:49:40 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-08-30 15:49:40 +0000 |
| commit | 18770eebe339cdc673812a48c5e05c7cdcb3a82e (patch) | |
| tree | 1e3846a72decad64d24100cdbe0a2e0d42f252b8 /src | |
| parent | Update to experimental r13464 (diff) | |
| parent | Fix paint-selector orientation (diff) | |
| download | inkscape-18770eebe339cdc673812a48c5e05c7cdcb3a82e.tar.gz inkscape-18770eebe339cdc673812a48c5e05c7cdcb3a82e.zip | |
Update to experimental r13527
(bzr r13341.5.15)
Diffstat (limited to 'src')
257 files changed, 4237 insertions, 3895 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d293020e..81b273da8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -299,7 +299,6 @@ set(inkscape_SRC composite-undo-stack-observer.h conditions.h conn-avoid-ref.h - connection-pool.h console-output-undo-observer.h context-fns.h decimal-round.h diff --git a/src/Makefile_insert b/src/Makefile_insert index f1185e96d..4dadcd2d3 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -24,7 +24,6 @@ ink_common_sources += \ composite-undo-stack-observer.h \ conditions.cpp conditions.h \ conn-avoid-ref.cpp conn-avoid-ref.h \ - connection-pool.h \ console-output-undo-observer.h console-output-undo-observer.cpp \ context-fns.cpp context-fns.h \ decimal-round.h \ diff --git a/src/attributes.cpp b/src/attributes.cpp index 2474e4abe..526476322 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -1,9 +1,4 @@ -#define __SP_ATTRIBUTES_C__ - -/** \file - * Lookup dictionary for attributes/properties. - */ -/* +/** * Author: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -25,6 +20,10 @@ typedef struct { gchar const *name; } SPStyleProp; +/** + * Lookup dictionary for attributes/properties. + */ + static SPStyleProp const props[] = { {SP_ATTR_INVALID, NULL}, /* SPObject */ @@ -539,4 +538,4 @@ sp_attribute_name(unsigned int id) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/axis-manip.cpp b/src/axis-manip.cpp index 1dfa0e6bf..1240d99e6 100644 --- a/src/axis-manip.cpp +++ b/src/axis-manip.cpp @@ -1,6 +1,4 @@ -#define __AXIS_MANIP_C__ - -/* +/** * Generic auxiliary routines for 3D axes * * Authors: @@ -44,4 +42,4 @@ get_remaining_axes (Axis axis) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/axis-manip.h b/src/axis-manip.h index 9392e2ddd..7842b4135 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -13,7 +13,7 @@ #define SEEN_AXIS_MANIP_H #include <utility> -#include <gtk/gtk.h> +#include <glib.h> namespace Proj { diff --git a/src/connection-pool.h b/src/connection-pool.h deleted file mode 100644 index 4637a3cc1..000000000 --- a/src/connection-pool.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Author: - * mderezynski <mderezynski@users.sourceforge.net> - * - * Copyright (C) 2006 Author - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef CONNECTION_POOL_H -#define CONNECTION_POOL_H - -#include <glib-object.h> -#include <sigc++/sigc++.h> - -#include <map> -#include <stddef.h> -#include <string> -#include <exception> - -namespace Inkscape { - -/** - * @class ConnectionPool - * an auxilliary class to manage sigc::connections as if the referred object - * were a GObject; in that way, the class that holds a ConnectionPool does not - * need to also hold several sigc::connection objects - */ -class ConnectionPool { -public: - typedef std::map<std::string, sigc::connection*> ConnectionMap; - - struct NameExistsException : public std::exception { - virtual const char* what() const throw() { return "Inkscape::ConnectionPool: name exists"; } - }; - struct NameDoesNotExistException : public std::exception { - virtual const char* what() const throw() { return "Inkscape::ConnectionPool: name doesn't exist"; } - }; - - void add_connection(std::string name, sigc::connection* connection) { - if (_map.find(name) != _map.end()) { - throw NameExistsException(); - } - _map.insert(std::make_pair(name, connection)); - } - - void del_connection(std::string name) { - ConnectionMap::iterator iter = _map.find(name); - if (iter == _map.end()) { - throw NameDoesNotExistException(); - } - sigc::connection* connection = (*iter).second; - connection->disconnect(); - delete connection; - } - - - static Inkscape::ConnectionPool* new_connection_pool(std::string name) { - return new ConnectionPool(name); - } - - static void del_connection_pool(ConnectionPool* pool) { - delete pool; - } - - static void connect_destroy(GObject *obj, ConnectionPool *pool) { - g_object_connect (obj, "swapped-signal::destroy", G_CALLBACK(del_connection_pool), pool, NULL); - } - - operator std::string() { - return _name; - } - -private: - ConnectionPool(std::string name) : _name(name) {} - virtual ~ConnectionPool() { - for (ConnectionMap::iterator iter = _map.begin(), end = _map.end(); iter != end; ++iter) { - sigc::connection* connection = (*iter).second; - connection->disconnect(); - delete connection; - } - } - - ConnectionMap _map; - std::string _name; -}; -} - -#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 : diff --git a/src/debug/log-display-config.cpp b/src/debug/log-display-config.cpp index 07380b3ad..ecc05b7b7 100644 --- a/src/debug/log-display-config.cpp +++ b/src/debug/log-display-config.cpp @@ -10,6 +10,7 @@ */ #include <iostream> +#include <gtk/gtk.h> #include <gdk/gdk.h> #include "debug/event-tracker.h" #include "debug/logger.h" @@ -58,11 +59,16 @@ public: Display() : ConfigurationEvent("display") {} void generateChildEvents() const { GdkDisplay *display=gdk_display_get_default(); +#if GTK_CHECK_VERSION(3,10,0) + GdkScreen *screen = gdk_display_get_screen(display, 0); + Logger::write<Screen>(screen); +#else gint n_screens = gdk_display_get_n_screens(display); for ( gint i = 0 ; i < n_screens ; i++ ) { GdkScreen *screen = gdk_display_get_screen(display, i); Logger::write<Screen>(screen); } +#endif } }; diff --git a/src/desktop-events.h b/src/desktop-events.h index 7123ce91b..dc85e563b 100644 --- a/src/desktop-events.h +++ b/src/desktop-events.h @@ -13,13 +13,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gdk/gdk.h> -#include <gtk/gtk.h> - class SPDesktop; struct SPDesktopWidget; struct SPCanvasItem; +typedef union _GdkEvent GdkEvent; +typedef struct _GdkEventCrossing GdkEventCrossing; +typedef struct _GdkEventMotion GdkEventMotion; +typedef struct _GtkWidget GtkWidget; + /* Item handlers */ int sp_desktop_root_handler (SPCanvasItem *item, GdkEvent *event, SPDesktop *desktop); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index f6347e5c0..91359983b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -14,6 +14,7 @@ #include <string> #include <cstring> +#include <glibmm.h> #include "desktop.h" #include "color-rgba.h" diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 57ec98f81..a49f925c3 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -16,6 +16,8 @@ #include "config.h" #endif +#include <glib.h> + #ifdef HAVE_OPENMP #include <omp.h> #include "preferences.h" @@ -25,7 +27,6 @@ static const int OPENMP_THRESHOLD = 2048; #include <algorithm> #include <cairo.h> -#include <glib.h> #include <math.h> #include "display/nr-3dutils.h" #include "display/cairo-utils.h" diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 505e2ca77..f252c4a44 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -14,7 +14,7 @@ #include <boost/noncopyable.hpp> //#include <glibmm/threads.h> // workaround -#include <glib.h> +//#include <glib.h> #include <cairomm/cairomm.h> //#include <gdkmm/pixbuf.h> #include <2geom/forward.h> diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 25d35fc6b..8738b93e4 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtk.h> +#include <gtkmm.h> #include "display/sp-canvas-util.h" #include "helper/sp-marshal.h" @@ -30,8 +30,6 @@ enum { LAST_SIGNAL }; -static void sp_canvas_arena_class_init(SPCanvasArenaClass *klass); -static void sp_canvas_arena_init(SPCanvasArena *group); static void sp_canvas_arena_destroy(SPCanvasItem *object); static void sp_canvas_arena_item_deleted(SPCanvasArena *arena, Inkscape::DrawingItem *item); @@ -46,7 +44,6 @@ static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); static void sp_canvas_arena_request_update (SPCanvasArena *ca, DrawingItem *item); static void sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect const &area); -static SPCanvasItemClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; struct CachePrefObserver : public Inkscape::Preferences::Observer { @@ -70,33 +67,13 @@ struct CachePrefObserver : public Inkscape::Preferences::Observer { SPCanvasArena *_arena; }; -GType -sp_canvas_arena_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPCanvasArenaClass), - NULL, NULL, - (GClassInitFunc) sp_canvas_arena_class_init, - NULL, NULL, - sizeof (SPCanvasArena), - 0, - (GInstanceInitFunc) sp_canvas_arena_init, - NULL - }; - type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasArena", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCanvasArena, sp_canvas_arena, SP_TYPE_CANVAS_ITEM); static void sp_canvas_arena_class_init (SPCanvasArenaClass *klass) { SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); - signals[ARENA_EVENT] = g_signal_new ("arena_event", G_TYPE_FROM_CLASS(item_class), G_SIGNAL_RUN_LAST, @@ -149,8 +126,8 @@ static void sp_canvas_arena_destroy(SPCanvasItem *object) delete arena->observer; arena->drawing.~Drawing(); - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_canvas_arena_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_canvas_arena_parent_class)->destroy(object); } static void @@ -158,8 +135,8 @@ sp_canvas_arena_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned { SPCanvasArena *arena = SP_CANVAS_ARENA (item); - if (((SPCanvasItemClass *) parent_class)->update) - (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_canvas_arena_parent_class)->update) + SP_CANVAS_ITEM_CLASS(sp_canvas_arena_parent_class)->update(item, affine, flags); arena->ctx.ctm = affine; diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 312a8d655..592c962a6 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -387,6 +387,9 @@ _wr.setUpdating (false); _rcp_gmcol->setRgba32 (empcolor); _rsi->setValue (empspacing); + _rsu_ox->setProgrammatically = false; + _rsu_oy->setProgrammatically = false; + return table; } diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index ee9e14f10..328409e12 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -27,42 +27,18 @@ #include "helper/geom.h" #include "display/sp-canvas.h" -static void sp_canvas_bpath_class_init (SPCanvasBPathClass *klass); -static void sp_canvas_bpath_init (SPCanvasBPath *path); static void sp_canvas_bpath_destroy(SPCanvasItem *object); static void sp_canvas_bpath_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf); static double sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -static SPCanvasItemClass *parent_class; - -GType -sp_canvas_bpath_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPCanvasBPathClass), - NULL, NULL, - (GClassInitFunc) sp_canvas_bpath_class_init, - NULL, NULL, - sizeof (SPCanvasBPath), - 0, - (GInstanceInitFunc) sp_canvas_bpath_init, - NULL - }; - type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasBPath", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCanvasBPath, sp_canvas_bpath, SP_TYPE_CANVAS_ITEM); static void sp_canvas_bpath_class_init(SPCanvasBPathClass *klass) { SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); - item_class->destroy = sp_canvas_bpath_destroy; item_class->update = sp_canvas_bpath_update; item_class->render = sp_canvas_bpath_render; @@ -90,8 +66,8 @@ static void sp_canvas_bpath_destroy(SPCanvasItem *object) cbp->curve = cbp->curve->unref(); } - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_canvas_bpath_parent_class)->destroy) + (* SP_CANVAS_ITEM_CLASS(sp_canvas_bpath_parent_class)->destroy) (object); } static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags) @@ -100,8 +76,8 @@ static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affin item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); - if (reinterpret_cast<SPCanvasItemClass *>(parent_class)->update) { - reinterpret_cast<SPCanvasItemClass *>(parent_class)->update(item, affine, flags); + if (reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update) { + reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update(item, affine, flags); } sp_canvas_item_reset_bounds (item); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 4b1dbd1ed..2eeaa7006 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -71,42 +71,16 @@ static gchar const *const grid_svgname[] = { // ########################################################## // Grid CanvasItem -static void grid_canvasitem_class_init (GridCanvasItemClass *klass); -static void grid_canvasitem_init (GridCanvasItem *grid); static void grid_canvasitem_destroy(SPCanvasItem *object); static void grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass * parent_class; - -GType -grid_canvasitem_get_type (void) -{ - static GType grid_canvasitem_type = 0; - - if (!grid_canvasitem_type) { - GTypeInfo grid_canvasitem_info = { - sizeof (GridCanvasItemClass), - NULL, NULL, - (GClassInitFunc) grid_canvasitem_class_init, - NULL, NULL, - sizeof (GridCanvasItem), - 0, - (GInstanceInitFunc) grid_canvasitem_init, - NULL - }; - - grid_canvasitem_type = g_type_register_static(SPCanvasItem::getType(), "GridCanvasItem", &grid_canvasitem_info, GTypeFlags(0)); - } - return grid_canvasitem_type; -} +G_DEFINE_TYPE(GridCanvasItem, grid_canvasitem, SP_TYPE_CANVAS_ITEM); static void grid_canvasitem_class_init(GridCanvasItemClass *klass) { SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); - item_class->destroy = grid_canvasitem_destroy; item_class->update = grid_canvasitem_update; item_class->render = grid_canvasitem_render; @@ -123,8 +97,8 @@ static void grid_canvasitem_destroy(SPCanvasItem *object) g_return_if_fail (object != NULL); g_return_if_fail (INKSCAPE_IS_GRID_CANVASITEM (object)); - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(grid_canvasitem_parent_class)->destroy) + (* SP_CANVAS_ITEM_CLASS(grid_canvasitem_parent_class)->destroy) (object); } /** @@ -145,8 +119,8 @@ grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned { GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item); - if (parent_class->update) - (* parent_class->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(grid_canvasitem_parent_class)->update) + SP_CANVAS_ITEM_CLASS(grid_canvasitem_parent_class)->update(item, affine, flags); if (gridcanvasitem->grid) { gridcanvasitem->grid->Update(affine, flags); diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index fe60d9c65..88812af0a 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -26,42 +26,17 @@ #include "color.h" #include "display/sp-canvas.h" -static void sp_canvastext_class_init (SPCanvasTextClass *klass); -static void sp_canvastext_init (SPCanvasText *canvastext); static void sp_canvastext_destroy(SPCanvasItem *object); static void sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass *parent_class_ct; - -GType -sp_canvastext_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (SPCanvasTextClass), - NULL, NULL, - (GClassInitFunc) sp_canvastext_class_init, - NULL, NULL, - sizeof (SPCanvasText), - 0, - (GInstanceInitFunc) sp_canvastext_init, - NULL - }; - type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCanvasText", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCanvasText, sp_canvastext, SP_TYPE_CANVAS_ITEM); static void sp_canvastext_class_init(SPCanvasTextClass *klass) { SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class_ct = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); - item_class->destroy = sp_canvastext_destroy; item_class->update = sp_canvastext_update; item_class->render = sp_canvastext_render; @@ -101,8 +76,8 @@ static void sp_canvastext_destroy(SPCanvasItem *object) canvastext->text = NULL; canvastext->item = NULL; - if (SP_CANVAS_ITEM_CLASS(parent_class_ct)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class_ct)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_canvastext_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_canvastext_parent_class)->destroy(object); } static void @@ -151,8 +126,8 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); - if (parent_class_ct->update) - (* parent_class_ct->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_canvastext_parent_class)->update) + SP_CANVAS_ITEM_CLASS(sp_canvastext_parent_class)->update(item, affine, flags); sp_canvas_item_reset_bounds (item); diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 50f4c8954..0a39a8e7f 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -1,10 +1,4 @@ -#define __CURVE_C__ - -/** \file - * Routines for SPCurve and for its Geom::PathVector - */ - -/* +/** * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Johan Engelen @@ -14,7 +8,7 @@ * Copyright (C) 2002 Lauris Kaplinski * Copyright (C) 2008 Johan Engelen * - * Released under GNU GPL + * Released under GNU GPL, see file 'COPYING' for more information */ #include "display/curve.h" @@ -25,6 +19,10 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/point.h> +/** + * Routines for SPCurve and for its Geom::PathVector + */ + /* Constructors */ /** @@ -686,4 +684,4 @@ SPCurve::last_point_additive_move(Geom::Point const & p) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8: diff --git a/src/display/curve.h b/src/display/curve.h index 4866655c4..b3f1e3702 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -1,8 +1,5 @@ -#ifndef SEEN_DISPLAY_CURVE_H -#define SEEN_DISPLAY_CURVE_H - -/* - * Author: +/** + * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * * Copyright (C) 2000 Lauris Kaplinski @@ -10,17 +7,18 @@ * Copyright (C) 2002 Lauris Kaplinski * Copyright (C) 2008 Johan Engelen * - * Released under GNU GPL + * Released under GNU GPL, see file 'COPYING' for more information */ -#include <glib.h> +#ifndef SEEN_DISPLAY_CURVE_H +#define SEEN_DISPLAY_CURVE_H +#include <glib.h> #include <2geom/forward.h> - #include <boost/optional.hpp> /** - * Wrapper around a Geom::PathVector objects. + * Wrapper around a Geom::PathVector object. */ class SPCurve { public: @@ -90,7 +88,7 @@ private: SPCurve& operator=(const SPCurve&); }; -#endif /* !SEEN_DISPLAY_CURVE_H */ +#endif // !SEEN_DISPLAY_CURVE_H /* Local Variables: @@ -101,4 +99,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index 38ace001f..bce89d70e 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -9,13 +9,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/cairo-utils.h" #include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" #include "display/drawing-group.h" #include "style.h" +#include "display/cairo-utils.h" + namespace Inkscape { DrawingGroup::DrawingGroup(Drawing &drawing) diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 00caef525..e56f3e58b 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -10,13 +10,15 @@ */ #include <2geom/bezier-curve.h> -#include "display/cairo-utils.h" + #include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-image.h" #include "preferences.h" #include "style.h" +#include "display/cairo-utils.h" + namespace Inkscape { DrawingImage::DrawingImage(Drawing &drawing) diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 80eb69546..bd6fb41d8 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -10,8 +10,7 @@ */ #include <climits> -#include "display/cairo-utils.h" -#include "display/cairo-templates.h" + #include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-item.h" @@ -21,6 +20,9 @@ #include "preferences.h" #include "style.h" +#include "display/cairo-utils.h" +#include "display/cairo-templates.h" + namespace Inkscape { void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 1a41bdb3a..88506f2b9 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -9,7 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> +#include <glibmm.h> #include <2geom/curves.h> #include <2geom/pathvector.h> #include <2geom/path-sink.h> diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 9f3b447df..97a8c23d3 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -9,8 +9,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/cairo-utils.h" -#include "display/canvas-bpath.h" // for SPWindRule (WTF!) +//#include "display/cairo-utils.h" +//#include "display/canvas-bpath.h" // for SPWindRule (WTF!) #include "display/drawing.h" #include "display/drawing-context.h" #include "display/drawing-surface.h" @@ -20,6 +20,9 @@ #include "style.h" #include "2geom/pathvector.h" +#include "display/cairo-utils.h" +#include "display/canvas-bpath.h" + namespace Inkscape { diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index 2cd0f296d..9147a1bbf 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -15,40 +15,17 @@ #include "gnome-canvas-acetate.h" -static void sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass); -static void sp_canvas_acetate_init (SPCanvasAcetate *acetate); static void sp_canvas_acetate_destroy(SPCanvasItem *object); static void sp_canvas_acetate_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -static SPCanvasItemClass *parent_class; - -GType sp_canvas_acetate_get_type (void) -{ - static GType acetate_type = 0; - if (!acetate_type) { - GTypeInfo acetate_info = { - sizeof (SPCanvasAcetateClass), - NULL, NULL, - (GClassInitFunc) sp_canvas_acetate_class_init, - NULL, NULL, - sizeof (SPCanvasAcetate), - 0, - (GInstanceInitFunc) sp_canvas_acetate_init, - NULL - }; - acetate_type = g_type_register_static(SPCanvasItem::getType(), "SPCanvasAcetate", &acetate_info, GTypeFlags(0)); - } - return acetate_type; -} +G_DEFINE_TYPE(SPCanvasAcetate, sp_canvas_acetate, SP_TYPE_CANVAS_ITEM); static void sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass) { SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); - item_class->destroy = sp_canvas_acetate_destroy; item_class->update = sp_canvas_acetate_update; item_class->point = sp_canvas_acetate_point; @@ -64,8 +41,8 @@ static void sp_canvas_acetate_destroy(SPCanvasItem *object) g_return_if_fail (object != NULL); g_return_if_fail (GNOME_IS_CANVAS_ACETATE (object)); - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_canvas_acetate_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_canvas_acetate_parent_class)->destroy(object); } static void sp_canvas_acetate_update( SPCanvasItem *item, Geom::Affine const &/*affine*/, unsigned int /*flags*/ ) diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 55c1ee495..44bbd14bd 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -29,8 +29,6 @@ using Inkscape::ControlManager; -static void sp_guideline_class_init(SPGuideLineClass *c); -static void sp_guideline_init(SPGuideLine *guideline); static void sp_guideline_destroy(SPCanvasItem *object); static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); @@ -40,34 +38,10 @@ static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba); -static SPCanvasItemClass *parent_class; - -GType sp_guideline_get_type() -{ - static GType guideline_type = 0; - - if (!guideline_type) { - static GTypeInfo const guideline_info = { - sizeof (SPGuideLineClass), - NULL, NULL, - (GClassInitFunc) sp_guideline_class_init, - NULL, NULL, - sizeof (SPGuideLine), - 16, - (GInstanceInitFunc) sp_guideline_init, - NULL, - }; - - guideline_type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPGuideLine", &guideline_info, (GTypeFlags) 0); - } - - return guideline_type; -} +G_DEFINE_TYPE(SPGuideLine, sp_guideline, SP_TYPE_CANVAS_ITEM); static void sp_guideline_class_init(SPGuideLineClass *c) { - parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c)); - SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c); item_class->destroy = sp_guideline_destroy; item_class->update = sp_guideline_update; @@ -108,7 +82,7 @@ static void sp_guideline_destroy(SPCanvasItem *object) g_free(gl->label); } - SP_CANVAS_ITEM_CLASS(parent_class)->destroy(object); + SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class)->destroy(object); } static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) @@ -197,8 +171,8 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, { SPGuideLine *gl = SP_GUIDELINE(item); - if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) { - (SP_CANVAS_ITEM_CLASS(parent_class))->update(item, affine, flags); + if ((SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class))->update) { + (SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class))->update(item, affine, flags); } gl->affine = affine; diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 25aea6f13..d0db6b42e 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -20,6 +20,7 @@ #include "config.h" #endif +#include <glibmm.h> #include "display/cairo-templates.h" #include "display/cairo-utils.h" #include "display/nr-filter-blend.h" diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 214b2cfc5..62f350844 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -11,6 +11,7 @@ #ifndef SEEN_NR_FILTER_PRIMITIVE_H #define SEEN_NR_FILTER_PRIMITIVE_H +#include <glib.h> #include <2geom/forward.h> #include <2geom/rect.h> #include "display/nr-filter-types.h" diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 90b233fbc..dec5b1f57 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -9,7 +9,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-filter-image.h" #include <glib.h> #include <cmath> #include <cstring> @@ -29,6 +28,7 @@ #include "display/nr-filter-component-transfer.h" #include "display/nr-filter-diffuselighting.h" #include "display/nr-filter-displacement-map.h" +#include "display/nr-filter-image.h" #include "display/nr-filter-flood.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-merge.h" diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index 3636319df..327fbce1f 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -25,9 +25,6 @@ enum { ARG_PIXBUF }; - -static void sp_ctrl_class_init (SPCtrlClass *klass); -static void sp_ctrl_init (SPCtrl *ctrl); static void sp_ctrl_destroy(SPCanvasItem *object); static void sp_ctrl_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void sp_ctrl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); @@ -36,29 +33,7 @@ static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf); static double sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -static SPCanvasItemClass *parent_class; - -GType -sp_ctrl_get_type (void) -{ - static GType ctrl_type = 0; - if (!ctrl_type) { - static GTypeInfo const ctrl_info = { - sizeof (SPCtrlClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_ctrl_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPCtrl), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_ctrl_init, - NULL - }; - ctrl_type = g_type_register_static (SP_TYPE_CANVAS_ITEM, "SPCtrl", &ctrl_info, (GTypeFlags)0); - } - return ctrl_type; -} +G_DEFINE_TYPE(SPCtrl, sp_ctrl, SP_TYPE_CANVAS_ITEM); static void sp_ctrl_class_init (SPCtrlClass *klass) @@ -66,8 +41,6 @@ sp_ctrl_class_init (SPCtrlClass *klass) SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); GObjectClass *g_object_class = (GObjectClass *) klass; - parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent (klass)); - g_object_class->set_property = sp_ctrl_set_property; g_object_class->get_property = sp_ctrl_get_property; @@ -239,8 +212,8 @@ static void sp_ctrl_destroy(SPCanvasItem *object) ctrl->cache = NULL; } - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_ctrl_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_ctrl_parent_class)->destroy(object); } static void @@ -251,8 +224,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla ctrl = SP_CTRL (item); - if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) - (* (SP_CANVAS_ITEM_CLASS(parent_class))->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_ctrl_parent_class)->update) + SP_CANVAS_ITEM_CLASS(sp_ctrl_parent_class)->update(item, affine, flags); sp_canvas_item_reset_bounds (item); diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index e6e427047..75789ff50 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -26,45 +26,19 @@ * Corner coords can be in any order - i.e. x1 < x0 is allowed */ -static void sp_ctrlrect_class_init(SPCtrlRectClass *c); -static void sp_ctrlrect_init(CtrlRect *ctrlrect); static void sp_ctrlrect_destroy(SPCanvasItem *object); static void sp_ctrlrect_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass *parent_class; - static const guint DASH_LENGTH = 4; -GType sp_ctrlrect_get_type() -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPCtrlRectClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_ctrlrect_class_init, - 0, // class_finalize - 0, // class_data - sizeof(CtrlRect), - 0, // n_preallocs - (GInstanceInitFunc)sp_ctrlrect_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlRect", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(CtrlRect, sp_ctrlrect, SP_TYPE_CANVAS_ITEM); -static void sp_ctrlrect_class_init(SPCtrlRectClass *c) +static void sp_ctrlrect_class_init(CtrlRectClass *c) { SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c); - parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c)); - item_class->destroy = sp_ctrlrect_destroy; item_class->update = sp_ctrlrect_update; item_class->render = sp_ctrlrect_render; @@ -77,8 +51,8 @@ static void sp_ctrlrect_init(CtrlRect *cr) static void sp_ctrlrect_destroy(SPCanvasItem *object) { - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) { - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy)(object); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlrect_parent_class)->destroy) { + (* SP_CANVAS_ITEM_CLASS(sp_ctrlrect_parent_class)->destroy)(object); } } @@ -171,8 +145,8 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags) using Geom::X; using Geom::Y; - if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) { - (SP_CANVAS_ITEM_CLASS(parent_class))->update(this, affine, flags); + if ((SP_CANVAS_ITEM_CLASS(sp_ctrlrect_parent_class))->update) { + (SP_CANVAS_ITEM_CLASS(sp_ctrlrect_parent_class))->update(this, affine, flags); } sp_canvas_item_reset_bounds(this); diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index 65a40a850..ff6c55b06 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -26,7 +26,7 @@ struct SPCanvasBuf; #define SP_TYPE_CTRLRECT (sp_ctrlrect_get_type ()) #define SP_CTRLRECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CTRLRECT, CtrlRect)) -#define SP_CTRLRECT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), SP_TYPE_CTRLRECT, SPCtrlRectClass)) +#define SP_CTRLRECT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), SP_TYPE_CTRLRECT, CtrlRectClass)) #define SP_IS_CTRLRECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLRECT)) #define SP_IS_CTRLRECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CTRLRECT)) @@ -57,7 +57,7 @@ private: int _shadow; }; -struct SPCtrlRectClass : public SPCanvasItemClass {}; +struct CtrlRectClass : public SPCanvasItemClass {}; GType sp_ctrlrect_get_type(); diff --git a/src/display/sp-canvas-item.h b/src/display/sp-canvas-item.h index f34ec453c..e19db928e 100644 --- a/src/display/sp-canvas-item.h +++ b/src/display/sp-canvas-item.h @@ -24,8 +24,6 @@ #endif #include <glib-object.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> #include <2geom/rect.h> #include "ui/control-types.h" @@ -36,6 +34,8 @@ struct SPCanvasBuf; struct SPCanvasGroup; typedef struct _SPCanvasItemClass SPCanvasItemClass; +typedef union _GdkEvent GdkEvent; +typedef struct _GdkCursor GdkCursor; #define SP_TYPE_CANVAS_ITEM (SPCanvasItem::getType()) #define SP_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem)) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3dc4a7504..8434f6ae2 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1230,7 +1230,7 @@ static void sp_canvas_init(SPCanvas *canvas) { gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); - gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); + //gtk_widget_set_double_buffered (GTK_WIDGET (canvas), TRUE); gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); canvas->pick_event.type = GDK_LEAVE_NOTIFY; diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 72ae4b6bc..adae30f35 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -30,7 +30,6 @@ # endif #endif -#include <glib.h> #include <gdk/gdk.h> #include <gtk/gtk.h> #include <glibmm/ustring.h> diff --git a/src/display/sp-ctrlcurve.cpp b/src/display/sp-ctrlcurve.cpp index d9b687f2e..2e0e8105b 100644 --- a/src/display/sp-ctrlcurve.cpp +++ b/src/display/sp-ctrlcurve.cpp @@ -23,42 +23,18 @@ namespace { -static void sp_ctrlcurve_class_init(SPCtrlCurveClass *klass, gpointer data); -static void sp_ctrlcurve_init(SPCtrlCurve *ctrlcurve, gpointer g_class); static void sp_ctrlcurve_destroy(SPCanvasItem *object); static void sp_ctrlcurve_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_ctrlcurve_render(SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass *parent_class; - } // namespace -GType SPCtrlCurve::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCtrlCurveClass), - NULL, NULL, - reinterpret_cast<GClassInitFunc>(sp_ctrlcurve_class_init), - NULL, NULL, - sizeof(SPCtrlCurve), - 0, - reinterpret_cast<GInstanceInitFunc>(sp_ctrlcurve_init), - NULL - }; - type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlCurve", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPCtrlCurve, sp_ctrlcurve, SP_TYPE_CANVAS_ITEM); -namespace { - -void sp_ctrlcurve_class_init(SPCtrlCurveClass *klass, gpointer /*g_class*/) +static void +sp_ctrlcurve_class_init(SPCtrlCurveClass *klass) { - parent_class = reinterpret_cast<SPCanvasItemClass*>(g_type_class_peek_parent(klass)); - klass->destroy = sp_ctrlcurve_destroy; klass->update = sp_ctrlcurve_update; @@ -66,13 +42,14 @@ void sp_ctrlcurve_class_init(SPCtrlCurveClass *klass, gpointer /*g_class*/) } static void -sp_ctrlcurve_init(SPCtrlCurve *ctrlcurve, gpointer /*g_class*/) +sp_ctrlcurve_init(SPCtrlCurve *ctrlcurve) { // Points are initialized to 0,0 ctrlcurve->rgba = 0x0000ff7f; ctrlcurve->item=NULL; } +namespace { static void sp_ctrlcurve_destroy(SPCanvasItem *object) { @@ -83,8 +60,8 @@ sp_ctrlcurve_destroy(SPCanvasItem *object) ctrlcurve->item=NULL; - if (SP_CANVAS_ITEM_CLASS (parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS (parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlcurve_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_ctrlcurve_parent_class)->destroy(object); } static void @@ -125,8 +102,8 @@ sp_ctrlcurve_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int item->canvas->requestRedraw(item->x1, item->y1, item->x2, item->y2); - if (parent_class->update) - (* parent_class->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlcurve_parent_class)->update) + SP_CANVAS_ITEM_CLASS(sp_ctrlcurve_parent_class)->update(item, affine, flags); sp_canvas_item_reset_bounds (item); diff --git a/src/display/sp-ctrlcurve.h b/src/display/sp-ctrlcurve.h index 90936185c..847944f38 100644 --- a/src/display/sp-ctrlcurve.h +++ b/src/display/sp-ctrlcurve.h @@ -19,14 +19,11 @@ class SPItem; -#define SP_TYPE_CTRLCURVE (SPCtrlCurve::getType()) +#define SP_TYPE_CTRLCURVE (sp_ctrlcurve_get_type()) #define SP_CTRLCURVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLCURVE, SPCtrlCurve)) #define SP_IS_CTRLCURVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLCURVE)) struct SPCtrlCurve : public SPCtrlLine { - - static GType getType(); - void setCoords( gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3 ); @@ -36,9 +33,9 @@ struct SPCtrlCurve : public SPCtrlLine { Geom::Point p0, p1, p2, p3; }; -struct SPCtrlCurveClass : public SPCtrlLineClass{}; - +GType sp_ctrlcurve_get_type(); +struct SPCtrlCurveClass : public SPCtrlLineClass{}; #endif // SEEN_INKSCAPE_CTRLCURVE_H diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index aef284c1a..1bde540c0 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -30,55 +30,31 @@ namespace { -void sp_ctrlline_class_init(SPCtrlLineClass *klass, gpointer data); -void sp_ctrlline_init(SPCtrlLine *ctrlline, gpointer g_class); void sp_ctrlline_destroy(SPCanvasItem *object); void sp_ctrlline_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); void sp_ctrlline_render(SPCanvasItem *item, SPCanvasBuf *buf); -SPCanvasItemClass *parent_class = 0; - } // namespace -GType SPCtrlLine::getType() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCtrlLineClass), - NULL, NULL, - reinterpret_cast<GClassInitFunc>(sp_ctrlline_class_init), - NULL, NULL, - sizeof(SPCtrlLine), - 0, - reinterpret_cast<GInstanceInitFunc>(sp_ctrlline_init), - NULL - }; - type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlLine", &info, static_cast<GTypeFlags>(0)); - } - return type; -} - -namespace { +G_DEFINE_TYPE(SPCtrlLine, sp_ctrlline, SP_TYPE_CANVAS_ITEM); -void sp_ctrlline_class_init(SPCtrlLineClass *klass, gpointer /*data*/) +static void sp_ctrlline_class_init(SPCtrlLineClass *klass) { - parent_class = reinterpret_cast<SPCanvasItemClass*>(g_type_class_peek_parent(klass)); - klass->destroy = sp_ctrlline_destroy; klass->update = sp_ctrlline_update; klass->render = sp_ctrlline_render; } -void sp_ctrlline_init(SPCtrlLine *ctrlline, gpointer /*g_class*/) +static void sp_ctrlline_init(SPCtrlLine *ctrlline) { ctrlline->rgba = 0x0000ff7f; ctrlline->s[Geom::X] = ctrlline->s[Geom::Y] = ctrlline->e[Geom::X] = ctrlline->e[Geom::Y] = 0.0; ctrlline->item=NULL; } +namespace { void sp_ctrlline_destroy(SPCanvasItem *object) { g_return_if_fail(object != NULL); @@ -88,8 +64,8 @@ void sp_ctrlline_destroy(SPCanvasItem *object) ctrlline->item = NULL; - if(SP_CANVAS_ITEM_CLASS (parent_class)->destroy) { - (* SP_CANVAS_ITEM_CLASS (parent_class)->destroy)(object); + if(SP_CANVAS_ITEM_CLASS (sp_ctrlline_parent_class)->destroy) { + SP_CANVAS_ITEM_CLASS (sp_ctrlline_parent_class)->destroy(object); } } @@ -134,8 +110,8 @@ void sp_ctrlline_update(SPCanvasItem *item, Geom::Affine const &affine, unsigned item->canvas->requestRedraw(item->x1, item->y1, item->x2, item->y2); - if (parent_class->update) { - (* parent_class->update)(item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlline_parent_class)->update) { + SP_CANVAS_ITEM_CLASS(sp_ctrlline_parent_class)->update(item, affine, flags); } sp_canvas_item_reset_bounds(item); diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index 12be03ca5..b2e222437 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -20,13 +20,11 @@ class SPItem; -#define SP_TYPE_CTRLLINE (SPCtrlLine::getType()) +#define SP_TYPE_CTRLLINE (sp_ctrlline_get_type()) #define SP_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLLINE, SPCtrlLine)) #define SP_IS_CTRLLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CTRLLINE)) struct SPCtrlLine : public SPCanvasItem { - static GType getType(); - void setRgba32(guint32 rgba); void setCoords(gdouble x0, gdouble y0, gdouble x1, gdouble y1); @@ -41,6 +39,8 @@ struct SPCtrlLine : public SPCanvasItem { Geom::Affine affine; }; +GType sp_ctrlline_get_type(); + struct SPCtrlLineClass : public SPCanvasItemClass{}; diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp index 026cc7589..1082cb1b3 100644 --- a/src/display/sp-ctrlpoint.cpp +++ b/src/display/sp-ctrlpoint.cpp @@ -20,42 +20,17 @@ #include "display/cairo-utils.h" #include "display/sp-canvas.h" - -static void sp_ctrlpoint_class_init (SPCtrlPointClass *klass); -static void sp_ctrlpoint_init (SPCtrlPoint *ctrlpoint); static void sp_ctrlpoint_destroy(SPCanvasItem *object); static void sp_ctrlpoint_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_ctrlpoint_render (SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass *parent_class; - -GType -sp_ctrlpoint_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCtrlPointClass), - NULL, NULL, - (GClassInitFunc) sp_ctrlpoint_class_init, - NULL, NULL, - sizeof(SPCtrlPoint), - 0, - (GInstanceInitFunc) sp_ctrlpoint_init, - NULL - }; - type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlPoint", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCtrlPoint, sp_ctrlpoint, SP_TYPE_CANVAS_ITEM); static void sp_ctrlpoint_class_init(SPCtrlPointClass *klass) { SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); - item_class->destroy = sp_ctrlpoint_destroy; item_class->update = sp_ctrlpoint_update; item_class->render = sp_ctrlpoint_render; @@ -79,8 +54,8 @@ static void sp_ctrlpoint_destroy(SPCanvasItem *object) ctrlpoint->item=NULL; - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlpoint_parent_class)->destroy) + SP_CANVAS_ITEM_CLASS(sp_ctrlpoint_parent_class)->destroy(object); } static void @@ -111,8 +86,8 @@ static void sp_ctrlpoint_update(SPCanvasItem *item, Geom::Affine const &affine, item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); - if (parent_class->update) { - (* parent_class->update) (item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlpoint_parent_class)->update) { + SP_CANVAS_ITEM_CLASS(sp_ctrlpoint_parent_class)->update(item, affine, flags); } sp_canvas_item_reset_bounds (item); diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index b6a0da109..760e93a6d 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -29,42 +29,18 @@ struct SPCtrlQuadr : public SPCanvasItem{ struct SPCtrlQuadrClass : public SPCanvasItemClass{}; -static void sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass); -static void sp_ctrlquadr_init (SPCtrlQuadr *ctrlquadr); static void sp_ctrlquadr_destroy(SPCanvasItem *object); static void sp_ctrlquadr_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static void sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf); -static SPCanvasItemClass *parent_class; - -GType -sp_ctrlquadr_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPCtrlQuadrClass), - NULL, NULL, - (GClassInitFunc) sp_ctrlquadr_class_init, - NULL, NULL, - sizeof(SPCtrlQuadr), - 0, - (GInstanceInitFunc) sp_ctrlquadr_init, - NULL - }; - type = g_type_register_static(SP_TYPE_CANVAS_ITEM, "SPCtrlQuadr", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPCtrlQuadr, sp_ctrlquadr, SP_TYPE_CANVAS_ITEM); static void sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass) { SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass); - parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass)); - item_class->destroy = sp_ctrlquadr_destroy; item_class->update = sp_ctrlquadr_update; item_class->render = sp_ctrlquadr_render; @@ -85,8 +61,8 @@ static void sp_ctrlquadr_destroy(SPCanvasItem *object) g_return_if_fail (object != NULL); g_return_if_fail (SP_IS_CTRLQUADR (object)); - if (SP_CANVAS_ITEM_CLASS(parent_class)->destroy) - (* SP_CANVAS_ITEM_CLASS(parent_class)->destroy) (object); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlquadr_parent_class)->destroy) + (* SP_CANVAS_ITEM_CLASS(sp_ctrlquadr_parent_class)->destroy) (object); } static void @@ -139,8 +115,8 @@ static void sp_ctrlquadr_update(SPCanvasItem *item, Geom::Affine const &affine, item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); - if (parent_class->update) { - (* parent_class->update)(item, affine, flags); + if (SP_CANVAS_ITEM_CLASS(sp_ctrlquadr_parent_class)->update) { + SP_CANVAS_ITEM_CLASS(sp_ctrlquadr_parent_class)->update(item, affine, flags); } sp_canvas_item_reset_bounds (item); diff --git a/src/ege-adjustment-action.h b/src/ege-adjustment-action.h index 590035eb3..8cfaa3e52 100644 --- a/src/ege-adjustment-action.h +++ b/src/ege-adjustment-action.h @@ -45,9 +45,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ -#include <glib.h> #include <gtk/gtk.h> -#include <glib-object.h> G_BEGIN_DECLS diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index eca90ecb7..78ee6b8b5 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -273,8 +273,13 @@ void ege_color_prof_tracker_get_profile_for( guint screenNum, guint monitor, gpo gpointer dataPos = 0; guint dataLen = 0; GdkDisplay* display = gdk_display_get_default(); + +#if GTK_CHECK_VERSION(3,10,0) + GdkScreen* screen = (screenNum < 1) ? gdk_display_get_screen(display, screenNum) : 0; +#else gint numScreens = gdk_display_get_n_screens(display); GdkScreen* screen = (screenNum < (guint)numScreens) ? gdk_display_get_screen(display, screenNum) : 0; +#endif if ( screen ) { GSList* curr = tracked_screens; @@ -494,7 +499,11 @@ GdkFilterReturn x11_win_filter(GdkXEvent *xevent, if ( stat ) { GdkDisplay* display = gdk_x11_lookup_xdisplay(native->xproperty.display); if ( display ) { +#if GTK_CHECK_VERSION(3,10,0) + gint screenCount = 1; +#else gint screenCount = gdk_display_get_n_screens(display); +#endif GdkScreen* targetScreen = 0; gint i = 0; for ( i = 0; i < screenCount; i++ ) { diff --git a/src/ege-output-action.h b/src/ege-output-action.h index fc21c2f27..0f4e21805 100644 --- a/src/ege-output-action.h +++ b/src/ege-output-action.h @@ -45,9 +45,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ -#include <glib.h> #include <gtk/gtk.h> -#include <glib-object.h> G_BEGIN_DECLS diff --git a/src/ege-select-one-action.h b/src/ege-select-one-action.h index d605f4a67..0c5cecaa3 100644 --- a/src/ege-select-one-action.h +++ b/src/ege-select-one-action.h @@ -48,9 +48,7 @@ /* Note: this file should be kept compilable as both .cpp and .c */ -#include <glib.h> #include <gtk/gtk.h> -#include <glib-object.h> G_BEGIN_DECLS diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 976cf42fc..1c13c27f1 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -1,28 +1,18 @@ -/** \file - * Code for handling extensions (i.e.\ scripts). - */ -/* +/** + * Code for handling extensions (i.e. scripts). + * * Authors: * Bryce Harrington <bryce@osdl.org> * Ted Gould <ted@gould.cx> * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma * - * Copyright (C) 2002-2005,2007 Authors + * Copyright (C) 2002-2007 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ -#define __INKSCAPE_EXTENSION_IMPLEMENTATION_SCRIPT_C__ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - +#include <glibmm.h> #include <gtkmm/messagedialog.h> #include <gtkmm/main.h> #include <gtkmm/scrolledwindow.h> @@ -32,44 +22,38 @@ #include <unistd.h> #include <errno.h> -#include <glib.h> #include <glib/gstdio.h> -#include "ui/view/view.h" #include "desktop-handles.h" #include "desktop.h" -#include "selection.h" -#include "sp-namedview.h" -#include "io/sys.h" -#include "preferences.h" -#include "../system.h" +#include "dialogs/dialog-events.h" #include "extension/effect.h" #include "extension/output.h" #include "extension/input.h" #include "extension/db.h" -#include "script.h" -#include "dialogs/dialog-events.h" #include "inkscape.h" +#include "io/sys.h" +#include "preferences.h" +#include "script.h" +#include "selection.h" +#include "sp-namedview.h" +#include "extension/system.h" +#include "ui/view/view.h" #include "xml/node.h" #include "xml/attribute-record.h" #include "util/glib-list-iterators.h" #include "path-prefix.h" - #ifdef WIN32 #include <windows.h> #include <sys/stat.h> #include "registrytool.h" #endif - - /** This is the command buffer that gets allocated from the stack */ #define BUFSIZE (255) - - /* Namespaces */ namespace Inkscape { namespace Extension { @@ -1063,4 +1047,4 @@ int Script::execute (const std::list<std::string> &in_command, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index 270c361af..6a7d0c3b8 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -22,81 +22,30 @@ namespace Inkscape { namespace XML { class Node; -} -} +} // namespace XML - -namespace Inkscape { namespace Extension { namespace Implementation { - /** * Utility class used for loading and launching script extensions */ class Script : public Implementation { - public: - /** - * - */ Script(void); - - /** - * - */ virtual ~Script(); - - - /** - * - */ virtual bool load(Inkscape::Extension::Extension *module); - - /** - * - */ virtual void unload(Inkscape::Extension::Extension *module); - - /** - * - */ virtual bool check(Inkscape::Extension::Extension *module); ImplementationDocumentCache * newDocCache(Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * view); - /** - * - */ - virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, - gchar const *filename); - - /** - * - */ - virtual SPDocument *open(Inkscape::Extension::Input *module, - gchar const *filename); - - /** - * - */ + virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module, gchar const *filename); + virtual SPDocument *open(Inkscape::Extension::Input *module, gchar const *filename); virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); - - /** - * - */ - virtual void save(Inkscape::Extension::Output *module, - SPDocument *doc, - gchar const *filename); - - /** - * - */ - virtual void effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View *doc, - ImplementationDocumentCache * docCache); - + virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename); + virtual void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc, ImplementationDocumentCache * docCache); virtual bool cancelProcessing (void); private: @@ -105,7 +54,7 @@ private: Glib::RefPtr<Glib::MainLoop> _main_loop; /** - * The command that has been dirived from + * The command that has been derived from * the configuration file with appropriate directories */ std::list<std::string> command; @@ -117,13 +66,10 @@ private: */ Glib::ustring helper_extension; - std::string solve_reldir (Inkscape::XML::Node *reprin); - bool check_existence (const std::string &command); - void copy_doc (Inkscape::XML::Node * olddoc, - Inkscape::XML::Node * newdoc); - void checkStderr (const Glib::ustring &filename, - Gtk::MessageType type, - const Glib::ustring &message); + std::string solve_reldir(Inkscape::XML::Node *repr_in); + bool check_existence (std::string const& command); + void copy_doc(Inkscape::XML::Node * olddoc, Inkscape::XML::Node * newdoc); + void checkStderr (Glib::ustring const& filename, Gtk::MessageType type, Glib::ustring const& message); class file_listener { Glib::ustring _string; @@ -140,6 +86,7 @@ private: bool isDead () { return _dead; } + // TODO move these definitions into script.cpp void init (int fd, Glib::RefPtr<Glib::MainLoop> main) { _channel = Glib::IOChannel::create_from_fd(fd); _channel->set_encoding(); @@ -202,11 +149,6 @@ private: std::string resolveInterpreterExecutable(const Glib::ustring &interpNameArg); }; // class Script - - - - - } // namespace Implementation } // namespace Extension } // namespace Inkscape diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index bcea06cb5..85ae9efde 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -20,6 +20,7 @@ #include "xslt.h" #include "../extension.h" #include "../output.h" +#include "extension/input.h" #include "xml/repr.h" #include "io/sys.h" @@ -53,8 +54,7 @@ XSLT::XSLT(void) : { } -Glib::ustring -XSLT::solve_reldir(Inkscape::XML::Node *reprin) { +Glib::ustring XSLT::solve_reldir(Inkscape::XML::Node *reprin) { gchar const *s = reprin->attribute("reldir"); @@ -90,8 +90,7 @@ XSLT::solve_reldir(Inkscape::XML::Node *reprin) { return ""; } -bool -XSLT::check(Inkscape::Extension::Extension *module) +bool XSLT::check(Inkscape::Extension::Extension *module) { if (load(module)) { unload(module); @@ -101,8 +100,7 @@ XSLT::check(Inkscape::Extension::Extension *module) } } -bool -XSLT::load(Inkscape::Extension::Extension *module) +bool XSLT::load(Inkscape::Extension::Extension *module) { if (module->loaded()) { return true; } @@ -130,8 +128,7 @@ XSLT::load(Inkscape::Extension::Extension *module) return true; } -void -XSLT::unload(Inkscape::Extension::Extension *module) +void XSLT::unload(Inkscape::Extension::Extension *module) { if (!module->loaded()) { return; } xsltFreeStylesheet(_stylesheet); @@ -139,8 +136,8 @@ XSLT::unload(Inkscape::Extension::Extension *module) return; } -SPDocument * -XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) +SPDocument * XSLT::open(Inkscape::Extension::Input */*module*/, + gchar const *filename) { xmlDocPtr filein = xmlParseFile(filename); if (filein == NULL) { return NULL; } @@ -184,8 +181,7 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) return doc; } -void -XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const *filename) +void XSLT::save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename) { /* TODO: Should we assume filename to be in utf8 or to be a raw filename? * See JavaFXOutput::save for discussion. */ @@ -214,10 +210,24 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const return; } - const char * params[1]; - params[0] = NULL; + std::list<std::string> params; + module->paramListString(params); + const int max_parameters = params.size() * 2; + const char * xslt_params[max_parameters+1] ; + + int count = 0; + for(std::list<std::string>::iterator t=params.begin(); t != params.end(); ++t) { + std::size_t pos = t->find("="); + std::ostringstream parameter; + std::ostringstream value; + parameter << t->substr(2,pos-2); + value << t->substr(pos+1); + xslt_params[count++] = g_strdup_printf("%s", parameter.str().c_str()); + xslt_params[count++] = g_strdup_printf("'%s'", value.str().c_str()); + } + xslt_params[count] = NULL; - xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, params); + xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, xslt_params); //xmlSaveFile(filename, newdoc); int success = xsltSaveResultToFilename(filename, newdoc, _stylesheet, 0); diff --git a/src/extension/input.h b/src/extension/input.h index b01ffeb86..2a0a177a0 100644 --- a/src/extension/input.h +++ b/src/extension/input.h @@ -14,9 +14,8 @@ #include <exception> #include <glib.h> #include "extension.h" -#include "xml/repr.h" -#include "document.h" -#include <gtk/gtk.h> + +class SPDocument; namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6fbc85c05..0fec68c06 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -202,8 +202,10 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) if ( shape->_marker[i] ) { SPMarker* marker = SP_MARKER (shape->_marker[i]); Geom::Affine tr; - if (marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_AUTO) { tr = sp_shape_marker_get_transform_at_start(pathv.begin()->front()); + } else if (marker->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) { + tr = Geom::Rotate::from_degrees( 180.0 ) * sp_shape_marker_get_transform_at_start(pathv.begin()->front()); } else { tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(pathv.begin()->front().pointAt(0)); } @@ -220,7 +222,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there { Geom::Affine tr; - if (marker->orient_auto) { + if (marker->orient_mode != MARKER_ORIENT_ANGLE) { tr = sp_shape_marker_get_transform_at_start(path_it->front()); } else { tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(path_it->front().pointAt(0)); @@ -237,7 +239,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) * Loop to end_default (so including closing segment), because when a path is closed, * there should be a midpoint marker between last segment and closing straight line segment */ Geom::Affine tr; - if (marker->orient_auto) { + if (marker->orient_mode != MARKER_ORIENT_ANGLE) { tr = sp_shape_marker_get_transform(*curve_it1, *curve_it2); } else { tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(curve_it1->pointAt(1)); @@ -253,7 +255,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) if ( path_it != (pathv.end()-1) && !path_it->empty()) { Geom::Curve const &lastcurve = path_it->back_default(); Geom::Affine tr; - if (marker->orient_auto) { + if (marker->orient_mode != MARKER_ORIENT_ANGLE) { tr = sp_shape_marker_get_transform_at_end(lastcurve); } else { tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1)); @@ -277,7 +279,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) Geom::Curve const &lastcurve = path_last[index]; Geom::Affine tr; - if (marker->orient_auto) { + if (marker->orient_mode != MARKER_ORIENT_ANGLE) { tr = sp_shape_marker_get_transform_at_end(lastcurve); } else { tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(lastcurve.pointAt(1)); diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index ffbfcc5e5..fa5cb70f9 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -139,9 +139,15 @@ CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec) _labelTotalPages->set_use_markup(false); _labelTotalPages->set_selectable(false); vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); +#if WITH_GTKMM_3_0 + this->get_content_area()->set_homogeneous(false); + this->get_content_area()->set_spacing(0); + this->get_content_area()->pack_start(*vbox2); +#else this->get_vbox()->set_homogeneous(false); this->get_vbox()->set_spacing(0); this->get_vbox()->pack_start(*vbox2); +#endif this->set_title(_("Page Selector")); this->set_modal(true); sp_transientize(GTK_WIDGET(this->gobj())); //Make transient diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 084fbcd58..9a5a78a34 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -27,12 +27,12 @@ # include "config.h" #endif -//#include <png.h> //This must precede text_reassemble.h or it blows up in pngconf.h when compiling #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <libuemf/symbol_convert.h> +#include "document.h" #include "sp-root.h" // even though it is included indirectly by wmf-inout.h #include "sp-path.h" #include "print.h" diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index ab51bbd73..0830ae2dd 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -138,9 +138,15 @@ VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec) _labelTotalPages->set_use_markup(false); _labelTotalPages->set_selectable(false); vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); +#if WITH_GTKMM_3_0 + this->get_content_area()->set_homogeneous(false); + this->get_content_area()->set_spacing(0); + this->get_content_area()->pack_start(*vbox2); +#else this->get_vbox()->set_homogeneous(false); this->get_vbox()->set_spacing(0); this->get_vbox()->pack_start(*vbox2); +#endif this->set_title(_("Page Selector")); this->set_modal(true); sp_transientize(GTK_WIDGET(this->gobj())); //Make transient diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 5ccad678a..c03e7efe0 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -33,6 +33,7 @@ #include <stdint.h> #include <libuemf/symbol_convert.h> +#include "document.h" #include "sp-root.h" // even though it is included indirectly by wmf-inout.h #include "sp-path.h" #include "print.h" diff --git a/src/extension/output.h b/src/extension/output.h index c5b1beb45..44a731ca0 100644 --- a/src/extension/output.h +++ b/src/extension/output.h @@ -13,7 +13,6 @@ #ifndef INKSCAPE_EXTENSION_OUTPUT_H__ #define INKSCAPE_EXTENSION_OUTPUT_H__ -#include <gtk/gtk.h> #include "extension.h" class SPDocument; diff --git a/src/file.cpp b/src/file.cpp index 7f1872ca2..4e46a6e16 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -148,14 +148,14 @@ SPDesktop *sp_file_new(const std::string &templ) DocumentUndo::setUndoSensitive(doc, true); } - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) - desktop->setWaitingCursor(); + SPDesktop *olddesktop = SP_ACTIVE_DESKTOP; + if (olddesktop) + olddesktop->setWaitingCursor(); SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. g_return_val_if_fail(dtw != NULL, NULL); sp_create_window(dtw, TRUE); - desktop = static_cast<SPDesktop *>(dtw->view); + SPDesktop* desktop = static_cast<SPDesktop *>(dtw->view); doc->doUnref(); @@ -166,6 +166,8 @@ SPDesktop *sp_file_new(const std::string &templ) Inkscape::Extension::Dbus::dbus_init_desktop_interface(desktop); #endif + if (olddesktop) + olddesktop->clearWaitingCursor(); if (desktop) desktop->clearWaitingCursor(); @@ -1087,9 +1089,9 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) Inkscape::Selection *selection = sp_desktop_selection(desktop); selection->setReprList(pasted_objects); - // invers apply parent transform + // Apply inverse of parent transform Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); + sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work target_document->ensureUpToDate(); @@ -1226,7 +1228,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); + sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); // move to mouse pointer { diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 151480177..9298a1ffc 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -15,6 +15,8 @@ #include <cstring> +#include <glibmm.h> + #include "style.h" #include "document-private.h" #include "desktop-style.h" diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp index 09a1a7614..037c66922 100644 --- a/src/filter-enums.cpp +++ b/src/filter-enums.cpp @@ -9,6 +9,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm.h> #include <glibmm/i18n.h> #include "filter-enums.h" diff --git a/src/filter-enums.h b/src/filter-enums.h index 3ced5ab94..e6d656f8a 100644 --- a/src/filter-enums.h +++ b/src/filter-enums.h @@ -12,6 +12,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm.h> + #include "display/nr-filter-blend.h" #include "display/nr-filter-colormatrix.h" #include "display/nr-filter-component-transfer.h" diff --git a/src/help.cpp b/src/help.cpp index 02a1930f4..643945a69 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -1,6 +1,4 @@ -#define __SP_HELP_C__ - -/* +/** * Help/About window * * Authors: @@ -17,20 +15,19 @@ # include "config.h" #endif -#include "ui/dialog/aboutbox.h" -#include "path-prefix.h" -#include "help.h" -#include "file.h" +#include <glibmm.h> +#include "file.h" +#include "help.h" +#include "path-prefix.h" +#include "ui/dialog/aboutbox.h" -void -sp_help_about (void) +void sp_help_about() { Inkscape::UI::Dialog::AboutBox::show_about(); } -void -sp_help_open_tutorial(GtkMenuItem *, gpointer data) +void sp_help_open_tutorial(GtkMenuItem *, void* data) { gchar const *name = static_cast<gchar const *>(data); gchar *c = g_build_filename(INKSCAPE_TUTORIALSDIR, name, NULL); diff --git a/src/help.h b/src/help.h index 3fce65fef..3f83e3367 100644 --- a/src/help.h +++ b/src/help.h @@ -1,6 +1,4 @@ -#ifndef SEEN_HELP_H -#define SEEN_HELP_H -/* +/** * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * @@ -10,18 +8,18 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> -#include <gtk/gtk.h> +#ifndef SEEN_HELP_H +#define SEEN_HELP_H + +typedef struct _GtkMenuItem GtkMenuItem; /** * Help/About window. */ -void sp_help_about(void); - -void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); - +void sp_help_about(); +void sp_help_open_tutorial(GtkMenuItem * /*unused*/, void* data); -#endif /* !SEEN_HELP_H */ +#endif // !SEEN_HELP_H /* Local Variables: @@ -32,4 +30,4 @@ void sp_help_open_tutorial(GtkMenuItem *menuitem, gpointer data); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/helper/action.h b/src/helper/action.h index 1f2de87b4..4b81ee7f9 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -13,12 +13,8 @@ #define SEEN_INKSCAPE_SP_ACTION_H #include "helper/action-context.h" -#include <sigc++/sigc++.h> +#include <sigc++/signal.h> #include <glibmm/ustring.h> -#include <glib-object.h> - -struct SPAction; -struct SPActionClass; #define SP_TYPE_ACTION (sp_action_get_type()) #define SP_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction)) diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp index 957b7ea5e..3d2b333a2 100644 --- a/src/helper/gnome-utils.cpp +++ b/src/helper/gnome-utils.cpp @@ -1,9 +1,7 @@ -#define __GNOME_UTILS_C__ - -/* +/** * Helpers * - * Author: + * Authors: * Mitsuru Oka * Lauris Kaplinski <lauris@kaplinski.com> * @@ -25,49 +23,48 @@ * Returns a GList containing strings allocated with g_malloc * that have been splitted from @uri-list. */ -GList* -gnome_uri_list_extract_uris (const gchar* uri_list) +GList *gnome_uri_list_extract_uris(const gchar *uri_list) { - const gchar *p, *q; - gchar *retval; - GList *result = NULL; - - g_return_val_if_fail (uri_list != NULL, NULL); - - p = uri_list; - - /* We don't actually try to validate the URI according to RFC - * 2396, or even check for allowed characters - we just ignore - * comments and trim whitespace off the ends. We also - * allow LF delimination as well as the specified CRLF. - */ - while (p) { - if (*p != '#') { - while (isspace(*p)) - p++; - - q = p; - while (*q && (*q != '\n') && (*q != '\r')) - q++; - - if (q > p) { - q--; - while (q > p && isspace(*q)) - q--; - - retval = (gchar*)g_malloc (q - p + 2); - strncpy (retval, p, q - p + 1); - retval[q - p + 1] = '\0'; - - result = g_list_prepend (result, retval); - } - } - p = strchr (p, '\n'); - if (p) - p++; - } - - return g_list_reverse (result); + const gchar *p, *q; + gchar *retval; + GList *result = NULL; + + g_return_val_if_fail(uri_list != NULL, NULL); + + p = uri_list; + + /* We don't actually try to validate the URI according to RFC + * 2396, or even check for allowed characters - we just ignore + * comments and trim whitespace off the ends. We also + * allow LF delimination as well as the specified CRLF. + */ + while (p) { + if (*p != '#') { + while (isspace(*p)) + p++; + + q = p; + while (*q && (*q != '\n') && (*q != '\r')) + q++; + + if (q > p) { + q--; + while (q > p && isspace(*q)) + q--; + + retval = (gchar *)g_malloc(q - p + 2); + strncpy(retval, p, q - p + 1); + retval[q - p + 1] = '\0'; + + result = g_list_prepend(result, retval); + } + } + p = strchr(p, '\n'); + if (p) + p++; + } + + return g_list_reverse(result); } /** @@ -80,29 +77,40 @@ gnome_uri_list_extract_uris (const gchar* uri_list) * Note that unlike gnome_uri_list_extract_uris() function, this * will discard any non-file uri from the result value. */ -GList* -gnome_uri_list_extract_filenames (const gchar* uri_list) +GList *gnome_uri_list_extract_filenames(const gchar *uri_list) { - g_return_val_if_fail (uri_list != NULL, NULL); - - GList *result = gnome_uri_list_extract_uris (uri_list); - - GList *tmp_list = result; - while (tmp_list) { - gchar *s = (gchar*)tmp_list->data; - - GList *node = tmp_list; - tmp_list = tmp_list->next; - - if (!strncmp (s, "file:", 5)) { - node->data = g_filename_from_uri (s, NULL, NULL); - /* not sure if this fallback is useful at all */ - if (!node->data) node->data = g_strdup (s+5); - } else { - result = g_list_remove_link(result, node); - g_list_free_1 (node); - } - g_free (s); - } - return result; + g_return_val_if_fail(uri_list != NULL, NULL); + + GList *result = gnome_uri_list_extract_uris(uri_list); + + GList *tmp_list = result; + while (tmp_list) { + gchar *s = (gchar *)tmp_list->data; + + GList *node = tmp_list; + tmp_list = tmp_list->next; + + if (!strncmp(s, "file:", 5)) { + node->data = g_filename_from_uri(s, NULL, NULL); + /* not sure if this fallback is useful at all */ + if (!node->data) + node->data = g_strdup(s + 5); + } else { + result = g_list_remove_link(result, node); + g_list_free_1(node); + } + g_free(s); + } + return result; } + +/* + 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 : diff --git a/src/helper/gnome-utils.h b/src/helper/gnome-utils.h index 3502b28df..6f2f28223 100644 --- a/src/helper/gnome-utils.h +++ b/src/helper/gnome-utils.h @@ -1,7 +1,7 @@ -/* +/** * GNOME Utils - Migration helper * - * Author: + * Authors: * GNOME Developer * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@ximian.com> @@ -11,17 +11,15 @@ * Released under GNU GPL */ - -#ifndef __GNOME_UTILS_H__ -#define __GNOME_UTILS_H__ +#ifndef SEEN_GNOME_UTILS_H +#define SEEN_GNOME_UTILS_H #include <glib.h> GList *gnome_uri_list_extract_uris(gchar const *uri_list); - GList *gnome_uri_list_extract_filenames(gchar const *uri_list); -#endif /* __GNOME_UTILS_H__ */ +#endif // !SEEN_GNOME_UTILS_H /* Local Variables: @@ -32,4 +30,4 @@ GList *gnome_uri_list_extract_filenames(gchar const *uri_list); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/helper/window.cpp b/src/helper/window.cpp index 98fbef170..98e886a38 100644 --- a/src/helper/window.cpp +++ b/src/helper/window.cpp @@ -1,6 +1,4 @@ -#define __SP_WINDOW_C__ - -/* +/** * Generic window implementation * * Author: @@ -9,61 +7,61 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - +#include <glibmm.h> #include <gtkmm/window.h> +#include "desktop.h" #include "inkscape.h" #include "shortcuts.h" -#include "desktop.h" #include "ui/tools/tool-base.h" #include "window.h" -#include <gtk/gtk.h> static bool on_window_key_press(GdkEventKey* event) { - unsigned int shortcut; - shortcut = Inkscape::UI::Tools::get_group0_keyval (event) | + unsigned shortcut = 0; + // FIXME why? + shortcut = Inkscape::UI::Tools::get_group0_keyval (event) | ( event->state & GDK_SHIFT_MASK ? SP_SHORTCUT_SHIFT_MASK : 0 ) | ( event->state & GDK_CONTROL_MASK ? SP_SHORTCUT_CONTROL_MASK : 0 ) | ( event->state & GDK_MOD1_MASK ? SP_SHORTCUT_ALT_MASK : 0 ); - return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP); + return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP); } -Gtk::Window * -Inkscape::UI::window_new (const gchar *title, unsigned int resizeable) +Gtk::Window * Inkscape::UI::window_new (const gchar *title, unsigned int resizeable) { - Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL); - window->set_title (title); - window->set_resizable (resizeable); - window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press)); + Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL); + window->set_title (title); + window->set_resizable (resizeable); + window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press)); - return window; + return window; } -static gboolean -sp_window_key_press(GtkWidget */*widget*/, GdkEventKey *event) +static gboolean sp_window_key_press(GtkWidget *, GdkEventKey *event) { return on_window_key_press(event); } -GtkWidget * -sp_window_new (const gchar *title, unsigned int resizeable) +GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable) { - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title ((GtkWindow *) window, title); - gtk_window_set_resizable ((GtkWindow *) window, resizeable); - g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL); + GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title ((GtkWindow *) window, title); + gtk_window_set_resizable ((GtkWindow *) window, resizeable); + g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL); - return window; + return window; } +/* + 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 : diff --git a/src/helper/window.h b/src/helper/window.h index c6807f9e5..a0efcd292 100644 --- a/src/helper/window.h +++ b/src/helper/window.h @@ -1,7 +1,7 @@ -#ifndef __SP_WINDOW_H__ -#define __SP_WINDOW_H__ +#ifndef SEEN_SP_WINDOW_H +#define SEEN_SP_WINDOW_H -/* +/** * Generic window implementation * * Author: @@ -17,10 +17,11 @@ namespace Gtk { class Window; } -/* - * This function is deprecated. Use Inkscape::UI::window_new instead. - */ -GtkWidget *sp_window_new (const gchar *title, unsigned int resizeable); +// Can we just get rid of this altogether? +#if defined(GCC_VERSION) || defined(__clang__) +__attribute__((deprecated)) +#endif +GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable); namespace Inkscape { namespace UI { @@ -30,7 +31,7 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable); } } -#endif +#endif // !SEEN_SP_WINDOW_H /* Local Variables: @@ -41,4 +42,4 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/icon-size.h b/src/icon-size.h index 4bb4f1df6..d7a9c9b0b 100644 --- a/src/icon-size.h +++ b/src/icon-size.h @@ -12,8 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> - #include <gtk/gtk.h> namespace Inkscape { diff --git a/src/ink-action.h b/src/ink-action.h index 1d4106681..ac5cb9873 100644 --- a/src/ink-action.h +++ b/src/ink-action.h @@ -2,9 +2,7 @@ #define SEEN_INK_ACTION -#include <glib.h> #include <gtk/gtk.h> -#include <glib-object.h> #include "icon-size.h" #include "attributes.h" diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index ebd238edc..6ae2a8485 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -383,6 +383,17 @@ GtkWidget* create_tool_item( GtkAction* action ) g_signal_connect( G_OBJECT(comboBoxEntry), "changed", G_CALLBACK(combo_box_changed_cb), action ); + // Optionally add separator function... + if( ink_comboboxentry_action->separator_func != NULL ) { + gtk_combo_box_set_row_separator_func( ink_comboboxentry_action->combobox, + GtkTreeViewRowSeparatorFunc (ink_comboboxentry_action->separator_func), + NULL, NULL ); + } + + // FIXME: once gtk3 migration is done this can be removed + // https://bugzilla.gnome.org/show_bug.cgi?id=734915 + gtk_widget_show_all (comboBoxEntry); + // Optionally add formatting... if( ink_comboboxentry_action->cell_data_func != NULL ) { GtkCellRenderer *cell = gtk_cell_renderer_text_new(); @@ -393,13 +404,6 @@ GtkWidget* create_tool_item( GtkAction* action ) NULL, NULL ); } - // Optionally add separator function... - if( ink_comboboxentry_action->separator_func != NULL ) { - gtk_combo_box_set_row_separator_func( ink_comboboxentry_action->combobox, - GtkTreeViewRowSeparatorFunc (ink_comboboxentry_action->separator_func), - NULL, NULL ); - } - // Optionally widen the combobox width... which widens the drop-down list in list mode. if( ink_comboboxentry_action->extra_width > 0 ) { GtkRequisition req; diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index a66f0790e..04b66e8fe 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -19,12 +19,8 @@ #ifndef SEEN_INK_COMBOBOXENTRY_ACTION #define SEEN_INK_COMBOBOXENTRY_ACTION -#include <glib.h> -#include <glib-object.h> - #include <gtk/gtk.h> - #define INK_COMBOBOXENTRY_TYPE_ACTION (ink_comboboxentry_action_get_type()) #define INK_COMBOBOXENTRY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_Action)) #define INK_COMBOBOXENTRY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INK_COMBOBOXENTRY_TYPE_ACTION, Ink_ComboBoxEntry_ActionClass)) diff --git a/src/inkscape-x64.rc b/src/inkscape-x64.rc index ce286c2ca..65a2b08b9 100644 --- a/src/inkscape-x64.rc +++ b/src/inkscape-x64.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkscape-manifest-x64.xml" 1 VERSIONINFO - FILEVERSION 0,48,0,9 - PRODUCTVERSION 0,48,0,9 + FILEVERSION 0,91,0,0 + PRODUCTVERSION 0,91,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkscape" - VALUE "FileVersion", "0.48+devel" + VALUE "FileVersion", "0.91pre2" VALUE "InternalName", "Inkscape" VALUE "LegalCopyright", "© 2014 Inkscape" VALUE "ProductName", "Inkscape" - VALUE "ProductVersion", "0.48+devel" + VALUE "ProductVersion", "0.91pre2" END END BLOCK "VarFileInfo" diff --git a/src/inkscape.rc b/src/inkscape.rc index 395ef39e1..689653f74 100644 --- a/src/inkscape.rc +++ b/src/inkscape.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkscape-manifest.xml" 1 VERSIONINFO - FILEVERSION 0,48,0,9 - PRODUCTVERSION 0,48,0,9 + FILEVERSION 0,91,0,0 + PRODUCTVERSION 0,91,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkscape" - VALUE "FileVersion", "0.48+devel" + VALUE "FileVersion", "0.91pre2" VALUE "InternalName", "Inkscape" VALUE "LegalCopyright", "© 2014 Inkscape" VALUE "ProductName", "Inkscape" - VALUE "ProductVersion", "0.48+devel" + VALUE "ProductVersion", "0.91pre2" END END BLOCK "VarFileInfo" diff --git a/src/inkview-x64.rc b/src/inkview-x64.rc index 2de16060b..f23fe84c9 100644 --- a/src/inkview-x64.rc +++ b/src/inkview-x64.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkview-manifest-x64.xml" 1 VERSIONINFO - FILEVERSION 0,48,0,9 - PRODUCTVERSION 0,48,0,9 + FILEVERSION 0,91,0,0 + PRODUCTVERSION 0,91,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkview" - VALUE "FileVersion", "0.48+devel" + VALUE "FileVersion", "0.91pre2" VALUE "InternalName", "Inkview" VALUE "LegalCopyright", "© 2014 Inkscape" VALUE "ProductName", "Inkview" - VALUE "ProductVersion", "0.48+devel" + VALUE "ProductVersion", "0.91pre2" END END BLOCK "VarFileInfo" diff --git a/src/inkview.rc b/src/inkview.rc index fd7eb50a1..43a63c725 100644 --- a/src/inkview.rc +++ b/src/inkview.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkview-manifest.xml" 1 VERSIONINFO - FILEVERSION 0,48,0,9 - PRODUCTVERSION 0,48,0,9 + FILEVERSION 0,91,0,0 + PRODUCTVERSION 0,91,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkview" - VALUE "FileVersion", "0.48+devel" + VALUE "FileVersion", "0.91pre2" VALUE "InternalName", "Inkview" VALUE "LegalCopyright", "© 2014 Inkscape" VALUE "ProductName", "Inkview" - VALUE "ProductVersion", "0.48+devel" + VALUE "ProductVersion", "0.91pre2" END END BLOCK "VarFileInfo" diff --git a/src/knot.cpp b/src/knot.cpp index 6205af26a..49b4dbb54 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -28,6 +28,7 @@ #include "message-stack.h" #include "message-context.h" #include "ui/tools/tool-base.h" +#include <gtk/gtk.h> using Inkscape::DocumentUndo; diff --git a/src/knot.h b/src/knot.h index b18f89566..b79614bcb 100644 --- a/src/knot.h +++ b/src/knot.h @@ -17,14 +17,12 @@ #include <gdk/gdk.h> #include <2geom/point.h> #include "knot-enums.h" -#include <stddef.h> #include <sigc++/sigc++.h> #include "enums.h" -#include <gtk/gtk.h> -#include "sp-item.h" class SPDesktop; struct SPCanvasItem; +class SPItem; #define SP_KNOT(obj) (dynamic_cast<SPKnot*>(static_cast<SPKnot*>(obj))) #define SP_IS_KNOT(obj) (dynamic_cast<const SPKnot*>(static_cast<const SPKnot*>(obj)) != NULL) diff --git a/src/libavoid/connector.cpp b/src/libavoid/connector.cpp index b8c99a48c..40ded7498 100644 --- a/src/libavoid/connector.cpp +++ b/src/libavoid/connector.cpp @@ -845,7 +845,10 @@ bool ConnRef::generatePath(void) break; } // Check we don't have an apparent infinite connector path. - COLA_ASSERT(pathlen < 200); +//#ifdef PATHDEBUG + db_printf("Path length: %i\n", pathlen); +//#endif + COLA_ASSERT(pathlen < 10000); } std::vector<Point> path(pathlen); diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 6859a4a5c..c5e68e264 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -513,6 +513,82 @@ static bool StyleNameCompareInternal(const StyleNames &style1, const StyleNames return( StyleNameValue( style1.CssName ) < StyleNameValue( style2.CssName ) ); } +static bool ustringPairSort(std::pair<PangoFontFamily*, Glib::ustring> const& first, std::pair<PangoFontFamily*, Glib::ustring> const& second) +{ + // well, this looks weird. + return first.second < second.second; +} + +void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out) +{ + // Gather the family names as listed by Pango + PangoFontFamily** families = NULL; + int numFamilies = 0; + pango_font_map_list_families(fontServer, &families, &numFamilies); + + std::vector<std::pair<PangoFontFamily *, Glib::ustring> > sorted; + + // not size_t + for (int currentFamily = 0; currentFamily < numFamilies; ++currentFamily) { + const char* displayName = pango_font_family_get_name(families[currentFamily]); + + if (displayName == 0 || *displayName == '\0') { + continue; + } + sorted.push_back(std::make_pair(families[currentFamily], displayName)); + } + + std::sort(sorted.begin(), sorted.end(), ustringPairSort); + + for (size_t i = 0; i < sorted.size(); ++i) { + out.push_back(sorted[i].first); + } +} + +GList* font_factory::GetUIStyles(PangoFontFamily * in) +{ + GList* ret = NULL; + // Gather the styles for this family + PangoFontFace** faces = NULL; + int numFaces = 0; + pango_font_family_list_faces(in, &faces, &numFaces); + + for (int currentFace = 0; currentFace < numFaces; currentFace++) { + + // If the face has a name, describe it, and then use the + // description to get the UI family and face strings + const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]); + if (displayName == NULL || *displayName == '\0') { + continue; + } + + PangoFontDescription *faceDescr = pango_font_face_describe(faces[currentFace]); + if (faceDescr) { + Glib::ustring familyUIName = GetUIFamilyString(faceDescr); + Glib::ustring styleUIName = GetUIStyleString(faceDescr); + + // Disable synthesized (faux) font faces except for CSS generic faces + if (pango_font_face_is_synthesized(faces[currentFace]) ) { + if (familyUIName.compare( "sans-serif" ) != 0 && + familyUIName.compare( "serif" ) != 0 && + familyUIName.compare( "monospace" ) != 0 && + familyUIName.compare( "fantasy" ) != 0 && + familyUIName.compare( "cursive" ) != 0 ) { + continue; + } + } + + if (!familyUIName.empty() && !styleUIName.empty()) { + // Add the style information + ret = g_list_append(ret, new StyleNames(styleUIName, displayName)); + } + } + pango_font_description_free(faceDescr); + } + g_free(faces); + return ret; +} + void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) { g_assert(map); diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 513ee4bf7..c48ae831a 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -23,7 +23,7 @@ #include "nr-type-primitives.h" #include "nr-type-pos-def.h" #include "font-style-to-pos.h" -#include "../style.h" +#include "style.h" /* Freetype */ #ifdef USE_PANGO_WIN32 @@ -123,7 +123,13 @@ public: // Gathers all strings needed for UI while storing pango information in // fontInstanceMap and fontStringMap + // don't use this function, it's too slow void GetUIFamiliesAndStyles(FamilyToStylesMap *map); + + // Helpfully inserts all font families into the provided vector + void GetUIFamilies(std::vector<PangoFontFamily *>& out); + // Retrieves style information about a family in a newly allocated GList. + GList* GetUIStyles(PangoFontFamily * in); /// Retrieve a font_instance from a style object, first trying to use the font-specification, the CSS information font_instance* FaceFromStyle(SPStyle const *style); @@ -177,4 +183,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 43c3045b1..6f25ab5f9 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -1,9 +1,9 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif -#include <gtkmm/treemodel.h> #include <gtkmm/liststore.h> +#include <gtkmm/treemodel.h> #include <libnrtype/font-instance.h> #include <libnrtype/TextWrapper.h> @@ -27,410 +27,432 @@ // CSS dictates that font family names are case insensitive. // This should really implement full Unicode case unfolding. -bool familyNamesAreEqual( const Glib::ustring &a, const Glib::ustring &b ) { +bool familyNamesAreEqual(const Glib::ustring &a, const Glib::ustring &b) +{ + return (a.casefold().compare(b.casefold()) == 0); +} - return( a.casefold().compare( b.casefold() ) == 0 ); +static const char* sp_font_family_get_name(PangoFontFamily* family) +{ + const char* name = pango_font_family_get_name(family); + if (strncmp(name, "Sans", 4) == 0 && strlen(name) == 4) + return "sans-serif"; + if (strncmp(name, "Serif", 5) == 0 && strlen(name) == 5) + return "serif"; + if (strncmp(name, "Monospace", 9) == 0 && strlen(name) == 9) + return "monospace"; + return name; } -namespace Inkscape +namespace Inkscape { + +FontLister::FontLister() { - FontLister::FontLister () - { - font_list_store = Gtk::ListStore::create (FontList); - font_list_store->freeze_notify(); - - FamilyToStylesMap familyStyleMap; - font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap); - - // Grab the family names into a list and then sort them - std::list<Glib::ustring> familyList; - for (FamilyToStylesMap::iterator iter = familyStyleMap.begin(); - iter != familyStyleMap.end(); - ++iter) { - familyList.push_back((*iter).first); + font_list_store = Gtk::ListStore::create(FontList); + font_list_store->freeze_notify(); + + /* Create default styles for use when font-family is unknown on system. */ + default_styles = g_list_append(NULL, new StyleNames("Normal")); + default_styles = g_list_append(default_styles, new StyleNames("Italic")); + default_styles = g_list_append(default_styles, new StyleNames("Bold")); + default_styles = g_list_append(default_styles, new StyleNames("Bold Italic")); + + // Get sorted font families from Pango + std::vector<PangoFontFamily *> familyVector; + font_factory::Default()->GetUIFamilies(familyVector); + + // Traverse through the family names and set up the list store + for (size_t i = 0; i < familyVector.size(); ++i) { + const char* displayName = sp_font_family_get_name(familyVector[i]); + + if (displayName == 0 || *displayName == '\0') { + continue; } - familyList.sort(); - // Traverse through the family names and set up the list store (note that - // the styles list that are the map's values are already sorted) - while (!familyList.empty()) { - Glib::ustring familyName = familyList.front(); - familyList.pop_front(); - - if (!familyName.empty()) { - Gtk::TreeModel::iterator treeModelIter = font_list_store->append(); - //(*treeModelIter)[FontList.family] = reinterpret_cast<const char*>(g_strdup(familyName.c_str())); - (*treeModelIter)[FontList.family] = familyName; - - // Now go through the styles - GList *styles = NULL; - std::list<StyleNames> &styleStrings = familyStyleMap[familyName]; - for (std::list<StyleNames>::iterator it=styleStrings.begin(); - it != styleStrings.end(); - ++it) { - // Our own copy - StyleNames *copy = new StyleNames( *it ); - styles = g_list_append(styles, copy); - } - - (*treeModelIter)[FontList.styles] = styles; - (*treeModelIter)[FontList.onSystem] = true; - } + Glib::ustring familyName = displayName; + if (!familyName.empty()) { + Gtk::TreeModel::iterator treeModelIter = font_list_store->append(); + (*treeModelIter)[FontList.family] = familyName; + + // we don't set this now (too slow) but the style will be cached if the user + // ever decides to use this font + (*treeModelIter)[FontList.styles] = NULL; + // store the pango representation for generating the style + (*treeModelIter)[FontList.pango_family] = familyVector[i]; + (*treeModelIter)[FontList.onSystem] = true; } - current_family_row = 0; - current_family = "sans-serif"; - current_style = "Normal"; - current_fontspec = "sans-serif"; // Empty style -> Normal - current_fontspec_system = "Sans"; - - /* Create default styles for use when font-family is unknown on system. */ - default_styles = g_list_append( NULL, new StyleNames( "Normal" ) ); - default_styles = g_list_append( default_styles, new StyleNames( "Italic" ) ); - default_styles = g_list_append( default_styles, new StyleNames( "Bold" ) ); - default_styles = g_list_append( default_styles, new StyleNames( "Bold Italic" ) ); - - font_list_store->thaw_notify(); - - style_list_store = Gtk::ListStore::create (FontStyleList); - - // Initialize style store with defaults - style_list_store->freeze_notify(); - style_list_store->clear(); - for (GList *l=default_styles; l; l = l->next) { - Gtk::TreeModel::iterator treeModelIter = style_list_store->append(); - (*treeModelIter)[FontStyleList.cssStyle] = ((StyleNames*)l->data)->CssName; - (*treeModelIter)[FontStyleList.displayStyle] = ((StyleNames*)l->data)->DisplayName; + } + + current_family_row = 0; + current_family = "sans-serif"; + current_style = "Normal"; + current_fontspec = "sans-serif"; // Empty style -> Normal + current_fontspec_system = "Sans"; + + font_list_store->thaw_notify(); + + style_list_store = Gtk::ListStore::create(FontStyleList); + + // Initialize style store with defaults + style_list_store->freeze_notify(); + style_list_store->clear(); + for (GList *l = default_styles; l; l = l->next) { + Gtk::TreeModel::iterator treeModelIter = style_list_store->append(); + (*treeModelIter)[FontStyleList.cssStyle] = ((StyleNames *)l->data)->CssName; + (*treeModelIter)[FontStyleList.displayStyle] = ((StyleNames *)l->data)->DisplayName; + } + style_list_store->thaw_notify(); +} + +FontLister::~FontLister() +{ + // Delete default_styles + for (GList *l = default_styles; l; l = l->next) { + delete ((StyleNames *)l->data); + } + + // Delete other styles + Gtk::TreeModel::iterator iter = font_list_store->get_iter("0"); + while (iter != font_list_store->children().end()) { + Gtk::TreeModel::Row row = *iter; + GList *styles = row[FontList.styles]; + for (GList *l = styles; l; l = l->next) { + delete ((StyleNames *)l->data); } - style_list_store->thaw_notify(); + ++iter; } +} - FontLister::~FontLister() { +FontLister *FontLister::get_instance() +{ + static Inkscape::FontLister *instance = new Inkscape::FontLister(); + return instance; +} - // Delete default_styles - for (GList *l=default_styles; l; l = l->next) { - delete ((StyleNames*)l->data); +void FontLister::ensureRowStyles(GtkTreeModel* model, GtkTreeIter const* iterator) +{ + Gtk::TreeIter iter(model, iterator); + Gtk::TreeModel::Row row = *iter; + if (!row[FontList.styles]) { + if (row[FontList.pango_family]) { + row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); } + } +} - // Delete other styles - Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); - while( iter != font_list_store->children().end() ) { - Gtk::TreeModel::Row row = *iter; - GList *styles = row[FontList.styles]; - for (GList *l=styles; l; l = l->next) { - delete ((StyleNames*)l->data); +// Example of how to use "foreach_iter" +// bool +// FontLister::print_document_font( const Gtk::TreeModel::iterator &iter ) { +// Gtk::TreeModel::Row row = *iter; +// if( !row[FontList.onSystem] ) { +// std::cout << " Not on system: " << row[FontList.family] << std::endl; +// return false; +// } +// return true; +// } +// font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font )); + +/* Used to insert a font that was not in the document and not on the system into the font list. */ +void FontLister::insert_font_family(Glib::ustring new_family) +{ + GList *styles = default_styles; + + /* In case this is a fallback list, check if first font-family on system. */ + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", new_family); + if (!tokens.empty() && !tokens[0].empty()) { + Gtk::TreeModel::iterator iter2 = font_list_store->get_iter("0"); + while (iter2 != font_list_store->children().end()) { + Gtk::TreeModel::Row row = *iter2; + if (row[FontList.onSystem] && familyNamesAreEqual(tokens[0], row[FontList.family])) { + if (!row[FontList.styles]) { + row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + } + styles = row[FontList.styles]; + break; } - ++iter; + ++iter2; } } - // Example of how to use "foreach_iter" - // bool - // FontLister::print_document_font( const Gtk::TreeModel::iterator &iter ) { - // Gtk::TreeModel::Row row = *iter; - // if( !row[FontList.onSystem] ) { - // std::cout << " Not on system: " << row[FontList.family] << std::endl; - // return false; - // } - // return true; - // } - // font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font )); - - /* Used to insert a font that was not in the document and not on the system into the font list. */ - void - FontLister::insert_font_family( Glib::ustring new_family ) { - - GList *styles = default_styles; - - /* In case this is a fallback list, check if first font-family on system. */ - std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", new_family ); - if( !tokens.empty() && !tokens[0].empty() ) { - - Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" ); - while( iter2 != font_list_store->children().end() ) { - Gtk::TreeModel::Row row = *iter2; - if( row[FontList.onSystem] && familyNamesAreEqual( tokens[0], row[FontList.family] ) ) { - styles = row[FontList.styles]; + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.family] = new_family; + (*treeModelIter)[FontList.styles] = styles; + (*treeModelIter)[FontList.onSystem] = false; +} + +void FontLister::update_font_list(SPDocument *document) +{ + SPObject *r = document->getRoot(); + if (!r) { + return; + } + + font_list_store->freeze_notify(); + + /* Find if current row is in document or system part of list */ + gboolean row_is_system = false; + if (current_family_row > -1) { + Gtk::TreePath path; + path.push_back(current_family_row); + Gtk::TreeModel::iterator iter = font_list_store->get_iter(path); + if (iter) { + row_is_system = (*iter)[FontList.onSystem]; + // std::cout << " In: row: " << current_family_row << " " << (*iter)[FontList.family] << std::endl; + } + } + + /* Clear all old document font-family entries */ + Gtk::TreeModel::iterator iter = font_list_store->get_iter("0"); + while (iter != font_list_store->children().end()) { + Gtk::TreeModel::Row row = *iter; + if (!row[FontList.onSystem]) { + // std::cout << " Not on system: " << row[FontList.family] << std::endl; + iter = font_list_store->erase(iter); + } else { + // std::cout << " First on system: " << row[FontList.family] << std::endl; break; - } - ++iter2; } - } + } + + /* Get "font-family"s used in document. */ + std::list<Glib::ustring> fontfamilies; + update_font_list_recursive(r, &fontfamilies); - Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); - (*treeModelIter)[FontList.family] = reinterpret_cast<const char*>(g_strdup(new_family.c_str())); - (*treeModelIter)[FontList.styles] = styles; - (*treeModelIter)[FontList.onSystem] = false; + fontfamilies.sort(); + fontfamilies.unique(); + fontfamilies.reverse(); + + + /* Insert separator */ + if (!fontfamilies.empty()) { + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.family] = "#"; + (*treeModelIter)[FontList.onSystem] = false; } - void - FontLister::update_font_list( SPDocument* document ) { - - SPObject *r = document->getRoot(); - if( !r ) { - return; - } - - font_list_store->freeze_notify(); - - /* Find if current row is in document or system part of list */ - gboolean row_is_system = false; - if( current_family_row > -1 ) { - Gtk::TreePath path; - path.push_back( current_family_row ); - Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); - if( iter ) { - row_is_system = (*iter)[FontList.onSystem]; - // std::cout << " In: row: " << current_family_row << " " << (*iter)[FontList.family] << std::endl; - } - } - - /* Clear all old document font-family entries */ - Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); - while( iter != font_list_store->children().end() ) { - Gtk::TreeModel::Row row = *iter; - if( !row[FontList.onSystem] ) { - // std::cout << " Not on system: " << row[FontList.family] << std::endl; - iter = font_list_store->erase( iter ); - } else { - // std::cout << " First on system: " << row[FontList.family] << std::endl; - break; - } - } - - /* Get "font-family"s used in document. */ - std::list<Glib::ustring> fontfamilies; - update_font_list_recursive( r, &fontfamilies ); - - fontfamilies.sort(); - fontfamilies.unique(); - fontfamilies.reverse(); - - /* Insert separator */ - if( !fontfamilies.empty() ) { - Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); - (*treeModelIter)[FontList.family] = "#"; - (*treeModelIter)[FontList.onSystem] = false; - } - - /* Insert font-family's in document. */ - std::list<Glib::ustring>::iterator i; - for( i = fontfamilies.begin(); i != fontfamilies.end(); ++i) { - - GList *styles = default_styles; + /* Insert font-family's in document. */ + std::list<Glib::ustring>::iterator i; + for (i = fontfamilies.begin(); i != fontfamilies.end(); ++i) { + + GList *styles = default_styles; /* See if font-family (or first in fallback list) is on system. If so, get styles. */ - std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", *i ); - if( !tokens.empty() && !tokens[0].empty() ) { - - Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" ); - while( iter2 != font_list_store->children().end() ) { - Gtk::TreeModel::Row row = *iter2; - if( row[FontList.onSystem] && familyNamesAreEqual( tokens[0], row[FontList.family] ) ) { - styles = row[FontList.styles]; - break; - } - ++iter2; - } - } - - Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); - (*treeModelIter)[FontList.family] = reinterpret_cast<const char*>(g_strdup((*i).c_str())); - (*treeModelIter)[FontList.styles] = styles; - (*treeModelIter)[FontList.onSystem] = false; - } - - /* Now we do a song and dance to find the correct row as the row corresponding - * to the current_family may have changed. We can't simply search for the - * family name in the list since it can occur twice, once in the document - * font family part and once in the system font family part. Above we determined - * which part it is in. - */ - if( current_family_row > -1 ) { - int start = 0; - if( row_is_system ) start = fontfamilies.size(); - int length = font_list_store->children().size(); - for( int i = 0; i < length; ++i ) { - int row = i + start; - if( row >= length ) row -= length; - Gtk::TreePath path; - path.push_back( row ); - Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); - if( iter ) { - if( familyNamesAreEqual( current_family, (*iter)[FontList.family] ) ) { - current_family_row = row; - break; - } - } - } - } - // std::cout << " Out: row: " << current_family_row << " " << current_family << std::endl; - - font_list_store->thaw_notify(); + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", *i); + if (!tokens.empty() && !tokens[0].empty()) { + + Gtk::TreeModel::iterator iter2 = font_list_store->get_iter("0"); + while (iter2 != font_list_store->children().end()) { + Gtk::TreeModel::Row row = *iter2; + if (row[FontList.onSystem] && familyNamesAreEqual(tokens[0], row[FontList.family])) { + if (!row[FontList.styles]) { + row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + } + styles = row[FontList.styles]; + break; + } + ++iter2; + } + } + + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.family] = reinterpret_cast<const char *>(g_strdup((*i).c_str())); + (*treeModelIter)[FontList.styles] = styles; + (*treeModelIter)[FontList.onSystem] = false; + + } + + /* Now we do a song and dance to find the correct row as the row corresponding + * to the current_family may have changed. We can't simply search for the + * family name in the list since it can occur twice, once in the document + * font family part and once in the system font family part. Above we determined + * which part it is in. + */ + if (current_family_row > -1) { + int start = 0; + if (row_is_system) + start = fontfamilies.size(); + int length = font_list_store->children().size(); + for (int i = 0; i < length; ++i) { + int row = i + start; + if (row >= length) + row -= length; + Gtk::TreePath path; + path.push_back(row); + Gtk::TreeModel::iterator iter = font_list_store->get_iter(path); + if (iter) { + if (familyNamesAreEqual(current_family, (*iter)[FontList.family])) { + current_family_row = row; + break; + } + } + } } + // std::cout << " Out: row: " << current_family_row << " " << current_family << std::endl; - void - FontLister::update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ) { + font_list_store->thaw_notify(); +} - const gchar *font_family = r->style->font_family.value; - if( font_family ) { - l->push_back( Glib::ustring( font_family ) ); - } +void FontLister::update_font_list_recursive(SPObject *r, std::list<Glib::ustring> *l) +{ + const gchar *font_family = r->style->font_family.value; + if (font_family) { + l->push_back(Glib::ustring(font_family)); + } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - update_font_list_recursive( child, l ); - } + for (SPObject *child = r->firstChild(); child; child = child->getNext()) { + update_font_list_recursive(child, l); } +} + +Glib::ustring FontLister::canonize_fontspec(Glib::ustring fontspec) +{ - Glib::ustring - FontLister::canonize_fontspec( Glib::ustring fontspec ) { - - // Pass fontspec to and back from Pango to get a the fontspec in - // canonical form. -inkscape-font-specification relies on the - // Pango constructed fontspec not changing form. If it does, - // this is the place to fix it. - PangoFontDescription *descr = pango_font_description_from_string( fontspec.c_str() ); - gchar* canonized = pango_font_description_to_string ( descr ); - Glib::ustring Canonized = canonized; - g_free( canonized ); - pango_font_description_free( descr ); - - // Pango canonized strings remove space after comma between family names. Put it back. - size_t i = 0; - while( (i = Canonized.find(",", i)) != std::string::npos) { - Canonized.replace(i, 1, ", "); - i += 2; - } - - return Canonized; + // Pass fontspec to and back from Pango to get a the fontspec in + // canonical form. -inkscape-font-specification relies on the + // Pango constructed fontspec not changing form. If it does, + // this is the place to fix it. + PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); + gchar *canonized = pango_font_description_to_string(descr); + Glib::ustring Canonized = canonized; + g_free(canonized); + pango_font_description_free(descr); + + // Pango canonized strings remove space after comma between family names. Put it back. + size_t i = 0; + while ((i = Canonized.find(",", i)) != std::string::npos) { + Canonized.replace(i, 1, ", "); + i += 2; } - Glib::ustring - FontLister::system_fontspec( Glib::ustring fontspec ) { + return Canonized; +} + +Glib::ustring FontLister::system_fontspec(Glib::ustring fontspec) +{ - // Find what Pango thinks is the closest match. - Glib::ustring out = fontspec; + // Find what Pango thinks is the closest match. + Glib::ustring out = fontspec; - PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); - font_instance *res = (font_factory::Default())->Face(descr); - if (res->pFont) { + PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); + font_instance *res = (font_factory::Default())->Face(descr); + if (res->pFont) { PangoFontDescription *nFaceDesc = pango_font_describe(res->pFont); out = sp_font_description_get_family(nFaceDesc); - } - pango_font_description_free(descr); - - return out; } + pango_font_description_free(descr); + + return out; +} - std::pair<Glib::ustring, Glib::ustring> - FontLister::ui_from_fontspec( Glib::ustring fontspec ) { - - PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); - const gchar* family = pango_font_description_get_family(descr); - if(!family) - family = "sans-serif"; - Glib::ustring Family = family; - - // PANGO BUG... - // A font spec of Delicious, 500 Italic should result in a family of 'Delicious' - // and a style of 'Medium Italic'. It results instead with: a family of - // 'Delicious, 500' with a style of 'Medium Italic'. We chop of any weight numbers - // at the end of the family: match ",[1-9]00^". - Glib::RefPtr<Glib::Regex> weight = Glib::Regex::create(",[1-9]00$"); - Family = weight->replace( Family, 0, "", Glib::REGEX_MATCH_PARTIAL ); - - // Pango canonized strings remove space after comma between family names. Put it back. - size_t i = 0; - while( (i = Family.find(",", i)) != std::string::npos) { - Family.replace(i, 1, ", "); - i += 2; - } - - pango_font_description_unset_fields(descr, PANGO_FONT_MASK_FAMILY); - gchar* style = pango_font_description_to_string( descr ); - Glib::ustring Style = style; - pango_font_description_free(descr); - g_free( style ); - - return std::make_pair( Family, Style ); +std::pair<Glib::ustring, Glib::ustring> FontLister::ui_from_fontspec(Glib::ustring fontspec) +{ + PangoFontDescription *descr = pango_font_description_from_string(fontspec.c_str()); + const gchar *family = pango_font_description_get_family(descr); + if (!family) + family = "sans-serif"; + Glib::ustring Family = family; + + // PANGO BUG... + // A font spec of Delicious, 500 Italic should result in a family of 'Delicious' + // and a style of 'Medium Italic'. It results instead with: a family of + // 'Delicious, 500' with a style of 'Medium Italic'. We chop of any weight numbers + // at the end of the family: match ",[1-9]00^". + Glib::RefPtr<Glib::Regex> weight = Glib::Regex::create(",[1-9]00$"); + Family = weight->replace(Family, 0, "", Glib::REGEX_MATCH_PARTIAL); + + // Pango canonized strings remove space after comma between family names. Put it back. + size_t i = 0; + while ((i = Family.find(",", i)) != std::string::npos) { + Family.replace(i, 1, ", "); + i += 2; } - std::pair<Glib::ustring, Glib::ustring> - FontLister::selection_update () { + pango_font_description_unset_fields(descr, PANGO_FONT_MASK_FAMILY); + gchar *style = pango_font_description_to_string(descr); + Glib::ustring Style = style; + pango_font_description_free(descr); + g_free(style); + + return std::make_pair(Family, Style); +} + +std::pair<Glib::ustring, Glib::ustring> FontLister::selection_update() +{ #ifdef DEBUG_FONT - std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cout << "FontLister::selection_update: entrance" << std::endl; + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister::selection_update: entrance" << std::endl; #endif - // Get fontspec from a selection, preferences, or thin air. - Glib::ustring fontspec; - SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); - - // Directly from stored font specification. - int result = - sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); - - //std::cout << " Attempting selected style" << std::endl; - if( result != QUERY_STYLE_NOTHING && query->font_specification.set ) { - fontspec = query->font_specification.value; - //std::cout << " fontspec from query :" << fontspec << ":" << std::endl; - } - - // From style - if( fontspec.empty() ) { + // Get fontspec from a selection, preferences, or thin air. + Glib::ustring fontspec; + SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT); + + // Directly from stored font specification. + int result = + sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION); + + //std::cout << " Attempting selected style" << std::endl; + if (result != QUERY_STYLE_NOTHING && query->font_specification.set) { + fontspec = query->font_specification.value; + //std::cout << " fontspec from query :" << fontspec << ":" << std::endl; + } + + // From style + if (fontspec.empty()) { //std::cout << " Attempting desktop style" << std::endl; - int rfamily = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); - int rstyle = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); - - // Must have text in selection - if( rfamily != QUERY_STYLE_NOTHING && rstyle != QUERY_STYLE_NOTHING ) { - fontspec = fontspec_from_style( query ); - } - //std::cout << " fontspec from style :" << fontspec << ":" << std::endl; - } - - // From preferences - if( fontspec.empty() ) { + int rfamily = sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY); + int rstyle = sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE); + + // Must have text in selection + if (rfamily != QUERY_STYLE_NOTHING && rstyle != QUERY_STYLE_NOTHING) { + fontspec = fontspec_from_style(query); + } + //std::cout << " fontspec from style :" << fontspec << ":" << std::endl; + } + + // From preferences + if (fontspec.empty()) { //std::cout << " Attempting preferences" << std::endl; sp_style_read_from_prefs(query, "/tools/text"); - fontspec = fontspec_from_style( query ); - //std::cout << " fontspec from prefs :" << fontspec << ":" << std::endl; - } - sp_style_unref(query); + fontspec = fontspec_from_style(query); + //std::cout << " fontspec from prefs :" << fontspec << ":" << std::endl; + } + sp_style_unref(query); - // From thin air - if( fontspec.empty() ) { + // From thin air + if (fontspec.empty()) { //std::cout << " Attempting thin air" << std::endl; - fontspec = current_family + ", " + current_style; - //std::cout << " fontspec from thin air :" << fontspec << ":" << std::endl; - } - - // Do we really need? Removes spaces between font-families. - //current_fontspec = canonize_fontspec( fontspec ); - current_fontspec = fontspec; // Ignore for now + fontspec = current_family + ", " + current_style; + //std::cout << " fontspec from thin air :" << fontspec << ":" << std::endl; + } + + // Do we really need? Removes spaces between font-families. + //current_fontspec = canonize_fontspec( fontspec ); + current_fontspec = fontspec; // Ignore for now - current_fontspec_system = system_fontspec( current_fontspec ); + current_fontspec_system = system_fontspec(current_fontspec); - std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec( current_fontspec ); - set_font_family( ui.first ); - set_font_style( ui.second ); + std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec(current_fontspec); + set_font_family(ui.first); + set_font_style(ui.second); #ifdef DEBUG_FONT - std::cout << " family_row: :" << current_family_row << ":" << std::endl; - std::cout << " canonized: :" << current_fontspec << ":" << std::endl; - std::cout << " system: :" << current_fontspec_system << ":" << std::endl; - std::cout << " family: :" << current_family << ":" << std::endl; - std::cout << " style: :" << current_style << ":" << std::endl; - std::cout << "FontLister::selection_update: exit" << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << " family_row: :" << current_family_row << ":" << std::endl; + std::cout << " canonized: :" << current_fontspec << ":" << std::endl; + std::cout << " system: :" << current_fontspec_system << ":" << std::endl; + std::cout << " family: :" << current_family << ":" << std::endl; + std::cout << " style: :" << current_style << ":" << std::endl; + std::cout << "FontLister::selection_update: exit" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - return std::make_pair( current_family, current_style ); - } - + return std::make_pair(current_family, current_style); +} + // Set fontspec. If check is false, best style match will not be done. -void FontLister::set_fontspec(Glib::ustring new_fontspec, gboolean /*check*/) +void FontLister::set_fontspec(Glib::ustring new_fontspec, bool /*check*/) { - std::pair<Glib::ustring,Glib::ustring> ui = ui_from_fontspec( new_fontspec ); + std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec(new_fontspec); Glib::ustring new_family = ui.first; Glib::ustring new_style = ui.second; @@ -439,13 +461,13 @@ void FontLister::set_fontspec(Glib::ustring new_fontspec, gboolean /*check*/) << " style:" << new_style << std::endl; #endif - set_font_family( new_family, false ); - set_font_style( new_style ); + set_font_family(new_family, false); + set_font_style(new_style); } // TODO: use to determine font-selector best style -std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family (Glib::ustring new_family, gboolean /*check_style*/ ) +std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family(Glib::ustring new_family, bool /*check_style*/) { #ifdef DEBUG_FONT std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; @@ -453,12 +475,12 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family (Glib::ustri #endif // No need to do anything if new family is same as old family. - if ( familyNamesAreEqual( new_family, current_family ) ) { + if (familyNamesAreEqual(new_family, current_family)) { #ifdef DEBUG_FONT - std::cout << "FontLister::new_font_family: exit: no change in family." << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << "FontLister::new_font_family: exit: no change in family." << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - return std::make_pair( current_family, current_style ); + return std::make_pair(current_family, current_style); } // We need to do two things: @@ -466,596 +488,597 @@ std::pair<Glib::ustring, Glib::ustring> FontLister::new_font_family (Glib::ustri // 2. Select best valid style match to old style. // For finding style list, use list of first family in font-family list. - GList* styles = NULL; - Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); - while( iter != font_list_store->children().end() ) { + GList *styles = NULL; + Gtk::TreeModel::iterator iter = font_list_store->get_iter("0"); + while (iter != font_list_store->children().end()) { - Gtk::TreeModel::Row row = *iter; + Gtk::TreeModel::Row row = *iter; - if( familyNamesAreEqual( new_family, row[FontList.family] ) ) { + if (familyNamesAreEqual(new_family, row[FontList.family])) { + if (!row[FontList.styles]) { + row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + } styles = row[FontList.styles]; break; - } - ++iter; + } + ++iter; } // Newly typed in font-family may not yet be in list... use default list. // TODO: if font-family is list, check if first family in list is on system // and set style accordingly. - if( styles == NULL ) { - styles = default_styles; + if (styles == NULL) { + styles = default_styles; } - + // Update style list. style_list_store->freeze_notify(); style_list_store->clear(); - for (GList *l=styles; l; l = l->next) { - Gtk::TreeModel::iterator treeModelIter = style_list_store->append(); - (*treeModelIter)[FontStyleList.cssStyle] = ((StyleNames*)l->data)->CssName; - (*treeModelIter)[FontStyleList.displayStyle] = ((StyleNames*)l->data)->DisplayName; + for (GList *l = styles; l; l = l->next) { + Gtk::TreeModel::iterator treeModelIter = style_list_store->append(); + (*treeModelIter)[FontStyleList.cssStyle] = ((StyleNames *)l->data)->CssName; + (*treeModelIter)[FontStyleList.displayStyle] = ((StyleNames *)l->data)->DisplayName; } style_list_store->thaw_notify(); - + // Find best match to the style from the old font-family to the // styles available with the new font. // TODO: Maybe check if an exact match exists before using Pango. - Glib::ustring best_style = get_best_style_match( new_family, current_style ); + Glib::ustring best_style = get_best_style_match(new_family, current_style); #ifdef DEBUG_FONT std::cout << "FontLister::new_font_family: exit: " << new_family << " " << best_style << std::endl; std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - return std::make_pair( new_family, best_style ); + return std::make_pair(new_family, best_style); } - - std::pair<Glib::ustring, Glib::ustring> - FontLister::set_font_family (Glib::ustring new_family, gboolean check_style) { + +std::pair<Glib::ustring, Glib::ustring> FontLister::set_font_family(Glib::ustring new_family, bool check_style) +{ #ifdef DEBUG_FONT - std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cout << "FontLister::set_font_family: " << new_family << std::endl; + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister::set_font_family: " << new_family << std::endl; #endif - std::pair<Glib::ustring, Glib::ustring> ui = new_font_family( new_family, check_style ); - current_family = ui.first; - current_style = ui.second; - current_fontspec = canonize_fontspec( current_family + ", " + current_style ); - current_fontspec_system = system_fontspec( current_fontspec ); + std::pair<Glib::ustring, Glib::ustring> ui = new_font_family(new_family, check_style); + current_family = ui.first; + current_style = ui.second; + current_fontspec = canonize_fontspec(current_family + ", " + current_style); + current_fontspec_system = system_fontspec(current_fontspec); #ifdef DEBUG_FONT - std::cout << " family_row: :" << current_family_row << ":" << std::endl; - std::cout << " canonized: :" << current_fontspec << ":" << std::endl; - std::cout << " system: :" << current_fontspec_system << ":" << std::endl; - std::cout << " family: :" << current_family << ":" << std::endl; - std::cout << " style: :" << current_style << ":" << std::endl; - std::cout << "FontLister::set_font_family: end" << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << " family_row: :" << current_family_row << ":" << std::endl; + std::cout << " canonized: :" << current_fontspec << ":" << std::endl; + std::cout << " system: :" << current_fontspec_system << ":" << std::endl; + std::cout << " family: :" << current_family << ":" << std::endl; + std::cout << " style: :" << current_style << ":" << std::endl; + std::cout << "FontLister::set_font_family: end" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - return ui; - } - + return ui; +} - std::pair<Glib::ustring, Glib::ustring> - FontLister::set_font_family (int row, gboolean check_style) { + +std::pair<Glib::ustring, Glib::ustring> FontLister::set_font_family(int row, bool check_style) +{ #ifdef DEBUG_FONT - std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cout << "FontLister::set_font_family( row ): " << row << std::endl; + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister::set_font_family( row ): " << row << std::endl; #endif - current_family_row = row; - Gtk::TreePath path; - path.push_back( row ); - Glib::ustring new_family = current_family; - Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); - if( iter ) { - new_family = (*iter)[FontList.family]; - } + current_family_row = row; + Gtk::TreePath path; + path.push_back(row); + Glib::ustring new_family = current_family; + Gtk::TreeModel::iterator iter = font_list_store->get_iter(path); + if (iter) { + new_family = (*iter)[FontList.family]; + } - std::pair<Glib::ustring, Glib::ustring> ui = set_font_family( new_family, check_style ); + std::pair<Glib::ustring, Glib::ustring> ui = set_font_family(new_family, check_style); #ifdef DEBUG_FONT - std::cout << "FontLister::set_font_family( row ): end" << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << "FontLister::set_font_family( row ): end" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - return ui; - } + return ui; +} - void - FontLister::set_font_style (Glib::ustring new_style) { +void FontLister::set_font_style(Glib::ustring new_style) +{ - // TODO: Validate input using Pango. If Pango doesn't recognize a style it will - // attach the "invalid" style to the font-family. +// TODO: Validate input using Pango. If Pango doesn't recognize a style it will +// attach the "invalid" style to the font-family. #ifdef DEBUG_FONT - std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cout << "FontLister:set_font_style: " << new_style << std::endl; + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister:set_font_style: " << new_style << std::endl; #endif - current_style = new_style; - current_fontspec = canonize_fontspec( current_family + ", " + current_style ); - current_fontspec_system = system_fontspec( current_fontspec ); + current_style = new_style; + current_fontspec = canonize_fontspec(current_family + ", " + current_style); + current_fontspec_system = system_fontspec(current_fontspec); #ifdef DEBUG_FONT - std::cout << " canonized: :" << current_fontspec << ":" << std::endl; - std::cout << " system: :" << current_fontspec_system << ":" << std::endl; - std::cout << " family: " << current_family << std::endl; - std::cout << " style: " << current_style << std::endl; - std::cout << "FontLister::set_font_style: end" << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << " canonized: :" << current_fontspec << ":" << std::endl; + std::cout << " system: :" << current_fontspec_system << ":" << std::endl; + std::cout << " family: " << current_family << std::endl; + std::cout << " style: " << current_style << std::endl; + std::cout << "FontLister::set_font_style: end" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif +} + + +// We do this ourselves as we can't rely on FontFactory. +void FontLister::fill_css(SPCSSAttr *css, Glib::ustring fontspec) +{ + + if (fontspec.empty()) { + fontspec = current_fontspec; + } + std::pair<Glib::ustring, Glib::ustring> ui = ui_from_fontspec(fontspec); + + Glib::ustring family = ui.first; + + + // Font spec is single quoted... for the moment + Glib::ustring fontspec_quoted(fontspec); + css_quote(fontspec_quoted); + sp_repr_css_set_property(css, "-inkscape-font-specification", fontspec_quoted.c_str()); + + // Font families needs to be properly quoted in CSS (used unquoted in font-lister) + css_font_family_quote(family); + sp_repr_css_set_property(css, "font-family", family.c_str()); + + PangoFontDescription *desc = pango_font_description_from_string(fontspec.c_str()); + PangoWeight weight = pango_font_description_get_weight(desc); + switch (weight) { + case PANGO_WEIGHT_THIN: + sp_repr_css_set_property(css, "font-weight", "100"); + break; + case PANGO_WEIGHT_ULTRALIGHT: + sp_repr_css_set_property(css, "font-weight", "200"); + break; + case PANGO_WEIGHT_LIGHT: + sp_repr_css_set_property(css, "font-weight", "300"); + break; + case PANGO_WEIGHT_BOOK: + sp_repr_css_set_property(css, "font-weight", "380"); + break; + case PANGO_WEIGHT_NORMAL: + sp_repr_css_set_property(css, "font-weight", "normal"); + break; + case PANGO_WEIGHT_MEDIUM: + sp_repr_css_set_property(css, "font-weight", "500"); + break; + case PANGO_WEIGHT_SEMIBOLD: + sp_repr_css_set_property(css, "font-weight", "600"); + break; + case PANGO_WEIGHT_BOLD: + sp_repr_css_set_property(css, "font-weight", "bold"); + break; + case PANGO_WEIGHT_ULTRABOLD: + sp_repr_css_set_property(css, "font-weight", "800"); + break; + case PANGO_WEIGHT_HEAVY: + sp_repr_css_set_property(css, "font-weight", "900"); + break; + case PANGO_WEIGHT_ULTRAHEAVY: + sp_repr_css_set_property(css, "font-weight", "1000"); + break; + } + + PangoStyle style = pango_font_description_get_style(desc); + switch (style) { + case PANGO_STYLE_NORMAL: + sp_repr_css_set_property(css, "font-style", "normal"); + break; + case PANGO_STYLE_OBLIQUE: + sp_repr_css_set_property(css, "font-style", "oblique"); + break; + case PANGO_STYLE_ITALIC: + sp_repr_css_set_property(css, "font-style", "italic"); + break; } + PangoStretch stretch = pango_font_description_get_stretch(desc); + switch (stretch) { + case PANGO_STRETCH_ULTRA_CONDENSED: + sp_repr_css_set_property(css, "font-stretch", "ultra-condensed"); + break; + case PANGO_STRETCH_EXTRA_CONDENSED: + sp_repr_css_set_property(css, "font-stretch", "extra-condensed"); + break; + case PANGO_STRETCH_CONDENSED: + sp_repr_css_set_property(css, "font-stretch", "condensed"); + break; + case PANGO_STRETCH_SEMI_CONDENSED: + sp_repr_css_set_property(css, "font-stretch", "semi-condensed"); + break; + case PANGO_STRETCH_NORMAL: + sp_repr_css_set_property(css, "font-stretch", "normal"); + break; + case PANGO_STRETCH_SEMI_EXPANDED: + sp_repr_css_set_property(css, "font-stretch", "semi-expanded"); + break; + case PANGO_STRETCH_EXPANDED: + sp_repr_css_set_property(css, "font-stretch", "expanded"); + break; + case PANGO_STRETCH_EXTRA_EXPANDED: + sp_repr_css_set_property(css, "font-stretch", "extra-expanded"); + break; + case PANGO_STRETCH_ULTRA_EXPANDED: + sp_repr_css_set_property(css, "font-stretch", "ultra-expanded"); + break; + } - // We do this ourselves as we can't rely on FontFactory. - void - FontLister::fill_css( SPCSSAttr *css, Glib::ustring fontspec ) { - - if( fontspec.empty() ) { - fontspec = current_fontspec; - } - std::pair<Glib::ustring,Glib::ustring> ui = ui_from_fontspec( fontspec ); - - Glib::ustring family = ui.first; - - - // Font spec is single quoted... for the moment - Glib::ustring fontspec_quoted( fontspec ); - css_quote( fontspec_quoted ); - sp_repr_css_set_property (css, "-inkscape-font-specification", fontspec_quoted.c_str() ); - - // Font families needs to be properly quoted in CSS (used unquoted in font-lister) - css_font_family_quote( family ); - sp_repr_css_set_property (css, "font-family", family.c_str() ); - - PangoFontDescription *desc = pango_font_description_from_string( fontspec.c_str() ); - PangoWeight weight = pango_font_description_get_weight( desc ); - switch ( weight ) { - case PANGO_WEIGHT_THIN: - sp_repr_css_set_property (css, "font-weight", "100" ); - break; - case PANGO_WEIGHT_ULTRALIGHT: - sp_repr_css_set_property (css, "font-weight", "200" ); - break; - case PANGO_WEIGHT_LIGHT: - sp_repr_css_set_property (css, "font-weight", "300" ); - break; - case PANGO_WEIGHT_BOOK: - sp_repr_css_set_property (css, "font-weight", "380" ); - break; - case PANGO_WEIGHT_NORMAL: - sp_repr_css_set_property (css, "font-weight", "normal" ); - break; - case PANGO_WEIGHT_MEDIUM: - sp_repr_css_set_property (css, "font-weight", "500" ); - break; - case PANGO_WEIGHT_SEMIBOLD: - sp_repr_css_set_property (css, "font-weight", "600" ); - break; - case PANGO_WEIGHT_BOLD: - sp_repr_css_set_property (css, "font-weight", "bold" ); - break; - case PANGO_WEIGHT_ULTRABOLD: - sp_repr_css_set_property (css, "font-weight", "800" ); - break; - case PANGO_WEIGHT_HEAVY: - sp_repr_css_set_property (css, "font-weight", "900" ); - break; - case PANGO_WEIGHT_ULTRAHEAVY: - sp_repr_css_set_property (css, "font-weight", "1000" ); - break; - } - - PangoStyle style = pango_font_description_get_style( desc ); - switch ( style ) { - case PANGO_STYLE_NORMAL: - sp_repr_css_set_property (css, "font-style", "normal" ); - break; - case PANGO_STYLE_OBLIQUE: - sp_repr_css_set_property (css, "font-style", "oblique" ); - break; - case PANGO_STYLE_ITALIC: - sp_repr_css_set_property (css, "font-style", "italic" ); - break; - } - - PangoStretch stretch = pango_font_description_get_stretch( desc ); - switch ( stretch ) { - case PANGO_STRETCH_ULTRA_CONDENSED: - sp_repr_css_set_property (css, "font-stretch", "ultra-condensed" ); - break; - case PANGO_STRETCH_EXTRA_CONDENSED: - sp_repr_css_set_property (css, "font-stretch", "extra-condensed" ); - break; - case PANGO_STRETCH_CONDENSED: - sp_repr_css_set_property (css, "font-stretch", "condensed" ); - break; - case PANGO_STRETCH_SEMI_CONDENSED: - sp_repr_css_set_property (css, "font-stretch", "semi-condensed" ); - break; - case PANGO_STRETCH_NORMAL: - sp_repr_css_set_property (css, "font-stretch", "normal" ); - break; - case PANGO_STRETCH_SEMI_EXPANDED: - sp_repr_css_set_property (css, "font-stretch", "semi-expanded" ); - break; - case PANGO_STRETCH_EXPANDED: - sp_repr_css_set_property (css, "font-stretch", "expanded" ); - break; - case PANGO_STRETCH_EXTRA_EXPANDED: - sp_repr_css_set_property (css, "font-stretch", "extra-expanded" ); - break; - case PANGO_STRETCH_ULTRA_EXPANDED: - sp_repr_css_set_property (css, "font-stretch", "ultra-expanded" ); - break; - } - - PangoVariant variant = pango_font_description_get_variant( desc ); - switch ( variant ) { - case PANGO_VARIANT_NORMAL: - sp_repr_css_set_property (css, "font-variant", "normal" ); - break; - case PANGO_VARIANT_SMALL_CAPS: - sp_repr_css_set_property (css, "font-variant", "small-caps" ); - break; - } + PangoVariant variant = pango_font_description_get_variant(desc); + switch (variant) { + case PANGO_VARIANT_NORMAL: + sp_repr_css_set_property(css, "font-variant", "normal"); + break; + case PANGO_VARIANT_SMALL_CAPS: + sp_repr_css_set_property(css, "font-variant", "small-caps"); + break; } +} - // We do this ourselves as we can't rely on FontFactory. - Glib::ustring - FontLister::fontspec_from_style (SPStyle* style) { +// We do this ourselves as we can't rely on FontFactory. +Glib::ustring FontLister::fontspec_from_style(SPStyle *style) +{ - //std::cout << "FontLister:fontspec_from_style: " << std::endl; + //std::cout << "FontLister:fontspec_from_style: " << std::endl; - Glib::ustring fontspec; - if (style) { + Glib::ustring fontspec; + if (style) { - // First try to use the font specification if it is set - if (style->font_specification.set - && style->font_specification.value - && *style->font_specification.value) { + // First try to use the font specification if it is set + if (style->font_specification.set && style->font_specification.value && *style->font_specification.value) { - fontspec = style->font_specification.value; + fontspec = style->font_specification.value; } else { - fontspec = style->font_family.value; - fontspec += ","; - - // Use weight names as defined by Pango - switch (style->font_weight.computed) { + fontspec = style->font_family.value; + fontspec += ","; + + // Use weight names as defined by Pango + switch (style->font_weight.computed) { - case SP_CSS_FONT_WEIGHT_100: - fontspec += " Thin"; - break; - - case SP_CSS_FONT_WEIGHT_200: - fontspec += " Ultra-Light"; - break; + case SP_CSS_FONT_WEIGHT_100: + fontspec += " Thin"; + break; - case SP_CSS_FONT_WEIGHT_300: - fontspec += " Light"; - break; + case SP_CSS_FONT_WEIGHT_200: + fontspec += " Ultra-Light"; + break; - case SP_CSS_FONT_WEIGHT_400: - case SP_CSS_FONT_WEIGHT_NORMAL: - //fontspec += " normal"; - break; - - case SP_CSS_FONT_WEIGHT_500: - fontspec += " Medium"; - break; - - case SP_CSS_FONT_WEIGHT_600: - fontspec += " Semi-Bold"; - break; - - case SP_CSS_FONT_WEIGHT_700: - case SP_CSS_FONT_WEIGHT_BOLD: - fontspec += " Bold"; - break; - - case SP_CSS_FONT_WEIGHT_800: - fontspec += " Ultra-Bold"; - break; - - case SP_CSS_FONT_WEIGHT_900: - fontspec += " Heavy"; - break; - - case SP_CSS_FONT_WEIGHT_LIGHTER: - case SP_CSS_FONT_WEIGHT_BOLDER: - default: - g_warning("Unrecognized font_weight.computed value"); - break; - } - - switch (style->font_style.computed) { - case SP_CSS_FONT_STYLE_ITALIC: - fontspec += " italic"; - break; - - case SP_CSS_FONT_STYLE_OBLIQUE: - fontspec += " oblique"; - break; - - case SP_CSS_FONT_STYLE_NORMAL: - default: - //fontspec += " normal"; - break; - } - - switch (style->font_stretch.computed) { - - case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: - fontspec += " extra-condensed"; - break; - - case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: - fontspec += " extra-condensed"; - break; - - case SP_CSS_FONT_STRETCH_CONDENSED: - case SP_CSS_FONT_STRETCH_NARROWER: - fontspec += " condensed"; - break; - - case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: - fontspec += " semi-condensed"; - break; - - case SP_CSS_FONT_STRETCH_NORMAL: - //fontspec += " normal"; - break; - - case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: - fontspec += " semi-expanded"; - break; - - case SP_CSS_FONT_STRETCH_EXPANDED: - case SP_CSS_FONT_STRETCH_WIDER: - fontspec += " expanded"; - break; - - case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: - fontspec += " extra-expanded"; - break; - - case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: - fontspec += " ultra-expanded"; - break; - - default: - //fontspec += " normal"; - break; - } - - switch (style->font_variant.computed) { - - case SP_CSS_FONT_VARIANT_SMALL_CAPS: - fontspec += "small-caps"; - break; - - default: - //fontspec += "normal"; - break; - } - } - } - return canonize_fontspec( fontspec ); - } + case SP_CSS_FONT_WEIGHT_300: + fontspec += " Light"; + break; + case SP_CSS_FONT_WEIGHT_400: + case SP_CSS_FONT_WEIGHT_NORMAL: + //fontspec += " normal"; + break; - Gtk::TreeModel::Row - FontLister::get_row_for_font (Glib::ustring family) - { - Gtk::TreePath path; + case SP_CSS_FONT_WEIGHT_500: + fontspec += " Medium"; + break; + + case SP_CSS_FONT_WEIGHT_600: + fontspec += " Semi-Bold"; + break; - Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); - while( iter != font_list_store->children().end() ) { + case SP_CSS_FONT_WEIGHT_700: + case SP_CSS_FONT_WEIGHT_BOLD: + fontspec += " Bold"; + break; - Gtk::TreeModel::Row row = *iter; + case SP_CSS_FONT_WEIGHT_800: + fontspec += " Ultra-Bold"; + break; - if( familyNamesAreEqual( family, row[FontList.family] ) ) { - return row; - } + case SP_CSS_FONT_WEIGHT_900: + fontspec += " Heavy"; + break; - ++iter; - } + case SP_CSS_FONT_WEIGHT_LIGHTER: + case SP_CSS_FONT_WEIGHT_BOLDER: + default: + g_warning("Unrecognized font_weight.computed value"); + break; + } - throw FAMILY_NOT_FOUND; - } + switch (style->font_style.computed) { + case SP_CSS_FONT_STYLE_ITALIC: + fontspec += " italic"; + break; - Gtk::TreePath - FontLister::get_path_for_font (Glib::ustring family) - { - return font_list_store->get_path( get_row_for_font ( family ) ); + case SP_CSS_FONT_STYLE_OBLIQUE: + fontspec += " oblique"; + break; + + case SP_CSS_FONT_STYLE_NORMAL: + default: + //fontspec += " normal"; + break; + } + + switch (style->font_stretch.computed) { + + case SP_CSS_FONT_STRETCH_ULTRA_CONDENSED: + fontspec += " extra-condensed"; + break; + + case SP_CSS_FONT_STRETCH_EXTRA_CONDENSED: + fontspec += " extra-condensed"; + break; + + case SP_CSS_FONT_STRETCH_CONDENSED: + case SP_CSS_FONT_STRETCH_NARROWER: + fontspec += " condensed"; + break; + + case SP_CSS_FONT_STRETCH_SEMI_CONDENSED: + fontspec += " semi-condensed"; + break; + + case SP_CSS_FONT_STRETCH_NORMAL: + //fontspec += " normal"; + break; + + case SP_CSS_FONT_STRETCH_SEMI_EXPANDED: + fontspec += " semi-expanded"; + break; + + case SP_CSS_FONT_STRETCH_EXPANDED: + case SP_CSS_FONT_STRETCH_WIDER: + fontspec += " expanded"; + break; + + case SP_CSS_FONT_STRETCH_EXTRA_EXPANDED: + fontspec += " extra-expanded"; + break; + + case SP_CSS_FONT_STRETCH_ULTRA_EXPANDED: + fontspec += " ultra-expanded"; + break; + + default: + //fontspec += " normal"; + break; + } + + switch (style->font_variant.computed) { + + case SP_CSS_FONT_VARIANT_SMALL_CAPS: + fontspec += "small-caps"; + break; + + default: + //fontspec += "normal"; + break; + } + } } + return canonize_fontspec(fontspec); +} - Gtk::TreeModel::Row - FontLister::get_row_for_style (Glib::ustring style) - { - Gtk::TreePath path; - Gtk::TreeModel::iterator iter = style_list_store->get_iter( "0" ); - while( iter != style_list_store->children().end() ) { +Gtk::TreeModel::Row FontLister::get_row_for_font(Glib::ustring family) +{ + Gtk::TreePath path; - Gtk::TreeModel::Row row = *iter; + Gtk::TreeModel::iterator iter = font_list_store->get_iter("0"); + while (iter != font_list_store->children().end()) { - if( familyNamesAreEqual( style, row[FontStyleList.cssStyle] ) ) { - return row; - } + Gtk::TreeModel::Row row = *iter; - ++iter; - } + if (familyNamesAreEqual(family, row[FontList.family])) { + return row; + } - throw STYLE_NOT_FOUND; + ++iter; } - static gint - compute_distance (const PangoFontDescription *a, - const PangoFontDescription *b ) { - - // Weight: multiples of 100 - gint distance = abs( pango_font_description_get_weight( a ) - - pango_font_description_get_weight( b ) ); - - distance += 10000 * abs( pango_font_description_get_stretch( a ) - - pango_font_description_get_stretch( b ) ); - - PangoStyle style_a = pango_font_description_get_style( a ); - PangoStyle style_b = pango_font_description_get_style( b ); - if( style_a != style_b ) { - if( (style_a == PANGO_STYLE_OBLIQUE && style_b == PANGO_STYLE_ITALIC) || - (style_b == PANGO_STYLE_OBLIQUE && style_a == PANGO_STYLE_ITALIC) ) { - distance += 1000; // Oblique and italic are almost the same - } else { - distance += 100000; // Normal vs oblique/italic, not so similar - } - } - - // Normal vs small-caps - distance += 1000000 * abs( pango_font_description_get_variant( a ) - - pango_font_description_get_variant( b ) ); - return distance; + throw FAMILY_NOT_FOUND; +} + +Gtk::TreePath FontLister::get_path_for_font(Glib::ustring family) +{ + return font_list_store->get_path(get_row_for_font(family)); +} + +Gtk::TreeModel::Row FontLister::get_row_for_style(Glib::ustring style) +{ + Gtk::TreePath path; + + Gtk::TreeModel::iterator iter = style_list_store->get_iter("0"); + while (iter != style_list_store->children().end()) { + + Gtk::TreeModel::Row row = *iter; + + if (familyNamesAreEqual(style, row[FontStyleList.cssStyle])) { + return row; + } + + ++iter; } - // This is inspired by pango_font_description_better_match, but that routine - // always returns false if variant or stretch are different. This means, for - // example, that PT Sans Narrow with style Bold Condensed is never matched - // to another font-family with Bold style. - gboolean - font_description_better_match( PangoFontDescription* target, - PangoFontDescription* old_desc, - PangoFontDescription* new_desc ) { + throw STYLE_NOT_FOUND; +} + +static gint compute_distance(const PangoFontDescription *a, const PangoFontDescription *b) +{ - if( old_desc == NULL ) return true; - if( new_desc == NULL ) return false; + // Weight: multiples of 100 + gint distance = abs(pango_font_description_get_weight(a) - + pango_font_description_get_weight(b)); - int old_distance = compute_distance( target, old_desc ); - int new_distance = compute_distance( target, new_desc ); - //std::cout << "font_description_better_match: old: " << old_distance << std::endl; - //std::cout << " new: " << new_distance << std::endl; + distance += 10000 * abs(pango_font_description_get_stretch(a) - + pango_font_description_get_stretch(b)); - return (new_distance < old_distance ); + PangoStyle style_a = pango_font_description_get_style(a); + PangoStyle style_b = pango_font_description_get_style(b); + if (style_a != style_b) { + if ((style_a == PANGO_STYLE_OBLIQUE && style_b == PANGO_STYLE_ITALIC) || + (style_b == PANGO_STYLE_OBLIQUE && style_a == PANGO_STYLE_ITALIC)) { + distance += 1000; // Oblique and italic are almost the same + } else { + distance += 100000; // Normal vs oblique/italic, not so similar + } } - // void - // font_description_dump( PangoFontDescription* target ) { - // std::cout << " Font: " << pango_font_description_to_string( target ) << std::endl; - // std::cout << " style: " << pango_font_description_get_style( target ) << std::endl; - // std::cout << " weight: " << pango_font_description_get_weight( target ) << std::endl; - // std::cout << " variant: " << pango_font_description_get_variant( target ) << std::endl; - // std::cout << " stretch: " << pango_font_description_get_stretch( target ) << std::endl; - // std::cout << " gravity: " << pango_font_description_get_gravity( target ) << std::endl; - // } - - /* Returns style string */ - // TODO: Remove or turn into function to be used by new_font_family. - Glib::ustring - FontLister::get_best_style_match (Glib::ustring family, Glib::ustring target_style) { + // Normal vs small-caps + distance += 1000000 * abs(pango_font_description_get_variant(a) - + pango_font_description_get_variant(b)); + return distance; +} -#ifdef DEBUG_FONT - std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - std::cout << "FontLister::get_best_style_match: " << family << " : " << target_style << std::endl; -#endif +// This is inspired by pango_font_description_better_match, but that routine +// always returns false if variant or stretch are different. This means, for +// example, that PT Sans Narrow with style Bold Condensed is never matched +// to another font-family with Bold style. +gboolean font_description_better_match(PangoFontDescription *target, PangoFontDescription *old_desc, PangoFontDescription *new_desc) +{ + if (old_desc == NULL) + return true; + if (new_desc == NULL) + return false; - Glib::ustring fontspec = family + ", " + target_style; - - Gtk::TreeModel::Row row; - try { - row = get_row_for_font( family ); - } catch (...) { - //std::cout << " ERROR: can't find family: " << family << std::endl; - return (target_style); - } - - PangoFontDescription* target = pango_font_description_from_string( fontspec.c_str() ); - PangoFontDescription* best = NULL; - - //font_description_dump( target ); - - GList* styles = row[FontList.styles]; - for (GList *l=styles; l; l = l->next) { - Glib::ustring fontspec = family + ", " + (char*)l->data; - PangoFontDescription* candidate = pango_font_description_from_string( fontspec.c_str() ); - //font_description_dump( candidate ); - //std::cout << " " << font_description_better_match( target, best, candidate ) << std::endl; - if( font_description_better_match( target, best, candidate ) ) { - pango_font_description_free( best ); - best = candidate; - //std::cout << " ... better: " << std::endl; - } else { - pango_font_description_free( candidate ); - //std::cout << " ... not better: " << std::endl; - } - } - - Glib::ustring best_style = target_style; - if( best ) { - pango_font_description_unset_fields( best, PANGO_FONT_MASK_FAMILY ); - best_style = pango_font_description_to_string( best ); - } - - if( target ) pango_font_description_free( target ); - if( best ) pango_font_description_free( best ); + int old_distance = compute_distance(target, old_desc); + int new_distance = compute_distance(target, new_desc); + //std::cout << "font_description_better_match: old: " << old_distance << std::endl; + //std::cout << " new: " << new_distance << std::endl; + + return (new_distance < old_distance); +} +// void +// font_description_dump( PangoFontDescription* target ) { +// std::cout << " Font: " << pango_font_description_to_string( target ) << std::endl; +// std::cout << " style: " << pango_font_description_get_style( target ) << std::endl; +// std::cout << " weight: " << pango_font_description_get_weight( target ) << std::endl; +// std::cout << " variant: " << pango_font_description_get_variant( target ) << std::endl; +// std::cout << " stretch: " << pango_font_description_get_stretch( target ) << std::endl; +// std::cout << " gravity: " << pango_font_description_get_gravity( target ) << std::endl; +// } + +/* Returns style string */ +// TODO: Remove or turn into function to be used by new_font_family. +Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustring target_style) +{ #ifdef DEBUG_FONT - std::cout << " Returning: " << best_style << std::endl; - std::cout << "FontLister::get_best_style_match: exit" << std::endl; - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister::get_best_style_match: " << family << " : " << target_style << std::endl; #endif - return best_style; - } - const Glib::RefPtr<Gtk::ListStore> - FontLister::get_font_list () const + Glib::ustring fontspec = family + ", " + target_style; + + Gtk::TreeModel::Row row; + try { - return font_list_store; + row = get_row_for_font(family); } - - const Glib::RefPtr<Gtk::ListStore> - FontLister::get_style_list () const + catch (...) { - return style_list_store; + //std::cout << " ERROR: can't find family: " << family << std::endl; + return (target_style); + } + + PangoFontDescription *target = pango_font_description_from_string(fontspec.c_str()); + PangoFontDescription *best = NULL; + + //font_description_dump( target ); + + if (!row[FontList.styles]) { + row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + } + GList *styles = row[FontList.styles]; + for (GList *l = styles; l; l = l->next) { + Glib::ustring fontspec = family + ", " + (char *)l->data; + PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str()); + //font_description_dump( candidate ); + //std::cout << " " << font_description_better_match( target, best, candidate ) << std::endl; + if (font_description_better_match(target, best, candidate)) { + pango_font_description_free(best); + best = candidate; + //std::cout << " ... better: " << std::endl; + } else { + pango_font_description_free(candidate); + //std::cout << " ... not better: " << std::endl; + } } + + Glib::ustring best_style = target_style; + if (best) { + pango_font_description_unset_fields(best, PANGO_FONT_MASK_FAMILY); + best_style = pango_font_description_to_string(best); + } + + if (target) + pango_font_description_free(target); + if (best) + pango_font_description_free(best); + + +#ifdef DEBUG_FONT + std::cout << " Returning: " << best_style << std::endl; + std::cout << "FontLister::get_best_style_match: exit" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; +#endif + return best_style; } +const Glib::RefPtr<Gtk::ListStore> FontLister::get_font_list() const +{ + return font_list_store; +} + +const Glib::RefPtr<Gtk::ListStore> FontLister::get_style_list() const +{ + return style_list_store; +} + +} // namespace Inkscape + // Helper functions // Separator function (if true, a separator will be drawn) -gboolean font_lister_separator_func(GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/) +gboolean font_lister_separator_func(GtkTreeModel *model, GtkTreeIter *iter, gpointer /*data*/) { - gchar* text = 0; - gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0: FontList.family - return (text && strcmp(text,"#") == 0); + gchar *text = 0; + gtk_tree_model_get(model, iter, 0, &text, -1); // Column 0: FontList.family + return (text && strcmp(text, "#") == 0); } -void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/) +void font_lister_cell_data_func(GtkCellLayout * /*cell_layout*/, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer /*data*/) { gchar *family; gboolean onSystem = false; gtk_tree_model_get(model, iter, 0, &family, 2, &onSystem, -1); - Glib::ustring family_escaped = g_markup_escape_text(family, -1); + gchar* family_escaped = g_markup_escape_text(family, -1); //g_free(family); Glib::ustring markup; - if( !onSystem ) { + if (!onSystem) { markup = "<span foreground='darkblue'>"; /* See if font-family on system */ - std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped ); - for( size_t i=0; i < tokens.size(); ++i ) { + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped); + for (size_t i = 0; i < tokens.size(); ++i) { Glib::ustring token = tokens[i]; @@ -1064,17 +1087,17 @@ void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, gchar *family = 0; gboolean onSystem = true; gboolean found = false; - for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter ); + for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter); valid; - valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ) ) { + valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)) { gtk_tree_model_get(model, &iter, 0, &family, 2, &onSystem, -1); - if( onSystem && familyNamesAreEqual( token, family ) ) { + if (onSystem && familyNamesAreEqual(token, family)) { found = true; break; } } - if( found ) { + if (found) { markup += g_markup_escape_text(token.c_str(), -1); markup += ", "; } else { @@ -1085,13 +1108,13 @@ void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, } } // Remove extra comma and space from end. - if( markup.size() >= 2 ) { - markup.resize( markup.size()-2 ); + if (markup.size() >= 2) { + markup.resize(markup.size() - 2); } markup += "</span>"; // std::cout << markup << std::endl; } else { - markup = family_escaped; + markup = family_escaped; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1099,17 +1122,20 @@ void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, if (show_sample) { Glib::ustring sample = prefs->getString("/tools/text/font_sample"); - Glib::ustring sample_escaped = g_markup_escape_text(sample.data(), -1); + gchar* sample_escaped = g_markup_escape_text(sample.data(), -1); markup += " <span foreground='gray' font_family='"; markup += family_escaped; markup += "'>"; markup += sample_escaped; markup += "</span>"; + g_free(sample_escaped); } - g_object_set (G_OBJECT (cell), "markup", markup.c_str(), NULL); + g_object_set(G_OBJECT(cell), "markup", markup.c_str(), NULL); + g_free(family_escaped); } + /* Local Variables: mode:c++ @@ -1119,4 +1145,4 @@ void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index c89dab550..18e0d4b6e 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -28,294 +28,280 @@ class SPDocument; class SPCSSAttr; class SPStyle; -namespace Inkscape -{ - /** - * This class enumerates fonts using libnrtype into reusable data stores and - * allows for random access to the font-family list and the font-style list. - * Setting the font-family updates the font-style list. "Style" in this case - * refers to everything but family and size (e.g. italic/oblique, weight). - * - * This class handles font-family lists and fonts that are not on the system, - * where there is not an entry in the fontInstanceMap. - * - * This class uses the idea of "font_spec". This is a plain text string as used by - * Pango. It is similar to the CSS font shorthand except that font-family comes - * first and in this class the font-size is not used. - * - * This class uses the FontFactory class to get a list of system fonts - * and to find best matches via Pango. The Pango interface is only setup - * to deal with fonts that are on the system so care must be taken. For - * example, best matches should only be done with the first font-family - * in a font-family list. If the first font-family is not on the system - * then a generic font-family should be used (sans-serif -> Sans). - * - * This class is used by the UI interface (text-toolbar, font-select, etc.). - * - * "Font" includes family and style. It should not be used when one - * means font-family. - */ - class FontLister - { - public: - - enum Exceptions - { - FAMILY_NOT_FOUND, - STYLE_NOT_FOUND - }; - - - virtual ~FontLister (); - - /** GtkTreeModelColumnRecord for the font-family list Gtk::ListStore - */ - class FontListClass - : public Gtk::TreeModelColumnRecord - { - public: - /** Column containing the family name - */ - Gtk::TreeModelColumn<Glib::ustring> family; - - /** Column containing the styles for each family name. - */ - Gtk::TreeModelColumn<GList*> styles; - - /** Column containing flag if font is on system - */ - Gtk::TreeModelColumn<gboolean> onSystem; - - FontListClass () - { - add (family); - add (styles); - add (onSystem); - } - }; - - FontListClass FontList; - - class FontStyleListClass - : public Gtk::TreeModelColumnRecord - { - public: - /** Column containing the styles as Font designer used. - */ - Gtk::TreeModelColumn<Glib::ustring> displayStyle; - - /** Column containing the styles in CSS/Pango format. - */ - Gtk::TreeModelColumn<Glib::ustring> cssStyle; - - FontStyleListClass () - { - add (cssStyle); - add (displayStyle); - } - }; - - FontStyleListClass FontStyleList; - - /** Returns the ListStore with the family names - * - * The return is const and the function is declared as const. - * The ListStore is ready to be used after class instantiation - * and should not (cannot) be modified. - */ - const Glib::RefPtr<Gtk::ListStore> - get_font_list () const; - - /** Returns the ListStore with the styles - * - */ - const Glib::RefPtr<Gtk::ListStore> - get_style_list () const; - - /** Inserts a font family or font-fallback list (for use when not - * already in document or on system). - */ - void - insert_font_family ( Glib::ustring new_family ); - - /** Updates font list to include fonts in document - * - */ - void - update_font_list ( SPDocument* document); - - private: - void - update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ); - - public: - static Inkscape::FontLister* - get_instance () - { - static Inkscape::FontLister* instance = new Inkscape::FontLister(); - return instance; - } - - /** Takes a hand written font spec and returns a Pango generated one in - * standard form. - */ - Glib::ustring canonize_fontspec( Glib::ustring fontspec ); - - /** Find closest system font to given font. - */ - Glib::ustring system_fontspec( Glib::ustring fontspec ); - - /** Gets font-family and style from fontspec. - * font-family and style returned. - */ - std::pair<Glib::ustring, Glib::ustring> - ui_from_fontspec (Glib::ustring fontspec); - - /** Sets font-family and style after a selection change. - * New font-family and style returned. - */ - std::pair<Glib::ustring, Glib::ustring> - selection_update (); - - /** Sets current_fontspec, etc. If check is false, won't - * try to find best style match (assumes style in fontspec - * valid for given font-family). - */ - void - set_fontspec (Glib::ustring fontspec, gboolean check=true); - - Glib::ustring - get_fontspec () - { - return current_fontspec; - } - - /** Changes font-family, updating style list and attempting to find - * closest style to current_style style (if check_style is true). - * New font-family and style returned. - * Does NOT update current_family and current_style. - * (For potential use in font-selector which doesn't update until - * "Apply" button clicked.) - */ - std::pair<Glib::ustring, Glib::ustring> - new_font_family (Glib::ustring family, gboolean check_style = true); - - /** Sets font-family, updating style list and attempting - * to find closest style to old current_style. - * New font-family and style returned. - * Updates current_family and current_style. - * Calls new_font_family(). - * (For use in text-toolbar where update is immediate.) - */ - std::pair<Glib::ustring, Glib::ustring> - set_font_family (Glib::ustring family, gboolean check_style = true); - - /** Sets font-family from row in list store. - * The row can be used to determine if we are in the - * document or system part of the font-family list. - * This is needed to handle scrolling through the - * font-family list correctly. - * Calls set_font_family(). - */ - std::pair<Glib::ustring, Glib::ustring> - set_font_family (int row, gboolean check_style = true); - - Glib::ustring - get_font_family () - { - return current_family; - } - - int - get_font_family_row () - { - return current_family_row; - } - - /** Sets style. Does not validate style for family. - */ - void - set_font_style (Glib::ustring style); - - Glib::ustring - get_font_style () - { - return current_style; - } - - Glib::ustring - fontspec_from_style (SPStyle* style); - - /** Fill css using current_fontspec. - */ - void - fill_css( SPCSSAttr *css, Glib::ustring fontspec = "" ); - - Gtk::TreeModel::Row - get_row_for_font (Glib::ustring family); - - Gtk::TreePath - get_path_for_font (Glib::ustring family); - - Gtk::TreeModel::Row - get_row_for_style (Glib::ustring style); - - Gtk::TreePath - get_path_for_style (Glib::ustring style); - - std::pair<Gtk::TreePath, Gtk::TreePath> - get_paths (Glib::ustring family, Glib::ustring style); - - /** Return best style match for new font given style for old font. - */ - Glib::ustring - get_best_style_match (Glib::ustring family, Glib::ustring style); - - /* Not Used */ - const NRNameList - get_name_list () const - { - return families; - } - - private: - - FontLister (); - - NRNameList families; - - Glib::RefPtr<Gtk::ListStore> font_list_store; - Glib::RefPtr<Gtk::ListStore> style_list_store; - - /** Info for currently selected font (what is shown in the UI). - * May include font-family lists and fonts not on system. - */ - int current_family_row; - Glib::ustring current_family; - Glib::ustring current_style; - Glib::ustring current_fontspec; - - /** fontspec of system font closest to current_fontspec. - * (What the system will use to display current_fontspec.) - */ - Glib::ustring current_fontspec_system; - - /** If a font-family is not on system, this list of styles is used. - */ - GList *default_styles; - }; -} +namespace Inkscape { + +/** + * This class enumerates fonts using libnrtype into reusable data stores and + * allows for random access to the font-family list and the font-style list. + * Setting the font-family updates the font-style list. "Style" in this case + * refers to everything but family and size (e.g. italic/oblique, weight). + * + * This class handles font-family lists and fonts that are not on the system, + * where there is not an entry in the fontInstanceMap. + * + * This class uses the idea of "font_spec". This is a plain text string as used by + * Pango. It is similar to the CSS font shorthand except that font-family comes + * first and in this class the font-size is not used. + * + * This class uses the FontFactory class to get a list of system fonts + * and to find best matches via Pango. The Pango interface is only setup + * to deal with fonts that are on the system so care must be taken. For + * example, best matches should only be done with the first font-family + * in a font-family list. If the first font-family is not on the system + * then a generic font-family should be used (sans-serif -> Sans). + * + * This class is used by the UI interface (text-toolbar, font-select, etc.). + * + * "Font" includes family and style. It should not be used when one + * means font-family. + */ + +class FontLister { +public: + enum Exceptions { + FAMILY_NOT_FOUND, + STYLE_NOT_FOUND + }; + + virtual ~FontLister(); + + /** + * GtkTreeModelColumnRecord for the font-family list Gtk::ListStore + */ + struct FontListClass : public Gtk::TreeModelColumnRecord { + /** + * Column containing the family name + */ + Gtk::TreeModelColumn<Glib::ustring> family; + + /** + * Column containing the styles for each family name. + */ + Gtk::TreeModelColumn<GList *> styles; + + /** + * Column containing flag if font is on system + */ + Gtk::TreeModelColumn<bool> onSystem; + + /** + * Not actually a column. + * Necessary for quick initialization of FontLister, + * we initially store the pango family and if the + * font style is actually used we'll cache it in + * %styles. + */ + Gtk::TreeModelColumn<PangoFontFamily *> pango_family; + + FontListClass() + { + add(family); + add(styles); + add(onSystem); + add(pango_family); + } + }; + + FontListClass FontList; + + struct FontStyleListClass : public Gtk::TreeModelColumnRecord { + /** + * Column containing the styles as Font designer used. + */ + Gtk::TreeModelColumn<Glib::ustring> displayStyle; + + /** + * Column containing the styles in CSS/Pango format. + */ + Gtk::TreeModelColumn<Glib::ustring> cssStyle; + + FontStyleListClass() + { + add(cssStyle); + add(displayStyle); + } + }; + + FontStyleListClass FontStyleList; + + /** + * @return the ListStore with the family names + * + * The return is const and the function is declared as const. + * The ListStore is ready to be used after class instantiation + * and should not be modified. + */ + const Glib::RefPtr<Gtk::ListStore> get_font_list() const; + + /** + * @return the ListStore with the styles + */ + const Glib::RefPtr<Gtk::ListStore> get_style_list() const; + + /** + * Inserts a font family or font-fallback list (for use when not + * already in document or on system). + */ + void insert_font_family(Glib::ustring new_family); + + /** + * Updates font list to include fonts in document. + */ + void update_font_list(SPDocument *document); + +public: + static Inkscape::FontLister *get_instance(); + + /** + * Takes a hand written font spec and returns a Pango generated one in + * standard form. + */ + Glib::ustring canonize_fontspec(Glib::ustring fontspec); + + /** + * Find closest system font to given font. + */ + Glib::ustring system_fontspec(Glib::ustring fontspec); + + /** + * Gets font-family and style from fontspec. + * font-family and style returned. + */ + std::pair<Glib::ustring, Glib::ustring> ui_from_fontspec(Glib::ustring fontspec); + + /** + * Sets font-family and style after a selection change. + * New font-family and style returned. + */ + std::pair<Glib::ustring, Glib::ustring> selection_update(); + + /** + * Sets current_fontspec, etc. If check is false, won't + * try to find best style match (assumes style in fontspec + * valid for given font-family). + */ + void set_fontspec(Glib::ustring fontspec, bool check = true); + + Glib::ustring get_fontspec() + { + return current_fontspec; + } + + /** + * Changes font-family, updating style list and attempting to find + * closest style to current_style style (if check_style is true). + * New font-family and style returned. + * Does NOT update current_family and current_style. + * (For potential use in font-selector which doesn't update until + * "Apply" button clicked.) + */ + std::pair<Glib::ustring, Glib::ustring> new_font_family(Glib::ustring family, bool check_style = true); + + /** + * Sets font-family, updating style list and attempting + * to find closest style to old current_style. + * New font-family and style returned. + * Updates current_family and current_style. + * Calls new_font_family(). + * (For use in text-toolbar where update is immediate.) + */ + std::pair<Glib::ustring, Glib::ustring> set_font_family(Glib::ustring family, bool check_style = true); + + /** + * Sets font-family from row in list store. + * The row can be used to determine if we are in the + * document or system part of the font-family list. + * This is needed to handle scrolling through the + * font-family list correctly. + * Calls set_font_family(). + */ + std::pair<Glib::ustring, Glib::ustring> set_font_family(int row, bool check_style = true); + + Glib::ustring get_font_family() + { + return current_family; + } + + int get_font_family_row() + { + return current_family_row; + } + + /** + * Sets style. Does not validate style for family. + */ + void set_font_style(Glib::ustring style); + + Glib::ustring get_font_style() + { + return current_style; + } + + Glib::ustring fontspec_from_style(SPStyle *style); + + /** + * Fill css using current_fontspec. + */ + void fill_css(SPCSSAttr *css, Glib::ustring fontspec = ""); + + Gtk::TreeModel::Row get_row_for_font(Glib::ustring family); + + Gtk::TreePath get_path_for_font(Glib::ustring family); + + Gtk::TreeModel::Row get_row_for_style(Glib::ustring style); + + Gtk::TreePath get_path_for_style(Glib::ustring style); + + std::pair<Gtk::TreePath, Gtk::TreePath> get_paths(Glib::ustring family, Glib::ustring style); + + /** + * Return best style match for new font given style for old font. + */ + Glib::ustring get_best_style_match(Glib::ustring family, Glib::ustring style); + + void ensureRowStyles(GtkTreeModel* model, GtkTreeIter const* iter); + +private: + FontLister(); + + void update_font_list_recursive(SPObject *r, std::list<Glib::ustring> *l); + + Glib::RefPtr<Gtk::ListStore> font_list_store; + Glib::RefPtr<Gtk::ListStore> style_list_store; + + /** + * Info for currently selected font (what is shown in the UI). + * May include font-family lists and fonts not on system. + */ + int current_family_row; + Glib::ustring current_family; + Glib::ustring current_style; + Glib::ustring current_fontspec; + + /** + * fontspec of system font closest to current_fontspec. + * (What the system will use to display current_fontspec.) + */ + Glib::ustring current_fontspec_system; + + /** + * If a font-family is not on system, this list of styles is used. + */ + GList *default_styles; +}; + +} // namespace Inkscape // Helper functions gboolean font_lister_separator_func(GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/); + GtkTreeIter *iter, + gpointer /*data*/); -void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer /*data*/); +void font_lister_cell_data_func(GtkCellLayout * /*cell_layout*/, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer /*data*/); #endif @@ -328,4 +314,4 @@ void font_lister_cell_data_func(GtkCellLayout */*cell_layout*/, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/libnrtype/nr-type-primitives.cpp b/src/libnrtype/nr-type-primitives.cpp index 63a3abcc5..3ad4a3771 100644 --- a/src/libnrtype/nr-type-primitives.cpp +++ b/src/libnrtype/nr-type-primitives.cpp @@ -1,6 +1,4 @@ -#define __NR_TYPE_PRIMITIVES_C__ - -/* +/** * Typeface and script library * * Authors: @@ -12,26 +10,27 @@ /* This should be enough for approximately 10000 fonts */ #define NR_DICTSIZE 2777 -#include <stdlib.h> +#include <cstdlib> #include <string.h> #include <glib.h> + #include "nr-type-primitives.h" /** * An entry in a list of key->value pairs */ struct NRTDEntry { - NRTDEntry *next; - const gchar *key; - void *val; + NRTDEntry *next; + const gchar *key; + void *val; }; /** * Type Dictionary, consisting of size number of key-value entries */ struct NRTypeDict { - unsigned int size; - NRTDEntry **entries; + unsigned int size; + NRTDEntry **entries; }; static NRTDEntry *nr_td_entry_new (void); @@ -42,17 +41,17 @@ static NRTDEntry *nr_td_entry_new (void); void nr_name_list_release (NRNameList *list) { - if (list->destructor) { - list->destructor (list); - } + if (list->destructor) { + list->destructor (list); + } } void nr_style_list_release (NRStyleList *list) { - if (list->destructor) { - list->destructor (list); - } + if (list->destructor) { + list->destructor (list); + } } /** @@ -62,18 +61,18 @@ nr_style_list_release (NRStyleList *list) NRTypeDict * nr_type_dict_new (void) { - NRTypeDict *td; - int i; + NRTypeDict *td; + int i; - td = g_new (NRTypeDict, 1); + td = g_new (NRTypeDict, 1); - td->size = NR_DICTSIZE; - td->entries = g_new (NRTDEntry *, td->size); - for (i = 0; i < NR_DICTSIZE; i++) { - td->entries[i] = NULL; - } + td->size = NR_DICTSIZE; + td->entries = g_new (NRTDEntry *, td->size); + for (i = 0; i < NR_DICTSIZE; i++) { + td->entries[i] = NULL; + } - return td; + return td; } /** @@ -82,15 +81,15 @@ nr_type_dict_new (void) static unsigned int nr_str_hash (const gchar *p) { - unsigned int h; + unsigned int h; - h = *p; + h = *p; - if (h != 0) { - for (p += 1; *p; p++) h = (h << 5) - h + *p; - } + if (h != 0) { + for (p += 1; *p; p++) h = (h << 5) - h + *p; + } - return h; + return h; } /** @@ -99,25 +98,25 @@ nr_str_hash (const gchar *p) void nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val) { - if (key) { - NRTDEntry *tde; - unsigned int hval; - - hval = nr_str_hash (key) % td->size; - - for (tde = td->entries[hval]; tde; tde = tde->next) { - if (!strcmp (key, tde->key)) { - tde->val = val; - return; - } - } - - tde = nr_td_entry_new (); - tde->next = td->entries[hval]; - tde->key = key; - tde->val = val; - td->entries[hval] = tde; - } + if (key) { + NRTDEntry *tde; + unsigned int hval; + + hval = nr_str_hash (key) % td->size; + + for (tde = td->entries[hval]; tde; tde = tde->next) { + if (!strcmp (key, tde->key)) { + tde->val = val; + return; + } + } + + tde = nr_td_entry_new (); + tde->next = td->entries[hval]; + tde->key = key; + tde->val = val; + td->entries[hval] = tde; + } } /** @@ -126,16 +125,16 @@ nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val) void * nr_type_dict_lookup (NRTypeDict *td, const gchar *key) { - if (key) { - NRTDEntry *tde; - unsigned int hval; - hval = nr_str_hash (key) % td->size; - for (tde = td->entries[hval]; tde; tde = tde->next) { - if (!strcmp (key, tde->key)) return tde->val; - } - } - - return NULL; + if (key) { + NRTDEntry *tde; + unsigned int hval; + hval = nr_str_hash (key) % td->size; + for (tde = td->entries[hval]; tde; tde = tde->next) { + if (!strcmp (key, tde->key)) return tde->val; + } + } + + return NULL; } #define NR_TDE_BLOCK_SIZE 32 @@ -148,20 +147,30 @@ static NRTDEntry *nr_tde_free_list; static NRTDEntry * nr_td_entry_new (void) { - NRTDEntry *tde; + NRTDEntry *tde; - if (!nr_tde_free_list) { - int i; - nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); - for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { - nr_tde_free_list[i].next = nr_tde_free_list + i + 1; - } - nr_tde_free_list[i].next = NULL; - } + if (!nr_tde_free_list) { + int i; + nr_tde_free_list = g_new (NRTDEntry, NR_TDE_BLOCK_SIZE); + for (i = 0; i < (NR_TDE_BLOCK_SIZE - 1); i++) { + nr_tde_free_list[i].next = nr_tde_free_list + i + 1; + } + nr_tde_free_list[i].next = NULL; + } - tde = nr_tde_free_list; - nr_tde_free_list = tde->next; + tde = nr_tde_free_list; + nr_tde_free_list = tde->next; - return tde; + return tde; } +/* + 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 : diff --git a/src/libnrtype/nr-type-primitives.h b/src/libnrtype/nr-type-primitives.h index 9bb181c4b..863803433 100644 --- a/src/libnrtype/nr-type-primitives.h +++ b/src/libnrtype/nr-type-primitives.h @@ -1,12 +1,12 @@ -#ifndef __NR_TYPE_PRIMITIVES_H__ -#define __NR_TYPE_PRIMITIVES_H__ +#ifndef SEEN_NR_TYPE_PRIMITIVES_H +#define SEEN_NR_TYPE_PRIMITIVES_H -/* +/** * Typeface and script library * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> - * g++ port: Nathan Hurst <njh@mail.csse.monash.edu.au> + * c++ port: Nathan Hurst <njh@mail.csse.monash.edu.au> * * This code is in public domain */ @@ -47,4 +47,15 @@ void nr_type_dict_insert (NRTypeDict *td, const gchar *key, void *val); void *nr_type_dict_lookup (NRTypeDict *td, const gchar *key); -#endif +#endif // !SEEN_NR_TYPE_PRIMITIVES_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/livarot/PathStroke.cpp b/src/livarot/PathStroke.cpp index 50c335176..6ec7fa209 100644 --- a/src/livarot/PathStroke.cpp +++ b/src/livarot/PathStroke.cpp @@ -748,12 +748,12 @@ void Path::RecRound(Shape *dest, int sNo, int eNo, // start and end index } /* - 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 : + 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/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 3c64e5c8e..d126aca9f 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -31,6 +31,7 @@ set(live_effects_SRC lpe-recursiveskeleton.cpp lpe-rough-hatches.cpp lpe-ruler.cpp + lpe-show_handles.cpp lpe-simplify.cpp # lpe-skeleton.cpp lpe-sketch.cpp @@ -99,6 +100,7 @@ set(live_effects_SRC lpe-rough-hatches.h lpe-ruler.h lpe-simplify.h + lpe-show_handles.h lpe-skeleton.h lpe-sketch.h lpe-spiro.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 91651a7c8..1b8f587e1 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -38,6 +38,8 @@ ink_common_sources += \ live_effects/lpe-gears.h \ live_effects/lpe-interpolate.cpp \ live_effects/lpe-interpolate.h \ + live_effects/lpe-interpolate_points.cpp \ + live_effects/lpe-interpolate_points.h \ live_effects/lpe-test-doEffect-stack.cpp \ live_effects/lpe-test-doEffect-stack.h \ live_effects/lpe-bspline.cpp \ @@ -48,6 +50,8 @@ ink_common_sources += \ live_effects/lpe-lattice2.h \ live_effects/lpe-roughen.cpp \ live_effects/lpe-roughen.h \ + live_effects/lpe-show_handles.cpp \ + live_effects/lpe-show_handles.h \ live_effects/lpe-simplify.cpp \ live_effects/lpe-simplify.h \ live_effects/lpe-envelope.cpp \ diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index dac44981c..30dbf4092 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -30,6 +30,7 @@ enum EffectType { LATTICE, LATTICE2, ROUGHEN, + SHOW_HANDLES, SIMPLIFY, ENVELOPE, CONSTRUCT_GRID, @@ -44,6 +45,7 @@ enum EffectType { RULER, BOOLOPS, INTERPOLATE, + INTERPOLATE_POINTS, TEXT_LABEL, PATH_LENGTH, LINE_SEGMENT, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5a9b6c7a2..b012e3ab1 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -28,6 +28,7 @@ #include "live_effects/lpe-lattice.h" #include "live_effects/lpe-lattice2.h" #include "live_effects/lpe-roughen.h" +#include "live_effects/lpe-show_handles.h" #include "live_effects/lpe-simplify.h" #include "live_effects/lpe-envelope.h" #include "live_effects/lpe-constructgrid.h" @@ -42,6 +43,7 @@ #include "live_effects/lpe-ruler.h" #include "live_effects/lpe-boolops.h" #include "live_effects/lpe-interpolate.h" +#include "live_effects/lpe-interpolate_points.h" #include "live_effects/lpe-text_label.h" #include "live_effects/lpe-path_length.h" #include "live_effects/lpe-line_segment.h" @@ -126,13 +128,16 @@ const Util::EnumData<EffectType> LPETypeData[] = { /* 0.91 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, - {ROUGHEN, N_("Roughen"), "roughen"}, +/* EXPERIMENTAL */ + {SHOW_HANDLES, N_("Show handles"), "show_handles"}, + {ROUGHEN, N_("Roughen"), "roughen"}, {BSPLINE, N_("BSpline"), "bspline"}, {SIMPLIFY, N_("Simplify"), "simplify"}, {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, // TRANSLATORS: "Envelope Perspective" should be equivalent to "perspective transformation" {ENVELOPE_PERSPECTIVE, N_("Envelope Perspective"), "envelope-perspective"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, + {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, }; const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -229,6 +234,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case INTERPOLATE: neweffect = static_cast<Effect*> ( new LPEInterpolate(lpeobj) ); break; + case INTERPOLATE_POINTS: + neweffect = static_cast<Effect*> ( new LPEInterpolatePoints(lpeobj) ); + break; case TEXT_LABEL: neweffect = static_cast<Effect*> ( new LPETextLabel(lpeobj) ); break; @@ -274,6 +282,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case ROUGHEN: neweffect = static_cast<Effect*> ( new LPERoughen(lpeobj) ); break; + case SHOW_HANDLES: + neweffect = static_cast<Effect*> ( new LPEShowHandles(lpeobj) ); + break; default: g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); neweffect = NULL; diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 0a5d8eca5..3a6dca795 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_BSPLINE_C - /* * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -8,23 +6,19 @@ # include <config.h> #endif -#if WITH_GLIBMM_2_32 && HAVE_GLIBMM_THREADS_H +#include <gtkmm.h> + +#if WITH_GLIBMM_2_32 # include <glibmm/threads.h> #endif -#include <2geom/bezier-curve.h> -#include <2geom/point.h> - -#include <gtkmm/box.h> -#include <gtkmm/entry.h> -#include <gtkmm/box.h> -#include <gtkmm/button.h> -#include <gtkmm/checkbutton.h> - #include <glib.h> #include <glibmm/i18n.h> + #include "display/curve.h" +#include <2geom/bezier-curve.h> +#include <2geom/point.h> #include "helper/geom-curves.h" #include "live_effects/lpe-bspline.h" #include "live_effects/lpeobject.h" @@ -48,8 +42,7 @@ #include "display/sp-canvas.h" #include <typeinfo> #include <vector> - -// For handling non-contiguous paths: +// For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" #include "desktop.h" diff --git a/src/live_effects/lpe-envelope-perspective.cpp b/src/live_effects/lpe-envelope-perspective.cpp index d9bf20752..6d3441d93 100644 --- a/src/live_effects/lpe-envelope-perspective.cpp +++ b/src/live_effects/lpe-envelope-perspective.cpp @@ -14,12 +14,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <gtkmm.h> #include "live_effects/lpe-envelope-perspective.h" #include "helper/geom.h" #include "display/curve.h" #include "svg/svg.h" -#include <gtkmm/separator.h> -#include <gtkmm/stock.h> #include <tools-switch.h> #include <gsl/gsl_linalg.h> #include "desktop.h" @@ -286,12 +285,20 @@ LPEEnvelopePerspective::newWidget() Gtk::Label* handles = Gtk::manage(new Gtk::Label(Glib::ustring(_("Handles:")),Gtk::ALIGN_START)); vbox->pack_start(*handles, false, false, 2); hboxUpHandles->pack_start(*widg, true, true, 2); +#if WITH_GTKMM_3_0 + hboxUpHandles->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_VERTICAL)), Gtk::PACK_EXPAND_WIDGET); +#else hboxUpHandles->pack_start(*Gtk::manage(new Gtk::VSeparator()), Gtk::PACK_EXPAND_WIDGET); +#endif }else if(param->param_key == "Up_Right_Point"){ hboxUpHandles->pack_start(*widg, true, true, 2); }else if(param->param_key == "Down_Left_Point"){ hboxDownHandles->pack_start(*widg, true, true, 2); +#if WITH_GTKMM_3_0 + hboxDownHandles->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_VERTICAL)), Gtk::PACK_EXPAND_WIDGET); +#else hboxDownHandles->pack_start(*Gtk::manage(new Gtk::VSeparator()), Gtk::PACK_EXPAND_WIDGET); +#endif }else{ hboxDownHandles->pack_start(*widg, true, true, 2); } @@ -320,8 +327,13 @@ LPEEnvelopePerspective::newWidget() } vbox->pack_start(*hboxUpHandles,true, true, 2); Gtk::HBox * hboxMiddle = Gtk::manage(new Gtk::HBox(true,2)); +#if WITH_GTKMM_3_0 + hboxMiddle->pack_start(*Gtk::manage(new Gtk::Separator()), Gtk::PACK_EXPAND_WIDGET); + hboxMiddle->pack_start(*Gtk::manage(new Gtk::Separator()), Gtk::PACK_EXPAND_WIDGET); +#else hboxMiddle->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); hboxMiddle->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); +#endif vbox->pack_start(*hboxMiddle, false, true, 2); vbox->pack_start(*hboxDownHandles, true, true, 2); Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); @@ -422,4 +434,4 @@ LPEEnvelopePerspective::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::v fill-column:99 End: */ -// vim: file_type=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp new file mode 100644 index 000000000..865b46ca7 --- /dev/null +++ b/src/live_effects/lpe-interpolate_points.cpp @@ -0,0 +1,94 @@ +/** \file + * LPE interpolate_points implementation + * Interpolates between knots of the input path. + */ +/* + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2014 <j.b.c.engelen@alumnus.utwente.nl> + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/lpe-interpolate_points.h" + +#include <2geom/path.h> + +#include "live_effects/lpe-powerstroke-interpolators.h" + +namespace Inkscape { +namespace LivePathEffect { + + +static const Util::EnumData<unsigned> InterpolatorTypeData[] = { + {Geom::Interpolate::INTERP_LINEAR , N_("Linear"), "Linear"}, + {Geom::Interpolate::INTERP_CUBICBEZIER , N_("CubicBezierFit"), "CubicBezierFit"}, + {Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN , N_("CubicBezierJohan"), "CubicBezierJohan"}, + {Geom::Interpolate::INTERP_SPIRO , N_("SpiroInterpolator"), "SpiroInterpolator"}, + {Geom::Interpolate::INTERP_CENTRIPETAL_CATMULLROM, N_("Centripetal Catmull-Rom"), "CentripetalCatmullRom"} +}; +static const Util::EnumDataConverter<unsigned> InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData)); + + +LPEInterpolatePoints::LPEInterpolatePoints(LivePathEffectObject *lpeobject) + : Effect(lpeobject) + , interpolator_type( + _("Interpolator type:"), + _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), + "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CENTRIPETAL_CATMULLROM) +{ + show_orig_path = false; + + registerParameter( dynamic_cast<Parameter *>(&interpolator_type) ); +} + +LPEInterpolatePoints::~LPEInterpolatePoints() +{ +} + + +Geom::PathVector +LPEInterpolatePoints::doEffect_path (Geom::PathVector const & path_in) +{ + Geom::PathVector path_out; + + std::auto_ptr<Geom::Interpolate::Interpolator> interpolator( Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())) ); + + for(Geom::PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { + if (path_it->empty()) + continue; + + if (path_it->closed()) { + g_warning("Interpolate points LPE currently ignores whether path is closed or not."); + } + + std::vector<Geom::Point> pts; + pts.push_back(path_it->initialPoint()); + + for (Geom::Path::const_iterator it = path_it->begin(), e = path_it->end_default(); it != e; ++it) { + pts.push_back((*it).finalPoint()); + } + + Geom::Path path = interpolator->interpolateToPath(pts); + + path_out.push_back(path); + } + + return path_out; +} + + +} //namespace LivePathEffect +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-interpolate_points.h b/src/live_effects/lpe-interpolate_points.h new file mode 100644 index 000000000..7a3364747 --- /dev/null +++ b/src/live_effects/lpe-interpolate_points.h @@ -0,0 +1,51 @@ +#ifndef INKSCAPE_LPE_INTERPOLATEPOINTS_H +#define INKSCAPE_LPE_INTERPOLATEPOINTS_H + +/** \file + * LPE interpolate_points implementation, see lpe-interpolate_points.cpp. + */ + +/* + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2014 <j.b.c.engelen@alumnus.utwente.nl> + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/parameter/enum.h" +#include "live_effects/effect.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEInterpolatePoints : public Effect { +public: + LPEInterpolatePoints(LivePathEffectObject *lpeobject); + virtual ~LPEInterpolatePoints(); + + virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); + +private: + EnumParam<unsigned> interpolator_type; + + LPEInterpolatePoints(const LPEInterpolatePoints&); + LPEInterpolatePoints& operator=(const LPEInterpolatePoints&); +}; + +} //namespace LivePathEffect +} //namespace Inkscape + +#endif // INKSCAPE_LPE_INTERPOLATEPOINTS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index a7748c5a8..fb5ac5363 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -10,17 +10,19 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include <gtkmm.h> #include <glibmm/i18n.h> #include "persp3d.h" //#include "transf_mat_3x4.h" #include "document.h" - +#include "document-private.h" #include "live_effects/lpe-perspective_path.h" +#include "live_effects/lpeobject.h" #include "sp-item-group.h" #include "knot-holder-entity.h" #include "knotholder.h" +#include "desktop.h" #include "inkscape.h" @@ -41,6 +43,7 @@ public: } // namespace PP +static Glib::ustring perspectiveID = _("First perspective"); LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: @@ -60,8 +63,18 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; - Persp3D *persp = persp3d_document_first_persp(SP_ACTIVE_DOCUMENT); + unapply = false; + Persp3D *persp = persp3d_document_first_persp(lpeobject->document); + if(persp == 0 ){ + char *msg = _("You need a BOX 3D object"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, + Gtk::BUTTONS_OK, true); + dialog.run(); + unapply = true; + return; + } Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; + pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt(); pmat.copy_tmat(tmat); } @@ -74,8 +87,50 @@ void LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem, true); + if(unapply){ + SP_LPE_ITEM(lpeitem)->removeCurrentPathEffect(false); + return; + } } +void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { + perspectiveID = perspective->get_text(); + Persp3D *first = 0; + Persp3D *persp = 0; + for ( SPObject *child = this->lpeobj->document->getDefs()->firstChild(); child && !persp; child = child->getNext() ) { + if (SP_IS_PERSP3D(child) && first == 0) { + first = SP_PERSP3D(child); + } + if (SP_IS_PERSP3D(child) && strcmp(child->getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) { + persp = SP_PERSP3D(child); + break; + } + } + if(first == 0 ){ + char *msg = _("You need a BOX 3D object"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, + Gtk::BUTTONS_OK, true); + dialog.run(); + return; + } + if(persp == 0){ + persp = first; + char *msg = _("First perspective selected"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, + Gtk::BUTTONS_OK, true); + dialog.run(); + perspectiveID = _("First perspective"); + }else{ + char *msg = _("Perspective changed"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO, + Gtk::BUTTONS_OK, true); + dialog.run(); + } + Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; + pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt(); + pmat.copy_tmat(tmat); +}; + Geom::Piecewise<Geom::D2<Geom::SBasis> > LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { @@ -91,7 +146,7 @@ LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > cons Piecewise<SBasis> preimage[4]; //Geom::Point orig = Geom::Point(bounds_X.min(), bounds_Y.middle()); - //orig = Geom::Point(orig[X], sp_document_height(inkscape_active_document()) - orig[Y]); + //orig = Geom::Point(orig[X], sp_document_height(this->lpeobj->document) - orig[Y]); //double offset = uses_plane_xy ? boundingbox_X.extent() : 0.0; @@ -139,6 +194,49 @@ LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > cons return output; } +Gtk::Widget * +LPEPerspectivePath::newWidget() +{ + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + + vbox->set_border_width(5); + std::vector<Parameter *>::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget()); + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } + + ++it; + } + Gtk::HBox * perspectiveId = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Label* labelPerspective = Gtk::manage(new Gtk::Label("Perspective ID:", 0., 0.)); + Gtk::Entry* perspective = Gtk::manage(new Gtk::Entry()); + perspective->set_text(perspectiveID); + perspective->set_tooltip_text("Set the perspective ID to apply"); + perspectiveId->pack_start(*labelPerspective, true, true, 2); + perspectiveId->pack_start(*perspective, true, true, 2); + vbox->pack_start(*perspectiveId, true, true, 2); + Gtk::Button* apply3D = Gtk::manage(new Gtk::Button(Glib::ustring(_("Refresh perspective")))); + apply3D->set_alignment(0.0, 0.5); + apply3D->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this,&LPEPerspectivePath::refresh),perspective)); + Gtk::Widget* apply3DWidget = dynamic_cast<Gtk::Widget *>(apply3D); + apply3DWidget->set_tooltip_text("Refresh perspective"); + vbox->pack_start(*apply3DWidget, true, true,2); + return dynamic_cast<Gtk::Widget *>(vbox); +} + void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { KnotHolderEntity *e = new PP::KnotHolderEntityOffset(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, diff --git a/src/live_effects/lpe-perspective_path.h b/src/live_effects/lpe-perspective_path.h index a9ee004f9..6ccac4a51 100644 --- a/src/live_effects/lpe-perspective_path.h +++ b/src/live_effects/lpe-perspective_path.h @@ -38,6 +38,8 @@ public: virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); + virtual void refresh(Gtk::Entry* perspective); + virtual Gtk::Widget * newWidget(); /* the knotholder entity classes must be declared friends */ friend class PP::KnotHolderEntityOffset; void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); @@ -52,6 +54,7 @@ private: BoolParam uses_plane_xy; // there are all kinds of parameters. Check the /live_effects/parameter directory which types exist! + bool unapply; Geom::Point orig; LPEPerspectivePath(const LPEPerspectivePath&); diff --git a/src/live_effects/lpe-powerstroke-interpolators.h b/src/live_effects/lpe-powerstroke-interpolators.h index 6f5b75af8..986bd3544 100644 --- a/src/live_effects/lpe-powerstroke-interpolators.h +++ b/src/live_effects/lpe-powerstroke-interpolators.h @@ -27,7 +27,8 @@ enum InterpolatorType { INTERP_LINEAR, INTERP_CUBICBEZIER, INTERP_CUBICBEZIER_JOHAN, - INTERP_SPIRO + INTERP_SPIRO, + INTERP_CENTRIPETAL_CATMULLROM }; class Interpolator { @@ -168,7 +169,88 @@ private: }; -Interpolator* +// Quick mockup for testing the behavior for powerstroke controlpoint interpolation +class CentripetalCatmullRomInterpolator : public Interpolator { +public: + CentripetalCatmullRomInterpolator() {}; + virtual ~CentripetalCatmullRomInterpolator() {}; + + virtual Path interpolateToPath(std::vector<Point> const &points) const { + unsigned int n_points = points.size(); + + Geom::Path fit(points.front()); + + if (n_points < 3) return fit; // TODO special cases for 0,1 and 2 input points + + // return n_points-1 cubic segments + + // duplicate first point + fit.append(calc_bezier(points[0],points[0],points[1],points[2])); + + for (std::size_t i = 0; i < n_points-2; ++i) { + Point p0 = points[i]; + Point p1 = points[i+1]; + Point p2 = points[i+2]; + Point p3 = (i < n_points-3) ? points[i+3] : points[i+2]; + + fit.append(calc_bezier(p0, p1, p2, p3)); + } + + return fit; + }; + +private: + CubicBezier calc_bezier(Point p0, Point p1, Point p2, Point p3) const { + // create interpolating bezier between p1 and p2 + + // Part of the code comes from StackOverflow user eriatarka84 + // http://stackoverflow.com/a/23980479/2929337 + + // calculate time coords (deltas) of points + // the factor 0.25 can be generalized for other Catmull-Rom interpolation types + // see alpha in Yuksel et al. "On the Parameterization of Catmull-Rom Curves", + // --> http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf + double dt0 = powf(distanceSq(p0, p1), 0.25); + double dt1 = powf(distanceSq(p1, p2), 0.25); + double dt2 = powf(distanceSq(p2, p3), 0.25); + + + // safety check for repeated points + double eps = Geom::EPSILON; + if (dt1 < eps) + dt1 = 1.0; + if (dt0 < eps) + dt0 = dt1; + if (dt2 < eps) + dt2 = dt1; + + // compute tangents when parameterized in [t1,t2] + Point tan1 = (p1 - p0) / dt0 - (p2 - p0) / (dt0 + dt1) + (p2 - p1) / dt1; + Point tan2 = (p2 - p1) / dt1 - (p3 - p1) / (dt1 + dt2) + (p3 - p2) / dt2; + // rescale tangents for parametrization in [0,1] + tan1 *= dt1; + tan2 *= dt1; + + // create bezier from tangents (this is already in 2geom somewhere, or should be moved to it) + // the tangent of a bezier curve is: B'(t) = 3(1-t)^2 (b1 - b0) + 6(1-t)t(b2-b1) + 3t^2(b3-b2) + // So we have to make sure that B'(0) = tan1 and B'(1) = tan2, and we already know that b0=p1 and b3=p2 + // tan1 = B'(0) = 3 (b1 - p1) --> p1 + (tan1)/3 = b1 + // tan2 = B'(1) = 3 (p2 - b2) --> p2 - (tan2)/3 = b2 + + Point b0 = p1; + Point b1 = p1 + tan1 / 3; + Point b2 = p2 - tan2 / 3; + Point b3 = p2; + + return CubicBezier(b0, b1, b2, b3); + } + + CentripetalCatmullRomInterpolator(const CentripetalCatmullRomInterpolator&); + CentripetalCatmullRomInterpolator& operator=(const CentripetalCatmullRomInterpolator&); +}; + + +inline Interpolator* Interpolator::create(InterpolatorType type) { switch (type) { case INTERP_LINEAR: @@ -179,6 +261,8 @@ Interpolator::create(InterpolatorType type) { return new Geom::Interpolate::CubicBezierJohan(); case INTERP_SPIRO: return new Geom::Interpolate::SpiroInterpolator(); + case INTERP_CENTRIPETAL_CATMULLROM: + return new Geom::Interpolate::CentripetalCatmullRomInterpolator(); default: return new Geom::Interpolate::Linear(); } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 90b01aaa4..5bfe88ed1 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -188,7 +188,8 @@ static const Util::EnumData<unsigned> InterpolatorTypeData[] = { {Geom::Interpolate::INTERP_LINEAR , N_("Linear"), "Linear"}, {Geom::Interpolate::INTERP_CUBICBEZIER , N_("CubicBezierFit"), "CubicBezierFit"}, {Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN , N_("CubicBezierJohan"), "CubicBezierJohan"}, - {Geom::Interpolate::INTERP_SPIRO , N_("SpiroInterpolator"), "SpiroInterpolator"} + {Geom::Interpolate::INTERP_SPIRO , N_("SpiroInterpolator"), "SpiroInterpolator"}, + {Geom::Interpolate::INTERP_CENTRIPETAL_CATMULLROM, N_("Centripetal Catmull-Rom"), "CentripetalCatmullRom"} }; static const Util::EnumDataConverter<unsigned> InterpolatorTypeConverter(InterpolatorTypeData, sizeof(InterpolatorTypeData)/sizeof(*InterpolatorTypeData)); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 9af849530..5f6acd6f4 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -2,9 +2,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtkmm.h> - #include "live_effects/lpe-roughen.h" +#include <gtkmm/separator.h> + #include "display/curve.h" #include "live_effects/parameter/parameter.h" #include "helper/geom.h" @@ -82,7 +82,11 @@ Gtk::Widget *LPERoughen::newWidget() { Glib::ustring(_("<b>Roughen unit</b>")), Gtk::ALIGN_START)); unitLabel->set_use_markup(true); vbox->pack_start(*unitLabel, false, false, 2); +#if WITH_GTKMM_3_0 + vbox->pack_start(*Gtk::manage(new Gtk::Separator()), +#else vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), +#endif Gtk::PACK_EXPAND_WIDGET); } if (param->param_key == "method") { @@ -91,7 +95,11 @@ Gtk::Widget *LPERoughen::newWidget() { Gtk::ALIGN_START)); methodLabel->set_use_markup(true); vbox->pack_start(*methodLabel, false, false, 2); +#if WITH_GTKMM_3_0 + vbox->pack_start(*Gtk::manage(new Gtk::Separator()), +#else vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), +#endif Gtk::PACK_EXPAND_WIDGET); } if (param->param_key == "displaceX") { @@ -100,7 +108,11 @@ Gtk::Widget *LPERoughen::newWidget() { Gtk::ALIGN_START)); displaceXLabel->set_use_markup(true); vbox->pack_start(*displaceXLabel, false, false, 2); +#if WITH_GTKMM_3_0 + vbox->pack_start(*Gtk::manage(new Gtk::Separator()), +#else vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), +#endif Gtk::PACK_EXPAND_WIDGET); } Glib::ustring *tip = param->param_getTooltip(); diff --git a/src/live_effects/lpe-show_handles.cpp b/src/live_effects/lpe-show_handles.cpp new file mode 100644 index 000000000..7b2b445b7 --- /dev/null +++ b/src/live_effects/lpe-show_handles.cpp @@ -0,0 +1,211 @@ +/* + * Authors: + * Jabier Arraiza Cenoz +* +* Copyright (C) Jabier Arraiza Cenoz 2014 <jabier.arraiza@marker.es> + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <gtkmm.h> +#include <glibmm/i18n.h> +#include "live_effects/lpe-show_handles.h" +#include "live_effects/parameter/parameter.h" +#include <2geom/sbasis-to-bezier.h> +#include <2geom/svg-path-parser.h> +#include "helper/geom.h" +#include "desktop-style.h" +#include "style.h" +#include "svg/svg.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEShowHandles::LPEShowHandles(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + nodes(_("Show nodes"), _("Show nodes"), "nodes", &wr, this, true), + handles(_("Show handles"), _("Show handles"), "handles", &wr, this, true), + originalPath(_("Show path"), _("Show path"), "originalPath", &wr, this, true), + scaleNodesAndHandles(_("Scale nodes and handles"), _("Scale nodes and handles"), "scaleNodesAndHandles", &wr, this, 10) +{ + registerParameter(dynamic_cast<Parameter *>(&nodes)); + registerParameter(dynamic_cast<Parameter *>(&handles)); + registerParameter(dynamic_cast<Parameter *>(&originalPath)); + registerParameter(dynamic_cast<Parameter *>(&scaleNodesAndHandles)); + scaleNodesAndHandles.param_set_range(0, 500.); + scaleNodesAndHandles.param_set_increments(1, 1); + scaleNodesAndHandles.param_set_digits(2); + strokeWidth = 1.0; +} + +bool LPEShowHandles::alertsOff = false; + +/** + * Sets default styles to element + * this permanently remove.some styles of the element + */ + +void LPEShowHandles::doOnApply(SPLPEItem const* lpeitem) +{ + if(!alertsOff) { + char *msg = _("The \"show handles\" path effect will remove any custom style on the object you are applying it to. If this is not what you want, click Cancel."); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL, true); + gint response = dialog.run(); + alertsOff = true; + if(response == GTK_RESPONSE_CANCEL) { + SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem); + item->removeCurrentPathEffect(false); + return; + } + } + SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem); + SPCSSAttr *css = sp_repr_css_attr_new (); + sp_repr_css_set_property (css, "stroke", "black"); + sp_repr_css_set_property (css, "stroke-width", "1"); + sp_repr_css_set_property (css, "stroke-linecap", "butt"); + sp_repr_css_set_property(css, "fill", "none"); + + sp_desktop_apply_css_recursive(item, css, true); + sp_repr_css_attr_unref (css); +} + +void LPEShowHandles::doBeforeEffect (SPLPEItem const* lpeitem) +{ + SPItem const* item = SP_ITEM(lpeitem); + strokeWidth = item->style->stroke_width.computed; +} + +std::vector<Geom::Path> LPEShowHandles::doEffect_path (std::vector<Geom::Path> const & path_in) +{ + std::vector<Geom::Path> path_out; + Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(path_in); + if(originalPath) { + for (unsigned int i=0; i < path_in.size(); i++) { + path_out.push_back(path_in[i]); + } + } + if(!outlinepath.empty()) { + outlinepath.clear(); + } + generateHelperPath(original_pathv); + for (unsigned int i=0; i < outlinepath.size(); i++) { + path_out.push_back(outlinepath[i]); + } + return path_out; +} + +void +LPEShowHandles::generateHelperPath(Geom::PathVector result) +{ + if(!handles && !nodes) { + return; + } + + Geom::CubicBezier const *cubic = NULL; + for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) { + //Si está vacÃo... + if (path_it->empty()) { + continue; + } + //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + if(nodes) { + drawNode(curve_it1->initialPoint()); + } + while (curve_it1 != curve_endit) { + cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); + if (cubic) { + if(handles) { + if(!are_near((*cubic)[0],(*cubic)[1])){ + drawHandle((*cubic)[1]); + drawHandleLine((*cubic)[0],(*cubic)[1]); + } + if(!are_near((*cubic)[3],(*cubic)[2])){ + drawHandle((*cubic)[2]); + drawHandleLine((*cubic)[3],(*cubic)[2]); + } + } + } + if(nodes) { + drawNode(curve_it1->finalPoint()); + } + ++curve_it1; + if(curve_it2 != curve_endit){ + ++curve_it2; + } + } + } +} + +void +LPEShowHandles::drawNode(Geom::Point p) +{ + if(strokeWidth * scaleNodesAndHandles > 0.0) { + double diameter = strokeWidth * scaleNodesAndHandles; + char const * svgd; + svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + pathv *= Geom::Affine(diameter,0,0,diameter,0,0); + pathv += p - Geom::Point(diameter/2,diameter/2); + outlinepath.push_back(pathv[0]); + outlinepath.push_back(pathv[1]); + } +} + +void +LPEShowHandles::drawHandle(Geom::Point p) +{ + if(strokeWidth * scaleNodesAndHandles > 0.0) { + double diameter = strokeWidth * scaleNodesAndHandles; + char const * svgd; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; + Geom::PathVector pathv = sp_svg_read_pathv(svgd); + pathv *= Geom::Affine(diameter,0,0,diameter,0,0); + pathv += p - Geom::Point(diameter * 0.35,diameter * 0.35); + outlinepath.push_back(pathv[0]); + } +} + + +void +LPEShowHandles::drawHandleLine(Geom::Point p,Geom::Point p2) +{ + Geom::Path path; + double diameter = strokeWidth * scaleNodesAndHandles; + if(diameter > 0.0 && Geom::distance(p,p2) > (diameter * 0.35)){ + Geom::Ray ray2(p, p2); + p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); + } + path.start( p ); + path.appendNew<Geom::LineSegment>( p2 ); + outlinepath.push_back(path); +} + +}; //namespace LivePathEffect +}; /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-show_handles.h b/src/live_effects/lpe-show_handles.h new file mode 100644 index 000000000..278908bb5 --- /dev/null +++ b/src/live_effects/lpe-show_handles.h @@ -0,0 +1,61 @@ +#ifndef INKSCAPE_LPE_SHOW_HANDLES_H +#define INKSCAPE_LPE_SHOW_HANDLES_H + +/* + * Authors: + * Jabier Arraiza Cenoz +* +* Copyright (C) Jabier Arraiza Cenoz 2014 <jabier.arraiza@marker.es> + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/lpegroupbbox.h" +#include "live_effects/parameter/bool.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEShowHandles : public Effect , GroupBBoxEffect { + +public: + LPEShowHandles(LivePathEffectObject *lpeobject); + virtual ~LPEShowHandles(){} + + virtual void doOnApply(SPLPEItem const* lpeitem); + + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + + virtual void generateHelperPath(Geom::PathVector result); + + virtual void drawNode(Geom::Point p); + + virtual void drawHandle(Geom::Point p); + + virtual void drawHandleLine(Geom::Point p,Geom::Point p2); + +protected: + + virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); + +private: + + BoolParam nodes; + BoolParam handles; + BoolParam originalPath; + ScalarParam scaleNodesAndHandles; + double strokeWidth; + static bool alertsOff; + + Geom::PathVector outlinepath; + + LPEShowHandles(const LPEShowHandles &); + LPEShowHandles &operator=(const LPEShowHandles &); + +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape +#endif + +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 1a02375cd..a817f30f1 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -202,33 +202,27 @@ LPESimplify::generateHelperPath(Geom::PathVector result) if(nodes){ drawNode(curve_it1->initialPoint()); } - while (curve_it2 != curve_endit) { - cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); - if (cubic) { - if(handles){ - drawHandle((*cubic)[1]); - drawHandle((*cubic)[2]); - drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[2],(*cubic)[3]); + while (curve_it1 != curve_endit) { + cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); + if (cubic) { + if(handles) { + if(!are_near((*cubic)[0],(*cubic)[1])){ + drawHandle((*cubic)[1]); + drawHandleLine((*cubic)[0],(*cubic)[1]); + } + if(!are_near((*cubic)[3],(*cubic)[2])){ + drawHandle((*cubic)[2]); + drawHandleLine((*cubic)[3],(*cubic)[2]); + } + } + } + if(nodes) { + drawNode(curve_it1->finalPoint()); + } + ++curve_it1; + if(curve_it2 != curve_endit){ + ++curve_it2; } - } - if(nodes){ - drawNode(curve_it1->finalPoint()); - } - ++curve_it1; - ++curve_it2; - } - cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); - if (cubic) { - if(handles){ - drawHandle((*cubic)[1]); - drawHandle((*cubic)[2]); - drawHandleLine((*cubic)[0],(*cubic)[1]); - drawHandleLine((*cubic)[2],(*cubic)[3]); - } - } - if(nodes){ - drawNode(curve_it1->finalPoint()); } } } @@ -238,13 +232,12 @@ LPESimplify::drawNode(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0.999993,0.5 C 1.000065,0.7757576 0.7761859,1 0.4999926,1 0.2237994,1 -7.933901e-5,0.7757576 -7.339015e-6,0.5 -7.933901e-5,0.2242424 0.2237994,0 0.4999926,0 0.7761859,0 1.000065,0.2242424 0.999993,0.5 Z m -0.058561,0 C 0.9414949,0.74327 0.7438375,0.9416286 0.4999928,0.9416286 0.2561481,0.9416286 0.0584908,0.74327 0.0585543,0.5 0.0584908,0.25673 0.2561481,0.0583714 0.4999928,0.0583714 0.7438375,0.0583714 0.9414949,0.25673 0.9414313,0.5 Z m -0.3828447,0 c 8.5e-6,0.030303 -0.026228,0.060606 -0.058593,0.060606 -0.032366,0 -0.058603,-0.030303 -0.058593,-0.060606 -8.5e-6,-0.030303 0.026227,-0.060606 0.058593,-0.060606 0.032366,0 0.058603,0.030303 0.058593,0.060606 z"; + svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.5*r,0.5*r); hp.push_back(pathv[0]); hp.push_back(pathv[1]); - hp.push_back(pathv[2]); } void @@ -252,7 +245,7 @@ LPESimplify::drawHandle(Geom::Point p) { double r = helper_size/0.67; char const * svgd; - svgd = "M 0.6999623,0.35 C 0.7000128,0.5430303 0.5433044,0.7 0.3499775,0.7 0.1566506,0.7 -5.778776e-5,0.5430303 -7.344202e-6,0.35 -5.778776e-5,0.1569697 0.1566506,0 0.3499775,0 0.5433044,0 0.7000128,0.1569697 0.6999623,0.35 Z"; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Geom::Affine(r,0,0,r,0,0); pathv += p - Geom::Point(0.35*r,0.35*r); @@ -265,6 +258,11 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) { Geom::Path path; path.start( p ); + double diameter = helper_size/0.67; + if(helper_size > 0.0 && Geom::distance(p,p2) > (diameter * 0.35)){ + Geom::Ray ray2(p, p2); + p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); + } path.appendNew<Geom::LineSegment>( p2 ); hp.push_back(path); } diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index 457b68dd2..a89a6279b 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -8,12 +8,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "ui/dialog/lpe-fillet-chamfer-properties.h" +#include "live_effects/parameter/filletchamferpointarray.h" #include <2geom/piecewise.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis-geometric.h> -#include "ui/dialog/lpe-fillet-chamfer-properties.h" -#include "live_effects/parameter/filletchamferpointarray.h" #include "live_effects/effect.h" #include "svg/svg.h" #include "svg/stringstream.h" @@ -332,10 +332,10 @@ void FilletChamferPointArrayParam::recalculate_knots( result.push_back(Point(xPos, 0)); } ++curve_it1; - ++curve_it2; if (curve_it2 != curve_endit) { - counter++; + ++curve_it2; } + counter++; counterCurves++; } } @@ -552,31 +552,40 @@ Point FilletChamferPointArrayParamKnotHolderEntity::knot_get() const void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state) { if (state & GDK_CONTROL_MASK) { - using namespace Geom; - double type = _pparam->_vector.at(_index)[Y] + 1; - if (type > 4) { - type = 1; - } - _pparam->_vector.at(_index) = Point(_pparam->_vector.at(_index)[X], type); - _pparam->param_set_and_write_new_value(_pparam->_vector); - sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); - const gchar *tip; - if (type == 3) { - tip = _("<b>Chamfer</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); - } else if (type == 2) { - tip = _("<b>Inverse Fillet</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); - } else if (type == 1) { - tip = _("<b>Fillet</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); - } else { - tip = _("<b>Double Chamfer</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); + if (state & GDK_MOD1_MASK) { + _pparam->_vector.at(_index) = Point(_index, _pparam->_vector.at(_index)[Y]); + _pparam->param_set_and_write_new_value(_pparam->_vector); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + }else{ + using namespace Geom; + double type = _pparam->_vector.at(_index)[Y] + 1; + if (type > 4) { + type = 1; + } + _pparam->_vector.at(_index) = Point(_pparam->_vector.at(_index)[X], type); + _pparam->param_set_and_write_new_value(_pparam->_vector); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + const gchar *tip; + if (type == 3) { + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == 2) { + tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else if (type == 1) { + tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } else { + tip = _("<b>Double Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); + } + this->knot->tip = g_strdup(tip); + this->knot->show(); } - this->knot->tip = g_strdup(tip); - this->knot->show(); - //} } else if ((state & GDK_MOD1_MASK) || (state & GDK_SHIFT_MASK)) { Geom::Point offset = Geom::Point(_pparam->_vector.at(_index).x(), _pparam->_vector.at(_index).y()); @@ -619,18 +628,23 @@ void FilletChamferPointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, } const gchar *tip; if (_vector[i][Y] == 3) { - tip = _("<b>Chamfer</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); } else if (_vector[i][Y] == 2) { - tip = _("<b>Inverse Fillet</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); + tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); } else if (_vector[i][Y] == 1) { - tip = _("<b>Fillet</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); + tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); } else { - tip = _("<b>Double Chamfer</b>: <b>Ctrl+click</b> toogle type, " - "<b>Shift+click</b> open dialog"); + tip = _("<b>Double Chamfer</b>: <b>Ctrl+Click</b> toogle type, " + "<b>Shift+Click</b> open dialog, " + "<b>Ctrl+Alt+Click</b> reset"); } + FilletChamferPointArrayParamKnotHolderEntity *e = new FilletChamferPointArrayParamKnotHolderEntity(this, i); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 7732eee76..7a2fd9769 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -36,14 +36,12 @@ Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip, { } - void Parameter::param_write_to_repr(const char * svgd) { param_effect->getRepr()->setAttribute(param_key.c_str(), svgd); } - // In gtk2, this wasn't an issue; we could toss around // G_MAXDOUBLE and not worry about size allocations. But // in gtk3, it is an issue: it allocates widget size for the maxmium @@ -51,6 +49,12 @@ Parameter::param_write_to_repr(const char * svgd) // If you need this to be more, please be conservative about it. const double SCALARPARAM_G_MAXDOUBLE = 10000000000; +void Parameter::write_to_SVG(void) +{ + gchar * str = param_getSVGValue(); + param_write_to_repr(str); + g_free(str); +} /*########################################### * REAL PARAM diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 785ada92e..2e6cae49f 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -49,7 +49,7 @@ public: virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted. virtual gchar * param_getSVGValue() const = 0; - void write_to_SVG() { param_write_to_repr(param_getSVGValue()); } + void write_to_SVG(); virtual void param_set_default() = 0; diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 5658d238f..c5da8b858 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -5,10 +5,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtkmm.h> +#include "ui/widget/registered-widget.h" #include <glibmm/i18n.h> -#include "ui/widget/registered-widget.h" #include "live_effects/parameter/togglebutton.h" #include "live_effects/effect.h" #include "svg/svg.h" @@ -75,7 +74,12 @@ ToggleButtonParam::param_newWidget() false, param_effect->getRepr(), param_effect->getSPDoc()) ); +#if GTK_CHECK_VERSION(3,0,0) + GtkWidget * boxButton = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(boxButton), false); +#else GtkWidget * boxButton = gtk_hbox_new (false, 0); +#endif GtkWidget * labelButton = gtk_label_new (""); if (!param_label.empty()) { if(value || inactiveLabel.empty()){ diff --git a/src/macros.h b/src/macros.h index b221ebdc2..cbb9bca78 100644 --- a/src/macros.h +++ b/src/macros.h @@ -1,7 +1,7 @@ -#ifndef __MACROS_H__ -#define __MACROS_H__ +#ifndef SEEN_MACROS_H +#define SEEN_MACROS_H -/* +/** * Useful macros for inkscape * * Author: @@ -12,6 +12,9 @@ * Released under GNU GPL */ +// I'm of the opinion that this file should be removed, so I will in the future take the necessary steps to wipe it out. +// Macros are not in general bad, but these particular ones are rather ugly. Especially that sp_round one. --Liam + #ifdef SP_MACROS_SILENT #define SP_PRINT_MATRIX(s,m) #define SP_PRINT_TRANSFORM(s,t) @@ -51,4 +54,4 @@ fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/marker.cpp b/src/marker.cpp index 7fee16ead..a4cbc30ca 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -52,7 +52,7 @@ SPMarker::SPMarker() : SPGroup(), SPViewBox() { this->markerUnits = 0; this->markerUnits_set = 0; - this->orient_auto = 0; + this->orient_mode = MARKER_ORIENT_ANGLE; this->orient_set = 0; this->orient = 0; @@ -158,16 +158,20 @@ void SPMarker::set(unsigned int key, const gchar* value) { case SP_ATTR_ORIENT: this->orient_set = FALSE; - this->orient_auto = FALSE; + this->orient_mode = MARKER_ORIENT_ANGLE; this->orient = 0.0; if (value) { - if (!strcmp (value, "auto")) { - this->orient_auto = TRUE; - this->orient_set = TRUE; - } else if (sp_svg_number_read_f (value, &this->orient)) { - this->orient_set = TRUE; - } + if (!strcmp (value, "auto")) { + this->orient_mode = MARKER_ORIENT_AUTO; + this->orient_set = TRUE; + } else if (!strcmp (value, "auto-start-reverse")) { + this->orient_mode = MARKER_ORIENT_AUTO_START_REVERSE; + this->orient_set = TRUE; + } else if (sp_svg_number_read_f (value, &this->orient)) { + this->orient_mode = MARKER_ORIENT_ANGLE; + this->orient_set = TRUE; + } } this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -264,15 +268,17 @@ Inkscape::XML::Node* SPMarker::write(Inkscape::XML::Document *xml_doc, Inkscape: } if (this->orient_set) { - if (this->orient_auto) { - repr->setAttribute("orient", "auto"); - } else { - sp_repr_set_css_double(repr, "orient", this->orient); - } + if (this->orient_mode == MARKER_ORIENT_AUTO) { + repr->setAttribute("orient", "auto"); + } else if (this->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) { + repr->setAttribute("orient", "auto-start-reverse"); + } else { + sp_repr_set_css_double(repr, "orient", this->orient); + } } else { - repr->setAttribute("orient", NULL); + repr->setAttribute("orient", NULL); } - + /* fixme: */ //XML Tree being used directly here while it shouldn't be.... repr->setAttribute("viewBox", this->getRepr()->attribute("viewBox")); @@ -381,7 +387,10 @@ sp_marker_show_instance ( SPMarker *marker, Inkscape::DrawingItem *parent, } if (v->items[pos]) { Geom::Affine m; - if (marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_AUTO) { + m = base; + } else if (marker->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) { + m = Geom::Rotate::from_degrees( 180.0 ) * base; m = base; } else { /* fixme: Orient units (Lauris) */ diff --git a/src/marker.h b/src/marker.h index 585615476..9eefcdf16 100644 --- a/src/marker.h +++ b/src/marker.h @@ -32,6 +32,12 @@ struct SPMarkerView; #include "uri-references.h" #include "viewbox.h" +enum markerOrient { + MARKER_ORIENT_ANGLE, + MARKER_ORIENT_AUTO, + MARKER_ORIENT_AUTO_START_REVERSE +}; + class SPMarker : public SPGroup, public SPViewBox { public: SPMarker(); @@ -51,7 +57,7 @@ public: /* orient */ unsigned int orient_set : 1; - unsigned int orient_auto : 1; + markerOrient orient_mode : 2; float orient; /* Private views */ diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp index 4fd68f8ed..e6c78403b 100644 --- a/src/perspective-line.cpp +++ b/src/perspective-line.cpp @@ -1,6 +1,4 @@ -#define __PERSPECTIVE_LINE_C__ - -/* +/** * Perspective line for 3D perspectives * * Authors: @@ -40,4 +38,4 @@ PerspectiveLine::PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/proj_pt.cpp b/src/proj_pt.cpp index 28286948d..f5cca8fca 100644 --- a/src/proj_pt.cpp +++ b/src/proj_pt.cpp @@ -1,6 +1,4 @@ -#define __PROJ_PT_C__ - -/* +/** * 3x4 transformation matrix to map points from projective 3-space into the projective plane * * Authors: @@ -117,4 +115,4 @@ Pt3::coord_string() { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/proj_pt.h b/src/proj_pt.h index 90b9df201..28ec0aca3 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -1,7 +1,4 @@ -#ifndef __PROJ_PT_H__ -#define __PROJ_PT_H__ - -/* +/** * 3x4 transformation matrix to map points from projective 3-space into the projective plane * * Authors: @@ -12,8 +9,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_PROJ_PT_H +#define SEEN_PROJ_PT_H + #include <2geom/point.h> -#include <gtk/gtk.h> +#include <glib.h> namespace Proj { @@ -157,7 +157,7 @@ private: } // namespace Proj -#endif /* __PROJ_PT_H__ */ +#endif // !SEEN_PROJ_PT_H /* Local Variables: @@ -168,4 +168,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index d77c06a95..c1c315835 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1466,7 +1466,7 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate) +void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center) { if (selection->isEmpty()) return; @@ -1621,14 +1621,13 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate); } - // if we're transforming the actual object, not just updating the repr, we can transform the - // center by the same matrix (only necessary for non-translations) - if (set_i2d && item->isCenterSet() && !(affine.isTranslation() || affine.isIdentity())) { - // If there's a viewbox, we might have an affine with a translation component; - // we will only apply the scaling/skewing components, not the translations - // because otherwise the center will move relative to the item - item->setCenter(old_center * affine.withoutTranslation()); - item->updateRepr(); + if (adjust_transf_center) { // The transformation center should not be touched in case of pasting or importing, which is allowed by this if clause + // if we're moving the actual object, not just updating the repr, we can transform the + // center by the same matrix (only necessary for non-translations) + if (set_i2d && item->isCenterSet() && !(affine.isTranslation() || affine.isIdentity())) { + item->setCenter(old_center * affine); + item->updateRepr(); + } } } } diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index d76a67a9d..01c35d65a 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -104,7 +104,7 @@ void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ) void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false ); -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true); +void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); void sp_selection_remove_transform (SPDesktop *desktop); void sp_selection_scale_absolute (Inkscape::Selection *selection, double x0, double x1, double y0, double y1); void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 6b8cd19bb..e15249f94 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -9,7 +9,7 @@ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski - * Copyright (C) 1999-2008 Authors + * Copyright (C) 1999-2014 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -1109,10 +1109,17 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, Geom::P break; } + // _point and _origin are noisy, ranging from 1 to 1e-9 or even smaller; this is due to the + // limited SVG output precision, which can be arbitrarily set in the preferences Geom::Point const initial_delta = _point - _origin; - if (fabs(initial_delta[dim_a]) < 1e-15) { - return false; + // The handle and the origin shouldn't be too close to each other; let's check for that! + // Due to the limited resolution though (see above), we'd better use a relative error here + if (_bbox) { + Geom::Coord d = (*_bbox).dimensions()[dim_a]; + if (fabs(initial_delta[dim_a]/d) < 1e-4) { + return false; + } } // Calculate the scale factors, which can be either visual or geometric diff --git a/src/snap.cpp b/src/snap.cpp index ea6322e37..5b795b22f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -274,7 +274,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint /* See the documentation for constrainedSnap() directly above for more details. * The difference is that multipleConstrainedSnaps() will take a list of constraints instead of a single one, - * and will try to snap the SnapCandidatePoint to all of the provided constraints and see which one fits best + * and will try to snap the SnapCandidatePoint to only the closest constraint * \param p Source point to be snapped * \param constraints List of directions or lines along which snapping must occur * \param dont_snap If true then we will only apply the constraint, without snapping @@ -293,16 +293,11 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi return no_snap; } - IntermSnapResults isr; - SnapperList const snappers = getSnappers(); - std::vector<Geom::Point> projections; - bool snapping_is_futile = !someSnapperMightSnap() || dont_snap; - - Inkscape::SnappedPoint result = no_snap; - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool snap_mouse = prefs->getBool("/options/snapmousepointer/value", false); + // We haven't tried to snap yet; we will first determine which constraint is closest to where we are now, + // i.e. lets find out which of the constraints yields the closest projection of point p + // Project the mouse pointer on each of the constraints + std::vector<Geom::Point> projections; for (std::vector<Inkscape::Snapper::SnapConstraint>::const_iterator c = constraints.begin(); c != constraints.end(); ++c) { // Project the mouse pointer onto the constraint; In case we don't snap then we will // return the projection onto the constraint, such that the constraint is always enforced @@ -310,55 +305,47 @@ Inkscape::SnappedPoint SnapManager::multipleConstrainedSnaps(Inkscape::SnapCandi projections.push_back(pp); } - if (snap_mouse && p.isSingleHandle() && !dont_snap) { + // Select the closest constraint + no_snap.setPoint(projections.front()); + Inkscape::Snapper::SnapConstraint cc = constraints.front(); //closest constraint + + std::vector<Inkscape::Snapper::SnapConstraint>::const_iterator c = constraints.begin(); + std::vector<Geom::Point>::iterator pp = projections.begin(); + for (; pp != projections.end(); ++pp) { + if (Geom::L2(*pp - p.getPoint()) < Geom::L2(no_snap.getPoint() - p.getPoint())) { + no_snap.setPoint(*pp); // Remember the projection onto the closest constraint + cc = *c; // Remember the closest constraint itself + } + ++c; + } + + if (!someSnapperMightSnap() || dont_snap) { + return no_snap; + } + + IntermSnapResults isr; + SnapperList const snappers = getSnappers(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool snap_mouse = prefs->getBool("/options/snapmousepointer/value", false); + + Inkscape::SnappedPoint result = no_snap; + if (snap_mouse && p.isSingleHandle()) { // Snapping the mouse pointer instead of the constrained position of the knot allows // to snap to things which don't intersect with the constraint line; this is basically // then just a freesnap with the constraint applied afterwards // We'll only to this if we're dragging a single handle, and for example not when transforming an object in the selector tool result = freeSnap(p, bbox_to_snap); + // Now apply the constraint afterwards + result.setPoint(cc.projection(result.getPoint())); } else { - // Iterate over the constraints - for (std::vector<Inkscape::Snapper::SnapConstraint>::const_iterator c = constraints.begin(); c != constraints.end(); ++c) { - // Try to snap to the constraint - if (!snapping_is_futile) { - for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { - (*i)->constrainedSnap(isr, p, bbox_to_snap, *c, &_items_to_ignore,_unselected_nodes); - } - } + // Try to snap along the closest constraint + for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); ++i) { + (*i)->constrainedSnap(isr, p, bbox_to_snap, cc, &_items_to_ignore,_unselected_nodes); } result = findBestSnap(p, isr, true); } - if (result.getSnapped()) { - if (snap_mouse) { - // If "snap_mouse" then we still have to apply the constraint, because so far we only tried a freeSnap - Geom::Point result_closest; - for (std::vector<Inkscape::Snapper::SnapConstraint>::const_iterator c = constraints.begin(); c != constraints.end(); ++c) { - // Project the mouse pointer onto the constraint; In case we don't snap then we will - // return the projection onto the constraint, such that the constraint is always enforced - Geom::Point result_p = (*c).projection(result.getPoint()); - if (c == constraints.begin() || (Geom::L2(result_p - p.getPoint()) < Geom::L2(result_closest - p.getPoint()))) { - result_closest = result_p; - } - } - result.setPoint(result_closest); - } - return result; - } - - // So we didn't snap, but we still need to return a point on one of the constraints - // Find out which of the constraints yielded the closest projection of point p - for (std::vector<Geom::Point>::iterator pp = projections.begin(); pp != projections.end(); ++pp) { - if (pp != projections.begin()) { - if (Geom::L2(*pp - p.getPoint()) < Geom::L2(no_snap.getPoint() - p.getPoint())) { - no_snap.setPoint(*pp); - } - } else { - no_snap.setPoint(projections.front()); - } - } - - return no_snap; + return result.getSnapped() ? result : no_snap; } Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandidatePoint const &p, diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index cda59e057..b5c6e4af8 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -14,26 +14,25 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "svg/svg.h" -#include "svg/path-string.h" -#include "xml/repr.h" -#include "attributes.h" -#include "style.h" -#include "display/curve.h" +#include <glibmm.h> #include <glibmm/i18n.h> + #include <2geom/angle.h> #include <2geom/ellipse.h> -#include <2geom/transforms.h> -#include <2geom/pathvector.h> #include <2geom/path-sink.h> +#include <2geom/pathvector.h> +#include <2geom/transforms.h> + +#include "attributes.h" +#include "display/curve.h" #include "document.h" -#include "sp-ellipse.h" #include "preferences.h" #include "snap-candidate.h" +#include "sp-ellipse.h" +#include "style.h" +#include "svg/svg.h" +#include "svg/path-string.h" +#include "xml/repr.h" #include "sp-factory.h" @@ -42,21 +41,21 @@ SPObject *create_ellipse() { SPGenericEllipse *ellipse = new SPGenericEllipse(); ellipse->type = SP_GENERIC_ELLIPSE_ELLIPSE; - return (SPObject*)ellipse; + return ellipse; } SPObject *create_circle() { SPGenericEllipse *circle = new SPGenericEllipse(); circle->type = SP_GENERIC_ELLIPSE_CIRCLE; - return (SPObject*)circle; + return circle; } SPObject *create_arc() { SPGenericEllipse *arc = new SPGenericEllipse(); arc->type = SP_GENERIC_ELLIPSE_ARC; - return (SPObject*)arc; + return arc; } bool ellipse_registered = SPFactory::instance().registerObject("svg:ellipse", create_ellipse); @@ -695,4 +694,4 @@ bool SPGenericEllipse::_isSlice() const fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index cb988b8bb..e575b8761 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -1,7 +1,4 @@ -#ifndef __SP_ELLIPSE_H__ -#define __SP_ELLIPSE_H__ - -/* +/** * SVG <ellipse> and related implementations * * Authors: @@ -16,12 +13,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_ELLIPSE_H +#define SEEN_SP_ELLIPSE_H + #include "svg/svg-length.h" #include "sp-shape.h" /* Common parent class */ -#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>((SPObject*)obj)) -#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((SPObject*)obj) != NULL) +#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>(obj)) +#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((obj)) != NULL) enum GenericEllipseType { SP_GENERIC_ELLIPSE_UNDEFINED, @@ -98,4 +98,4 @@ protected: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index ceb91c984..1f85c8193 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -19,14 +19,15 @@ #include <string.h> +#include "display/nr-filter-primitive.h" +#include "display/nr-filter-types.h" + #include "attributes.h" #include "style.h" #include "sp-filter-primitive.h" #include "xml/repr.h" #include "sp-filter.h" #include "sp-item.h" -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-types.h" // CPPIFY: Make pure virtual. diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index e8319baca..9a184952c 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -22,8 +22,9 @@ using std::map; using std::pair; -#include <glibmm/stringutils.h> +#include <glibmm.h> #include "attributes.h" +#include "display/nr-filter.h" #include "document.h" #include "sp-filter.h" #include "sp-filter-reference.h" @@ -37,8 +38,6 @@ using std::pair; #define SP_MACROS_SILENT #include "macros.h" -#include "display/nr-filter.h" - static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index be47c7621..f33d3c509 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -1,18 +1,12 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#define __SP_ANCHOR_C__ - -/* +/** * SVG <hkern> and <vkern> elements implementation * W3C SVG 1.1 spec, page 476, section 20.7 * - * Author: + * Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> * Abhishek Sharma * - * Copyright (C) 2008, Felipe C. da S. Sanches + * Copyright (C) 2008 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -26,45 +20,49 @@ #include <cstring> -SPGlyphKerning::SPGlyphKerning() : SPObject() { +SPGlyphKerning::SPGlyphKerning() + : SPObject() //TODO: correct these values: - this->u1 = NULL; - this->g1 = NULL; - this->u2 = NULL; - this->g2 = NULL; - this->k = 0; -} - -SPGlyphKerning::~SPGlyphKerning() { + , u1(NULL) + , g1(NULL) + , u2(NULL) + , g2(NULL) + , k(0) +{ } -void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPObject::build(document, repr); +void SPGlyphKerning::build(SPDocument *document, Inkscape::XML::Node *repr) +{ + SPObject::build(document, repr); - this->readAttr( "u1" ); - this->readAttr( "g1" ); - this->readAttr( "u2" ); - this->readAttr( "g2" ); - this->readAttr( "k" ); + this->readAttr( "u1" ); + this->readAttr( "g1" ); + this->readAttr( "u2" ); + this->readAttr( "g2" ); + this->readAttr( "k" ); } -void SPGlyphKerning::release() { - SPObject::release(); +void SPGlyphKerning::release() +{ + SPObject::release(); } -GlyphNames::GlyphNames(const gchar* value){ +GlyphNames::GlyphNames(const gchar* value) +{ if (value) { - this->names = strdup(value); + names = g_strdup(value); } } -GlyphNames::~GlyphNames(){ - if (this->names) { - g_free(this->names); +GlyphNames::~GlyphNames() +{ + if (names) { + g_free(names); } } -bool GlyphNames::contains(const char* name){ +bool GlyphNames::contains(const char* name) +{ if (!(this->names) || !name) { return false; } @@ -75,14 +73,15 @@ bool GlyphNames::contains(const char* name){ while (is >> str) { if (str == s) { - return true; + return true; } } return false; } -void SPGlyphKerning::set(unsigned int key, const gchar *value) { +void SPGlyphKerning::set(unsigned int key, const gchar *value) +{ switch (key) { case SP_ATTR_U1: { @@ -143,15 +142,16 @@ void SPGlyphKerning::set(unsigned int key, const gchar *value) { } /** - * * Receives update notifications. - * */ -void SPGlyphKerning::update(SPCtx *ctx, guint flags) { + * Receives update notifications. + */ +void SPGlyphKerning::update(SPCtx *ctx, guint flags) +{ if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - this->readAttr( "u1" ); - this->readAttr( "u2" ); - this->readAttr( "g2" ); - this->readAttr( "k" ); + this->readAttr( "u1" ); + this->readAttr( "u2" ); + this->readAttr( "g2" ); + this->readAttr( "k" ); } SPObject::update(ctx, flags); @@ -159,37 +159,26 @@ void SPGlyphKerning::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyphkerning");//fix this! - } - - /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca - repr->setAttribute("unicode", glyph->unicode); - repr->setAttribute("glyph-name", glyph->glyph_name); - repr->setAttribute("d", glyph->d); - sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); - sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); - repr->setAttribute("lang", glyph->lang); - sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); - sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); - sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); - sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); - */ - if (repr != this->getRepr()) { - // All the COPY_ATTR functions below use - // XML Tree directly, while they shouldn't. - COPY_ATTR(repr, this->getRepr(), "u1"); - COPY_ATTR(repr, this->getRepr(), "g1"); - COPY_ATTR(repr, this->getRepr(), "u2"); - COPY_ATTR(repr, this->getRepr(), "g2"); - COPY_ATTR(repr, this->getRepr(), "k"); - } - - SPObject::write(xml_doc, repr, flags); - - return repr; +Inkscape::XML::Node* SPGlyphKerning::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:glyphkerning"); // fix this! + } + + if (repr != this->getRepr()) { + // All the COPY_ATTR functions below use + // XML Tree directly, while they shouldn't. + COPY_ATTR(repr, this->getRepr(), "u1"); + COPY_ATTR(repr, this->getRepr(), "g1"); + COPY_ATTR(repr, this->getRepr(), "u2"); + COPY_ATTR(repr, this->getRepr(), "g2"); + COPY_ATTR(repr, this->getRepr(), "k"); + } + SPObject::write(xml_doc, repr, flags); + + return repr; } + /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index 5cae6b9dd..52413f8a7 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -1,10 +1,3 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifndef __SP_GLYPH_KERNING_H__ -#define __SP_GLYPH_KERNING_H__ - /* * SVG <hkern> and <vkern> elements implementation * @@ -16,41 +9,35 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_GLYPH_KERNING_H +#define SEEN_SP_GLYPH_KERNING_H + #include "sp-object.h" #include "unicoderange.h" -//#define SP_HKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_HKERN, SPHkern)) -//#define SP_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_HKERN, SPGlyphKerningClass)) -//#define SP_IS_HKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_HKERN)) -//#define SP_IS_HKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_HKERN)) +#define SP_HKERN(obj) (dynamic_cast<SPHkern*>(obj)) +#define SP_IS_HKERN(obj) (dynamic_cast<const SPHkern*>(obj) != NULL) -#define SP_HKERN(obj) (dynamic_cast<SPHkern*>((SPObject*)obj)) -#define SP_IS_HKERN(obj) (dynamic_cast<const SPHkern*>((SPObject*)obj) != NULL) - -//#define SP_VKERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_VKERN, SPVkern)) -//#define SP_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_VKERN, SPGlyphKerningClass)) -//#define SP_IS_VKERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_VKERN)) -//#define SP_IS_VKERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_VKERN)) - -#define SP_VKERN(obj) (dynamic_cast<SPVkern*>((SPObject*)obj)) -#define SP_IS_VKERN(obj) (dynamic_cast<const SPVkern*>((SPObject*)obj) != NULL) +#define SP_VKERN(obj) (dynamic_cast<SPVkern*>(obj)) +#define SP_IS_VKERN(obj) (dynamic_cast<const SPVkern*>(obj) != NULL) // CPPIFY: These casting macros are buggy, as Vkern and Hkern aren't "real" classes. -class GlyphNames{ +class GlyphNames { public: -GlyphNames(const gchar* value); -~GlyphNames(); -bool contains(const char* name); + GlyphNames(const gchar* value); + ~GlyphNames(); + bool contains(const char* name); private: -gchar* names; + gchar* names; }; class SPGlyphKerning : public SPObject { public: - SPGlyphKerning(); - virtual ~SPGlyphKerning(); + SPGlyphKerning(); + virtual ~SPGlyphKerning() {} + // FIXME encapsulation UnicodeRange* u1; GlyphNames* g1; UnicodeRange* u2; @@ -58,22 +45,30 @@ public: double k; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - - virtual void set(unsigned int key, const gchar* value); - - virtual void update(SPCtx* ctx, unsigned int flags); - - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const gchar* value); + virtual void update(SPCtx* ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); }; class SPHkern : public SPGlyphKerning { - + virtual ~SPHkern() {} }; class SPVkern : public SPGlyphKerning { - + virtual ~SPVkern() {} }; -#endif //#ifndef __SP_GLYPH_KERNING_H__ +#endif // !SEEN_SP_GLYPH_KERNING_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 695af03ba..eaa69d486 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -2,8 +2,6 @@ # include <config.h> #endif -#define __SP_GLYPH_C__ - /* * SVG <glyph> element implementation * @@ -25,46 +23,44 @@ #include "sp-factory.h" namespace { - SPObject* createGlyph() { - return new SPGlyph(); - } - - bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); + SPObject* createGlyph() { + return new SPGlyph(); + } + bool glyphRegistered = SPFactory::instance().registerObject("svg:glyph", createGlyph); } -SPGlyph::SPGlyph() : SPObject() { +SPGlyph::SPGlyph() + : SPObject() //TODO: correct these values: - - this->d = NULL; - this->orientation = GLYPH_ORIENTATION_BOTH; - this->arabic_form = GLYPH_ARABIC_FORM_INITIAL; - this->lang = NULL; - this->horiz_adv_x = 0; - this->vert_origin_x = 0; - this->vert_origin_y = 0; - this->vert_adv_y = 0; -} - -SPGlyph::~SPGlyph() { + , d(NULL) + , orientation(GLYPH_ORIENTATION_BOTH) + , arabic_form(GLYPH_ARABIC_FORM_INITIAL) + , lang(NULL) + , horiz_adv_x(0) + , vert_origin_x(0) + , vert_origin_y(0) + , vert_adv_y(0) +{ } -void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPObject::build(document, repr); +void SPGlyph::build(SPDocument *document, Inkscape::XML::Node *repr) +{ + SPObject::build(document, repr); - this->readAttr( "unicode" ); - this->readAttr( "glyph-name" ); - this->readAttr( "d" ); - this->readAttr( "orientation" ); - this->readAttr( "arabic-form" ); - this->readAttr( "lang" ); - this->readAttr( "horiz-adv-x" ); - this->readAttr( "vert-origin-x" ); - this->readAttr( "vert-origin-y" ); - this->readAttr( "vert-adv-y" ); + this->readAttr( "unicode" ); + this->readAttr( "glyph-name" ); + this->readAttr( "d" ); + this->readAttr( "orientation" ); + this->readAttr( "arabic-form" ); + this->readAttr( "lang" ); + this->readAttr( "horiz-adv-x" ); + this->readAttr( "vert-origin-x" ); + this->readAttr( "vert-origin-y" ); + this->readAttr( "vert-adv-y" ); } void SPGlyph::release() { - SPObject::release(); + SPObject::release(); } static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ @@ -97,7 +93,8 @@ static glyphArabicForm sp_glyph_read_arabic_form(gchar const *value){ return GLYPH_ARABIC_FORM_INITIAL; //TODO: VERIFY DEFAULT! } -static glyphOrientation sp_glyph_read_orientation(gchar const *value){ +static glyphOrientation sp_glyph_read_orientation(gchar const *value) +{ if (!value) { return GLYPH_ORIENTATION_BOTH; } @@ -115,7 +112,8 @@ static glyphOrientation sp_glyph_read_orientation(gchar const *value){ return GLYPH_ORIENTATION_BOTH; } -void SPGlyph::set(unsigned int key, const gchar *value) { +void SPGlyph::set(unsigned int key, const gchar *value) +{ switch (key) { case SP_ATTR_UNICODE: { @@ -228,21 +226,22 @@ void SPGlyph::set(unsigned int key, const gchar *value) { } /** - * * Receives update notifications. - * */ -void SPGlyph::update(SPCtx *ctx, guint flags) { + * Receives update notifications. + */ +void SPGlyph::update(SPCtx *ctx, guint flags) +{ if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - this->readAttr( "unicode" ); - this->readAttr( "glyph-name" ); - this->readAttr( "d" ); - this->readAttr( "orientation" ); - this->readAttr( "arabic-form" ); - this->readAttr( "lang" ); - this->readAttr( "horiz-adv-x" ); - this->readAttr( "vert-origin-x" ); - this->readAttr( "vert-origin-y" ); - this->readAttr( "vert-adv-y" ); + this->readAttr( "unicode" ); + this->readAttr( "glyph-name" ); + this->readAttr( "d" ); + this->readAttr( "orientation" ); + this->readAttr( "arabic-form" ); + this->readAttr( "lang" ); + this->readAttr( "horiz-adv-x" ); + this->readAttr( "vert-origin-x" ); + this->readAttr( "vert-origin-y" ); + this->readAttr( "vert-adv-y" ); } SPObject::update(ctx, flags); @@ -250,42 +249,45 @@ void SPGlyph::update(SPCtx *ctx, guint flags) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); -Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:glyph"); - } +Inkscape::XML::Node* SPGlyph::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +{ + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { + repr = xml_doc->createElement("svg:glyph"); + } - /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca - repr->setAttribute("unicode", glyph->unicode); - repr->setAttribute("glyph-name", glyph->glyph_name); - repr->setAttribute("d", glyph->d); - sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); - sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); - repr->setAttribute("lang", glyph->lang); - sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); - sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); - sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); - sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); - */ - if (repr != this->getRepr()) { - // All the COPY_ATTR functions below use - // XML Tree directly while they shouldn't. - COPY_ATTR(repr, this->getRepr(), "unicode"); - COPY_ATTR(repr, this->getRepr(), "glyph-name"); - COPY_ATTR(repr, this->getRepr(), "d"); - COPY_ATTR(repr, this->getRepr(), "orientation"); - COPY_ATTR(repr, this->getRepr(), "arabic-form"); - COPY_ATTR(repr, this->getRepr(), "lang"); - COPY_ATTR(repr, this->getRepr(), "horiz-adv-x"); - COPY_ATTR(repr, this->getRepr(), "vert-origin-x"); - COPY_ATTR(repr, this->getRepr(), "vert-origin-y"); - COPY_ATTR(repr, this->getRepr(), "vert-adv-y"); - } + /* I am commenting out this part because I am not certain how does it work. I will have to study it later. Juca + repr->setAttribute("unicode", glyph->unicode); + repr->setAttribute("glyph-name", glyph->glyph_name); + repr->setAttribute("d", glyph->d); + sp_repr_set_svg_double(repr, "orientation", (double) glyph->orientation); + sp_repr_set_svg_double(repr, "arabic-form", (double) glyph->arabic_form); + repr->setAttribute("lang", glyph->lang); + sp_repr_set_svg_double(repr, "horiz-adv-x", glyph->horiz_adv_x); + sp_repr_set_svg_double(repr, "vert-origin-x", glyph->vert_origin_x); + sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); + sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); + */ - SPObject::write(xml_doc, repr, flags); + if (repr != this->getRepr()) { + // All the COPY_ATTR functions below use + // XML Tree directly while they shouldn't. + COPY_ATTR(repr, this->getRepr(), "unicode"); + COPY_ATTR(repr, this->getRepr(), "glyph-name"); + COPY_ATTR(repr, this->getRepr(), "d"); + COPY_ATTR(repr, this->getRepr(), "orientation"); + COPY_ATTR(repr, this->getRepr(), "arabic-form"); + COPY_ATTR(repr, this->getRepr(), "lang"); + COPY_ATTR(repr, this->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, this->getRepr(), "vert-adv-y"); + } - return repr; + SPObject::write(xml_doc, repr, flags); + + return repr; } + /* Local Variables: mode:c++ diff --git a/src/sp-glyph.h b/src/sp-glyph.h index 798d9ff2f..e92357c94 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -1,13 +1,4 @@ -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifndef __SP_GLYPH_H__ -#define __SP_GLYPH_H__ - -/* - * SVG <glyph> element implementation - * +/** * Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> * @@ -16,6 +7,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_GLYPH_H +#define SEEN_SP_GLYPH_H + #include "sp-object.h" #define SP_GLYPH(obj) (dynamic_cast<SPGlyph*>((SPObject*)obj)) @@ -34,11 +28,16 @@ enum glyphOrientation { GLYPH_ORIENTATION_BOTH }; +/* + * SVG <glyph> element + */ + class SPGlyph : public SPObject { public: - SPGlyph(); - virtual ~SPGlyph(); + SPGlyph(); + virtual ~SPGlyph() {} + // FIXME encapsulation Glib::ustring unicode; Glib::ustring glyph_name; char* d; @@ -51,14 +50,23 @@ public: double vert_adv_y; protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void release(); - - virtual void set(unsigned int key, const gchar* value); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + virtual void set(unsigned int key, const gchar* value); + virtual void update(SPCtx* ctx, unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); - virtual void update(SPCtx* ctx, unsigned int flags); - - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); }; -#endif //#ifndef __SP_GLYPH_H__ +#endif // !SEEN_SP_GLYPH_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/sp-image.cpp b/src/sp-image.cpp index cb8ede2b2..b6177fae6 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -20,6 +20,7 @@ #include <cstring> #include <algorithm> #include <string> +#include <glibmm.h> #include <glib/gstdio.h> #include <2geom/rect.h> #include <2geom/transforms.h> diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 657aca692..bb52b0c55 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -660,12 +660,6 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) Geom::Translate const s(p); Geom::Affine final = s.inverse() * sc * s; - Geom::Point old_center(0,0); - if (item->isCenterSet()) { - item->scaleCenter(sc.inverse()); // Convert the old relative center position to the new coordinates already now - old_center = item->getCenter(); // because getCenter() will use the bbox midpoint, which is also already in the new coordinates - } - gchar const *conn_type = NULL; if (SP_IS_TEXT_TEXTPATH(item)) { SP_TEXT(item)->optimizeTextpathText(); @@ -710,7 +704,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) } if (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) { - item->setCenter(old_center * final); + item->scaleCenter(sc); // All coordinates have been scaled, so also the center must be scaled item->updateRepr(); } } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 251825299..ecaea1586 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -228,18 +228,25 @@ void SPItem::setExplicitlyHidden(bool val) { } /** - * Sets the transform_center_x and transform_center_y properties to retain the rotation centre - */ + * Sets the transform_center_x and transform_center_y properties to retain the rotation center +*/ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); + // Copied from DocumentProperties::onDocUnitChange() + gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); + gdouble viewscale = std::min(viewscale_h, viewscale_w); + // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { - transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; + // object centre is document coordinates (i.e. in pixels), so we need to consider the viewbox + // to translate to user units; transform_center_x/y is in user units + transform_center_x = (object_centre[Geom::X] - bbox->midpoint()[Geom::X])/viewscale; if (Geom::are_near(transform_center_x, 0)) // rounding error transform_center_x = 0; - transform_center_y = object_centre[Geom::Y] - bbox->midpoint()[Geom::Y]; + transform_center_y = (object_centre[Geom::Y] - bbox->midpoint()[Geom::Y])/viewscale; if (Geom::are_near(transform_center_y, 0)) // rounding error transform_center_y = 0; } @@ -255,16 +262,25 @@ bool SPItem::isCenterSet() const { return (transform_center_x != 0 || transform_center_y != 0); } +// Get the item's transformation center in document coordinates (i.e. in pixels) Geom::Point SPItem::getCenter() const { document->ensureUpToDate(); + // Copied from DocumentProperties::onDocUnitChange() + gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); + gdouble viewscale = std::min(viewscale_h, viewscale_w); + // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { - return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); + // transform_center_x/y are stored in user units, so we have to take the viewbox into account to translate to document coordinates + return bbox->midpoint() + Geom::Point (transform_center_x*viewscale, transform_center_y*viewscale); + } else { return Geom::Point(0, 0); // something's wrong! } + } void diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index ab14e75d2..300f2ad19 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -37,6 +37,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +// For color picking +#include "display/drawing.h" +#include "display/drawing-context.h" +#include "display/cairo-utils.h" +#include "document.h" +#include "sp-root.h" + #include "sp-mesh-array.h" #include "sp-mesh-gradient.h" #include "sp-mesh-row.h" @@ -51,13 +58,6 @@ // For writing color/opacity to style #include "svg/css-ostringstream.h" -// For color picking -#include "display/drawing.h" -#include "display/drawing-context.h" -#include "display/cairo-utils.h" -#include "document.h" -#include "sp-root.h" - // For default color #include "style.h" #include "svg/svg-color.h" diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index eb5ed1bd0..1b04a6f8e 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -1,8 +1,8 @@ -#include "sp-mesh-gradient.h" - #include "attributes.h" -#include "xml/repr.h" #include "display/cairo-utils.h" +#include "xml/repr.h" + +#include "sp-mesh-gradient.h" #include "sp-factory.h" diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9b7330a24..961ab0f84 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -18,7 +18,9 @@ #include <cstring> #include <string> +#include <glibmm.h> #include <2geom/transforms.h> + #include "macros.h" #include "svg/svg.h" #include "display/cairo-utils.h" diff --git a/src/sp-pattern.h b/src/sp-pattern.h index eb34b6714..8f7dbbadd 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -13,21 +13,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtk.h> - -#include "sp-item.h" - #define SP_PATTERN(obj) (dynamic_cast<SPPattern*>((SPObject*)obj)) #define SP_IS_PATTERN(obj) (dynamic_cast<const SPPattern*>((SPObject*)obj) != NULL) class SPPatternReference; +class SPItem; #include "svg/svg-length.h" #include "sp-paint-server.h" #include "uri-references.h" #include "viewbox.h" -#include <stddef.h> #include <sigc++/connection.h> diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index de9103dee..d76bd9780 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -288,8 +288,13 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) Geom::Affine const m (sp_shape_marker_get_transform_at_start(pathv.begin()->front())); for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( shape->_marker[i] ) { + Geom::Affine m_auto = m; + // Reverse start marker if necessary. + if (SP_MARKER(shape->_marker[i])->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) { + m_auto = Geom::Rotate::from_degrees( 180.0 ) * m; + } sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, - ai->key() + i, counter[i], m, + ai->key() + i, counter[i], m_auto, shape->style->stroke_width.computed); counter[i]++; } @@ -425,7 +430,10 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox if (marker_item) { Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); - if (!marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) { + // Reverse start marker if necessary + tr = Geom::Rotate::from_degrees( 180.0 ) * tr; + } else if (marker->orient_mode == MARKER_ORIENT_ANGLE) { Geom::Point transl = tr.translation(); tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } @@ -463,7 +471,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox { Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front())); - if (!marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_ANGLE) { Geom::Point transl = tr.translation(); tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } @@ -493,7 +501,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox if (marker_item) { Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); - if (!marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_ANGLE) { Geom::Point transl = tr.translation(); tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } @@ -516,7 +524,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::Curve const &lastcurve = path_it->back_default(); Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_ANGLE) { Geom::Point transl = tr.translation(); tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } @@ -551,7 +559,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { + if (marker->orient_mode == MARKER_ORIENT_ANGLE) { Geom::Point transl = tr.translation(); tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp index 1f606d176..9f6692f98 100644 --- a/src/sp-solid-color.cpp +++ b/src/sp-solid-color.cpp @@ -72,7 +72,7 @@ Inkscape::XML::Node* SPSolidColor::write(Inkscape::XML::Document* xml_doc, Inksc return repr; } -cairo_pattern_t* SPSolidColor::pattern_new(cairo_t * /*ct*/, Geom::OptRect const &bbox, double opacity) { +cairo_pattern_t* SPSolidColor::pattern_new(cairo_t * /*ct*/, Geom::OptRect const & /*bbox*/, double opacity) { SPIColor *c = &(this->style->solid_color); cairo_pattern_t *cp = cairo_pattern_create_rgba ( c->value.color.v.c[0], c->value.color.v.c[1], c->value.color.v.c[2], SP_SCALE24_TO_FLOAT(this->style->solid_opacity.value) * opacity ); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 712029468..97a690520 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -513,12 +513,11 @@ void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape:: } } -Geom::Affine SPStar::set_transform(Geom::Affine const &tform) +Geom::Affine SPStar::set_transform(Geom::Affine const &xform) { - Geom::Affine xform = (randomized == 0 ? tform.withoutTranslation() : tform); - + bool opt_trans = (randomized == 0); // Only set transform with proportional scaling - if (!xform.isUniformScale()) { + if (!xform.withoutTranslation().isUniformScale()) { return xform; } @@ -532,7 +531,7 @@ Geom::Affine SPStar::set_transform(Geom::Affine const &tform) /* This function takes care of translation and scaling, we return whatever parts we can't handle. */ - Geom::Affine ret(xform); + Geom::Affine ret(opt_trans ? xform.withoutTranslation() : xform); gdouble const s = hypot(ret[0], ret[1]); if (s > 1e-9) { ret[0] /= s; diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index 567156fec..c568d3ca7 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -14,7 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtk.h> #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" #include "display/canvas-arena.h" @@ -23,8 +22,6 @@ #include "svg-view-widget.h" #include "util/units.h" -static void sp_svg_view_widget_class_init (SPSVGSPViewWidgetClass *klass); -static void sp_svg_view_widget_init (SPSVGSPViewWidget *widget); static void sp_svg_view_widget_dispose(GObject *object); static void sp_svg_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); @@ -42,28 +39,7 @@ static void sp_svg_view_widget_get_preferred_height(GtkWidget *widget, static void sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::View::View *view, gdouble width, gdouble height); -static SPViewWidgetClass *widget_parent_class; - -GType sp_svg_view_widget_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPSVGSPViewWidgetClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_svg_view_widget_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPSVGSPViewWidget), - 0, // n_preallocs - (GInstanceInitFunc)sp_svg_view_widget_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_VIEW_WIDGET, "SPSVGSPViewWidget", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPSVGSPViewWidget, sp_svg_view_widget, SP_TYPE_VIEW_WIDGET); /** * Callback to initialize SPSVGSPViewWidget vtable. @@ -74,8 +50,6 @@ static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); SPViewWidgetClass *vw_class = SP_VIEW_WIDGET_CLASS (klass); - widget_parent_class = static_cast<SPViewWidgetClass *>(g_type_class_peek_parent (klass)); - object_class->dispose = sp_svg_view_widget_dispose; widget_class->size_allocate = sp_svg_view_widget_size_allocate; @@ -94,7 +68,6 @@ static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass) */ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) { - GtkStyle *style; SPCanvasItem *parent; /* Settings */ @@ -117,14 +90,22 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) vw->canvas = SPCanvas::createAA(); -#if !GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA white = {1,1,1,0}; + gtk_widget_override_background_color(vw->canvas, GTK_STATE_FLAG_NORMAL, &white); +#else gtk_widget_pop_colormap (); -#endif - - style = gtk_style_copy (gtk_widget_get_style (vw->canvas)); + GtkStyle *style = gtk_style_copy (gtk_widget_get_style (vw->canvas)); style->bg[GTK_STATE_NORMAL] = style->white; gtk_widget_set_style (vw->canvas, style); +#endif + +#if GTK_CHECK_VERSION(3,8,0) + gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas); +#else gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (vw->sw), vw->canvas); +#endif + gtk_widget_show (vw->canvas); /* View */ @@ -142,8 +123,8 @@ static void sp_svg_view_widget_dispose(GObject *object) vw->canvas = NULL; - if (((GObjectClass *) (widget_parent_class))->dispose) { - (* ((GObjectClass *) (widget_parent_class))->dispose) (object); + if (G_OBJECT_CLASS(sp_svg_view_widget_parent_class)->dispose) { + G_OBJECT_CLASS(sp_svg_view_widget_parent_class)->dispose(object); } } @@ -156,17 +137,18 @@ static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *r Inkscape::UI::View::View *v = SP_VIEW_WIDGET_VIEW (widget); #if GTK_CHECK_VERSION(3,0,0) - if (((GtkWidgetClass *) (widget_parent_class))->get_preferred_width && ((GtkWidgetClass *) (widget_parent_class))->get_preferred_width) { + if (GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_width && + GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_height) { gint width_min, height_min, width_nat, height_nat; - (* ((GtkWidgetClass *) (widget_parent_class))->get_preferred_width) (widget, &width_min, &width_nat); - (* ((GtkWidgetClass *) (widget_parent_class))->get_preferred_height) (widget, &height_min, &height_nat); + GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_width(widget, &width_min, &width_nat); + GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_height(widget, &height_min, &height_nat); req->width=width_min; req->height=height_min; } #else - if (((GtkWidgetClass *) (widget_parent_class))->size_request) { - (* ((GtkWidgetClass *) (widget_parent_class))->size_request) (widget, req); + if (GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_request) { + GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_request(widget, req); } #endif @@ -220,8 +202,8 @@ static void sp_svg_view_widget_size_allocate(GtkWidget *widget, GtkAllocation *a { SPSVGSPViewWidget *svgvw = SP_SVG_VIEW_WIDGET (widget); - if (((GtkWidgetClass *) (widget_parent_class))->size_allocate) { - (* ((GtkWidgetClass *) (widget_parent_class))->size_allocate) (widget, allocation); + if (GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_allocate) { + GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_allocate(widget, allocation); } if (!svgvw->resize) { diff --git a/src/svg/svg-length.cpp b/src/svg/svg-length.cpp index b9e8e6340..b9b475f4b 100644 --- a/src/svg/svg-length.cpp +++ b/src/svg/svg-length.cpp @@ -1,6 +1,4 @@ -#define __SP_SVG_LENGTH_C__ - -/* +/** * SVG data parser * * Authors: @@ -12,20 +10,15 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - +#include <cmath> #include <cstring> #include <string> -#include <math.h> #include <glib.h> #include "svg.h" #include "stringstream.h" #include "util/units.h" - static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next); #ifndef MAX @@ -570,4 +563,4 @@ void SVGLength::readOrUnset(gchar const *str, Unit u, float v, float c) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/svg/svg-length.h b/src/svg/svg-length.h index 477b3ef81..c34905d07 100644 --- a/src/svg/svg-length.h +++ b/src/svg/svg-length.h @@ -1,11 +1,4 @@ -#ifndef SEEN_SP_SVG_LENGTH_H -#define SEEN_SP_SVG_LENGTH_H - /** - * \file src/svg/svg-length.h - * \brief SVG length type - */ -/* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Carl Hetherington <inkscape@carlh.net> @@ -16,10 +9,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> +#ifndef SEEN_SP_SVG_LENGTH_H +#define SEEN_SP_SVG_LENGTH_H -class SVGLength -{ +/** + * SVG length type + */ +class SVGLength { public: SVGLength(); @@ -57,9 +53,9 @@ public: return v; } - bool read(gchar const *str); - void readOrUnset(gchar const *str, Unit u = NONE, float v = 0, float c = 0); - bool readAbsolute(gchar const *str); + bool read(char const *str); + void readOrUnset(char const *str, Unit u = NONE, float v = 0, float c = 0); + bool readAbsolute(char const *str); void set(Unit u, float v, float c); void unset(Unit u = NONE, float v = 0, float c = 0); void update(double em, double ex, double scale); @@ -76,4 +72,4 @@ public: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 59dad9ead..9ba3c0ebd 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -1,41 +1,25 @@ -#define __SP_SVG_PARSE_C__ /* - svg-path.c: Parse SVG path element data into bezier path. - - Copyright (C) 2000 Eazel, Inc. - Copyright (C) 2000 Lauris Kaplinski - Copyright (C) 2001 Ximian, Inc. - Copyright (C) 2008 Johan Engelen - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: - Johan Engelen - (old nartbpath code that has been deleted: Raph Levien <raph@artofcode.com>) - (old nartbpath code that has been deleted: Lauris Kaplinski <lauris@ximian.com>) -*/ + * svg-path.cpp: Parse SVG path element data into bezier path. + * Authors: + * Johan Engelen + * (old nartbpath code that has been deleted: Raph Levien <raph@artofcode.com>) + * (old nartbpath code that has been deleted: Lauris Kaplinski <lauris@ximian.com>) + * + * Copyright (C) 2000 Eazel, Inc. + * Copyright (C) 2000 Lauris Kaplinski + * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2008 Johan Engelen + * + * Copyright (C) 2000-2008 authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ #include <cstring> #include <string> #include <cassert> #include <glib.h> // g_assert() -#include "svg/svg.h" -#include "svg/path-string.h" - #include <2geom/pathvector.h> #include <2geom/path.h> #include <2geom/curves.h> @@ -45,6 +29,9 @@ #include <2geom/exception.h> #include <2geom/angle.h> +#include "svg/svg.h" +#include "svg/path-string.h" + /* * Parses the path in str. When an error is found in the pathstring, this method * returns a truncated path up to where the error was found in the pathstring. @@ -150,4 +137,4 @@ gchar * sp_svg_write_path(Geom::Path const &p) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index a66855b2a..44ed3b58f 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -941,13 +941,13 @@ void AboutBox::initStrings() { } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/aboutbox.h b/src/ui/dialog/aboutbox.h index 7b3308672..015e344a1 100644 --- a/src/ui/dialog/aboutbox.h +++ b/src/ui/dialog/aboutbox.h @@ -55,13 +55,13 @@ private: #endif // INKSCAPE_UI_DIALOG_ABOUTBOX_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index 879fed8c2..e5f5638b2 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -11,7 +11,6 @@ #define __SP_CLONE_TILER_H__ #include "ui/widget/panel.h" -#include <gtk/gtk.h> #include "ui/dialog/desktop-tracker.h" #include "ui/widget/color-picker.h" diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 70f9c6a70..13e828337 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -287,20 +287,8 @@ void Dialog::_apply() void Dialog::_close() { - GtkWidget *dlg = GTK_WIDGET(_behavior->gobj()); - - GdkEventAny event; - event.type = GDK_DELETE; - event.window = gtk_widget_get_window(dlg); - event.send_event = TRUE; - - if (event.window) - g_object_ref(G_OBJECT(event.window)); - - gtk_main_do_event ((GdkEvent*)&event); - - if (event.window) - g_object_unref(G_OBJECT(event.window)); + _behavior->hide(); + _onDeleteEvent(NULL); } void Dialog::_defocus() diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 00b54017c..559cd6bbc 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -45,6 +45,7 @@ #include "widgets/icon.h" #include "xml/node-event-vector.h" #include "xml/repr.h" +#include <algorithm> // std::min #include "rdf.h" #include "ui/widget/entity-entry.h" @@ -1735,9 +1736,9 @@ void DocumentProperties::onDocUnitChange() prefs->setBool("/options/transform/gradient", true); { ShapeEditor::blockSetItem(true); - gdouble viewscale = doc->getWidth().value("px")/doc->getRoot()->viewBox.width(); - if (doc->getHeight().value("px")/doc->getRoot()->viewBox.height() < viewscale) - viewscale = doc->getHeight().value("px")/doc->getRoot()->viewBox.height(); + gdouble viewscale_w = doc->getWidth().value("px")/doc->getRoot()->viewBox.width(); + gdouble viewscale_h = doc->getHeight().value("px")/doc->getRoot()->viewBox.height(); + gdouble viewscale = std::min(viewscale_h, viewscale_w); gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(-viewscale*doc->getRoot()->viewBox.min()[Geom::X] + (doc->getWidth().value("px") - viewscale*doc->getRoot()->viewBox.width())/2, diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 6f3c0dfac..23af0109b 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -12,20 +12,11 @@ #ifndef SP_EXPORT_H #define SP_EXPORT_H -#include <gtk/gtk.h> -#include <glibmm/i18n.h> - -#include <gtkmm/comboboxtext.h> -#include <gtkmm/expander.h> -#include <gtkmm/frame.h> #include <gtkmm/progressbar.h> -#include <gtkmm/textview.h> -#include "desktop.h" #include "ui/dialog/desktop-tracker.h" #include "ui/widget/panel.h" #include "ui/widget/button.h" -#include "ui/widget/entry.h" namespace Gtk { class Dialog; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 2abe78e49..9b75d360a 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -40,6 +40,7 @@ #include <glibmm/i18n.h> #include <glibmm/miscutils.h> +#include "document.h" #include "extension/input.h" #include "extension/output.h" #include "extension/db.h" diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h index 9d6700b39..a137d1694 100644 --- a/src/ui/dialog/grid-arrange-tab.h +++ b/src/ui/dialog/grid-arrange-tab.h @@ -17,14 +17,16 @@ #ifndef INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H #define INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H -#include <gtkmm.h> - +#include "ui/widget/scalar-unit.h" #include "ui/dialog/arrange-tab.h" #include "ui/widget/anchor-selector.h" -#include "ui/widget/scalar-unit.h" #include "ui/widget/spinbutton.h" +#include <gtkmm/checkbutton.h> +#include <gtkmm/radiobutton.h> +#include <gtkmm/radiobuttongroup.h> + namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 5e698355c..2b1198ba0 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -76,7 +76,8 @@ InkscapePreferences::InkscapePreferences() : UI::Widget::Panel ("", "/dialogs/preferences", SP_VERB_DIALOG_DISPLAY), _max_dialog_width(0), _max_dialog_height(0), - _current_page(0) + _current_page(0), + _init(true) { //get the width of a spinbutton Inkscape::UI::Widget::SpinButton* sb = new Inkscape::UI::Widget::SpinButton; @@ -2000,6 +2001,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) Gtk::TreeModel::Row row = *iter; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int desired_page = prefs->getInt("/dialogs/preferences/page", 0); + _init = false; if (desired_page == row[_page_list_columns._col_id]) { if (desired_page >= PREFS_PAGE_TOOLS && desired_page <= PREFS_PAGE_TOOLS_CONNECTOR) @@ -2049,7 +2051,9 @@ void InkscapePreferences::on_pagelist_selection_changed() Gtk::TreeModel::Row row = *iter; _current_page = row[_page_list_columns._col_page]; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt("/dialogs/preferences/page", row[_page_list_columns._col_id]); + if (!_init) { + prefs->setInt("/dialogs/preferences/page", row[_page_list_columns._col_id]); + } _page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>"); _page_frame.add(*_current_page); _current_page->show(); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 1c2151605..dcea91741 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -532,6 +532,7 @@ private: InkscapePreferences(); InkscapePreferences(InkscapePreferences const &d); InkscapePreferences operator=(InkscapePreferences const &d); + bool _init; }; } // namespace Dialog @@ -544,9 +545,9 @@ private: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index a68c7ee08..eef32d10d 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -44,20 +44,38 @@ namespace Dialogs { FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() : _desktop(NULL), _knotpoint(NULL), _position_visible(false) { +#if WITH_GTKMM_3_0 + Gtk::Box *mainVBox = get_content_area(); +#else Gtk::Box *mainVBox = get_vbox(); +#endif + mainVBox->set_homogeneous(false); + +#if WITH_GTKMM_3_0 + _layout_table.set_row_spacing(4); + _layout_table.set_column_spacing(4); +#else _layout_table.set_spacings(4); _layout_table.resize(2, 2); +#endif // Layer name widgets _fillet_chamfer_position_entry.set_activates_default(true); _fillet_chamfer_position_label.set_label(_("Radius (pixels):")); _fillet_chamfer_position_label.set_alignment(1.0, 0.5); +#if WITH_GTKMM_3_0 + _layout_table.attach(_fillet_chamfer_position_label, 0, 0, 1, 1); + _layout_table.attach(_fillet_chamfer_position_entry, 1, 0, 1, 1); + _fillet_chamfer_position_entry.set_hexpand(); +#else _layout_table.attach(_fillet_chamfer_position_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); _layout_table.attach(_fillet_chamfer_position_entry, 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); +#endif + _fillet_chamfer_type_fillet.set_label(_("Fillet")); _fillet_chamfer_type_fillet.set_group(_fillet_chamfer_type_group); _fillet_chamfer_type_inverse_fillet.set_label(_("Inverse fillet")); diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h index d3e859bff..9beca02e1 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.h +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h @@ -8,10 +8,24 @@ #ifndef INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H #define INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <gtkmm/dialog.h> #include <2geom/point.h> -#include <gtkmm.h> #include "live_effects/parameter/filletchamferpointarray.h" +#include <gtkmm/entry.h> +#include <gtkmm/label.h> +#include <gtkmm/radiobutton.h> + +#if WITH_GTKMM_3_0 + #include <gtkmm/grid.h> +#else + #include <gtkmm/table.h> +#endif + class SPDesktop; namespace Inkscape { @@ -46,7 +60,12 @@ protected: Gtk::RadioButton _fillet_chamfer_type_chamfer; Gtk::RadioButton _fillet_chamfer_type_double_chamfer; +#if WITH_GTKMM_3_0 + Gtk::Grid _layout_table; +#else Gtk::Table _layout_table; +#endif + bool _position_visible; double _index; diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index f326bb3ee..e30b148bb 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -8,6 +8,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#if HAVE_CONFIG_H + #include "config.h" +#endif #include "new-from-template.h" #include "file.h" @@ -25,12 +28,22 @@ NewFromTemplate::NewFromTemplate() { set_title(_("New From Template")); resize(400, 400); - + +#if WITH_GTKMM_3_0 + get_content_area()->pack_start(_main_widget); +#else get_vbox()->pack_start(_main_widget); +#endif Gtk::Alignment *align; align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + +#if WITH_GTKMM_3_0 + get_content_area()->pack_end(*align, Gtk::PACK_SHRINK); +#else get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); +#endif + align->set_padding(0, 0, 0, 15); align->add(_create_template_button); diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index a00b8fc02..80579c9d3 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -25,6 +25,7 @@ #include "desktop.h" #include "sp-ellipse.h" #include "sp-item-transform.h" +#include <gtkmm/messagedialog.h> namespace Inkscape { namespace UI { @@ -32,7 +33,11 @@ namespace Dialog { PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) : parent(parent_), +#if WITH_GTKMM_3_0 + parametersTable(), +#else parametersTable(3, 3, false), +#endif centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), centerX("", "X coordinate of the center", centerY), radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), @@ -76,7 +81,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) pack_start(arrangeOnParametersRadio, false, false); centerLabel.set_text(_("Center X/Y:")); +#if WITH_GTKMM_3_0 + parametersTable.attach(centerLabel, 0, 0, 1, 1); +#else parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); +#endif centerX.setDigits(2); centerX.setIncrements(0.2, 0); centerX.setRange(-10000, 10000); @@ -85,11 +94,20 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) centerY.setIncrements(0.2, 0); centerY.setRange(-10000, 10000); centerY.setValue(0, "px"); +#if WITH_GTKMM_3_0 + parametersTable.attach(centerX, 1, 0, 1, 1); + parametersTable.attach(centerY, 2, 0, 1, 1); +#else parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); +#endif radiusLabel.set_text(_("Radius X/Y:")); +#if WITH_GTKMM_3_0 + parametersTable.attach(radiusLabel, 0, 1, 1, 1); +#else parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); +#endif radiusX.setDigits(2); radiusX.setIncrements(0.2, 0); radiusX.setRange(0.001, 10000); @@ -98,11 +116,20 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusY.setIncrements(0.2, 0); radiusY.setRange(0.001, 10000); radiusY.setValue(100, "px"); +#if WITH_GTKMM_3_0 + parametersTable.attach(radiusX, 1, 1, 1, 1); + parametersTable.attach(radiusY, 2, 1, 1, 1); +#else parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); +#endif angleLabel.set_text(_("Angle X/Y:")); +#if WITH_GTKMM_3_0 + parametersTable.attach(angleLabel, 0, 2, 1, 1); +#else parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); +#endif angleX.setDigits(2); angleX.setIncrements(0.2, 0); angleX.setRange(-10000, 10000); @@ -111,8 +138,13 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleY.setIncrements(0.2, 0); angleY.setRange(-10000, 10000); angleY.setValue(180, "°"); +#if WITH_GTKMM_3_0 + parametersTable.attach(angleX, 1, 2, 1, 1); + parametersTable.attach(angleY, 2, 2, 1, 1); +#else parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); +#endif pack_start(parametersTable, false, false); rotateObjectsCheckBox.set_label(_("Rotate objects")); diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index f6c3b2906..f7d7bf11f 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -10,9 +10,22 @@ #ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H #define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include "ui/widget/scalar-unit.h" #include "ui/widget/anchor-selector.h" #include "ui/dialog/arrange-tab.h" -#include "ui/widget/scalar-unit.h" + +#include <gtkmm/radiobutton.h> +#include <gtkmm/radiobuttongroup.h> + +#if WITH_GTKMM_3_0 + #include <gtkmm/grid.h> +#else + #include <gtkmm/table.h> +#endif namespace Inkscape { namespace UI { @@ -62,7 +75,11 @@ private: Gtk::RadioButton arrangeOnLastCircleRadio; Gtk::RadioButton arrangeOnParametersRadio; +#if WITH_GTKMM_3_0 + Gtk::Grid parametersTable; +#else Gtk::Table parametersTable; +#endif Gtk::Label centerLabel; Inkscape::UI::Widget::ScalarUnit centerY; diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 459e64041..a015d28f9 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -14,8 +14,15 @@ # include <config.h> #endif +#include <gtkmm.h> + +#ifdef WIN32 +#include <io.h> +#include <windows.h> +#endif + +#include "preferences.h" #include "print.h" -#include <gtkmm/stock.h> #include "extension/internal/cairo-render-context.h" #include "extension/internal/cairo-renderer.h" @@ -29,11 +36,6 @@ #include <glibmm/i18n.h> -#ifdef WIN32 -#include <io.h> -#include <windows.h> -#endif - static void draw_page( #ifdef WIN32 @@ -45,14 +47,18 @@ static void draw_page( gint /*page_nr*/, gpointer user_data) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); struct workaround_gtkmm *junk = (struct workaround_gtkmm*)user_data; //printf("%s %d\n",__FUNCTION__, page_nr); if (junk->_tab->as_bitmap()) { // Render as exported PNG + prefs->setBool("/dialogs/printing/asbitmap", true); gdouble width = (junk->_doc)->getWidth().value("px"); gdouble height = (junk->_doc)->getHeight().value("px"); gdouble dpi = junk->_tab->bitmap_dpi(); + prefs->setDouble("/dialogs/printing/dpi", dpi); + std::string tmp_png; std::string tmp_base = "inkscape-print-png-XXXXXX"; @@ -93,7 +99,7 @@ static void draw_page( cairo_get_matrix(cr, &m); cairo_scale(cr, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi); // FIXME: why is the origin offset?? - cairo_set_source_surface(cr, png->cobj(), -16.0, -16.0); + cairo_set_source_surface(cr, png->cobj(), 0, 0); cairo_paint(cr); cairo_set_matrix(cr, &m); } @@ -107,6 +113,7 @@ static void draw_page( } else { // Render as vectors + prefs->setBool("/dialogs/printing/asbitmap", false); Inkscape::Extension::Internal::CairoRenderer renderer; Inkscape::Extension::Internal::CairoRenderContext *ctx = renderer.createContext(); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c1ebb32e0..e44809c65 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -344,9 +344,9 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); - // This is done for us by text-toolbar. No need to do it twice. - // fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); - // fontlister->selection_update(); + // This is normally done for us by text-toolbar but only when we are in text editing context + fontlister->update_font_list(sp_desktop_document(this->desktop)); + fontlister->selection_update(); Glib::ustring fontspec = fontlister->get_fontspec(); diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 55d0aff09..c87e42633 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -1033,6 +1033,7 @@ void XmlTree::cmd_set_attr() updated->updateRepr(); } + reinterpret_cast<SPObject *>(current_desktop->currentLayer())->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, _("Change attribute")); diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index d10ed0f0d..998f74ee0 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -74,7 +74,7 @@ ControlPointSelection::~ControlPointSelection() } /** Add a control point to the selection. */ -std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(const value_type &x) +std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(const value_type &x, bool notify) { iterator found = _points.find(x); if (found != _points.end()) { @@ -86,6 +86,10 @@ std::pair<ControlPointSelection::iterator, bool> ControlPointSelection::insert(c x->updateState(); _pointChanged(x, true); + if (notify) { + signal_selection_changed.emit(std::vector<key_type>(1, x), true); + } + return std::pair<iterator, bool>(found, true); } @@ -97,47 +101,75 @@ void ControlPointSelection::erase(iterator pos) erased->updateState(); _pointChanged(erased, false); } -ControlPointSelection::size_type ControlPointSelection::erase(const key_type &k) +ControlPointSelection::size_type ControlPointSelection::erase(const key_type &k, bool notify) { iterator pos = _points.find(k); if (pos == _points.end()) return 0; erase(pos); + + if (notify) { + signal_selection_changed.emit(std::vector<key_type>(1, k), false); + } return 1; } void ControlPointSelection::erase(iterator first, iterator last) { + std::vector<SelectableControlPoint *> out(first, last); while (first != last) erase(first++); + signal_selection_changed.emit(out, false); } /** Remove all points from the selection, making it empty. */ void ControlPointSelection::clear() { + std::vector<SelectableControlPoint *> out(begin(), end()); for (iterator i = begin(); i != end(); ) erase(i++); + if (!out.empty()) + signal_selection_changed.emit(out, false); } /** Select all points that this selection can contain. */ void ControlPointSelection::selectAll() { for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - insert(*i); + insert(*i, false); } + std::vector<SelectableControlPoint *> out(_all_points.begin(), _all_points.end()); + if (!out.empty()) + signal_selection_changed.emit(out, true); } /** Select all points inside the given rectangle (in desktop coordinates). */ void ControlPointSelection::selectArea(Geom::Rect const &r) { + std::vector<SelectableControlPoint *> out; for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if (r.contains(**i)) - insert(*i); + if (r.contains(**i)) { + insert(*i, false); + out.push_back(*i); + } } + if (!out.empty()) + signal_selection_changed.emit(out, true); } /** Unselect all selected points and select all unselected points. */ void ControlPointSelection::invertSelection() { + std::vector<SelectableControlPoint *> in, out; for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { - if ((*i)->selected()) erase(*i); - else insert(*i); + if ((*i)->selected()) { + in.push_back(*i); + erase(*i); + } + else { + out.push_back(*i); + insert(*i, false); + } } + if (!in.empty()) + signal_selection_changed.emit(in, false); + if (!out.empty()) + signal_selection_changed.emit(out, true); } void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) { @@ -166,6 +198,7 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) if (match) { if (grow) insert(match); else erase(match); + signal_selection_changed.emit(std::vector<value_type>(1, match), grow); } } @@ -389,7 +422,7 @@ void ControlPointSelection::_pointChanged(SelectableControlPoint *p, bool select _handles->rotationCenter().move(_bounds->midpoint()); } - signal_point_changed.emit(p, selected); + //signal_point_changed.emit(p, selected); } void ControlPointSelection::_mouseoverChanged() diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index a087e0455..2d812c0a3 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -62,18 +62,19 @@ public: const_iterator end() const { return _points.end(); } // insert - std::pair<iterator, bool> insert(const value_type& x); + std::pair<iterator, bool> insert(const value_type& x, bool notify = true); template <class InputIterator> void insert(InputIterator first, InputIterator last) { for (; first != last; ++first) { - insert(*first); + insert(*first, false); } + signal_selection_changed.emit(std::vector<key_type>(first, last), true); } // erase void clear(); void erase(iterator pos); - size_type erase(const key_type& k); + size_type erase(const key_type& k, bool notify = true); void erase(iterator first, iterator last); // find @@ -108,7 +109,9 @@ public: void toggleTransformHandlesMode(); sigc::signal<void> signal_update; - sigc::signal<void, SelectableControlPoint *, bool> signal_point_changed; + // It turns out that emitting a signal after every point is selected or deselected is not too efficient, + // so this can be done in a massive group once the selection is finally changed. + sigc::signal<void, std::vector<SelectableControlPoint *>, bool> signal_selection_changed; sigc::signal<void, CommitEvent> signal_commit; void getOriginalPoints(std::vector<Inkscape::SnapCandidatePoint> &pts); @@ -166,4 +169,4 @@ private: fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 68aaa77a5..b32bafdbf 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -122,7 +122,7 @@ MultiPathManipulator::MultiPathManipulator(PathSharedData &data, sigc::connectio { _selection.signal_commit.connect( sigc::mem_fun(*this, &MultiPathManipulator::_commit)); - _selection.signal_point_changed.connect( + _selection.signal_selection_changed.connect( sigc::hide( sigc::hide( signal_coords_changed.make_slot()))); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index ed0843b65..e38f82673 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1623,7 +1623,37 @@ void NodeList::reverse() void NodeList::clear() { - for (iterator i = begin(); i != end();) erase (i++); + // ugly but more efficient clearing mechanism + std::vector<ControlPointSelection *> to_clear; + std::vector<std::pair<SelectableControlPoint *, long> > nodes; + long in = -1; + for (iterator i = begin(); i != end(); ++i) { + SelectableControlPoint *rm = static_cast<Node*>(i._node); + if (std::find(to_clear.begin(), to_clear.end(), &rm->_selection) == to_clear.end()) { + to_clear.push_back(&rm->_selection); + ++in; + } + nodes.push_back(std::make_pair(rm, in)); + } + for (size_t i = 0, e = nodes.size(); i != e; ++i) { + to_clear[nodes[i].second]->erase(nodes[i].first, false); + } + std::vector<std::vector<SelectableControlPoint *> > emission; + for (long i = 0, e = to_clear.size(); i != e; ++i) { + emission.push_back(std::vector<SelectableControlPoint *>()); + for (size_t j = 0, f = nodes.size(); j != f; ++j) { + if (nodes[j].second != i) + break; + emission[i].push_back(nodes[j].first); + } + } + + for (size_t i = 0, e = emission.size(); i != e; ++i) { + to_clear[i]->signal_selection_changed.emit(emission[i], false); + } + + for (iterator i = begin(); i != end();) + erase (i++); } NodeList::iterator NodeList::erase(iterator i) diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 9839be437..5f20aece7 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -140,8 +140,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _selection.signal_update.connect( sigc::bind(sigc::mem_fun(*this, &PathManipulator::update), false)); - _selection.signal_point_changed.connect( - sigc::mem_fun(*this, &PathManipulator::_selectionChanged)); + _selection.signal_selection_changed.connect( + sigc::mem_fun(*this, &PathManipulator::_selectionChangedM)); _desktop->signal_zoom_changed.connect( sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); @@ -1524,6 +1524,12 @@ bool PathManipulator::_handleClicked(Handle *h, GdkEventButton *event) return false; } +void PathManipulator::_selectionChangedM(std::vector<SelectableControlPoint *> pvec, bool selected) { + for (size_t n = 0, e = pvec.size(); n < e; ++n) { + _selectionChanged(pvec[n], selected); + } +} + void PathManipulator::_selectionChanged(SelectableControlPoint *p, bool selected) { if (selected) ++_num_selected; diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 151805c83..4d2bf4300 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -122,7 +122,8 @@ private: Glib::ustring _nodetypesKey(); Inkscape::XML::Node *_getXMLNode(); - void _selectionChanged(SelectableControlPoint *p, bool selected); + void _selectionChangedM(std::vector<SelectableControlPoint *> pvec, bool selected); + void _selectionChanged(SelectableControlPoint * p, bool selected); bool _nodeClicked(Node *, GdkEventButton *); void _handleGrabbed(); bool _handleClicked(Handle *, GdkEventButton *); diff --git a/src/ui/tool/selectable-control-point.h b/src/ui/tool/selectable-control-point.h index 8acfc1168..362d4addc 100644 --- a/src/ui/tool/selectable-control-point.h +++ b/src/ui/tool/selectable-control-point.h @@ -28,6 +28,7 @@ public: virtual Geom::Rect bounds() const { return Geom::Rect(position(), position()); } + friend class NodeList; protected: diff --git a/src/ui/tools/arc-tool.h b/src/ui/tools/arc-tool.h index c4c67660d..55cbaf78c 100644 --- a/src/ui/tools/arc-tool.h +++ b/src/ui/tools/arc-tool.h @@ -30,7 +30,7 @@ namespace Inkscape { } #define SP_ARC_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ArcTool*>((Inkscape::UI::Tools::ToolBase*)obj)) -#define SP_IS_ARC_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::ArcTool*>(const Inkscape::UI::Tools::ToolBase*(obj)) != NULL) +#define SP_IS_ARC_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::ArcTool*>(obj) != NULL) namespace Inkscape { namespace UI { diff --git a/src/ui/tools/flood-tool.h b/src/ui/tools/flood-tool.h index 3ed670e8b..5104a42e9 100644 --- a/src/ui/tools/flood-tool.h +++ b/src/ui/tools/flood-tool.h @@ -11,9 +11,7 @@ * Released under GNU GPL */ -#include <stddef.h> -#include <sigc++/sigc++.h> -#include <gtk/gtk.h> +#include <sigc++/connection.h> #include "ui/tools/tool-base.h" #define SP_FLOOD_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::FloodTool*>((Inkscape::UI::Tools::ToolBase*)obj)) diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index aad924844..72250a550 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -610,13 +610,13 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) if (dc->sa) { SPCurve *s = dc->sa->curve; dc->white_curves = g_slist_remove(dc->white_curves, s); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - s = dc->overwriteCurve; - } if (dc->sa->start) { s = reverse_then_unref(s); } + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + dc->overwriteCurve = s; + } s->append_continuous(c, 0.0625); c->unref(); c = s; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index a0bbfbaf1..4f9a7b59b 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -213,17 +213,20 @@ sp_gradient_context_is_over_line (GradientTool *rc, SPItem *item, Geom::Point ev //Translate mouse point into proper coord system rc->mousepoint_doc = desktop->w2d(event_p); - SPCtrlLine* line = SP_CTRLLINE(item); + if (SP_IS_CTRLLINE(item)) { + SPCtrlLine* line = SP_CTRLLINE(item); - Geom::LineSegment ls(line->s, line->e); - Geom::Point nearest = ls.pointAt(ls.nearestPoint(rc->mousepoint_doc)); - double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); + Geom::LineSegment ls(line->s, line->e); + Geom::Point nearest = ls.pointAt(ls.nearestPoint(rc->mousepoint_doc)); + double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); - double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; + double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; - bool close = (dist_screen < tolerance); + bool close = (dist_screen < tolerance); - return close; + return close; + } + return false; } static std::vector<Geom::Point> diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index d2584ee74..d4d7b2c35 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -245,7 +245,7 @@ void NodeTool::setup() { ) ); - this->_selected_nodes->signal_point_changed.connect( + this->_selected_nodes->signal_selection_changed.connect( // Hide both signal parameters and bind the function parameter to 0 // sigc::signal<void, SelectableControlPoint *, bool> // <=> diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index edc4069a2..5af99a56a 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -13,7 +13,6 @@ */ #include "ui/tools/tool-base.h" -#include <gtk/gtk.h> #define SP_SELECT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::SelectTool*>((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_SELECT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::SelectTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) diff --git a/src/ui/tools/spiral-tool.h b/src/ui/tools/spiral-tool.h index 416aeb7e4..add92342d 100644 --- a/src/ui/tools/spiral-tool.h +++ b/src/ui/tools/spiral-tool.h @@ -15,17 +15,15 @@ * Released under GNU GPL */ -#include <gtk/gtk.h> -#include <stddef.h> -#include <sigc++/sigc++.h> +#include <sigc++/connection.h> #include <2geom/point.h> #include "ui/tools/tool-base.h" -#include "sp-spiral.h" - #define SP_SPIRAL_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::SpiralTool*>((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_SPIRAL_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::SpiralTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) +class SPSpiral; + namespace Inkscape { namespace UI { namespace Tools { diff --git a/src/ui/tools/text-tool.h b/src/ui/tools/text-tool.h index ca2b3d19a..289ee180d 100644 --- a/src/ui/tools/text-tool.h +++ b/src/ui/tools/text-tool.h @@ -14,10 +14,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/* #include <gdk/gdkic.h> */ -#include <stddef.h> -#include <sigc++/sigc++.h> -#include <gtk/gtk.h> +#include <sigc++/connection.h> #include "ui/tools/tool-base.h" #include <2geom/point.h> @@ -26,6 +23,8 @@ #define SP_TEXT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::TextTool*>((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_TEXT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::TextTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) +typedef struct _GtkIMContext GtkIMContext; + struct SPCtrlLine; namespace Inkscape { diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index c23da87c0..c28b86416 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -18,6 +18,8 @@ # include "config.h" #endif +#include "widgets/desktop-widget.h" + #if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H #include <glibmm/threads.h> #endif @@ -40,7 +42,6 @@ #include "desktop-handles.h" #include "desktop-events.h" #include "desktop-style.h" -#include "widgets/desktop-widget.h" #include "sp-namedview.h" #include "selection.h" #include "interface.h" diff --git a/src/ui/view/view-widget.cpp b/src/ui/view/view-widget.cpp index 5cb0df215..671a4afe6 100644 --- a/src/ui/view/view-widget.cpp +++ b/src/ui/view/view-widget.cpp @@ -15,32 +15,9 @@ //using namespace Inkscape::UI::View; // SPViewWidget - -static void sp_view_widget_class_init(SPViewWidgetClass *vwc); -static void sp_view_widget_init(SPViewWidget *widget); static void sp_view_widget_dispose(GObject *object); -static GtkEventBoxClass *widget_parent_class; - -GType sp_view_widget_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPViewWidgetClass), - 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; -} +G_DEFINE_TYPE(SPViewWidget, sp_view_widget, GTK_TYPE_EVENT_BOX); /** * Callback to initialize the SPViewWidget vtable. @@ -48,8 +25,6 @@ GType sp_view_widget_get_type(void) static void sp_view_widget_class_init(SPViewWidgetClass *vwc) { GObjectClass *object_class = G_OBJECT_CLASS(vwc); - - widget_parent_class = (GtkEventBoxClass*) g_type_class_peek_parent(vwc); object_class->dispose = sp_view_widget_dispose; } @@ -77,8 +52,8 @@ static void sp_view_widget_dispose(GObject *object) vw->view = NULL; } - if (((GObjectClass *) (widget_parent_class))->dispose) { - (* ((GObjectClass *) (widget_parent_class))->dispose)(object); + if (G_OBJECT_CLASS(sp_view_widget_parent_class)->dispose) { + G_OBJECT_CLASS(sp_view_widget_parent_class)->dispose(object); } Inkscape::GC::request_early_collection(); diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index 82e27ee89..df00b786a 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -28,7 +28,11 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b AnchorSelector::AnchorSelector() : Gtk::Alignment(0.5, 0, 0, 0), +#if WITH_GTKMM_3_0 + _container() +#else _container(3, 3, true) +#endif { setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]); setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]); @@ -40,10 +44,20 @@ AnchorSelector::AnchorSelector() setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]); setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]); +#if WITH_GTKMM_3_0 + _container.set_row_homogeneous(); + _container.set_column_homogeneous(true); +#endif + for(int i = 0; i < 9; ++i) { _buttons[i].signal_clicked().connect( sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i)); + +#if WITH_GTKMM_3_0 + _container.attach(_buttons[i], i % 3, i / 3, 1, 1); +#else _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL); +#endif } _selection = 4; _buttons[4].set_active(); @@ -94,4 +108,4 @@ void AnchorSelector::setAlignment(int horizontal, int vertical) fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index 2263438e3..0a702d296 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -10,7 +10,18 @@ #ifndef ANCHOR_SELECTOR_H_ #define ANCHOR_SELECTOR_H_ -#include <gtkmm.h> +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <gtkmm/alignment.h> +#include <gtkmm/togglebutton.h> + +#if WITH_GTKMM_3_0 + #include <gtkmm/grid.h> +#else + #include <gtkmm/table.h> +#endif namespace Inkscape { namespace UI { @@ -21,7 +32,12 @@ class AnchorSelector : public Gtk::Alignment private: Gtk::ToggleButton _buttons[9]; int _selection; + +#if WITH_GTKMM_3_0 + Gtk::Grid _container; +#else Gtk::Table _container; +#endif sigc::signal<void> _selectionChanged; @@ -56,4 +72,4 @@ public: fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/button.cpp b/src/ui/widget/button.cpp index bac866920..6c2d419cf 100644 --- a/src/ui/widget/button.cpp +++ b/src/ui/widget/button.cpp @@ -51,13 +51,13 @@ RadioButton::RadioButton(Glib::ustring const &label, Glib::ustring const &toolti } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/button.h b/src/ui/widget/button.h index a214dd881..471b7d8a2 100644 --- a/src/ui/widget/button.h +++ b/src/ui/widget/button.h @@ -67,13 +67,13 @@ public: #endif // INKSCAPE_UI_WIDGET_BUTTON_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index 0f526f77a..c7d5efe29 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -206,9 +206,9 @@ EntityMultiLineEntry::on_changed() Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/entity-entry.h b/src/ui/widget/entity-entry.h index 09289496d..35f6ecfb4 100644 --- a/src/ui/widget/entity-entry.h +++ b/src/ui/widget/entity-entry.h @@ -76,9 +76,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index 42f352e3c..7429bb07e 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -160,9 +160,9 @@ void Licensor::update (SPDocument *doc) Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/licensor.h b/src/ui/widget/licensor.h index 0ac3e5ab8..c75c5fe9e 100644 --- a/src/ui/widget/licensor.h +++ b/src/ui/widget/licensor.h @@ -56,9 +56,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index 6653499b8..2f03ed23b 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -44,13 +44,13 @@ NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, gu } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index 38ae9e054..4f7915423 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -67,13 +67,13 @@ protected: #endif // INKSCAPE_UI_WIDGET_NOTEBOOK_PAGE_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index eae0d4a95..89b0b8f7e 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -728,9 +728,9 @@ PageSizer::on_units_changed() Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index dc8e34d82..f4bcae4b6 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -277,9 +277,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index cb4ce17d1..5d9816e74 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -306,9 +306,9 @@ public: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 8a81b1c02..44d8dcbf3 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -788,9 +788,9 @@ RegisteredRandom::on_value_changed() Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index d8c0e6602..1f505a3cd 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -419,9 +419,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/registry.cpp b/src/ui/widget/registry.cpp index 725e52791..ea8198422 100644 --- a/src/ui/widget/registry.cpp +++ b/src/ui/widget/registry.cpp @@ -48,9 +48,9 @@ Registry::setUpdating (bool upd) Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/registry.h b/src/ui/widget/registry.h index 2da29735c..a236b96ad 100644 --- a/src/ui/widget/registry.h +++ b/src/ui/widget/registry.h @@ -39,9 +39,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index d6248df69..837387f7b 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -12,6 +12,9 @@ # include <config.h> #endif +#include <gtkmm.h> + +#include "preferences.h" #include "rendering-options.h" #include "util/units.h" #include <glibmm/i18n.h> @@ -38,6 +41,7 @@ RenderingOptions::RenderingOptions () : Glib::ustring(""), Glib::ustring(""), false) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // set up tooltips _radio_vector.set_tooltip_text( _("Render using Cairo vector operations. " @@ -52,15 +56,21 @@ RenderingOptions::RenderingOptions () : set_border_width(2); - // default to vector operations - _radio_vector.set_active (true); Gtk::RadioButtonGroup group = _radio_vector.get_group (); _radio_bitmap.set_group (group); _radio_bitmap.signal_toggled().connect(sigc::mem_fun(*this, &RenderingOptions::_toggled)); - + + // default to vector operations + if (prefs->getBool("/dialogs/printing/asbitmap", false)) { + _radio_bitmap.set_active(); + } else { + _radio_vector.set_active(); + } + // configure default DPI _dpi.setRange(Inkscape::Util::Quantity::convert(1, "in", "pt"),2400.0); - _dpi.setValue(Inkscape::Util::Quantity::convert(1, "in", "pt")); + _dpi.setValue(prefs->getDouble("/dialogs/printing/dpi", + Inkscape::Util::Quantity::convert(1, "in", "pt"))); _dpi.setIncrements(1.0,10.0); _dpi.setDigits(0); _dpi.update(); diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 72ec69362..2d7597d7c 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -173,13 +173,13 @@ Rotateable::~Rotateable() { } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h index 52fb5306c..6404c3550 100644 --- a/src/ui/widget/rotateable.h +++ b/src/ui/widget/rotateable.h @@ -62,9 +62,9 @@ private: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 042a6614e..a0a163286 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -25,6 +25,7 @@ #include "desktop-style.h" #include "sp-namedview.h" #include "sp-linear-gradient.h" +#include "sp-mesh-gradient.h" #include "sp-radial-gradient.h" #include "sp-pattern.h" #include "ui/dialog/dialog-manager.h" @@ -209,6 +210,18 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _gradient_box_r[i].pack_start(*(Glib::wrap(_gradient_preview_r[i]))); _gradient_box_r[i].show_all(); +#ifdef WITH_MESH + _mgradient[i].set_markup (_("<b>M</b>")); + sp_set_font_size_smaller (GTK_WIDGET(_mgradient[i].gobj())); + _mgradient[i].show_all(); + __mgradient[i] = (i == SS_FILL)? (_("Mesh gradient fill")) : (_("Mesh gradient stroke")); + + _gradient_preview_m[i] = GTK_WIDGET(sp_gradient_image_new (NULL)); + _gradient_box_m[i].pack_start(_mgradient[i]); + _gradient_box_m[i].pack_start(*(Glib::wrap(_gradient_preview_m[i]))); + _gradient_box_m[i].show_all(); +#endif + _many[i].set_markup (_("Different")); sp_set_font_size_smaller (GTK_WIDGET(_many[i].gobj())); _many[i].show_all(); @@ -1028,6 +1041,14 @@ SelectedStyle::update() place->add(_gradient_box_r[i]); place->set_tooltip_text(__rgradient[i]); _mode[i] = SS_RGRADIENT; +#ifdef WITH_MESH + } else if (SP_IS_MESHGRADIENT(server)) { + SPGradient *vector = SP_GRADIENT(server)->getVector(); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector); + place->add(_gradient_box_m[i]); + place->set_tooltip_text(__mgradient[i]); + _mode[i] = SS_MGRADIENT; +#endif } else if (SP_IS_PATTERN (server)) { place->add(_pattern[i]); place->set_tooltip_text(__pattern[i]); @@ -1550,9 +1571,9 @@ Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop) Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 9557a8d74..0b6a14762 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -60,6 +60,9 @@ enum { SS_PATTERN, SS_LGRADIENT, SS_RGRADIENT, +#ifdef WITH_MESH + SS_MGRADIENT, +#endif SS_MANY, SS_COLOR }; @@ -186,6 +189,14 @@ protected: GtkWidget *_gradient_preview_r[2]; Gtk::HBox _gradient_box_r[2]; +#ifdef WITH_MESH + Gtk::Label _mgradient[2]; + Glib::ustring __mgradient[2]; + + GtkWidget *_gradient_preview_m[2]; + Gtk::HBox _gradient_box_m[2]; +#endif + Gtk::Label _many[2]; Glib::ustring __many[2]; @@ -290,13 +301,13 @@ protected: #endif // INKSCAPE_UI_WIDGET_BUTTON_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp index ade3d1e60..bb08d67df 100644 --- a/src/ui/widget/spin-scale.cpp +++ b/src/ui/widget/spin-scale.cpp @@ -235,13 +235,13 @@ void DualSpinScale::update_linked() } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h index 5fec8b1d8..d0447e4a6 100644 --- a/src/ui/widget/spin-scale.h +++ b/src/ui/widget/spin-scale.h @@ -113,13 +113,13 @@ private: #endif // INKSCAPE_UI_WIDGET_SPIN_SCALE_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 1cb59a7b3..9b361ae78 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -262,13 +262,13 @@ void DualSpinSlider::update_linked() } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index 5f86fd15a..74982ea58 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -111,13 +111,13 @@ private: #endif // INKSCAPE_UI_WIDGET_SPIN_SLIDER_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 7709a837b..d7669d4e5 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -100,13 +100,13 @@ void SpinButton::undo() } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 812b5f515..cbe33e8ea 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -111,13 +111,13 @@ private: #endif // INKSCAPE_UI_WIDGET_SPINBUTTON_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 98f4e47cd..157fd2ad9 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -386,9 +386,9 @@ void StyleSwatch::setStyle(SPStyle *query) Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index 557ca82e2..582d2ebb3 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -108,13 +108,13 @@ friend class ToolObserver; #endif // INKSCAPE_UI_WIDGET_BUTTON_H -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 5fc588fdc..aac7451f4 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -216,9 +216,9 @@ void ToleranceSlider::update (double val) Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 2184cd52b..7ae8e4712 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -88,9 +88,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 7416a2f02..423313a1f 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -140,13 +140,13 @@ bool UnitMenu::isRadial() const } // namespace UI } // namespace Inkscape -/* +/* Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 114c536c9..2fd25a6a9 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -141,9 +141,9 @@ protected: Local Variables: mode:c++ c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)) + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ -// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 61bb556ef..06245930e 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -16,13 +16,16 @@ #define INKSCAPE_UI_WIDGET_UNIT_TRACKER_H #include <map> -#include <gtk/gtk.h> - #include "util/units.h" using Inkscape::Util::Unit; using Inkscape::Util::UnitType; +typedef struct _GObject GObject; +typedef struct _GtkAction GtkAction; +typedef struct _GtkAdjustment GtkAdjustment; +typedef struct _GtkListStore GtkListStore; + namespace Inkscape { namespace UI { namespace Widget { diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 6db2ed21f..b23bed74a 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -1,6 +1,4 @@ -#define __SP_URI_REFERENCES_C__ - -/* +/** * Helper methods for resolving URI References * * Authors: @@ -206,4 +204,4 @@ sp_uri_reference_resolve (SPDocument *document, const gchar *uri) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/uri-references.h b/src/uri-references.h index 631d440da..f68fe70c4 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -62,7 +62,7 @@ public: * @param rel_document document for relative URIs * @param uri the URI to watch */ - void attach(const URI &uri) throw(BadURIException); + void attach(URI const& uri) throw(BadURIException); /** * Detaches from the currently attached URI target, if any; @@ -105,7 +105,7 @@ public: * * @returns the currently attached URI, or NULL */ - const URI *getURI() const { + URI const* getURI() const { return _uri; } @@ -140,7 +140,7 @@ private: void _setObject(SPObject *object); void _release(SPObject *object); - void operator=(const URIReference &ref); + void operator=(URIReference const& ref); /* Private and definition-less to prevent accidental use. */ }; @@ -164,4 +164,4 @@ SPObject *sp_uri_reference_resolve (SPDocument *document, const gchar *uri); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/util/units.cpp b/src/util/units.cpp index d2053f60b..eb4a313e0 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -291,11 +291,15 @@ Quantity UnitTable::parseQuantity(Glib::ustring const &q) const std::istringstream tmp_v(match_info.fetch(0)); tmp_v >> value; } + int start_pos, end_pos; + match_info.fetch_pos(0, end_pos, start_pos); + end_pos = q.size() - start_pos; + Glib::ustring u = q.substr(start_pos, end_pos); // Extract unit abbreviation Glib::ustring abbr; Glib::RefPtr<Glib::Regex> unit_regex = Glib::Regex::create("[A-z%]+"); - if (unit_regex->match(q, match_info)) { + if (unit_regex->match(u, match_info)) { abbr = match_info.fetch(0); } diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index ca6810c81..1005de70d 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -45,6 +45,7 @@ #include "toolbox.h" #include "ui/icon-names.h" #include "ui/uxmanager.h" +#include "ui/tools/arc-tool.h" #include "verbs.h" #include "widgets/spinbutton-events.h" #include "xml/node-event-vector.h" @@ -304,6 +305,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb } } +static void arc_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { @@ -402,14 +404,22 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec sp_arctb_sensitivize( holder, gtk_adjustment_get_value(adj1), gtk_adjustment_get_value(adj2) ); } - - sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), G_OBJECT(holder))) - ); - g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(arc_toolbox_check_ec), holder)); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); } +static void arc_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection changed; + + if (SP_IS_ARC_CONTEXT(ec)) { + changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), holder)); + sp_arc_toolbox_selection_changed(sp_desktop_selection(desktop), holder); + } else { + if (changed) + changed.disconnect(); + } +} /* Local Variables: diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index 532eecb0f..052eb230b 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -43,6 +43,7 @@ #include "selection.h" #include "toolbox.h" #include "ui/icon-names.h" +#include "ui/tools/box3d-tool.h" #include "ui/uxmanager.h" #include "verbs.h" #include "xml/node-event-vector.h" @@ -280,6 +281,8 @@ static void box3d_vp_z_state_changed( GtkToggleAction *act, GtkAction *box3d_ang box3d_vp_state_changed(act, box3d_angle, Proj::Z); } +static void box3d_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); + void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -409,13 +412,22 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) ); } - sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), G_OBJECT(holder))) - ); - g_signal_connect(holder, "destroy", G_CALLBACK(delete_connection), connection); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_check_ec), holder)); g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder); } +static void box3d_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection changed; + if (SP_IS_BOX3D_CONTEXT(ec)) { + changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), holder)); + box3d_toolbox_selection_changed(sp_desktop_selection(desktop), holder); + } else { + if (changed) + changed.disconnect(); + } +} + /* Local Variables: mode:c++ diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index a1bd9b792..cda97654e 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -1,6 +1,4 @@ -#define __SP_BUTTON_C__ - -/* +/** * Generic button widget * * Authors: @@ -13,282 +11,257 @@ * This code is in public domain */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - +#include <glibmm.h> #include "icon.h" -#include "shortcuts.h" -#include "interface.h" + +#include "button.h" #include "helper/action-context.h" +#include "interface.h" +#include "shortcuts.h" +#include "helper/action.h" #include <gdk/gdkkeysyms.h> -#include "button.h" - static void sp_button_dispose(GObject *object); -#if GTK_CHECK_VERSION(3,0,0) -static void sp_button_get_preferred_width(GtkWidget *widget, - gint *minimal_width, - gint *natural_width); +#if GTK_CHECK_VERSION(3, 0, 0) +static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width); -static void sp_button_get_preferred_height(GtkWidget *widget, - gint *minimal_height, - gint *natural_height); +static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); #else -static void sp_button_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition); #endif -static void sp_button_clicked (GtkButton *button); -static void sp_button_perform_action (SPButton *button, gpointer data); -static gint sp_button_process_event (SPButton *button, GdkEvent *event); +static void sp_button_clicked(GtkButton *button); +static void sp_button_perform_action(SPButton *button, gpointer data); +static gint sp_button_process_event(SPButton *button, GdkEvent *event); -static void sp_button_set_action (SPButton *button, SPAction *action); -static void sp_button_set_doubleclick_action (SPButton *button, SPAction *action); -static void sp_button_action_set_active (SPButton *button, bool active); -static void sp_button_set_composed_tooltip (GtkWidget *widget, SPAction *action); +static void sp_button_set_action(SPButton *button, SPAction *action); +static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action); +static void sp_button_action_set_active(SPButton *button, bool active); +static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action); G_DEFINE_TYPE(SPButton, sp_button, GTK_TYPE_TOGGLE_BUTTON); -static void -sp_button_class_init (SPButtonClass *klass) +static void sp_button_class_init(SPButtonClass *klass) { - GObjectClass *object_class=G_OBJECT_CLASS(klass); - GtkWidgetClass *widget_class=GTK_WIDGET_CLASS(klass); - GtkButtonClass *button_class=GTK_BUTTON_CLASS(klass); - - object_class->dispose = sp_button_dispose; -#if GTK_CHECK_VERSION(3,0,0) - widget_class->get_preferred_width = sp_button_get_preferred_width; - widget_class->get_preferred_height = sp_button_get_preferred_height; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + GtkButtonClass *button_class = GTK_BUTTON_CLASS(klass); + + object_class->dispose = sp_button_dispose; +#if GTK_CHECK_VERSION(3, 0, 0) + widget_class->get_preferred_width = sp_button_get_preferred_width; + widget_class->get_preferred_height = sp_button_get_preferred_height; #else - widget_class->size_request = sp_button_size_request; + widget_class->size_request = sp_button_size_request; #endif - button_class->clicked = sp_button_clicked; + button_class->clicked = sp_button_clicked; } -static void -sp_button_init (SPButton *button) +static void sp_button_init(SPButton *button) { - button->action = NULL; - button->doubleclick_action = NULL; - new (&button->c_set_active) sigc::connection(); - new (&button->c_set_sensitive) sigc::connection(); + button->action = NULL; + button->doubleclick_action = NULL; + new (&button->c_set_active) sigc::connection(); + new (&button->c_set_sensitive) sigc::connection(); - gtk_container_set_border_width (GTK_CONTAINER (button), 0); + gtk_container_set_border_width(GTK_CONTAINER(button), 0); - gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE); - gtk_widget_set_can_default (GTK_WIDGET (button), FALSE); + gtk_widget_set_can_focus(GTK_WIDGET(button), FALSE); + gtk_widget_set_can_default(GTK_WIDGET(button), FALSE); - g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (sp_button_perform_action), NULL); - g_signal_connect_after (G_OBJECT (button), "event", G_CALLBACK (sp_button_process_event), NULL); + g_signal_connect_after(G_OBJECT(button), "clicked", G_CALLBACK(sp_button_perform_action), NULL); + g_signal_connect_after(G_OBJECT(button), "event", G_CALLBACK(sp_button_process_event), NULL); } static void sp_button_dispose(GObject *object) { - SPButton *button = SP_BUTTON (object); + SPButton *button = SP_BUTTON(object); - if (button->action) { - sp_button_set_action (button, NULL); - } - if (button->doubleclick_action) { - sp_button_set_doubleclick_action (button, NULL); - } + if (button->action) { + sp_button_set_action(button, NULL); + } + if (button->doubleclick_action) { + sp_button_set_doubleclick_action(button, NULL); + } - button->c_set_active.~connection(); - button->c_set_sensitive.~connection(); + button->c_set_active.~connection(); + button->c_set_sensitive.~connection(); - (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); + (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } - - -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3, 0, 0) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { - GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style(widget); - - if (child) { - gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); - } else { - *minimal_width = 0; - *natural_width = 0; - } - - *minimal_width += 2 + 2 * MAX(2, style->xthickness); - *natural_width += 2 + 2 * MAX(2, style->xthickness); + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); + } else { + *minimal_width = 0; + *natural_width = 0; + } + + *minimal_width += 2 + 2 * MAX(2, style->xthickness); + *natural_width += 2 + 2 * MAX(2, style->xthickness); } static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) { - GtkWidget *child = gtk_bin_get_child(GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style(widget); - - if (child) { - gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); - } else { - *minimal_height = 0; - *natural_height = 0; - } + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); - *minimal_height += 2 + 2 * MAX(2, style->ythickness); - *natural_height += 2 + 2 * MAX(2, style->ythickness); + if (child) { + gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); + } else { + *minimal_height = 0; + *natural_height = 0; + } + *minimal_height += 2 + 2 * MAX(2, style->ythickness); + *natural_height += 2 + 2 * MAX(2, style->ythickness); } #else static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) { - GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); - GtkStyle *style = gtk_widget_get_style (widget); - - if (child) { - gtk_widget_size_request (GTK_WIDGET (child), requisition); - } else { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += 2 + 2 * MAX (2, style->xthickness); - requisition->height += 2 + 2 * MAX (2, style->ythickness); + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + GtkStyle *style = gtk_widget_get_style(widget); + + if (child) { + gtk_widget_size_request(GTK_WIDGET(child), requisition); + } else { + requisition->width = 0; + requisition->height = 0; + } + + requisition->width += 2 + 2 * MAX(2, style->xthickness); + requisition->height += 2 + 2 * MAX(2, style->ythickness); } #endif -static void -sp_button_clicked (GtkButton *button) +static void sp_button_clicked(GtkButton *button) { - SPButton *sp_button=SP_BUTTON (button); + SPButton *sp_button = SP_BUTTON(button); - if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { - (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked (button); - } + if (sp_button->type == SP_BUTTON_TYPE_TOGGLE) { + (GTK_BUTTON_CLASS(sp_button_parent_class))->clicked(button); + } } -static gint -sp_button_process_event (SPButton *button, GdkEvent *event) +static gint sp_button_process_event(SPButton *button, GdkEvent *event) { - switch (event->type) { - case GDK_2BUTTON_PRESS: - if (button->doubleclick_action) { - sp_action_perform (button->doubleclick_action, NULL); - } - return TRUE; - break; - default: - break; - } - - return FALSE; + switch (event->type) { + case GDK_2BUTTON_PRESS: + if (button->doubleclick_action) { + sp_action_perform(button->doubleclick_action, NULL); + } + return TRUE; + break; + default: + break; + } + + return FALSE; } -static void -sp_button_perform_action (SPButton *button, gpointer /*data*/) +static void sp_button_perform_action(SPButton *button, gpointer /*data*/) { - if (button->action) { - sp_action_perform (button->action, NULL); - } + if (button->action) { + sp_action_perform(button->action, NULL); + } } - -GtkWidget * -sp_button_new( Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action ) +GtkWidget *sp_button_new(Inkscape::IconSize size, SPButtonType type, SPAction *action, SPAction *doubleclick_action) { - SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); + SPButton *button = SP_BUTTON(g_object_new(SP_TYPE_BUTTON, NULL)); - button->type = type; - button->lsize = CLAMP( size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION ); + button->type = type; + button->lsize = CLAMP(size, Inkscape::ICON_SIZE_MENU, Inkscape::ICON_SIZE_DECORATION); - sp_button_set_action (button, action); - if (doubleclick_action) - sp_button_set_doubleclick_action (button, doubleclick_action); + sp_button_set_action(button, action); + if (doubleclick_action) + sp_button_set_doubleclick_action(button, doubleclick_action); - // The Inkscape style is no-relief buttons - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); + // The Inkscape style is no-relief buttons + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - return GTK_WIDGET(button); + return GTK_WIDGET(button); } -void -sp_button_toggle_set_down (SPButton *button, gboolean down) +void sp_button_toggle_set_down(SPButton *button, gboolean down) { - g_return_if_fail (button->type == SP_BUTTON_TYPE_TOGGLE); - g_signal_handlers_block_by_func (G_OBJECT (button), (gpointer)G_CALLBACK (sp_button_perform_action), NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), (unsigned int)down); - g_signal_handlers_unblock_by_func (G_OBJECT (button), (gpointer)G_CALLBACK (sp_button_perform_action), NULL); + g_return_if_fail(button->type == SP_BUTTON_TYPE_TOGGLE); + g_signal_handlers_block_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (unsigned int)down); + g_signal_handlers_unblock_by_func(G_OBJECT(button), (gpointer)G_CALLBACK(sp_button_perform_action), NULL); } -static void -sp_button_set_doubleclick_action (SPButton *button, SPAction *action) +static void sp_button_set_doubleclick_action(SPButton *button, SPAction *action) { - if (button->doubleclick_action) { - g_object_unref (button->doubleclick_action); - } - button->doubleclick_action = action; - if (action) { - g_object_ref(action); - } - + if (button->doubleclick_action) { + g_object_unref(button->doubleclick_action); + } + button->doubleclick_action = action; + if (action) { + g_object_ref(action); + } } -static void -sp_button_set_action (SPButton *button, SPAction *action) +static void sp_button_set_action(SPButton *button, SPAction *action) { - GtkWidget *child; - - if (button->action) { - button->c_set_active.disconnect(); - button->c_set_sensitive.disconnect(); - child = gtk_bin_get_child (GTK_BIN (button)); - if (child) { - gtk_container_remove (GTK_CONTAINER (button), child); - } - g_object_unref(button->action); - } - button->action = action; - if (action) { - g_object_ref(action); - button->c_set_active = action->signal_set_active.connect( - sigc::bind<0>( - sigc::ptr_fun(&sp_button_action_set_active), - SP_BUTTON(button))); - button->c_set_sensitive = action->signal_set_sensitive.connect( - sigc::bind<0>( - sigc::ptr_fun(>k_widget_set_sensitive), - GTK_WIDGET(button))); - if (action->image) { - child = sp_icon_new (button->lsize, action->image); - gtk_widget_show (child); - gtk_container_add (GTK_CONTAINER (button), child); - } - } - - sp_button_set_composed_tooltip(GTK_WIDGET(button), action); + GtkWidget *child; + + if (button->action) { + button->c_set_active.disconnect(); + button->c_set_sensitive.disconnect(); + child = gtk_bin_get_child(GTK_BIN(button)); + if (child) { + gtk_container_remove(GTK_CONTAINER(button), child); + } + g_object_unref(button->action); + } + button->action = action; + if (action) { + g_object_ref(action); + button->c_set_active = action->signal_set_active.connect( + sigc::bind<0>(sigc::ptr_fun(&sp_button_action_set_active), SP_BUTTON(button))); + button->c_set_sensitive = action->signal_set_sensitive.connect( + sigc::bind<0>(sigc::ptr_fun(>k_widget_set_sensitive), GTK_WIDGET(button))); + if (action->image) { + child = sp_icon_new(button->lsize, action->image); + gtk_widget_show(child); + gtk_container_add(GTK_CONTAINER(button), child); + } + } + + sp_button_set_composed_tooltip(GTK_WIDGET(button), action); } -static void -sp_button_action_set_active (SPButton *button, bool active) +static void sp_button_action_set_active(SPButton *button, bool active) { - if (button->type != SP_BUTTON_TYPE_TOGGLE) { - return; - } - - /* temporarily lobotomized until SPActions are per-view */ - if (0 && !active != !SP_BUTTON_IS_DOWN (button)) { - sp_button_toggle_set_down (button, active); - } + if (button->type != SP_BUTTON_TYPE_TOGGLE) { + return; + } + + /* temporarily lobotomized until SPActions are per-view */ + if (0 && !active != !SP_BUTTON_IS_DOWN(button)) { + sp_button_toggle_set_down(button, active); + } } static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) { if (action) { - unsigned int shortcut = sp_shortcut_get_primary (action->verb); + unsigned int shortcut = sp_shortcut_get_primary(action->verb); if (shortcut != GDK_KEY_VoidSymbol) { // there's both action and shortcut gchar *key = sp_shortcut_get_label(shortcut); - gchar *tip = g_strdup_printf ("%s (%s)", action->tip, key); + gchar *tip = g_strdup_printf("%s (%s)", action->tip, key); gtk_widget_set_tooltip_text(widget, tip); g_free(tip); g_free(key); @@ -302,18 +275,14 @@ static void sp_button_set_composed_tooltip(GtkWidget *widget, SPAction *action) } } -GtkWidget * -sp_button_new_from_data( Inkscape::IconSize size, - SPButtonType type, - Inkscape::UI::View::View *view, - const gchar *name, - const gchar *tip ) +GtkWidget *sp_button_new_from_data(Inkscape::IconSize size, SPButtonType type, Inkscape::UI::View::View *view, + const gchar *name, const gchar *tip) { - GtkWidget *button; - SPAction *action=sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); - button = sp_button_new (size, type, action, NULL); - g_object_unref(action); - return button; + GtkWidget *button; + SPAction *action = sp_action_new(Inkscape::ActionContext(view), name, name, tip, name, 0); + button = sp_button_new(size, type, action, NULL); + g_object_unref(action); + return button; } /* @@ -325,4 +294,4 @@ sp_button_new_from_data( Inkscape::IconSize size, fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/button.h b/src/widgets/button.h index 41863357d..2bceb5e97 100644 --- a/src/widgets/button.h +++ b/src/widgets/button.h @@ -1,7 +1,7 @@ -#ifndef __SP_BUTTON_H__ -#define __SP_BUTTON_H__ +#ifndef SEEN_SP_BUTTON_H +#define SEEN_SP_BUTTON_H -/* +/** * Generic button widget * * Author: @@ -17,10 +17,18 @@ #define SP_IS_BUTTON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_BUTTON)) #include <gtk/gtk.h> -#include <sigc++/sigc++.h> -#include "helper/action.h" +#include <sigc++/connection.h> #include "icon-size.h" +struct SPAction; + +namespace Inkscape { +namespace UI { +namespace View { +class View; +} +} +} typedef enum { SP_BUTTON_TYPE_NORMAL, @@ -61,6 +69,15 @@ GtkWidget *sp_button_new_from_data (Inkscape::IconSize size, const gchar *name, const gchar *tip); +#endif // !SEEN_SP_BUTTON_H - -#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 : diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 7717a304d..d772253cb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -98,7 +98,6 @@ enum { //--------------------------------------------------------------------- /* SPDesktopWidget */ -static void sp_desktop_widget_class_init (SPDesktopWidgetClass *klass); static void sp_desktop_widget_dispose(GObject *object); static void sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); @@ -128,8 +127,6 @@ static void sp_dtw_zoom_drawing (GtkMenuItem *item, gpointer data); static void sp_dtw_zoom_selection (GtkMenuItem *item, gpointer data); static void sp_dtw_sticky_zoom_toggled (GtkMenuItem *item, gpointer data); -SPViewWidgetClass *dtw_parent_class; - class CMSPrefWatcher { public: CMSPrefWatcher() : @@ -268,31 +265,19 @@ SPDesktopWidget::window_get_pointer() static GTimer *overallTimer = 0; -/** - * Registers SPDesktopWidget class and returns its type number. - */ -GType SPDesktopWidget::getType(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPDesktopWidgetClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_desktop_widget_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPDesktopWidget), - 0, // n_preallocs - (GInstanceInitFunc)SPDesktopWidget::init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_VIEW_WIDGET, "SPDesktopWidget", &info, static_cast<GTypeFlags>(0)); - // Begin a timer to watch for the first desktop to appear on-screen - overallTimer = g_timer_new(); - } - return type; -} +struct SPDesktopWidgetPrivate +{ + GtkWidget *tool_toolbox; + GtkWidget *aux_toolbox; + GtkWidget *commands_toolbox; + GtkWidget *snap_toolbox; +}; + +G_DEFINE_TYPE_WITH_CODE(SPDesktopWidget, sp_desktop_widget, SP_TYPE_VIEW_WIDGET, + // Begin a timer to watch for the first desktop to appear on-screen + overallTimer = g_timer_new(); + G_ADD_PRIVATE(SPDesktopWidget); + ); /** * SPDesktopWidget vtable initialization @@ -300,8 +285,6 @@ GType SPDesktopWidget::getType(void) static void sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) { - dtw_parent_class = SP_VIEW_WIDGET_CLASS(g_type_class_peek_parent(klass)); - GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); @@ -329,10 +312,12 @@ static void canvas_tbl_size_allocate(GtkWidget * /*widget*/, /** * Callback for SPDesktopWidget object initialization. */ -void SPDesktopWidget::init( SPDesktopWidget *dtw ) +void sp_desktop_widget_init( SPDesktopWidget *dtw ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + dtw->priv = reinterpret_cast<SPDesktopWidgetPrivate *>(sp_desktop_widget_get_instance_private(dtw)); + new (&dtw->modified_connection) sigc::connection(); dtw->window = 0; @@ -377,19 +362,19 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); gtk_widget_show(dtw->hbox); - dtw->aux_toolbox = ToolboxFactory::createAuxToolbox(); - gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0); + dtw->priv->aux_toolbox = ToolboxFactory::createAuxToolbox(); + gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->priv->aux_toolbox, FALSE, TRUE, 0); - dtw->snap_toolbox = ToolboxFactory::createSnapToolbox(); - ToolboxFactory::setOrientation( dtw->snap_toolbox, GTK_ORIENTATION_VERTICAL ); - gtk_box_pack_end( GTK_BOX(dtw->hbox), dtw->snap_toolbox, FALSE, TRUE, 0 ); + dtw->priv->snap_toolbox = ToolboxFactory::createSnapToolbox(); + ToolboxFactory::setOrientation( dtw->priv->snap_toolbox, GTK_ORIENTATION_VERTICAL ); + gtk_box_pack_end( GTK_BOX(dtw->hbox), dtw->priv->snap_toolbox, FALSE, TRUE, 0 ); - dtw->commands_toolbox = ToolboxFactory::createCommandsToolbox(); - gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->commands_toolbox, FALSE, TRUE, 0); + dtw->priv->commands_toolbox = ToolboxFactory::createCommandsToolbox(); + gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->priv->commands_toolbox, FALSE, TRUE, 0); - dtw->tool_toolbox = ToolboxFactory::createToolToolbox(); - ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL ); - gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 ); + dtw->priv->tool_toolbox = ToolboxFactory::createToolToolbox(); + ToolboxFactory::setOrientation( dtw->priv->tool_toolbox, GTK_ORIENTATION_VERTICAL ); + gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->priv->tool_toolbox, FALSE, TRUE, 0 ); /* Horizontal ruler */ GtkWidget *eventbox = gtk_event_box_new (); @@ -804,8 +789,8 @@ static void sp_desktop_widget_dispose(GObject *object) dtw->modified_connection.~connection(); - if (G_OBJECT_CLASS (dtw_parent_class)->dispose) { - (* G_OBJECT_CLASS (dtw_parent_class)->dispose) (object); + if (G_OBJECT_CLASS (sp_desktop_widget_parent_class)->dispose) { + G_OBJECT_CLASS (sp_desktop_widget_parent_class)->dispose(object); } } @@ -908,8 +893,8 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) (allocation->y == widg_allocation.y) && (allocation->width == widg_allocation.width) && (allocation->height == widg_allocation.height)) { - if (GTK_WIDGET_CLASS (dtw_parent_class)->size_allocate) - GTK_WIDGET_CLASS (dtw_parent_class)->size_allocate (widget, allocation); + if (GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->size_allocate) + GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->size_allocate (widget, allocation); return; } @@ -917,8 +902,8 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) Geom::Rect const area = dtw->desktop->get_display_area(); double zoom = dtw->desktop->current_zoom(); - if (GTK_WIDGET_CLASS(dtw_parent_class)->size_allocate) { - GTK_WIDGET_CLASS(dtw_parent_class)->size_allocate (widget, allocation); + if (GTK_WIDGET_CLASS(sp_desktop_widget_parent_class)->size_allocate) { + GTK_WIDGET_CLASS(sp_desktop_widget_parent_class)->size_allocate (widget, allocation); } if (SP_BUTTON_IS_DOWN(dtw->sticky_zoom)) { @@ -936,8 +921,8 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) dtw->desktop->show_dialogs(); } else { - if (GTK_WIDGET_CLASS (dtw_parent_class)->size_allocate) { - GTK_WIDGET_CLASS (dtw_parent_class)->size_allocate (widget, allocation); + if (GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->size_allocate) { + GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->size_allocate (widget, allocation); } // this->size_allocate (widget, allocation); } @@ -952,8 +937,8 @@ sp_desktop_widget_realize (GtkWidget *widget) SPDesktopWidget *dtw = SP_DESKTOP_WIDGET (widget); - if (GTK_WIDGET_CLASS (dtw_parent_class)->realize) - (* GTK_WIDGET_CLASS (dtw_parent_class)->realize) (widget); + if (GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->realize) + GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->realize(widget); Geom::Rect d = Geom::Rect::from_xywh(Geom::Point(0,0), (dtw->desktop->doc())->getDimensions()); @@ -998,8 +983,8 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt } } - if (GTK_WIDGET_CLASS (dtw_parent_class)->event) { - return (* GTK_WIDGET_CLASS (dtw_parent_class)->event) (widget, event); + if (GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->event) { + return GTK_WIDGET_CLASS (sp_desktop_widget_parent_class)->event(widget, event); } else { // The key press/release events need to be passed to desktop handler explicitly, // because otherwise the event contexts only receive key events when the mouse cursor @@ -1499,29 +1484,29 @@ void SPDesktopWidget::layoutWidgets() } if (!prefs->getBool(pref_root + "commands/state", true)) { - gtk_widget_hide (dtw->commands_toolbox); + gtk_widget_hide (dtw->priv->commands_toolbox); } else { - gtk_widget_show_all (dtw->commands_toolbox); + gtk_widget_show_all (dtw->priv->commands_toolbox); } if (!prefs->getBool(pref_root + "snaptoolbox/state", true)) { - gtk_widget_hide (dtw->snap_toolbox); + gtk_widget_hide (dtw->priv->snap_toolbox); } else { - gtk_widget_show_all (dtw->snap_toolbox); + gtk_widget_show_all (dtw->priv->snap_toolbox); } if (!prefs->getBool(pref_root + "toppanel/state", true)) { - gtk_widget_hide (dtw->aux_toolbox); + gtk_widget_hide (dtw->priv->aux_toolbox); } else { // we cannot just show_all because that will show all tools' panels; // this is a function from toolbox.cpp that shows only the current tool's panel - ToolboxFactory::showAuxToolbox(dtw->aux_toolbox); + ToolboxFactory::showAuxToolbox(dtw->priv->aux_toolbox); } if (!prefs->getBool(pref_root + "toolbox/state", true)) { - gtk_widget_hide (dtw->tool_toolbox); + gtk_widget_hide (dtw->priv->tool_toolbox); } else { - gtk_widget_show_all (dtw->tool_toolbox); + gtk_widget_show_all (dtw->priv->tool_toolbox); } if (!prefs->getBool(pref_root + "statusbar/state", true)) { @@ -1558,7 +1543,7 @@ void SPDesktopWidget::layoutWidgets() void SPDesktopWidget::setToolboxFocusTo (const gchar* label) { - gpointer hb = sp_search_by_data_recursive(aux_toolbox, (gpointer) label); + gpointer hb = sp_search_by_data_recursive(priv->aux_toolbox, (gpointer) label); if (hb && GTK_IS_WIDGET(hb)) { gtk_widget_grab_focus(GTK_WIDGET(hb)); @@ -1569,7 +1554,7 @@ void SPDesktopWidget::setToolboxAdjustmentValue (gchar const *id, double value) { GtkAdjustment *a = NULL; - gpointer hb = sp_search_by_data_recursive (aux_toolbox, (gpointer) id); + gpointer hb = sp_search_by_data_recursive (priv->aux_toolbox, (gpointer) id); if (hb && GTK_IS_WIDGET(hb)) { if (GTK_IS_SPIN_BUTTON(hb)) a = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(hb)); @@ -1586,7 +1571,7 @@ SPDesktopWidget::setToolboxAdjustmentValue (gchar const *id, double value) void SPDesktopWidget::setToolboxSelectOneValue (gchar const *id, int value) { - gpointer hb = sp_search_by_data_recursive(aux_toolbox, (gpointer) id); + gpointer hb = sp_search_by_data_recursive(priv->aux_toolbox, (gpointer) id); if (hb) { ege_select_one_action_set_active(EGE_SELECT_ONE_ACTION(hb), value); } @@ -1597,7 +1582,7 @@ bool SPDesktopWidget::isToolboxButtonActive (const gchar* id) { bool isActive = false; - gpointer thing = sp_search_by_data_recursive(aux_toolbox, (gpointer) id); + gpointer thing = sp_search_by_data_recursive(priv->aux_toolbox, (gpointer) id); if ( !thing ) { //g_message( "Unable to locate item for {%s}", id ); } else if ( GTK_IS_TOGGLE_BUTTON(thing) ) { @@ -1618,13 +1603,13 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp // Note - later on these won't be individual member variables. GtkWidget* toolbox = 0; if (id == "ToolToolbar") { - toolbox = tool_toolbox; + toolbox = priv->tool_toolbox; } else if (id == "AuxToolbar") { - toolbox = aux_toolbox; + toolbox = priv->aux_toolbox; } else if (id == "CommandsToolbar") { - toolbox = commands_toolbox; + toolbox = priv->commands_toolbox; } else if (id == "SnapToolbar") { - toolbox = snap_toolbox; + toolbox = priv->snap_toolbox; } @@ -1697,10 +1682,10 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview) dtw->layoutWidgets(); std::vector<GtkWidget *> toolboxes; - toolboxes.push_back(dtw->tool_toolbox); - toolboxes.push_back(dtw->aux_toolbox); - toolboxes.push_back(dtw->commands_toolbox); - toolboxes.push_back(dtw->snap_toolbox); + toolboxes.push_back(dtw->priv->tool_toolbox); + toolboxes.push_back(dtw->priv->aux_toolbox); + toolboxes.push_back(dtw->priv->commands_toolbox); + toolboxes.push_back(dtw->priv->snap_toolbox); dtw->panels->setDesktop( dtw->desktop ); @@ -1754,8 +1739,8 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) * * This should solve: https://bugs.launchpad.net/inkscape/+bug/362995 */ - if (GTK_IS_CONTAINER(aux_toolbox)) { - GList *ch = gtk_container_get_children (GTK_CONTAINER(aux_toolbox)); + if (GTK_IS_CONTAINER(priv->aux_toolbox)) { + GList *ch = gtk_container_get_children (GTK_CONTAINER(priv->aux_toolbox)); for (GList *i = ch; i != NULL; i = i->next) { if (GTK_IS_CONTAINER(i->data)) { GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data)); @@ -1781,7 +1766,7 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags) gtk_widget_set_tooltip_text(this->vruler_box, gettext(nv->doc_units->name_plural.c_str())); sp_desktop_widget_update_rulers(this); - ToolboxFactory::updateSnapToolbox(this->desktop, 0, this->snap_toolbox); + ToolboxFactory::updateSnapToolbox(this->desktop, 0, priv->snap_toolbox); } } diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index a77d56fc3..9a4834d3d 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -34,15 +34,33 @@ typedef struct _EgeColorProfTracker EgeColorProfTracker; struct SPCanvas; class SPDesktop; struct SPDesktopWidget; +struct SPDesktopWidgetPrivate; class SPObject; +namespace Inkscape { + namespace Widgets { + class LayerSelector; + } -#define SP_TYPE_DESKTOP_WIDGET SPDesktopWidget::getType() -#define SP_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget)) -#define SP_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass)) -#define SP_IS_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_DESKTOP_WIDGET)) + namespace UI { + namespace Widget { + class SelectedStyle; + } + + namespace Dialogs { + class SwatchesPanel; + } + } +} + +#define SP_TYPE_DESKTOP_WIDGET (sp_desktop_widget_get_type ()) +#define SP_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget)) +#define SP_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass)) +#define SP_IS_DESKTOP_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_DESKTOP_WIDGET)) #define SP_IS_DESKTOP_WIDGET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_DESKTOP_WIDGET)) +GType sp_desktop_widget_get_type(); + void sp_desktop_widget_show_decorations(SPDesktopWidget *dtw, gboolean show); void sp_desktop_widget_iconify(SPDesktopWidget *dtw); void sp_desktop_widget_maximize(SPDesktopWidget *dtw); @@ -62,12 +80,6 @@ bool sp_desktop_widget_color_prof_adj_enabled( SPDesktopWidget *dtw ); void sp_dtw_desktop_activate (SPDesktopWidget *dtw); void sp_dtw_desktop_deactivate (SPDesktopWidget *dtw); -namespace Inkscape { namespace Widgets { class LayerSelector; } } - -namespace Inkscape { namespace UI { namespace Widget { class SelectedStyle; } } } - -namespace Inkscape { namespace UI { namespace Dialogs { class SwatchesPanel; } } } - /// A GtkEventBox on an SPDesktop. struct SPDesktopWidget { SPViewWidget viewwidget; @@ -248,22 +260,15 @@ struct SPDesktopWidget { Inkscape::UI::Widget::Dock* getDock(); - static GType getType(); static SPDesktopWidget* createInstance(SPNamedView *namedview); void updateNamedview(); + SPDesktopWidgetPrivate *priv; private: - GtkWidget *tool_toolbox; - GtkWidget *aux_toolbox; - GtkWidget *commands_toolbox; - GtkWidget *snap_toolbox; - - static void init(SPDesktopWidget *widget); void layoutWidgets(); void namedviewModified(SPObject *obj, guint flags); - }; /// The SPDesktopWidget vtable diff --git a/src/widgets/eek-preview.h b/src/widgets/eek-preview.h index e4c724cc5..883ce713e 100644 --- a/src/widgets/eek-preview.h +++ b/src/widgets/eek-preview.h @@ -37,7 +37,6 @@ #ifndef SEEN_EEK_PREVIEW_H #define SEEN_EEK_PREVIEW_H -#include <gdk/gdk.h> #include <gtk/gtk.h> /** diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index ccaf93e55..943434868 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -1,6 +1,4 @@ -#define __SP_FONT_SELECTOR_C__ - -/* +/** * Font selection widgets * * Authors: @@ -38,7 +36,11 @@ struct SPFontSelector { +#if GTK_CHECK_VERSION(3,0,0) + GtkBox hbox; +#else GtkHBox hbox; +#endif unsigned int block_emit : 1; @@ -59,7 +61,11 @@ struct SPFontSelector struct SPFontSelectorClass { +#if GTK_CHECK_VERSION(3,0,0) + GtkBoxClass parent_class; +#else GtkHBoxClass parent_class; +#endif void (* font_set) (SPFontSelector *fsel, gchar *fontspec); }; @@ -69,8 +75,6 @@ enum { LAST_SIGNAL }; -static void sp_font_selector_class_init (SPFontSelectorClass *c); -static void sp_font_selector_init (SPFontSelector *fsel); static void sp_font_selector_dispose (GObject *object); static void sp_font_selector_family_select_row (GtkTreeSelection *selection, @@ -85,36 +89,18 @@ static void sp_font_selector_size_changed (GtkComboBox *combobo static void sp_font_selector_emit_set (SPFontSelector *fsel); static void sp_font_selector_set_sizes( SPFontSelector *fsel ); -static GtkHBoxClass *fs_parent_class = NULL; static guint fs_signals[LAST_SIGNAL] = { 0 }; -GType sp_font_selector_get_type() -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPFontSelectorClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_font_selector_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPFontSelector), - 0, // n_preallocs - (GInstanceInitFunc)sp_font_selector_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_HBOX, "SPFontSelector", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +#if GTK_CHECK_VERSION(3,0,0) +G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_BOX); +#else +G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_HBOX); +#endif static void sp_font_selector_class_init(SPFontSelectorClass *c) { GObjectClass *object_class = G_OBJECT_CLASS(c); - fs_parent_class = (GtkHBoxClass* )g_type_class_peek_parent (c); - fs_signals[FONT_SET] = g_signal_new ("font_set", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)G_SIGNAL_RUN_FIRST, @@ -157,6 +143,10 @@ static void sp_font_selector_init(SPFontSelector *fsel) gtk_container_add(GTK_CONTAINER(f), sw); fsel->family_treeview = gtk_tree_view_new (); + gtk_tree_view_set_row_separator_func( GTK_TREE_VIEW(fsel->family_treeview), + GtkTreeViewRowSeparatorFunc ((gpointer)font_lister_separator_func), + NULL, NULL ); + gtk_widget_show_all(GTK_WIDGET (fsel->family_treeview)); GtkTreeViewColumn *column = gtk_tree_view_column_new (); GtkCellRenderer *cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); @@ -166,9 +156,6 @@ static void sp_font_selector_init(SPFontSelector *fsel) NULL, NULL ); gtk_tree_view_append_column (GTK_TREE_VIEW(fsel->family_treeview), column); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->family_treeview), FALSE); - gtk_tree_view_set_row_separator_func( GTK_TREE_VIEW(fsel->family_treeview), - GtkTreeViewRowSeparatorFunc ((gpointer)font_lister_separator_func), - NULL, NULL ); /* Muck with style, see text-toolbar.cpp */ gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" ); @@ -284,8 +271,8 @@ static void sp_font_selector_dispose(GObject *object) fsel->styles.length = 0; } - if (G_OBJECT_CLASS(fs_parent_class)->dispose) { - G_OBJECT_CLASS(fs_parent_class)->dispose(object); + if (G_OBJECT_CLASS(sp_font_selector_parent_class)->dispose) { + G_OBJECT_CLASS(sp_font_selector_parent_class)->dispose(object); } } @@ -303,6 +290,9 @@ static void sp_font_selector_family_select_row(GtkTreeSelection *selection, GtkTreeModel *model; GtkTreeIter iter; if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return; + + Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance(); + fontlister->ensureRowStyles(model, &iter); // Next get family name with its style list gchar *family; @@ -310,7 +300,6 @@ static void sp_font_selector_family_select_row(GtkTreeSelection *selection, gtk_tree_model_get (model, &iter, 0, &family, 1, &list, -1); // Find best style match for selected family with current style (e.g. of selected text). - Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance(); Glib::ustring style = fontlister->get_font_style(); Glib::ustring best = fontlister->get_best_style_match (family, style); @@ -551,4 +540,4 @@ double sp_font_selector_get_size(SPFontSelector *fsel) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 66715f048..ff5472d2d 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -54,7 +54,7 @@ Glib::ustring sp_font_selector_get_fontspec (SPFontSelector *fsel); double sp_font_selector_get_size (SPFontSelector *fsel); -#endif // SP_FONT_SELECTOR_H +#endif // !SP_FONT_SELECTOR_H /* Local Variables: @@ -65,4 +65,4 @@ double sp_font_selector_get_size (SPFontSelector *fsel); fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 64b058f62..6901b8549 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -1,6 +1,4 @@ -#define __SP_GRADIENT_IMAGE_C__ - -/* +/** * A simple gradient preview * * Author: @@ -12,18 +10,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "macros.h" +#include <sigc++/sigc++.h> + #include "display/cairo-utils.h" #include "gradient-image.h" +#include "macros.h" #include "sp-gradient.h" -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> - #define VBLOCK 16 -static void sp_gradient_image_class_init (SPGradientImageClass *klass); -static void sp_gradient_image_init (SPGradientImage *image); static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition); #if GTK_CHECK_VERSION(3,0,0) @@ -45,35 +40,13 @@ static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im) static void sp_gradient_image_gradient_modified (SPObject *, guint flags, SPGradientImage *im); static void sp_gradient_image_update (SPGradientImage *img); -static GtkWidgetClass *parent_class; - -GType sp_gradient_image_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPGradientImageClass), - NULL, NULL, - (GClassInitFunc) sp_gradient_image_class_init, - NULL, NULL, - sizeof (SPGradientImage), - 0, - (GInstanceInitFunc) sp_gradient_image_init, - NULL - }; - type = g_type_register_static (GTK_TYPE_WIDGET, "SPGradientImage", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPGradientImage, sp_gradient_image, GTK_TYPE_WIDGET); static void sp_gradient_image_class_init(SPGradientImageClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent (klass)); #if GTK_CHECK_VERSION(3,0,0) -// GObjectClass *object_class = G_OBJECT_CLASS(klass); - widget_class->get_preferred_width = sp_gradient_image_get_preferred_width; widget_class->get_preferred_height = sp_gradient_image_get_preferred_height; widget_class->draw = sp_gradient_image_draw; @@ -116,11 +89,11 @@ static void sp_gradient_image_destroy(GtkObject *object) image->modified_connection.~connection(); #if GTK_CHECK_VERSION(3,0,0) - if (parent_class->destroy) - (* (parent_class)->destroy) (object); + if (GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy) + GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy(object); #else - if ((GTK_OBJECT_CLASS(parent_class))->destroy) - (* (GTK_OBJECT_CLASS(parent_class))->destroy) (object); + if (GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy) + GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy(object); #endif } @@ -269,3 +242,14 @@ sp_gradient_image_update (SPGradientImage *image) gtk_widget_queue_draw (GTK_WIDGET (image)); } } + +/* + 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 : diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h index 904ce4cac..0d3833441 100644 --- a/src/widgets/gradient-image.h +++ b/src/widgets/gradient-image.h @@ -1,7 +1,7 @@ -#ifndef __SP_GRADIENT_IMAGE_H__ -#define __SP_GRADIENT_IMAGE_H__ +#ifndef SEEN_SP_GRADIENT_IMAGE_H +#define SEEN_SP_GRADIENT_IMAGE_H -/* +/** * A simple gradient preview * * Author: @@ -17,9 +17,6 @@ class SPGradient; -#include <glib.h> - -#include <stddef.h> #include <sigc++/connection.h> #define SP_TYPE_GRADIENT_IMAGE (sp_gradient_image_get_type ()) @@ -29,15 +26,15 @@ class SPGradient; #define SP_IS_GRADIENT_IMAGE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_IMAGE)) struct SPGradientImage { - GtkWidget widget; - SPGradient *gradient; + GtkWidget widget; + SPGradient *gradient; - sigc::connection release_connection; - sigc::connection modified_connection; + sigc::connection release_connection; + sigc::connection modified_connection; }; struct SPGradientImageClass { - GtkWidgetClass parent_class; + GtkWidgetClass parent_class; }; GType sp_gradient_image_get_type (void); @@ -47,3 +44,14 @@ GdkPixbuf *sp_gradient_to_pixbuf (SPGradient *gr, int width, int height); void sp_gradient_image_set_gradient (SPGradientImage *gi, SPGradient *gr); #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 : diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 871d1ee4c..a5e16aed2 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -16,13 +16,15 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif + +#include <gtkmm/treeview.h> + #include "gradient-vector.h" -#include <gtk/gtk.h> #include "document.h" -#include "../document-undo.h" -#include "../document-private.h" -#include "../gradient-chemistry.h" +#include "document-undo.h" +#include "document-private.h" +#include "gradient-chemistry.h" #include "inkscape.h" #include "verbs.h" #include "helper/action.h" @@ -47,8 +49,6 @@ enum { }; -static void sp_gradient_selector_class_init (SPGradientSelectorClass *klass); -static void sp_gradient_selector_init (SPGradientSelector *selector); static void sp_gradient_selector_dispose(GObject *object); /* Signal handlers */ @@ -57,41 +57,18 @@ static void sp_gradient_selector_edit_vector_clicked (GtkWidget *w, SPGradientSe static void sp_gradient_selector_add_vector_clicked (GtkWidget *w, SPGradientSelector *sel); static void sp_gradient_selector_delete_vector_clicked (GtkWidget *w, SPGradientSelector *sel); - -static GtkVBoxClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; -GType sp_gradient_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof(SPGradientSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_gradient_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPGradientSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_gradient_selector_init, - 0, /* value_table */ - }; - - type = g_type_register_static( GTK_TYPE_VBOX, - "SPGradientSelector", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} +#if GTK_CHECK_VERSION(3,0,0) +G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_BOX); +#else +G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_VBOX); +#endif static void sp_gradient_selector_class_init(SPGradientSelectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - parent_class = GTK_VBOX_CLASS(g_type_class_peek_parent (klass)); - signals[GRABBED] = g_signal_new ("grabbed", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), @@ -128,6 +105,11 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) { sel->safelyInit = true; sel->blocked = false; + +#if GTK_CHECK_VERSION(3,0,0) + gtk_orientable_set_orientation(GTK_ORIENTABLE(sel), GTK_ORIENTATION_VERTICAL); +#endif + new (&sel->nonsolid) std::vector<GtkWidget*>(); new (&sel->swatch_widgets) std::vector<GtkWidget*>(); @@ -269,8 +251,8 @@ static void sp_gradient_selector_dispose(GObject *object) sel->text_renderer = NULL; } - if ((G_OBJECT_CLASS(parent_class))->dispose) { - (* (G_OBJECT_CLASS(parent_class))->dispose) (object); + if ((G_OBJECT_CLASS(sp_gradient_selector_parent_class))->dispose) { + (G_OBJECT_CLASS(sp_gradient_selector_parent_class))->dispose(object); } } diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index 1f58de2e4..e090d7cbd 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -19,27 +19,23 @@ # include <config.h> #endif -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - -#include <glib.h> -#include <gtk/gtk.h> - -#include <gtkmm/entry.h> -#include <gtkmm/label.h> -#include <gtkmm/table.h> #include <gtkmm/liststore.h> -#include <gtkmm/treeview.h> #include <gtkmm/scrolledwindow.h> #include <vector> -#include "sp-gradient.h" #include "sp-gradient-spread.h" #include "sp-gradient-units.h" +class SPDocument; class SPGradient; +namespace Gtk { +class CellRendererPixbuf; +class CellRendererText; +class ScrolledWindow; +class TreeView; +} + #define SP_TYPE_GRADIENT_SELECTOR (sp_gradient_selector_get_type ()) #define SP_GRADIENT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelector)) #define SP_GRADIENT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_GRADIENT_SELECTOR, SPGradientSelectorClass)) @@ -49,11 +45,18 @@ class SPGradient; struct SPGradientSelector { +#if GTK_CHECK_VERSION(3,0,0) + GtkBox vbox; +#else GtkVBox vbox; +#endif enum SelectorMode { MODE_LINEAR, MODE_RADIAL, +#ifdef WITH_MESH + MODE_MESH, +#endif MODE_SWATCH }; @@ -128,7 +131,11 @@ struct SPGradientSelector { }; struct SPGradientSelectorClass { +#if GTK_CHECK_VERSION(3,0,0) + GtkBoxClass parent_class; +#else GtkVBoxClass parent_class; +#endif void (* grabbed) (SPGradientSelector *sel); void (* dragged) (SPGradientSelector *sel); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 4fda44c8d..f5a99f3e7 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -448,11 +448,6 @@ static void gr_defs_modified(SPObject * /*defs*/, guint /*flags*/, GtkWidget *wi gr_tb_selection_changed(NULL, (gpointer) widget); } -static void gr_disconnect_sigc(GObject * /*obj*/, sigc::connection *connection) { - connection->disconnect(); - delete connection; -} - static SPStop *get_selected_stop( GtkWidget *vb) { SPStop *stop = NULL; @@ -1018,6 +1013,9 @@ void check_renderer(GtkWidget *combo) g_object_set_data(G_OBJECT(combo), "renderers", renderer); } } + +static void gradient_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); + /** * Gradient auxiliary toolbar construction and setup. * @@ -1229,34 +1227,51 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), !linkedmode ); } - Inkscape::Selection *selection = sp_desktop_selection(desktop); - SPDocument *document = sp_desktop_document(desktop); - g_object_set_data(holder, "desktop", desktop); - // connect to selection modified and changed signals - sigc::connection *conn1 = new sigc::connection( - selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), (gpointer) holder))); - sigc::connection *conn2 = new sigc::connection( - selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), (gpointer) holder))); - sigc::connection *conn3 = new sigc::connection( - desktop->connectToolSubselectionChanged( sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), (gpointer) holder))); - - // when holder is destroyed, disconnect - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn1); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn2); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn3); - - // connect to release and modified signals of the defs (i.e. when someone changes gradient) - sigc::connection *release_connection = new sigc::connection(); - *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder))); - sigc::connection *modified_connection = new sigc::connection(); - *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder))); - - // when holder is destroyed, disconnect - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), release_connection); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), modified_connection); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(&gradient_toolbox_check_ec), holder)); +} + +// lp:1327267 +/** + * Checks the current tool and connects gradient aux toolbox signals if it happens to be the gradient tool. + * Called every time the current tool changes by signal emission. + */ +static void gradient_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection connChanged; + static sigc::connection connModified; + static sigc::connection connSubselectionChanged; + static sigc::connection connDefsRelease; + static sigc::connection connDefsModified; + + if (SP_IS_GRADIENT_CONTEXT(ec)) { + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPDocument *document = sp_desktop_document(desktop); + // connect to selection modified and changed signals + connChanged = selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), holder)); + connModified = selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), holder)); + connSubselectionChanged = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), holder)); + + // Is this necessary? Couldn't hurt. + gr_tb_selection_changed(selection, holder); + + // connect to release and modified signals of the defs (i.e. when someone changes gradient) + connDefsRelease = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder))); + connDefsModified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder))); + } else { + if (connChanged) + connChanged.disconnect(); + if (connModified) + connModified.disconnect(); + if (connSubselectionChanged) + connSubselectionChanged.disconnect(); + if (connDefsRelease) + connDefsRelease.disconnect(); + if (connDefsModified) + connDefsModified.disconnect(); + } } /* diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 62a6599f2..7b1b4991c 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -23,6 +23,7 @@ # include "config.h" #endif +#include <glibmm.h> #include "gradient-vector.h" #include "ui/widget/color-preview.h" #include "verbs.h" @@ -30,17 +31,17 @@ #include "macros.h" #include <glibmm/i18n.h> #include <set> -#include "../widgets/gradient-image.h" -#include "../inkscape.h" -#include "../document-private.h" -#include "../gradient-chemistry.h" -#include "../helper/window.h" +#include "widgets/gradient-image.h" +#include "inkscape.h" +#include "document-private.h" +#include "gradient-chemistry.h" +#include "helper/window.h" #include "io/resource.h" #include "xml/repr.h" -#include "../dialogs/dialog-events.h" -#include "../preferences.h" +#include "dialogs/dialog-events.h" +#include "preferences.h" #include "svg/css-ostringstream.h" #include "sp-stop.h" #include "selection-chemistry.h" @@ -50,8 +51,7 @@ #include "desktop.h" #include "layer-manager.h" -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> +#include <sigc++/sigc++.h> #include "document-undo.h" using Inkscape::DocumentUndo; @@ -61,9 +61,6 @@ enum { LAST_SIGNAL }; -static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass); -static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs); - #if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_selector_destroy(GtkWidget *object); #else @@ -79,7 +76,6 @@ static SPStop *get_selected_stop( GtkWidget *vb); void gr_get_usage_counts(SPDocument *doc, std::map<SPGradient *, gint> *mapUsageCount ); unsigned long sp_gradient_to_hhssll(SPGradient *gr); -static GtkVBoxClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; // TODO FIXME kill these globals!!! @@ -88,35 +84,15 @@ static win_data wd; static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs static Glib::ustring const prefs_path = "/dialogs/gradienteditor/"; -GType sp_gradient_vector_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof(SPGradientVectorSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - reinterpret_cast<GClassInitFunc>(sp_gradient_vector_selector_class_init), - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPGradientVectorSelector), - 0, /* n_preallocs */ - reinterpret_cast<GInstanceInitFunc>(sp_gradient_vector_selector_init), - 0, /* value_table */ - }; - - type = g_type_register_static( GTK_TYPE_VBOX, - "SPGradientVectorSelector", - &info, - static_cast< GTypeFlags >(0) ); - } - return type; -} +#if GTK_CHECK_VERSION(3,0,0) +G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_BOX); +#else +G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_VBOX); +#endif static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - parent_class = static_cast<GtkVBoxClass*>(g_type_class_peek_parent(klass)); signals[VECTOR_SET] = g_signal_new( "vector_set", G_TYPE_FROM_CLASS(gobject_class), @@ -138,6 +114,10 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_orientable_set_orientation(GTK_ORIENTABLE(gvs), GTK_ORIENTATION_VERTICAL); +#endif + gvs->idlabel = TRUE; gvs->swatched = false; @@ -181,12 +161,12 @@ static void sp_gradient_vector_selector_destroy(GtkObject *object) gvs->tree_select_connection.~connection(); #if GTK_CHECK_VERSION(3,0,0) - if ((reinterpret_cast<GtkWidgetClass *>(parent_class))->destroy) { - (* (reinterpret_cast<GtkWidgetClass *>(parent_class))->destroy) (object); + if ((GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy) { + (GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object); } #else - if ((reinterpret_cast<GtkObjectClass *>(parent_class))->destroy) { - (* (reinterpret_cast<GtkObjectClass *>(parent_class))->destroy) (object); + if ((GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy) { + (GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object); } #endif } @@ -488,10 +468,10 @@ void SPGradientVectorSelector::setSwatched() ### Vector Editing Widget ##################################################################*/ -#include "../widgets/sp-color-notebook.h" -#include "../widgets/widget-sizes.h" -#include "../xml/node-event-vector.h" -#include "../svg/svg-color.h" +#include "widgets/sp-color-notebook.h" +#include "widgets/widget-sizes.h" +#include "xml/node-event-vector.h" +#include "svg/svg-color.h" #define PAD 4 diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index b63120a6e..5ae90b28f 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -19,16 +19,8 @@ # include "config.h" #endif -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - #include <gtkmm/liststore.h> - -#include <stddef.h> #include <sigc++/connection.h> - -#include <gtk/gtk.h> #include "gradient-selector.h" #define SP_TYPE_GRADIENT_VECTOR_SELECTOR (sp_gradient_vector_selector_get_type ()) @@ -43,7 +35,11 @@ class SPGradient; class SPStop; struct SPGradientVectorSelector { +#if GTK_CHECK_VERSION(3,0,0) + GtkBox vbox; +#else GtkVBox vbox; +#endif guint idlabel : 1; @@ -65,7 +61,11 @@ struct SPGradientVectorSelector { }; struct SPGradientVectorSelectorClass { +#if GTK_CHECK_VERSION(3,0,0) + GtkBoxClass parent_class; +#else GtkVBoxClass parent_class; +#endif void (* vector_set) (SPGradientVectorSelector *gvs, SPGradient *gr); }; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index e0b834961..afc4fcfb0 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -247,7 +247,11 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) bool unref_image = false; /* copied from the expose function of GtkImage */ +#if GTK_CHECK_VERSION(3,0,0) + if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) { +#else if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { +#endif GtkIconSource *source = gtk_icon_source_new(); gtk_icon_source_set_pixbuf(source, icon->pb); gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used diff --git a/src/widgets/icon.h b/src/widgets/icon.h index e1dae0d6a..5838d8de4 100644 --- a/src/widgets/icon.h +++ b/src/widgets/icon.h @@ -14,14 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include <glibmm/threads.h> -#endif - #include <gtkmm/widget.h> #include "icon-size.h" diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 94d42b5eb..7ad88b856 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -30,7 +30,6 @@ #include "live_effects/lpe-line_segment.h" #include "lpe-toolbar.h" -#include "connection-pool.h" #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" @@ -276,6 +275,8 @@ static void lpetool_open_lpe_dialog(GtkToggleAction *act, gpointer data) gtk_toggle_action_set_active(act, false); } +static void lpetool_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); + void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); @@ -402,21 +403,27 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), FALSE ); } - //watch selection - Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox"); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(lpetool_toolbox_watch_ec), holder)); +} - sigc::connection *c_selection_modified = - new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), holder))); - pool->add_connection ("selection-modified", c_selection_modified); +static void lpetool_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection c_selection_modified; + static sigc::connection c_selection_changed; - sigc::connection *c_selection_changed = - new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder))); - pool->add_connection ("selection-changed", c_selection_changed); + if (SP_IS_LPETOOL_CONTEXT(ec)) { + // Watch selection + c_selection_modified = sp_desktop_selection(desktop)->connectModified(sigc::bind(sigc::ptr_fun(sp_lpetool_toolbox_sel_modified), holder)); + c_selection_changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder)); + sp_lpetool_toolbox_sel_changed(sp_desktop_selection(desktop), holder); + } else { + if (c_selection_modified) + c_selection_modified.disconnect(); + if (c_selection_changed) + c_selection_changed.disconnect(); + } } - /* Local Variables: mode:c++ @@ -426,4 +433,4 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 15dda94f0..73e450926 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -42,6 +42,7 @@ #include <glibmm/i18n.h> #include "ui/tools/gradient-tool.h" +#include "ui/tools/mesh-tool.h" #include "gradient-drag.h" #include "sp-mesh-gradient.h" #include "gradient-chemistry.h" @@ -49,17 +50,16 @@ #include "selection.h" #include "ui/icon-names.h" -#include "../ege-adjustment-action.h" -#include "../ege-output-action.h" -#include "../ege-select-one-action.h" -#include "../ink-action.h" -#include "../ink-comboboxentry-action.h" +#include "ege-adjustment-action.h" +#include "ege-output-action.h" +#include "ege-select-one-action.h" +#include "ink-action.h" +#include "ink-comboboxentry-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" #include "svg/svg-color.h" #include "desktop-style.h" -#include "ui/tools/gradient-tool.h" #include "toolbox.h" @@ -67,7 +67,7 @@ using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; -static gboolean blocked = FALSE; +static bool blocked = false; //######################## //## Mesh ## @@ -116,22 +116,16 @@ static void ms_drag_selection_changed(gpointer /*dragger*/, gpointer data) } -static void ms_defs_release(SPObject * /*defs*/, GtkWidget *widget) +static void ms_defs_release(SPObject * /*defs*/, GObject *widget) { ms_tb_selection_changed(NULL, widget); } -static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GtkWidget *widget) +static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GObject *widget) { - ms_tb_selection_changed(NULL, (gpointer) widget); -} - -static void ms_disconnect_sigc(GObject * /*obj*/, sigc::connection *connection) { - connection->disconnect(); - delete connection; + ms_tb_selection_changed(NULL, widget); } - /* * Callback functions for user actions */ @@ -184,6 +178,8 @@ static void ms_col_changed(GtkAdjustment *adj, GObject * /*tbl*/ ) blocked = FALSE; } +static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); + /** * Mesh auxiliary toolbar construction and setup. * @@ -323,35 +319,43 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } - - Inkscape::Selection *selection = sp_desktop_selection (desktop); - SPDocument *document = sp_desktop_document (desktop); - g_object_set_data(holder, "desktop", desktop); - // connect to selection modified and changed signals - sigc::connection *conn1 = new sigc::connection( - selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), (gpointer) holder))); - sigc::connection *conn2 = new sigc::connection( - selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), (gpointer) holder))); - sigc::connection *conn3 = new sigc::connection( - desktop->connectToolSubselectionChanged( sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), (gpointer) holder))); - - // when holder is destroyed, disconnect - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn1); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn2); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn3); - - // connect to release and modified signals of the defs (i.e. when someone changes mesh) - sigc::connection *release_connection = new sigc::connection(); - *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), GTK_WIDGET(holder))); - sigc::connection *modified_connection = new sigc::connection(); - *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), GTK_WIDGET(holder))); - - // when holder is destroyed, disconnect - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), release_connection); - g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), modified_connection); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(mesh_toolbox_watch_ec), holder)); +} +static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection c_selection_changed; + static sigc::connection c_selection_modified; + static sigc::connection c_subselection_changed; + static sigc::connection c_defs_release; + static sigc::connection c_defs_modified; + + if (SP_IS_MESH_CONTEXT(ec)) { + // connect to selection modified and changed signals + Inkscape::Selection *selection = sp_desktop_selection (desktop); + SPDocument *document = sp_desktop_document (desktop); + + c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder)); + c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder)); + c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder)); + + c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder)); + c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder)); + ms_tb_selection_changed(selection, holder); + } else { + if (c_selection_changed) + c_selection_changed.disconnect(); + if (c_selection_modified) + c_selection_modified.disconnect(); + if (c_subselection_changed) + c_subselection_changed.disconnect(); + if (c_defs_release) + c_defs_release.disconnect(); + if (c_defs_modified) + c_defs_modified.disconnect(); + } } /* diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 38e3f4fbd..ace78f8f5 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -31,7 +31,6 @@ #include "ui/tool/multi-path-manipulator.h" #include <glibmm/i18n.h> #include "node-toolbar.h" -#include "connection-pool.h" #include "desktop-handles.h" #include "desktop.h" #include "document-undo.h" @@ -322,7 +321,7 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint / sp_node_toolbox_sel_changed (selection, tbl); } - +static void node_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); //################################ //## Node Editing Toolbox ## @@ -615,32 +614,33 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_action_group_add_action( mainActions, act ); } - sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(node_toolbox_watch_ec), holder)); - //watch selection - Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox"); - - sigc::connection *c_selection_changed = - new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder))); - pool->add_connection ("selection-changed", c_selection_changed); - - sigc::connection *c_selection_modified = - new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder))); - pool->add_connection ("selection-modified", c_selection_modified); - - sigc::connection *c_subselection_changed = - new sigc::connection (desktop->connectToolSubselectionChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder))); - pool->add_connection ("tool-subselection-changed", c_subselection_changed); +} // end of sp_node_toolbox_prep() - Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); +static void node_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection c_selection_changed; + static sigc::connection c_selection_modified; + static sigc::connection c_subselection_changed; - g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); -} // end of sp_node_toolbox_prep() + if (INK_IS_NODE_TOOL(ec)) { + // watch selection + c_selection_changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_node_toolbox_sel_changed), holder)); + c_selection_modified = sp_desktop_selection(desktop)->connectModified(sigc::bind(sigc::ptr_fun(sp_node_toolbox_sel_modified), holder)); + c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(sp_node_toolbox_coord_changed), holder)); + sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder); + } else { + if (c_selection_changed) + c_selection_changed.disconnect(); + if (c_selection_modified) + c_selection_modified.disconnect(); + if (c_subselection_changed) + c_subselection_changed.disconnect(); + } +} /* diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 9466c875e..6ef910f61 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -29,14 +29,15 @@ #endif #include "widgets/swatch-selector.h" -#include "../sp-pattern.h" +#include "sp-pattern.h" #include <glibmm/i18n.h> -#include "../widgets/icon.h" +#include "widgets/icon.h" #include "widgets/widget-sizes.h" #include "xml/repr.h" #include "sp-color-notebook.h" #include "sp-linear-gradient.h" +#include "sp-mesh-gradient.h" #include "sp-radial-gradient.h" /* fixme: Move it from dialogs to here */ #include "gradient-selector.h" @@ -71,8 +72,6 @@ enum { LAST_SIGNAL }; -static void sp_paint_selector_class_init(SPPaintSelectorClass *klass); -static void sp_paint_selector_init(SPPaintSelector *slider); static void sp_paint_selector_dispose(GObject *object); static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gchar const *px, SPPaintSelector::Mode mode, gchar const *tip); @@ -91,7 +90,6 @@ static void sp_paint_selector_set_mode_unset(SPPaintSelector *psel); static void sp_paint_selector_set_style_buttons(SPPaintSelector *psel, GtkWidget *active); -static GtkVBoxClass *parent_class; static guint psel_signals[LAST_SIGNAL] = {0}; #ifdef SP_PS_VERBOSE @@ -113,10 +111,13 @@ static gchar const* modeStrings[] = { #endif -static bool isPaintModeGradient( SPPaintSelector::Mode mode ) +static bool isPaintModeGradient(SPPaintSelector::Mode mode) { bool isGrad = (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) || +#ifdef WITH_MESH + (mode == SPPaintSelector::MODE_GRADIENT_MESH) || +#endif (mode == SPPaintSelector::MODE_SWATCH); return isGrad; @@ -136,34 +137,17 @@ static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel) return grad; } -GType sp_paint_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPPaintSelectorClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_paint_selector_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPPaintSelector), - 0, // n_preallocs - (GInstanceInitFunc)sp_paint_selector_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_VBOX, "SPPaintSelector", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +#if GTK_CHECK_VERSION(3,0,0) +G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_BOX); +#else +G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_VBOX); +#endif static void sp_paint_selector_class_init(SPPaintSelectorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - parent_class = GTK_VBOX_CLASS(g_type_class_peek_parent(klass)); - psel_signals[MODE_CHANGED] = g_signal_new("mode_changed", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), @@ -216,6 +200,10 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) static void sp_paint_selector_init(SPPaintSelector *psel) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_orientable_set_orientation(GTK_ORIENTABLE(psel), GTK_ORIENTATION_VERTICAL); +#endif + psel->mode = static_cast<SPPaintSelector::Mode>(-1); // huh? do you mean 0xff? -- I think this means "not in the enum" /* Paint style button box */ @@ -238,6 +226,10 @@ sp_paint_selector_init(SPPaintSelector *psel) SPPaintSelector::MODE_GRADIENT_LINEAR, _("Linear gradient")); psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-radial"), SPPaintSelector::MODE_GRADIENT_RADIAL, _("Radial gradient")); +#ifdef WITH_MESH + psel->mesh = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-mesh"), + SPPaintSelector::MODE_GRADIENT_MESH, _("Mesh gradient")); +#endif psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-pattern"), SPPaintSelector::MODE_PATTERN, _("Pattern")); psel->swatch = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-swatch"), @@ -314,8 +306,8 @@ static void sp_paint_selector_dispose(GObject *object) // clean up our long-living pattern menu g_object_set_data(G_OBJECT(psel),"patternmenu",NULL); - if ((G_OBJECT_CLASS(parent_class))->dispose) - (* (G_OBJECT_CLASS(parent_class))->dispose)(object); + if ((G_OBJECT_CLASS(sp_paint_selector_parent_class))->dispose) + (G_OBJECT_CLASS(sp_paint_selector_parent_class))->dispose(object); } static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, @@ -413,6 +405,9 @@ void SPPaintSelector::setMode(Mode mode) break; case MODE_GRADIENT_LINEAR: case MODE_GRADIENT_RADIAL: +#ifdef WITH_MESH + case MODE_GRADIENT_MESH: +#endif sp_paint_selector_set_mode_gradient(this, mode); break; case MODE_PATTERN: @@ -511,6 +506,21 @@ void SPPaintSelector::setGradientRadial(SPGradient *vector) gsel->setVector((vector) ? vector->document : 0, vector); } +#ifdef WITH_MESH +void SPPaintSelector::setGradientMesh(SPGradient *vector) +{ +#ifdef SP_PS_VERBOSE + g_print("PaintSelector set GRADIENT MESH\n"); +#endif + setMode(MODE_GRADIENT_RADIAL); + + SPGradientSelector *gsel = getGradientFromData(this); + + gsel->setMode(SPGradientSelector::MODE_MESH); + gsel->setVector((vector) ? vector->document : 0, vector); +} +#endif + void SPPaintSelector::setGradientProperties( SPGradientUnits units, SPGradientSpread spread ) { g_return_if_fail(isPaintModeGradient(mode)); @@ -665,8 +675,8 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec /* Create new color selector */ /* Create vbox */ #if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); - gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); + GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); #else GtkWidget *vb = gtk_vbox_new(FALSE, 4); #endif @@ -728,9 +738,14 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe if (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) { sp_paint_selector_set_style_buttons(psel, psel->gradient); - } else { + } else if (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) { sp_paint_selector_set_style_buttons(psel, psel->radial); } +#ifdef WITH_MESH + else { + sp_paint_selector_set_style_buttons(psel, psel->mesh); + } +#endif gtk_widget_set_sensitive(psel->style, TRUE); if ((psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (psel->mode == SPPaintSelector::MODE_GRADIENT_RADIAL)) { @@ -756,10 +771,17 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_LINEAR); //sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_LINEAR); gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Linear gradient</b>")); - } else { + } else if (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) { SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL); gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Radial gradient</b>")); } +#ifdef WITH_MESH + else { + SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL); + gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Mesh gradient</b>")); + } +#endif + #ifdef SP_PS_VERBOSE g_print("Gradient req\n"); #endif @@ -772,6 +794,9 @@ sp_paint_selector_set_style_buttons(SPPaintSelector *psel, GtkWidget *active) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->solid), (active == psel->solid)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->gradient), (active == psel->gradient)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->radial), (active == psel->radial)); +#ifdef WITH_MESH + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->mesh), (active == psel->mesh)); +#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->pattern), (active == psel->pattern)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->swatch), (active == psel->swatch)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->unset), (active == psel->unset)); @@ -1004,8 +1029,8 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel /* Create vbox */ #if GTK_CHECK_VERSION(3,0,0) - tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); - gtk_box_set_homogeneous(GTK_BOX(tbl), FALSE); + tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_set_homogeneous(GTK_BOX(tbl), FALSE); #else tbl = gtk_vbox_new(FALSE, 4); #endif @@ -1218,6 +1243,10 @@ SPPaintSelector::Mode SPPaintSelector::getModeForStyle(SPStyle const & style, Fi mode = MODE_GRADIENT_LINEAR; } else if (SP_IS_RADIALGRADIENT(server)) { mode = MODE_GRADIENT_RADIAL; +#ifdef WITH_MESH + } else if (SP_IS_MESHGRADIENT(server)) { + mode = MODE_GRADIENT_MESH; +#endif } else if (SP_IS_PATTERN(server)) { mode = MODE_PATTERN; } else { diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index d6ad3f50c..788aa673e 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -12,7 +12,6 @@ * */ -#include <glib.h> #include <gtk/gtk.h> #include "color.h" @@ -35,7 +34,11 @@ class SPStyle; * Generic paint selector widget. */ struct SPPaintSelector { +#if GTK_CHECK_VERSION(3,0,0) + GtkBox vbox; +#else GtkVBox vbox; +#endif enum Mode { MODE_EMPTY, @@ -45,6 +48,9 @@ struct SPPaintSelector { MODE_COLOR_CMYK, MODE_GRADIENT_LINEAR, MODE_GRADIENT_RADIAL, +#ifdef WITH_MESH + MODE_GRADIENT_MESH, +#endif MODE_PATTERN, MODE_SWATCH, MODE_UNSET @@ -64,6 +70,9 @@ struct SPPaintSelector { GtkWidget *solid; GtkWidget *gradient; GtkWidget *radial; +#ifdef WITH_MESH + GtkWidget *mesh; +#endif GtkWidget *pattern; GtkWidget *swatch; GtkWidget *unset; @@ -88,6 +97,9 @@ struct SPPaintSelector { void setGradientLinear( SPGradient *vector ); void setGradientRadial( SPGradient *vector ); +#ifdef WITH_MESH + void setGradientMesh(SPGradient *vector); +#endif void setSwatch( SPGradient *vector ); void setGradientProperties( SPGradientUnits units, SPGradientSpread spread ); @@ -109,7 +121,11 @@ enum {COMBO_COL_LABEL=0, COMBO_COL_STOCK=1, COMBO_COL_PATTERN=2, COMBO_COL_SEP=3 /// The SPPaintSelector vtable struct SPPaintSelectorClass { +#if GTK_CHECK_VERSION(3,0,0) + GtkBoxClass parent_class; +#else GtkVBoxClass parent_class; +#endif void (* mode_changed) (SPPaintSelector *psel, SPPaintSelector::Mode mode); diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index c9a09e908..48808fe70 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -44,6 +44,7 @@ #include "sp-rect.h" #include "toolbox.h" #include "ui/icon-names.h" +#include "ui/tools/rect-tool.h" #include "ui/uxmanager.h" #include "ui/widget/unit-tracker.h" #include "util/units.h" @@ -288,6 +289,7 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } } +static void rect_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { @@ -394,13 +396,21 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje g_object_set_data( holder, "single", GINT_TO_POINTER(TRUE) ); sp_rtb_sensitivize( holder ); - sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder)) - ); - g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(rect_toolbox_watch_ec), holder)); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); } +static void rect_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection changed; + + if (SP_IS_RECT_CONTEXT(ec)) { + changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder)); + } else { + if (changed) + changed.disconnect(); + } +} /* Local Variables: @@ -411,4 +421,4 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index 53e73dd57..d0d302ff4 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -67,10 +67,7 @@ extern guint update_in_progress; G_BEGIN_DECLS -static void sp_color_icc_selector_class_init (SPColorICCSelectorClass *klass); -static void sp_color_icc_selector_init (SPColorICCSelector *cs); static void sp_color_icc_selector_dispose(GObject *object); - static void sp_color_icc_selector_show_all (GtkWidget *widget); static void sp_color_icc_selector_hide(GtkWidget *widget); @@ -161,9 +158,6 @@ public: #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) }; - -static SPColorSelectorClass *parent_class; - #define XPAD 4 #define YPAD 1 @@ -205,8 +199,14 @@ void attachToGridOrTable(GtkWidget *parent, guint ypadding = YPAD) { #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start( child, xpadding ); + gtk_widget_set_margin_end( child, xpadding ); + #else gtk_widget_set_margin_left( child, xpadding ); gtk_widget_set_margin_right( child, xpadding ); + #endif + gtk_widget_set_margin_top( child, ypadding ); gtk_widget_set_margin_bottom( child, ypadding ); if (hexpand) { @@ -227,30 +227,7 @@ void attachToGridOrTable(GtkWidget *parent, } // namespace -GType sp_color_icc_selector_get_type(void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof (SPColorICCSelectorClass), - NULL, // base_init - NULL, // base_finalize - (GClassInitFunc) sp_color_icc_selector_class_init, - NULL, // class_finalize - NULL, // class_data - sizeof (SPColorICCSelector), - 0, // n_preallocs - (GInstanceInitFunc) sp_color_icc_selector_init, - 0, // value_table - }; - - type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, - "SPColorICCSelector", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} +G_DEFINE_TYPE(SPColorICCSelector, sp_color_icc_selector, SP_TYPE_COLOR_SELECTOR); static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) { @@ -259,8 +236,6 @@ static void sp_color_icc_selector_class_init(SPColorICCSelectorClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); SPColorSelectorClass *selector_class = SP_COLOR_SELECTOR_CLASS (klass); - parent_class = SP_COLOR_SELECTOR_CLASS (g_type_class_peek_parent (klass)); - selector_class->name = nameset; selector_class->submode_count = 1; @@ -599,8 +574,8 @@ void ColorICCSelector::init() static void sp_color_icc_selector_dispose(GObject *object) { - if ((G_OBJECT_CLASS(parent_class))->dispose) { - (* (G_OBJECT_CLASS(parent_class))->dispose)(object); + if (G_OBJECT_CLASS(sp_color_icc_selector_parent_class)->dispose) { + G_OBJECT_CLASS(sp_color_icc_selector_parent_class)->dispose(object); } } diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index f63ab0853..6cdaff639 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -2,8 +2,6 @@ #define SEEN_SP_COLOR_ICC_SELECTOR_H #include <glib.h> -#include <gtk/gtk.h> - #include "sp-color-selector.h" namespace Inkscape { diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index e081f98e0..9f927b51f 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -53,46 +53,21 @@ struct SPColorNotebookTracker { SPColorNotebook *backPointer; }; -static void sp_color_notebook_class_init (SPColorNotebookClass *klass); -static void sp_color_notebook_init (SPColorNotebook *colorbook); static void sp_color_notebook_dispose(GObject *object); static void sp_color_notebook_show_all (GtkWidget *widget); static void sp_color_notebook_hide(GtkWidget *widget); -static SPColorSelectorClass *parent_class; - #define XPAD 4 #define YPAD 1 -GType sp_color_notebook_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPColorNotebookClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_color_notebook_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPColorNotebook), - 0, // n_preallocs - (GInstanceInitFunc)sp_color_notebook_init, - 0 // value_table - }; - type = g_type_register_static(SP_TYPE_COLOR_SELECTOR, "SPColorNotebook", &info, static_cast<GTypeFlags>(0)); - } - return type; -} +G_DEFINE_TYPE(SPColorNotebook, sp_color_notebook, SP_TYPE_COLOR_SELECTOR); static void sp_color_notebook_class_init(SPColorNotebookClass *klass) { GObjectClass *object_class = reinterpret_cast<GObjectClass *>(klass); GtkWidgetClass *widget_class = reinterpret_cast<GtkWidgetClass *>(klass); - parent_class = SP_COLOR_SELECTOR_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_color_notebook_dispose; widget_class->show_all = sp_color_notebook_show_all; @@ -289,8 +264,13 @@ void ColorNotebook::init() sp_set_font_size_smaller (_buttonbox); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_buttonbox, XPAD); + gtk_widget_set_margin_end(_buttonbox, XPAD); + #else gtk_widget_set_margin_left(_buttonbox, XPAD); gtk_widget_set_margin_right(_buttonbox, XPAD); + #endif gtk_widget_set_margin_top(_buttonbox, YPAD); gtk_widget_set_margin_bottom(_buttonbox, YPAD); gtk_widget_set_hexpand(_buttonbox, TRUE); @@ -306,8 +286,13 @@ void ColorNotebook::init() row++; #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_book, XPAD*2); + gtk_widget_set_margin_end(_book, XPAD*2); + #else gtk_widget_set_margin_left(_book, XPAD*2); gtk_widget_set_margin_right(_book, XPAD*2); + #endif gtk_widget_set_margin_top(_book, YPAD); gtk_widget_set_margin_bottom(_book, YPAD); gtk_widget_set_hexpand(_book, TRUE); @@ -434,8 +419,13 @@ void ColorNotebook::init() #endif //defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(rgbabox, XPAD); + gtk_widget_set_margin_end(rgbabox, XPAD); + #else gtk_widget_set_margin_left(rgbabox, XPAD); gtk_widget_set_margin_right(rgbabox, XPAD); + #endif gtk_widget_set_margin_top(rgbabox, YPAD); gtk_widget_set_margin_bottom(rgbabox, YPAD); gtk_grid_attach(GTK_GRID(table), rgbabox, 0, row, 2, 1); @@ -457,8 +447,8 @@ void ColorNotebook::init() static void sp_color_notebook_dispose(GObject *object) { - if (((GObjectClass *) (parent_class))->dispose) - (* ((GObjectClass *) (parent_class))->dispose) (object); + if (G_OBJECT_CLASS(sp_color_notebook_parent_class)->dispose) + G_OBJECT_CLASS(sp_color_notebook_parent_class)->dispose(object); } ColorNotebook::~ColorNotebook() diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index 6e5111132..469bb56e8 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -12,14 +12,10 @@ * This code is in public domain */ -#include <gtk/gtk.h> -#include "../color.h" #include "sp-color-selector.h" #include <glib.h> - - struct SPColorNotebook; class ColorNotebook: public ColorSelector diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index c3f9d511c..5fddacf59 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -10,6 +10,7 @@ #include <glibmm/i18n.h> #include "../dialogs/dialog-events.h" #include "sp-color-scales.h" +#include "sp-color-slider.h" #include "svg/svg-icc-color.h" #define CSC_CHANNEL_R (1 << 0) @@ -30,8 +31,6 @@ G_BEGIN_DECLS -static void sp_color_scales_class_init (SPColorScalesClass *klass); -static void sp_color_scales_init (SPColorScales *cs); static void sp_color_scales_dispose(GObject *object); static void sp_color_scales_show_all (GtkWidget *widget); @@ -41,38 +40,12 @@ static const gchar *sp_color_scales_hue_map (void); G_END_DECLS -static SPColorSelectorClass *parent_class; - #define XPAD 4 #define YPAD 1 #define noDUMP_CHANGE_INFO 1 -GType -sp_color_scales_get_type (void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof (SPColorScalesClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_scales_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPColorScales), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_scales_init, - NULL - }; - - type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, - "SPColorScales", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} +G_DEFINE_TYPE(SPColorScales, sp_color_scales, SP_TYPE_COLOR_SELECTOR); static void sp_color_scales_class_init (SPColorScalesClass *klass) @@ -82,8 +55,6 @@ sp_color_scales_class_init (SPColorScalesClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); SPColorSelectorClass *selector_class = SP_COLOR_SELECTOR_CLASS (klass); - parent_class = SP_COLOR_SELECTOR_CLASS (g_type_class_peek_parent (klass)); - selector_class->name = nameset; selector_class->submode_count = 3; @@ -151,8 +122,13 @@ void ColorScales::init() gtk_widget_show (_l[i]); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_l[i], XPAD); + gtk_widget_set_margin_end(_l[i], XPAD); + #else gtk_widget_set_margin_left(_l[i], XPAD); gtk_widget_set_margin_right(_l[i], XPAD); + #endif gtk_widget_set_margin_top(_l[i], YPAD); gtk_widget_set_margin_bottom(_l[i], YPAD); gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1); @@ -167,8 +143,13 @@ void ColorScales::init() gtk_widget_show (_s[i]); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_s[i], XPAD); + gtk_widget_set_margin_end(_s[i], XPAD); + #else gtk_widget_set_margin_left(_s[i], XPAD); gtk_widget_set_margin_right(_s[i], XPAD); + #endif gtk_widget_set_margin_top(_s[i], YPAD); gtk_widget_set_margin_bottom(_s[i], YPAD); gtk_widget_set_hexpand(_s[i], TRUE); @@ -184,8 +165,13 @@ void ColorScales::init() gtk_widget_show (_b[i]); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_b[i], XPAD); + gtk_widget_set_margin_end(_b[i], XPAD); + #else gtk_widget_set_margin_left(_b[i], XPAD); gtk_widget_set_margin_right(_b[i], XPAD); + #endif gtk_widget_set_margin_top(_b[i], YPAD); gtk_widget_set_margin_bottom(_b[i], YPAD); gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER); @@ -214,8 +200,8 @@ void ColorScales::init() static void sp_color_scales_dispose(GObject *object) { - if ((G_OBJECT_CLASS(parent_class))->dispose) - (* (G_OBJECT_CLASS(parent_class))->dispose) (object); + if (G_OBJECT_CLASS(sp_color_scales_parent_class)->dispose) + G_OBJECT_CLASS(sp_color_scales_parent_class)->dispose(object); } static void diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index 3b11bc05e..72cbafa2f 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -2,15 +2,12 @@ #define SEEN_SP_COLOR_SCALES_H #include <glib.h> -#include <gtk/gtk.h> -#include <color.h> -#include <widgets/sp-color-slider.h> #include <widgets/sp-color-selector.h> - struct SPColorScales; struct SPColorScalesClass; +struct SPColorSlider; typedef enum { SP_COLOR_SCALES_MODE_NONE = 0, diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 6d62acecd..e97c36431 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -22,42 +22,20 @@ enum { #define noDUMP_CHANGE_INFO #define FOO_NAME(x) g_type_name( G_TYPE_FROM_INSTANCE(x) ) -static void sp_color_selector_class_init( SPColorSelectorClass *klass ); -static void sp_color_selector_init( SPColorSelector *csel ); static void sp_color_selector_dispose(GObject *object); static void sp_color_selector_show_all( GtkWidget *widget ); static void sp_color_selector_hide( GtkWidget *widget ); -static GtkVBoxClass *parent_class; static guint csel_signals[LAST_SIGNAL] = {0}; double ColorSelector::_epsilon = 1e-4; -GType sp_color_selector_get_type( void ) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof(SPColorSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof(SPColorSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_selector_init, - NULL - }; - - type = g_type_register_static( GTK_TYPE_VBOX, - "SPColorSelector", - &info, - static_cast<GTypeFlags>(0) ); - } - return type; -} +#if GTK_CHECK_VERSION(3,0,0) +G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_BOX); +#else +G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_VBOX); +#endif void sp_color_selector_class_init( SPColorSelectorClass *klass ) { @@ -66,8 +44,6 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass ) GtkWidgetClass *widget_class; widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_VBOX_CLASS( g_type_class_peek_parent(klass) ); - csel_signals[GRABBED] = g_signal_new( "grabbed", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), @@ -109,6 +85,10 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass ) void sp_color_selector_init( SPColorSelector *csel ) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_orientable_set_orientation(GTK_ORIENTABLE(csel), GTK_ORIENTATION_VERTICAL); +#endif + if ( csel->base ) { csel->base->init(); @@ -125,8 +105,8 @@ void sp_color_selector_dispose(GObject *object) csel->base = 0; } - if ( (G_OBJECT_CLASS(parent_class))->dispose ) { - (* (G_OBJECT_CLASS(parent_class))->dispose)(object); + if ((G_OBJECT_CLASS(sp_color_selector_parent_class))->dispose ) { + (G_OBJECT_CLASS(sp_color_selector_parent_class))->dispose(object); } } diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index 616d5a9e7..30061774a 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -2,9 +2,7 @@ #define SEEN_SP_COLOR_SELECTOR_H #include <gtk/gtk.h> -#include "../color.h" - -#include <glib.h> +#include "color.h" struct SPColorSelector; @@ -62,13 +60,21 @@ private: #define SP_COLOR_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass)) struct SPColorSelector { +#if GTK_CHECK_VERSION(3,0,0) + GtkBox vbox; +#else GtkVBox vbox; +#endif ColorSelector* base; }; struct SPColorSelectorClass { +#if GTK_CHECK_VERSION(3,0,0) + GtkBoxClass parent_class; +#else GtkVBoxClass parent_class; +#endif const gchar **name; guint submode_count; diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index 9b13ba1c5..ab7e2cd84 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -12,6 +12,7 @@ #include <gtk/gtk.h> #include "sp-color-scales.h" +#include "sp-color-slider.h" #include "preferences.h" #define SLIDER_WIDTH 96 @@ -26,8 +27,6 @@ enum { LAST_SIGNAL }; -static void sp_color_slider_class_init (SPColorSliderClass *klass); -static void sp_color_slider_init (SPColorSlider *slider); static void sp_color_slider_dispose(GObject *object); static void sp_color_slider_realize (GtkWidget *widget); @@ -61,36 +60,15 @@ static const guchar *sp_color_slider_render_gradient (gint x0, gint y0, gint wid static const guchar *sp_color_slider_render_map (gint x0, gint y0, gint width, gint height, guchar *map, gint start, gint step, guint b0, guint b1, guint mask); -static GtkWidgetClass *parent_class; static guint slider_signals[LAST_SIGNAL] = {0}; -GType -sp_color_slider_get_type (void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPColorSliderClass), - NULL, NULL, - (GClassInitFunc) sp_color_slider_class_init, - NULL, NULL, - sizeof (SPColorSlider), - 0, - (GInstanceInitFunc) sp_color_slider_init, - NULL - }; - type = g_type_register_static (GTK_TYPE_WIDGET, "SPColorSlider", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPColorSlider, sp_color_slider, GTK_TYPE_WIDGET); static void sp_color_slider_class_init(SPColorSliderClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent(klass)); - slider_signals[GRABBED] = g_signal_new ("grabbed", G_TYPE_FROM_CLASS(object_class), (GSignalFlags)(G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE), @@ -183,8 +161,8 @@ static void sp_color_slider_dispose(GObject *object) slider->adjustment = NULL; } - if ((G_OBJECT_CLASS(parent_class))->dispose) - (* (G_OBJECT_CLASS(parent_class))->dispose) (object); + if (G_OBJECT_CLASS(sp_color_slider_parent_class)->dispose) + G_OBJECT_CLASS(sp_color_slider_parent_class)->dispose (object); } static void diff --git a/src/widgets/sp-color-slider.h b/src/widgets/sp-color-slider.h index 591d8368a..b81d62e41 100644 --- a/src/widgets/sp-color-slider.h +++ b/src/widgets/sp-color-slider.h @@ -14,13 +14,6 @@ #include <gtk/gtk.h> -#include <glib.h> - - - -struct SPColorSlider; -struct SPColorSliderClass; - #define SP_TYPE_COLOR_SLIDER (sp_color_slider_get_type ()) #define SP_COLOR_SLIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_SLIDER, SPColorSlider)) #define SP_COLOR_SLIDER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_SLIDER, SPColorSliderClass)) diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 7c8bb1df7..404874db7 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -7,14 +7,13 @@ #include "../dialogs/dialog-events.h" #include "sp-color-wheel-selector.h" #include "sp-color-scales.h" +#include "sp-color-slider.h" #include "sp-color-icc-selector.h" #include "../svg/svg-icc-color.h" #include "ui/widget/gimpcolorwheel.h" G_BEGIN_DECLS -static void sp_color_wheel_selector_class_init (SPColorWheelSelectorClass *klass); -static void sp_color_wheel_selector_init (SPColorWheelSelector *cs); static void sp_color_wheel_selector_dispose(GObject *object); static void sp_color_wheel_selector_show_all (GtkWidget *widget); @@ -23,36 +22,10 @@ static void sp_color_wheel_selector_hide(GtkWidget *widget); G_END_DECLS -static SPColorSelectorClass *parent_class; - #define XPAD 4 #define YPAD 1 -GType -sp_color_wheel_selector_get_type (void) -{ - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof (SPColorWheelSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_wheel_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPColorWheelSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_wheel_selector_init, - 0, /* value_table */ - }; - - type = g_type_register_static (SP_TYPE_COLOR_SELECTOR, - "SPColorWheelSelector", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; -} +G_DEFINE_TYPE(SPColorWheelSelector, sp_color_wheel_selector, SP_TYPE_COLOR_SELECTOR); static void sp_color_wheel_selector_class_init(SPColorWheelSelectorClass *klass) { @@ -61,8 +34,6 @@ static void sp_color_wheel_selector_class_init(SPColorWheelSelectorClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); SPColorSelectorClass *selector_class = SP_COLOR_SELECTOR_CLASS (klass); - parent_class = SP_COLOR_SELECTOR_CLASS (g_type_class_peek_parent (klass)); - selector_class->name = nameset; selector_class->submode_count = 1; @@ -142,8 +113,13 @@ void ColorWheelSelector::init() gtk_widget_show (_label); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_label, XPAD); + gtk_widget_set_margin_end(_label, XPAD); + #else gtk_widget_set_margin_left(_label, XPAD); gtk_widget_set_margin_right(_label, XPAD); + #endif gtk_widget_set_margin_top(_label, YPAD); gtk_widget_set_margin_bottom(_label, YPAD); gtk_widget_set_halign(_label, GTK_ALIGN_FILL); @@ -162,8 +138,13 @@ void ColorWheelSelector::init() gtk_widget_show (_slider); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_slider, XPAD); + gtk_widget_set_margin_end(_slider, XPAD); + #else gtk_widget_set_margin_left(_slider, XPAD); gtk_widget_set_margin_right(_slider, XPAD); + #endif gtk_widget_set_margin_top(_slider, YPAD); gtk_widget_set_margin_bottom(_slider, YPAD); gtk_widget_set_hexpand(_slider, TRUE); @@ -188,8 +169,13 @@ void ColorWheelSelector::init() gtk_widget_show (_sbtn); #if GTK_CHECK_VERSION(3,0,0) + #if GTK_CHECK_VERSION(3,12,0) + gtk_widget_set_margin_start(_sbtn, XPAD); + gtk_widget_set_margin_end(_sbtn, XPAD); + #else gtk_widget_set_margin_left(_sbtn, XPAD); gtk_widget_set_margin_right(_sbtn, XPAD); + #endif gtk_widget_set_margin_top(_sbtn, YPAD); gtk_widget_set_margin_bottom(_sbtn, YPAD); gtk_widget_set_halign(_sbtn, GTK_ALIGN_CENTER); @@ -216,8 +202,8 @@ void ColorWheelSelector::init() static void sp_color_wheel_selector_dispose(GObject *object) { - if ((G_OBJECT_CLASS(parent_class))->dispose) - (* (G_OBJECT_CLASS(parent_class))->dispose) (object); + if (G_OBJECT_CLASS(sp_color_wheel_selector_parent_class)->dispose) + G_OBJECT_CLASS(sp_color_wheel_selector_parent_class)->dispose(object); } static void diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index bbd377422..12b060dbe 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -1,15 +1,12 @@ #ifndef SEEN_SP_COLOR_WHEEL_SELECTOR_H #define SEEN_SP_COLOR_WHEEL_SELECTOR_H -#include <glib.h> #include <gtk/gtk.h> -#include "sp-color-slider.h" #include "sp-color-selector.h" - - typedef struct _GimpColorWheel GimpColorWheel; +struct SPColorSlider; struct SPColorWheelSelector; struct SPColorWheelSelectorClass; diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 8feb5b994..5ab6b1bb5 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -37,8 +37,6 @@ public: SPWidgetImpl(SPWidget &target); ~SPWidgetImpl(); - static void classInit(SPWidgetClass *klass); - static void init(SPWidget *widget); static void dispose(GObject *object); static void show(GtkWidget *widget); static void hide(GtkWidget *widget); @@ -69,57 +67,20 @@ public: void setSelection(Selection *selection); private: - static GtkBinClass *parentClass; - static guint signals[LAST_SIGNAL]; - SPWidget &_target; }; - -GtkBinClass *SPWidgetImpl::parentClass = 0; -guint SPWidgetImpl::signals[LAST_SIGNAL] = {0}; - } // namespace Inkscape -GType SPWidget::getType() -{ - static GType type = 0; - if (!type) { - static GTypeInfo const info = { - sizeof(SPWidgetClass), - NULL, NULL, - reinterpret_cast<GClassInitFunc>(SPWidgetImpl::classInit), - NULL, NULL, - sizeof(SPWidget), - 0, - reinterpret_cast<GInstanceInitFunc>(SPWidgetImpl::init), - NULL - }; - type = g_type_register_static(GTK_TYPE_BIN, - "SPWidget", - &info, - static_cast<GTypeFlags>(0)); - } - return type; -} - -namespace Inkscape { +G_DEFINE_TYPE(SPWidget, sp_widget, GTK_TYPE_BIN); -SPWidgetImpl::SPWidgetImpl(SPWidget &target) : - _target(target) -{ -} - -SPWidgetImpl::~SPWidgetImpl() -{ -} +static guint signals[LAST_SIGNAL] = {0}; -void SPWidgetImpl::classInit(SPWidgetClass *klass) +static void +sp_widget_class_init(SPWidgetClass *klass) { GObjectClass *object_class = reinterpret_cast<GObjectClass *>(klass); GtkWidgetClass *widget_class = reinterpret_cast<GtkWidgetClass *>(klass); - parentClass = reinterpret_cast<GtkBinClass *>(g_type_class_peek_parent(klass)); - object_class->dispose = SPWidgetImpl::dispose; signals[CONSTRUCT] = g_signal_new ("construct", @@ -170,11 +131,22 @@ void SPWidgetImpl::classInit(SPWidgetClass *klass) widget_class->size_allocate = SPWidgetImpl::sizeAllocate; } -void SPWidgetImpl::init(SPWidget *spw) +static void sp_widget_init(SPWidget *spw) { spw->_impl = new SPWidgetImpl(*spw); // ctor invoked after all other init } +namespace Inkscape { + +SPWidgetImpl::SPWidgetImpl(SPWidget &target) : + _target(target) +{ +} + +SPWidgetImpl::~SPWidgetImpl() +{ +} + void SPWidgetImpl::dispose(GObject *object) { SPWidget *spw = reinterpret_cast<SPWidget *>(object); @@ -189,8 +161,8 @@ void SPWidgetImpl::dispose(GObject *object) delete spw->_impl; spw->_impl = 0; - if (reinterpret_cast<GObjectClass *>(parentClass)->dispose) { - (*reinterpret_cast<GObjectClass *>(parentClass)->dispose)(object); + if (G_OBJECT_CLASS(sp_widget_parent_class)->dispose) { + G_OBJECT_CLASS(sp_widget_parent_class)->dispose(object); } } @@ -214,8 +186,8 @@ void SPWidgetImpl::show(GtkWidget *widget) ); } - if (reinterpret_cast<GtkWidgetClass *>(parentClass)->show) { - (*reinterpret_cast<GtkWidgetClass *>(parentClass)->show)(widget); + if (GTK_WIDGET_CLASS(sp_widget_parent_class)->show) { + GTK_WIDGET_CLASS(sp_widget_parent_class)->show(widget); } } @@ -230,8 +202,8 @@ void SPWidgetImpl::hide(GtkWidget *widget) spw->selSet.disconnect(); } - if (reinterpret_cast<GtkWidgetClass *>(parentClass)->hide) { - (*reinterpret_cast<GtkWidgetClass *>(parentClass)->hide)(widget); + if (GTK_WIDGET_CLASS(sp_widget_parent_class)->hide) { + GTK_WIDGET_CLASS(sp_widget_parent_class)->hide(widget); } } diff --git a/src/widgets/sp-widget.h b/src/widgets/sp-widget.h index b4696e66e..9a1a93a45 100644 --- a/src/widgets/sp-widget.h +++ b/src/widgets/sp-widget.h @@ -15,11 +15,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <glib.h> #include <gtk/gtk.h> #include "inkscape.h" -#define SP_TYPE_WIDGET (SPWidget::getType()) +#define SP_TYPE_WIDGET (sp_widget_get_type()) #define SP_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_WIDGET, SPWidget)) #define SP_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_WIDGET, SPWidgetClass)) #define SP_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_WIDGET)) @@ -40,11 +39,11 @@ struct SPWidget { GtkBin bin; + Inkscape::SPWidgetImpl *_impl; +private: sigc::connection selModified; sigc::connection selChanged; sigc::connection selSet; -private: - Inkscape::SPWidgetImpl *_impl; }; struct SPWidgetClass { @@ -58,7 +57,7 @@ struct SPWidgetClass { void (* set_selection) (SPWidget *spw, Inkscape::Selection *selection); }; -/* fixme: Think (Lauris) */ +GType sp_widget_get_type(); /** Generic constructor for global widget. */ GtkWidget *sp_widget_new_global(); diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index 47b0ebb9d..dd763aea5 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -20,9 +20,6 @@ #include "../xml/node-event-vector.h" #include "sp-xmlview-attr-list.h" -static void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass); -static void sp_xmlview_attr_list_init (SPXMLViewAttrList * list); - #if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_attr_list_destroy(GtkWidget * object); #else @@ -31,8 +28,6 @@ static void sp_xmlview_attr_list_destroy(GtkObject * object); static void event_attr_changed (Inkscape::XML::Node * repr, const gchar * name, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data); -static GtkTreeViewClass * parent_class = NULL; - static Inkscape::XML::NodeEventVector repr_events = { NULL, /* child_added */ NULL, /* child_removed */ @@ -88,28 +83,7 @@ sp_xmlview_attr_list_set_repr (SPXMLViewAttrList * list, Inkscape::XML::Node * r } } -GType sp_xmlview_attr_list_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPXMLViewAttrListClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_xmlview_attr_list_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPXMLViewAttrList), - 0, // n_preallocs - (GInstanceInitFunc)sp_xmlview_attr_list_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TREE_VIEW, "SPXMLViewAttrList", &info, static_cast<GTypeFlags>(0)); - } - - return type; -} +G_DEFINE_TYPE(SPXMLViewAttrList, sp_xmlview_attr_list, GTK_TYPE_TREE_VIEW); void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) { @@ -121,8 +95,6 @@ void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) object_class->destroy = sp_xmlview_attr_list_destroy; #endif - parent_class = GTK_TREE_VIEW_CLASS(g_type_class_peek_parent (klass)); - g_signal_new("row-value-changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_FIRST, @@ -154,9 +126,9 @@ void sp_xmlview_attr_list_destroy(GtkObject * object) sp_xmlview_attr_list_set_repr (list, NULL); #if GTK_CHECK_VERSION(3,0,0) - GTK_WIDGET_CLASS(parent_class)->destroy (object); + GTK_WIDGET_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object); #else - GTK_OBJECT_CLASS(parent_class)->destroy (object); + GTK_OBJECT_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object); #endif } diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index 367ef1a12..08b115bfa 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -12,10 +12,8 @@ * Released under the GNU GPL; see COPYING for details */ -#include <stdio.h> #include <gtk/gtk.h> - #define SP_TYPE_XMLVIEW_ATTR_LIST (sp_xmlview_attr_list_get_type ()) #define SP_XMLVIEW_ATTR_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_ATTR_LIST, SPXMLViewAttrList)) #define SP_IS_XMLVIEW_ATTR_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_XMLVIEW_ATTR_LIST)) @@ -23,7 +21,6 @@ struct SPXMLViewAttrList { - GtkTreeView list; GtkListStore *store; diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index ac64dabdb..9243760bd 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -23,9 +23,6 @@ using Inkscape::DocumentUndo; -static void sp_xmlview_content_class_init (SPXMLViewContentClass * klass); -static void sp_xmlview_content_init (SPXMLViewContent * text); - #if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_content_destroy(GtkWidget * object); #else @@ -36,8 +33,6 @@ void sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text); static void event_content_changed (Inkscape::XML::Node * repr, const gchar * old_content, const gchar * new_content, gpointer data); -static GtkTextViewClass * parent_class = NULL; - static Inkscape::XML::NodeEventVector repr_events = { NULL, /* child_added */ NULL, /* child_removed */ @@ -81,28 +76,7 @@ sp_xmlview_content_set_repr (SPXMLViewContent * text, Inkscape::XML::Node * repr } } -GType sp_xmlview_content_get_type(void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof(SPXMLViewContentClass), - 0, // base_init - 0, // base_finalize - (GClassInitFunc)sp_xmlview_content_class_init, - 0, // class_finalize - 0, // class_data - sizeof(SPXMLViewContent), - 0, // n_preallocs - (GInstanceInitFunc)sp_xmlview_content_init, - 0 // value_table - }; - type = g_type_register_static(GTK_TYPE_TEXT_VIEW, "SPXMLViewContent", &info, static_cast<GTypeFlags>(0)); - } - - return type; -} +G_DEFINE_TYPE(SPXMLViewContent, sp_xmlview_content, GTK_TYPE_TEXT_VIEW); void sp_xmlview_content_class_init(SPXMLViewContentClass * klass) { @@ -113,8 +87,6 @@ void sp_xmlview_content_class_init(SPXMLViewContentClass * klass) GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass); object_class->destroy = sp_xmlview_content_destroy; #endif - - parent_class = GTK_TEXT_VIEW_CLASS(g_type_class_peek_parent (klass)); } void @@ -135,9 +107,9 @@ void sp_xmlview_content_destroy(GtkObject * object) sp_xmlview_content_set_repr (text, NULL); #if GTK_CHECK_VERSION(3,0,0) - GTK_WIDGET_CLASS (parent_class)->destroy (object); + GTK_WIDGET_CLASS (sp_xmlview_content_parent_class)->destroy (object); #else - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (sp_xmlview_content_parent_class)->destroy (object); #endif } diff --git a/src/widgets/sp-xmlview-content.h b/src/widgets/sp-xmlview-content.h index 8b1342c5e..140eacf46 100644 --- a/src/widgets/sp-xmlview-content.h +++ b/src/widgets/sp-xmlview-content.h @@ -13,10 +13,7 @@ */ #include <config.h> -#include <stdio.h> #include <gtk/gtk.h> -#include <glib.h> - #define SP_TYPE_XMLVIEW_CONTENT (sp_xmlview_content_get_type ()) #define SP_XMLVIEW_CONTENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_CONTENT, SPXMLViewContent)) diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index 43b7dc289..5dff9adf3 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -1,6 +1,4 @@ -#define __SP_XMLVIEW_TREE_C__ - -/* +/** * Specialization of GtkTreeView for the XML tree view * * Authors: @@ -14,7 +12,7 @@ #include <cstring> #include <string> -#include "../xml/node-event-vector.h" +#include "xml/node-event-vector.h" #include "sp-xmlview-tree.h" struct NodeData { @@ -25,9 +23,6 @@ struct NodeData { enum { STORE_TEXT_COL = 0, STORE_DATA_COL, STORE_REPR_COL, STORE_N_COLS }; -static void sp_xmlview_tree_class_init (SPXMLViewTreeClass * klass); -static void sp_xmlview_tree_init (SPXMLViewTree * tree); - #if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_tree_destroy(GtkWidget * object); #else @@ -92,8 +87,6 @@ static const Inkscape::XML::NodeEventVector pi_repr_events = { NULL /* order_changed */ }; -static GtkTreeViewClass * parent_class = NULL; - GtkWidget *sp_xmlview_tree_new(Inkscape::XML::Node * repr, void * /*factory*/, void * /*data*/) { SPXMLViewTree *tree = SP_XMLVIEW_TREE(g_object_new (SP_TYPE_XMLVIEW_TREE, NULL)); @@ -124,28 +117,7 @@ GtkWidget *sp_xmlview_tree_new(Inkscape::XML::Node * repr, void * /*factory*/, v return GTK_WIDGET(tree); } -GType -sp_xmlview_tree_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (SPXMLViewTreeClass), - NULL, NULL, - (GClassInitFunc) sp_xmlview_tree_class_init, - NULL, NULL, - sizeof (SPXMLViewTree), - 0, - (GInstanceInitFunc) sp_xmlview_tree_init, - NULL - }; - type = g_type_register_static (GTK_TYPE_TREE_VIEW, "SPXMLViewTree", &info, (GTypeFlags)0); - } - - - return type; -} +G_DEFINE_TYPE(SPXMLViewTree, sp_xmlview_tree, GTK_TYPE_TREE_VIEW); void sp_xmlview_tree_class_init(SPXMLViewTreeClass * klass) { @@ -157,8 +129,6 @@ void sp_xmlview_tree_class_init(SPXMLViewTreeClass * klass) object_class->destroy = sp_xmlview_tree_destroy; #endif - parent_class = GTK_TREE_VIEW_CLASS(g_type_class_peek_parent (klass)); - // Signal for when a tree drag and drop has completed g_signal_new ( "tree_move", G_TYPE_FROM_CLASS(klass), @@ -190,9 +160,9 @@ void sp_xmlview_tree_destroy(GtkObject * object) sp_xmlview_tree_set_repr (tree, NULL); #if GTK_CHECK_VERSION(3,0,0) - GTK_WIDGET_CLASS(parent_class)->destroy (object); + GTK_WIDGET_CLASS(sp_xmlview_tree_parent_class)->destroy (object); #else - GTK_OBJECT_CLASS(parent_class)->destroy (object); + GTK_OBJECT_CLASS(sp_xmlview_tree_parent_class)->destroy (object); #endif } @@ -734,4 +704,4 @@ gboolean search_equal_func(GtkTreeModel *model, gint /*column*/, const gchar *ke fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/sp-xmlview-tree.h b/src/widgets/sp-xmlview-tree.h index 69228fa88..7ecbcb471 100644 --- a/src/widgets/sp-xmlview-tree.h +++ b/src/widgets/sp-xmlview-tree.h @@ -1,9 +1,4 @@ -#ifndef __SP_XMLVIEW_TREE_H__ -#define __SP_XMLVIEW_TREE_H__ - -/* - * Specialization of GtkTreeView for the XML editor - * +/** * Authors: * MenTaLguY <mental@rydia.net> * @@ -12,9 +7,15 @@ * Released under the GNU GPL; see COPYING for details */ +#ifndef SEEN_SP_XMLVIEW_TREE_H +#define SEEN_SP_XMLVIEW_TREE_H + #include <gtk/gtk.h> #include <glib.h> +/** + * Specialization of GtkTreeView for the XML editor + */ #define SP_TYPE_XMLVIEW_TREE (sp_xmlview_tree_get_type ()) #define SP_XMLVIEW_TREE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_XMLVIEW_TREE, SPXMLViewTree)) @@ -49,7 +50,7 @@ Inkscape::XML::Node * sp_xmlview_tree_node_get_repr (GtkTreeModel *model, GtkTre gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Node * repr, GtkTreeIter *node); -#endif +#endif // !SEEN_SP_XMLVIEW_TREE_H /* Local Variables: @@ -60,4 +61,4 @@ gboolean sp_xmlview_tree_get_repr_node (SPXMLViewTree * tree, Inkscape::XML::Nod fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/spinbutton-events.h b/src/widgets/spinbutton-events.h index c1df88c8a..9bf50d87c 100644 --- a/src/widgets/spinbutton-events.h +++ b/src/widgets/spinbutton-events.h @@ -10,7 +10,9 @@ */ #include <glib.h> -#include <gtk/gtk.h> /* GtkWidget */ + +typedef struct _GdkEventKey GdkEventKey; +typedef struct _GtkWidget GtkWidget; gboolean spinbutton_focus_in (GtkWidget *w, GdkEventKey *event, gpointer data); void spinbutton_undo (GtkWidget *w); diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 9c0c8d7c6..f87889bb1 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -64,8 +64,15 @@ Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int label_widget->set_hexpand(); label_widget->set_halign(Gtk::ALIGN_FILL); label_widget->set_valign(Gtk::ALIGN_CENTER); + + #if GTK_CHECK_VERSION(3,12,0) + label_widget->set_margin_start(4); + label_widget->set_margin_end(4); + #else label_widget->set_margin_left(4); label_widget->set_margin_right(4); + #endif + table->attach(*label_widget, col, row, 1, 1); #else table->attach(*label_widget, col, col+1, row, row+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 4, 0); @@ -238,7 +245,11 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font) PangoFontDescription* pan = pango_font_description_new (); pango_font_description_set_size (pan, size); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_override_font (w, pan); +#else gtk_widget_modify_font (w, pan); +#endif if (GTK_IS_CONTAINER(w)) { gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 7a7d0dc71..0f8c31be8 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -42,6 +42,7 @@ #include "sp-star.h" #include "toolbox.h" #include "ui/icon-names.h" +#include "ui/tools/star-tool.h" #include "ui/uxmanager.h" #include "verbs.h" #include "widgets/../preferences.h" @@ -435,6 +436,7 @@ static void sp_stb_defaults( GtkWidget * /*widget*/, GObject *dataKludge ) gtk_adjustment_value_changed(adj); } +static void star_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { @@ -571,15 +573,22 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje } } - sigc::connection *connection = new sigc::connection( - sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder)) - ); - g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection ); - g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); + desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(star_toolbox_watch_ec), holder)); + g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder); } +static void star_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) +{ + static sigc::connection changed; - + if (dynamic_cast<Inkscape::UI::Tools::StarTool const*>(ec) != NULL) { + changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder)); + sp_star_toolbox_selection_changed(sp_desktop_selection(desktop), holder); + } else { + if (changed) + changed.disconnect(); + } +} /* Local Variables: @@ -590,4 +599,4 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 36a151c52..88f698bc4 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -819,7 +819,7 @@ static void sp_text_set_sizes(GtkListStore* model_size, int unit) * It is called whenever a text selection is changed, including stepping cursor * through text, or setting focus to text. */ -static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/, GObject *tbl) +static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/, GObject *tbl, bool subselection = false) // don't bother to update font list if subsel changed { #ifdef DEBUG_TEXT static int count = 0; @@ -859,7 +859,9 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontStyleAction" ) ); Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); - fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + if (!subselection) { + fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); + } fontlister->selection_update(); // Update font list, but only if widget already created. @@ -1154,7 +1156,7 @@ static void sp_text_toolbox_selection_modified(Inkscape::Selection *selection, g static void sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl) { - sp_text_toolbox_selection_changed (NULL, tbl); + sp_text_toolbox_selection_changed (NULL, tbl, true); } // TODO: possibly share with font-selector by moving most code to font-lister (passing family name) @@ -1640,7 +1642,7 @@ static void text_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolB if (SP_IS_TEXT_CONTEXT(ec)) { // Watch selection - c_selection_changed = sp_desktop_selection(desktop)->connectChanged(bind(ptr_fun(sp_text_toolbox_selection_changed), holder)); + c_selection_changed = sp_desktop_selection(desktop)->connectChanged(bind(ptr_fun(sp_text_toolbox_selection_changed), holder, false)); c_selection_modified = sp_desktop_selection (desktop)->connectModified(bind(ptr_fun(sp_text_toolbox_selection_modified), holder)); c_subselection_changed = desktop->connectToolSubselectionChanged(bind(ptr_fun(sp_text_toolbox_subselection_changed), holder)); } else { @@ -1661,4 +1663,4 @@ static void text_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolB fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h index fb749bfb5..db9130034 100644 --- a/src/widgets/toolbox.h +++ b/src/widgets/toolbox.h @@ -13,15 +13,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtk/gtk.h> #include <glibmm/ustring.h> #include "icon-size.h" -#include "../ege-adjustment-action.h" -#include "../preferences.h" +#include "preferences.h" #define TOOLBAR_SLIDER_HINT "full" +typedef struct _EgeAdjustmentAction EgeAdjustmentAction; + class SPDesktop; namespace Inkscape { |
