From d2a3bc0b327557fba34f09a110a0ac5b6d18f85e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 12:38:28 +0100 Subject: Move background drawing to SPCanvas to avoid temporarily drawing an incorrect background. #Hackfest2016 (bzr r14821) --- src/desktop.cpp | 17 ++-------- src/desktop.h | 1 - src/display/sp-canvas.cpp | 85 +++++++++++++++++++++++++++++++++++------------ src/display/sp-canvas.h | 18 +++++++--- 4 files changed, 79 insertions(+), 42 deletions(-) diff --git a/src/desktop.cpp b/src/desktop.cpp index 331ab3351..5cd9ef32f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -111,7 +111,6 @@ SPDesktop::SPDesktop() : sketch( NULL ), controls( NULL ), tempgroup ( NULL ), - table( NULL ), page( NULL ), page_border( NULL ), current( NULL ), @@ -211,11 +210,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid g_signal_connect (G_OBJECT (main), "event", G_CALLBACK (sp_desktop_root_handler), this); /* This is the background the page sits on. */ - table = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL); - SP_CTRLRECT(table)->setRectangle(Geom::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000))); - SP_CTRLRECT(table)->setColor(0x00000000, true, 0x00000000); - SP_CTRLRECT(table)->setCheckerboard( false ); - sp_canvas_item_move_to_z (table, 0); + canvas->setBackgroundColor(0xffffff00); page = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL); ((CtrlRect *) page)->setColor(0x00000000, FALSE, 0x00000000); @@ -1733,17 +1728,11 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) SPNamedView *nv=SP_NAMEDVIEW(obj); if (flags & SP_OBJECT_MODIFIED_FLAG) { - - /* Set page background */ - sp_canvas_item_show (desktop->table); if (nv->pagecheckerboard) { - ((CtrlRect *) desktop->table)->setCheckerboard( true ); - ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor ); // | 0xff); + desktop->canvas->setBackgroundCheckerboard(); } else { - ((CtrlRect *) desktop->table)->setCheckerboard( false ); - ((CtrlRect *) desktop->table)->setColor(0x00000000, true, nv->pagecolor | 0xff); + desktop->canvas->setBackgroundColor(nv->pagecolor); } - sp_canvas_item_move_to_z (desktop->table, 0); /* Show/hide page border */ if (nv->showborder) { diff --git a/src/desktop.h b/src/desktop.h index f1444ba7b..3652d4a97 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -174,7 +174,6 @@ public: SPCanvasGroup *sketch; SPCanvasGroup *controls; SPCanvasGroup *tempgroup; ///< contains temporary canvas items - SPCanvasItem *table; ///< outside-of-page background SPCanvasItem *page; ///< page background SPCanvasItem *page_border; ///< page border SPCSSAttr *current; ///< current style diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 644da8d5a..6b7836d2e 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -27,6 +27,7 @@ #include "helper/sp-marshal.h" #include <2geom/rect.h> #include <2geom/affine.h> +#include "display/cairo-utils.h" #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" #include "preferences.h" @@ -37,6 +38,7 @@ #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" +#include "color.h" using Inkscape::Debug::GdkEventLatencyTracker; @@ -959,6 +961,8 @@ static void sp_canvas_init(SPCanvas *canvas) canvas->_backing_store = NULL; canvas->_clean_region = cairo_region_create(); + canvas->_background = cairo_pattern_create_rgb(1, 1, 1); + canvas->_background_is_checkerboard = false; canvas->_forced_redraw_count = 0; canvas->_forced_redraw_limit = -1; @@ -972,10 +976,7 @@ static void sp_canvas_init(SPCanvas *canvas) void SPCanvas::shutdownTransients() { // Reset the clean region - if (_clean_region && !cairo_region_is_empty(_clean_region)) { - cairo_region_destroy(_clean_region); - _clean_region = cairo_region_create(); - } + dirtyAll(); if (_grabbed_item) { _grabbed_item = NULL; @@ -1006,6 +1007,10 @@ void SPCanvas::dispose(GObject *object) cairo_region_destroy(canvas->_clean_region); canvas->_clean_region = NULL; } + if (canvas->_background) { + cairo_pattern_destroy(canvas->_background); + canvas->_background = NULL; + } canvas->shutdownTransients(); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -1529,9 +1534,6 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect { GtkWidget *widget = GTK_WIDGET (this); - // Mark the region clean - markRect(paint_rect, 0); - SPCanvasBuf buf; buf.buf = NULL; buf.buf_rowstride = 0; @@ -1543,7 +1545,6 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect // create temporary surface cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height()); buf.ct = cairo_create(imgs); - //cairo_translate(buf.ct, -x0, -y0); // fix coordinates, clip all drawing to the tile and clear the background //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); @@ -1553,18 +1554,12 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect //cairo_stroke_preserve(buf.ct); //cairo_clip(buf.ct); -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *context = gtk_widget_get_style_context(widget); - gtk_render_background(context, buf.ct, 0, 0, paint_rect.width(), paint_rect.height()); -#else - GtkStyle *style = gtk_widget_get_style (widget); - gdk_cairo_set_source_color(buf.ct, &style->bg[GTK_STATE_NORMAL]); -#endif - + cairo_save(buf.ct); + cairo_translate(buf.ct, -paint_rect.left(), -paint_rect.top()); + cairo_set_source(buf.ct, _background); cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); - //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rec.height()); cairo_paint(buf.ct); - cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); + cairo_restore(buf.ct); if (_root->visible) { SP_CANVAS_ITEM_GET_CLASS(_root)->render(_root, &buf); @@ -1608,8 +1603,8 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect cairo_destroy(xct); cairo_surface_destroy(imgs); - cairo_rectangle_int_t crect = { paint_rect.left(), paint_rect.right(), paint_rect.width(), paint_rect.height() }; - cairo_region_union_rectangle(_clean_region, &crect); + // Mark the painted rectangle clean + markRect(paint_rect, 0); gtk_widget_queue_draw_area(GTK_WIDGET(this), paint_rect.left() -_x0, paint_rect.top() - _y0, paint_rect.width(), paint_rect.height()); @@ -1816,6 +1811,16 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { cairo_region_subtract(draw_dirty, canvas->_clean_region); cairo_region_intersect(draw_region, canvas->_clean_region); + // Draw the background + cairo_save(cr); + cairo_translate(cr, -canvas->_x0, -canvas->_y0); + cairo_set_source(cr, canvas->_background); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_paint(cr); + cairo_restore(cr); + /*cairo_set_source(cr, canvas->_background); + cairo_paint(cr);*/ + // Draw the clean portion if (!cairo_region_is_empty(draw_region)) { cairo_region_translate(draw_region, -canvas->_x0, -canvas->_y0); @@ -2007,6 +2012,7 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll gtk_widget_get_allocation(&_widget, &allocation); + // adjust backing store contents assert(_backing_store); cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); @@ -2021,8 +2027,7 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll _backing_store = new_backing_store; if (clear) { - cairo_region_destroy(_clean_region); - _clean_region = cairo_region_create(); + dirtyAll(); } else { cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height }; cairo_region_intersect_rectangle(_clean_region, &crect); @@ -2070,6 +2075,35 @@ void SPCanvas::requestRedraw(int x0, int y0, int x1, int y1) addIdle(); } +void SPCanvas::setBackgroundColor(guint32 rgba) { + double new_r = SP_RGBA32_R_F(rgba); + double new_g = SP_RGBA32_G_F(rgba); + double new_b = SP_RGBA32_B_F(rgba); + if (!_background_is_checkerboard) { + double old_r, old_g, old_b; + cairo_pattern_get_rgba(_background, &old_r, &old_g, &old_b, NULL); + if (new_r == old_r && new_g == old_g && new_b == old_b) return; + } + if (_background) { + cairo_pattern_destroy(_background); + } + _background = cairo_pattern_create_rgb(new_r, new_g, new_b); + _background_is_checkerboard = false; + dirtyAll(); + addIdle(); +} + +void SPCanvas::setBackgroundCheckerboard() { + if (_background_is_checkerboard) return; + if (_background) { + cairo_pattern_destroy(_background); + } + _background = ink_cairo_pattern_create_checkerboard(); + _background_is_checkerboard = true; + dirtyAll(); + addIdle(); +} + /** * Sets world coordinates from win and canvas. */ @@ -2175,6 +2209,13 @@ void SPCanvas::dirtyRect(Geom::IntRect const &area) { markRect(area, 1); } +void SPCanvas::dirtyAll() { + if (_clean_region && !cairo_region_is_empty(_clean_region)) { + cairo_region_destroy(_clean_region); + _clean_region = cairo_region_create(); + } +} + void SPCanvas::markRect(Geom::IntRect const &area, uint8_t val) { cairo_rectangle_int_t crect = { area.left(), area.top(), area.width(), area.height() }; diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index a1f8d0a1a..171fdaf67 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -87,6 +87,9 @@ struct SPCanvas { Geom::IntRect getViewboxIntegers() const; SPCanvasGroup *getRoot(); + void setBackgroundColor(guint32 rgba); + void setBackgroundCheckerboard(); + /// Returns new canvas as widget. static GtkWidget *createAA(); @@ -105,7 +108,8 @@ private: /// Marks the specified area as dirty (requiring redraw) void dirtyRect(Geom::IntRect const &area); - /// Marks specific canvas rectangle as clean (val == 0) or dirty (otherwise) + /// Marks the whole widget for redraw + void dirtyAll(); void markRect(Geom::IntRect const &area, uint8_t val); /// Invokes update, paint, and repick on canvas. @@ -177,14 +181,18 @@ public: bool _is_dragging; double _dx0; double _dy0; - int _x0; - int _y0; + int _x0; ///< World coordinate of the leftmost pixels + int _y0; ///< World coordinate of the topmost pixels - /* Area that needs redrawing, stored as a microtile array */ + /// Image surface storing the contents of the widget cairo_surface_t *_backing_store; + /// Area of the widget that has up-to-date content cairo_region_t *_clean_region; + /// Widget background, defaults to white + cairo_pattern_t *_background; + bool _background_is_checkerboard; - /** Last known modifier state, for deferred repick when a button is down. */ + /// Last known modifier state, for deferred repick when a button is down. int _state; /** The item containing the mouse pointer, or NULL if none. */ -- cgit v1.2.3 From ea551934712e32620210338aa47f6bf5a6f81043 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 13 Apr 2016 13:53:54 +0200 Subject: Fix referencing problem with widget is moved from one container to another. Hackfest 2016. (bzr r14822) --- src/widgets/desktop-widget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 759be551f..19c07075b 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1698,8 +1698,11 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp case GTK_POS_TOP: case GTK_POS_BOTTOM: if ( gtk_widget_is_ancestor(toolbox, hbox) ) { + // Removing a widget can reduce ref count to zero + gtk_object_ref(GTK_OBJECT(toolbox)); gtk_container_remove(GTK_CONTAINER(hbox), toolbox); gtk_container_add(GTK_CONTAINER(vbox), toolbox); + gtk_object_unref(GTK_OBJECT(toolbox)); gtk_box_set_child_packing(GTK_BOX(vbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); } ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_HORIZONTAL); @@ -1707,8 +1710,10 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp case GTK_POS_LEFT: case GTK_POS_RIGHT: if ( !gtk_widget_is_ancestor(toolbox, hbox) ) { + gtk_object_ref(GTK_OBJECT(toolbox)); gtk_container_remove(GTK_CONTAINER(vbox), toolbox); gtk_container_add(GTK_CONTAINER(hbox), toolbox); + gtk_object_unref(GTK_OBJECT(toolbox)); gtk_box_set_child_packing(GTK_BOX(hbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); if (pos == GTK_POS_LEFT) { gtk_box_reorder_child( GTK_BOX(hbox), toolbox, 0 ); -- cgit v1.2.3 From 16b2c93dcfca8c6ee6cd61f4065a9a387fcde3bd Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 13 Apr 2016 13:58:08 +0200 Subject: Fix CMake caching issue with GtkSpell (bzr r14823) --- CMakeScripts/DefineDependsandFlags.cmake | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index d8088bf9a..4429758c0 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -247,9 +247,12 @@ if("${WITH_GTK3_EXPERIMENTAL}") pkg_check_modules(GTKSPELL3 gtkspell3-3.0) if("${GTKSPELL3_FOUND}") - message("Using GtkSpell3 3.0") + message("Using GtkSpell3") set (WITH_GTKSPELL 1) + else() + unset(WITH_GTKSPELL) endif() + list(APPEND INKSCAPE_INCS_SYS ${GTK3_INCLUDE_DIRS} ${GTKSPELL3_INCLUDE_DIRS} @@ -268,19 +271,21 @@ else() ) list(APPEND INKSCAPE_CXX_FLAGS ${GTK_CFLAGS_OTHER}) pkg_check_modules(GTKSPELL2 gtkspell-2.0) - if("${GTKSPELL3_FOUND}") - message("Using GtkSpell3 3.0") - add_definitions(${GTK_CFLAGS_OTHER}) + if("${GTKSPELL2_FOUND}") + message("Using GtkSpell 2") + add_definitions(${GTKSPELL2_CFLAGS_OTHER}) set (WITH_GTKSPELL 1) + else() + unset(WITH_GTKSPELL) endif() list(APPEND INKSCAPE_INCS_SYS ${GTK_INCLUDE_DIRS} - ${GTKSPELL_INCLUDE_DIRS} + ${GTKSPELL2_INCLUDE_DIRS} ) list(APPEND INKSCAPE_LIBS ${GTK_LIBRARIES} - ${GTKSPELL_LIBRARIES} + ${GTKSPELL2_LIBRARIES} ) endif() @@ -300,17 +305,6 @@ if(ASPELL_FOUND) set(HAVE_ASPELL TRUE) endif() -if("${TRY_GTKSPELL}" AND "${WITH_GTKSPELL}") - find_package(GtkSpell) - if(GTKSPELL_FOUND) - list(APPEND INKSCAPE_INCS_SYS ${GTKSPELL_INCLUDE_DIR}) - list(APPEND INKSCAPE_LIBS ${GTKSPELL_LIBRARIES}) - add_definitions(${GTKSPELL_DEFINITIONS}) - else() - set(WITH_GTKSPELL OFF) - endif() -endif() - #find_package(OpenSSL) #list(APPEND INKSCAPE_INCS_SYS ${OPENSSL_INCLUDE_DIR}) #list(APPEND INKSCAPE_LIBS ${OPENSSL_LIBRARIES}) -- cgit v1.2.3 From de93b23d78770247c0b69a0b11b6097396a09fb5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 12:58:25 +0100 Subject: Fix redraw problems when shrinking and then enlarging the SPCanvas widget. #Hackfest2016 (bzr r14824) --- src/display/sp-canvas.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 6b7836d2e..a311de7f1 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1154,7 +1154,7 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->_x0, canvas->_y0, allocation->width, allocation->height); - // resize backing store; the clean region does not change + // resize backing store cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation->width, allocation->height); if (canvas->_backing_store) { @@ -1167,9 +1167,12 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation } canvas->_backing_store = new_backing_store; + // Clip the clean region to the new allocation + cairo_rectangle_int_t crect = { canvas->_x0, canvas->_y0, allocation->width, allocation->height }; + cairo_region_intersect_rectangle(canvas->_clean_region, &crect); + gtk_widget_set_allocation (widget, allocation); - // Schedule redraw of new region if (SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed) SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed (canvas->_root, new_area); @@ -1178,6 +1181,7 @@ void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation allocation->x, allocation->y, allocation->width, allocation->height); } + // Schedule redraw of any newly exposed regions canvas->addIdle(); } @@ -1818,8 +1822,6 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); cairo_restore(cr); - /*cairo_set_source(cr, canvas->_background); - cairo_paint(cr);*/ // Draw the clean portion if (!cairo_region_is_empty(draw_region)) { -- cgit v1.2.3 From c9d41b9a25cdcd58087f37c73f60638cb79bf309 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 13 Apr 2016 14:11:41 +0200 Subject: Gtk3 compatibility fix. Hackfest 2016 (bzr r14825) --- src/widgets/desktop-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 19c07075b..fe724a964 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1699,10 +1699,10 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp case GTK_POS_BOTTOM: if ( gtk_widget_is_ancestor(toolbox, hbox) ) { // Removing a widget can reduce ref count to zero - gtk_object_ref(GTK_OBJECT(toolbox)); + g_object_ref(G_OBJECT(toolbox)); gtk_container_remove(GTK_CONTAINER(hbox), toolbox); gtk_container_add(GTK_CONTAINER(vbox), toolbox); - gtk_object_unref(GTK_OBJECT(toolbox)); + g_object_unref(G_OBJECT(toolbox)); gtk_box_set_child_packing(GTK_BOX(vbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); } ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_HORIZONTAL); @@ -1710,10 +1710,10 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp case GTK_POS_LEFT: case GTK_POS_RIGHT: if ( !gtk_widget_is_ancestor(toolbox, hbox) ) { - gtk_object_ref(GTK_OBJECT(toolbox)); + g_object_ref(G_OBJECT(toolbox)); gtk_container_remove(GTK_CONTAINER(vbox), toolbox); gtk_container_add(GTK_CONTAINER(hbox), toolbox); - gtk_object_unref(GTK_OBJECT(toolbox)); + g_object_unref(G_OBJECT(toolbox)); gtk_box_set_child_packing(GTK_BOX(hbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); if (pos == GTK_POS_LEFT) { gtk_box_reorder_child( GTK_BOX(hbox), toolbox, 0 ); -- cgit v1.2.3 From 8948544b36d4caef900860cd6aa8672deb5814b0 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 13 Apr 2016 14:18:46 +0100 Subject: Remove old uses of GTK_STOCK macros (bzr r14826) --- src/libgdl/gdl-dock-bar.c | 2 +- src/live_effects/parameter/originalpatharray.cpp | 8 ++++---- src/ui/dialog/objects.cpp | 4 ++-- src/ui/widget/addtoicon.cpp | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 1d7b33b5f..c1fe21872 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -314,7 +314,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar, } else if (pixbuf_icon) { image = gtk_image_new_from_pixbuf (pixbuf_icon); } else { - image = gtk_image_new_from_stock (GTK_STOCK_NEW, + image = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_SMALL_TOOLBAR); } gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0); diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 7e3a6f5fe..4ee068ebf 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -144,7 +144,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget() { // Paste path to link button - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-stock", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -156,7 +156,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget() } { // Remove linked path - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_REMOVE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-remove", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -168,7 +168,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget() } { // Move Down - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_DOWN, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-down", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -180,7 +180,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget() } { // Move Down - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_GO_UP, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( "gtk-go-up", Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 891048beb..27694a9ac 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -1907,8 +1907,8 @@ ObjectsPanel::ObjectsPanel() : _popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem())); - _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_RAISE, GTK_STOCK_GO_UP, _("Up"), (int)BUTTON_UP ) ); - _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_LOWER, GTK_STOCK_GO_DOWN, _("Down"), (int)BUTTON_DOWN ) ); + _watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_RAISE, "gtk-go-up", _("Up"), (int)BUTTON_UP ) ); + _watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_SELECTION_LOWER, "gtk-go-down", _("Down"), (int)BUTTON_DOWN ) ); _popupMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem())); diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp index 823e24a00..10294125d 100644 --- a/src/ui/widget/addtoicon.cpp +++ b/src/ui/widget/addtoicon.cpp @@ -48,7 +48,6 @@ AddToIcon::AddToIcon() : // // _property_pixbuf_add = Gtk::Widget:: - //property_stock_id() = GTK_STOCK_ADD; set_pixbuf(); } -- cgit v1.2.3 From 1853340f66e25dbece6666c7ebf71f93ed203ba7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 14:45:53 +0100 Subject: text-toolbar: Gtk+ 3 theming #Hackfest2016 (bzr r14827) --- src/widgets/text-toolbar.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 661fc6fa9..23acb74af 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1562,6 +1562,23 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje g_object_set_data( holder, "TextFontFamilyAction", act ); // Change style of drop-down from menu to list +#if GTK_CHECK_VERSION(3,0,0) + GtkCssProvider *css_provider = gtk_css_provider_new(); + gtk_css_provider_load_from_data(css_provider, + "#TextFontFamilyAction_combobox {\n" + " -GtkComboBox-appears-as-list: true;\n" + "}\n" + "combobox window.popup scrolledwindow treeview separator {\n" + " -GtkWidget-wide-separators: true;\n" + " -GtkWidget-separator-height: 6;\n" + "}\n", + -1, NULL); + + GdkScreen *screen = gdk_screen_get_default(); + gtk_style_context_add_provider_for_screen(screen, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); +#else gtk_rc_parse_string ( "style \"dropdown-as-list-style\"\n" "{\n" @@ -1574,6 +1591,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje " GtkWidget::separator-height = 6\n" "}\n" "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\""); +#endif } /* Font size */ -- cgit v1.2.3 From 62468bff6706859d2aaa9d14a23221270f5d3053 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 14:48:21 +0100 Subject: spw-utilities: Fix gtk_widget_set_margin_* API #Hackfest2016 (bzr r14828) --- src/widgets/spw-utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 89ab76585..5500e1068 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -94,9 +94,9 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) gtk_widget_show (label_widget); #if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,12,0) gtk_widget_set_margin_start(label_widget, 4); gtk_widget_set_margin_end(label_widget, 4); -#if GTK_CHECK_VERSION(3,12,0) #else gtk_widget_set_margin_left(label_widget, 4); gtk_widget_set_margin_right(label_widget, 4); -- cgit v1.2.3 From 9e005239a9a2c93f40b1ac0e1a8e711ec7a2234e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 14:56:01 +0100 Subject: Fix canvas flicker while dragging objects. #Hackfest2016 (bzr r14829) --- src/display/sp-canvas.cpp | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index a311de7f1..3a801826b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1798,8 +1798,14 @@ void SPCanvas::endForcedFullRedraws() gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { SPCanvas *canvas = SP_CANVAS(widget); + // Blit from the backing store, without regard for the clean region. + // This is necessary because GTK clears the widget for us, which causes + // severe flicker while drawing if we don't blit the old contents. + cairo_set_source_surface(cr, canvas->_backing_store, 0, 0); + cairo_paint(cr); + cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr); - cairo_region_t *draw_region = cairo_region_create(); + cairo_region_t *dirty_region = cairo_region_create(); for (int i = 0; i < rects->num_rectangles; i++) { cairo_rectangle_t rectangle = rects->rectangles[i]; @@ -1807,44 +1813,16 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { rectangle.width, rectangle.height); Geom::IntRect ir = dr.roundOutwards(); cairo_rectangle_int_t irect = { ir.left(), ir.top(), ir.width(), ir.height() }; - cairo_region_union_rectangle(draw_region, &irect); + cairo_region_union_rectangle(dirty_region, &irect); } cairo_rectangle_list_destroy(rects); - - cairo_region_t *draw_dirty = cairo_region_copy(draw_region); - cairo_region_subtract(draw_dirty, canvas->_clean_region); - cairo_region_intersect(draw_region, canvas->_clean_region); - - // Draw the background - cairo_save(cr); - cairo_translate(cr, -canvas->_x0, -canvas->_y0); - cairo_set_source(cr, canvas->_background); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint(cr); - cairo_restore(cr); - - // Draw the clean portion - if (!cairo_region_is_empty(draw_region)) { - cairo_region_translate(draw_region, -canvas->_x0, -canvas->_y0); - cairo_save(cr); - int n_rects = cairo_region_num_rectangles(draw_region); - for (int i = 0; i < n_rects; ++i) { - cairo_rectangle_int_t crect; - cairo_region_get_rectangle(draw_region, i, &crect); - cairo_rectangle(cr, crect.x, crect.y, crect.width, crect.height); - } - cairo_clip(cr); - cairo_set_source_surface(cr, canvas->_backing_store, 0, 0); - cairo_paint(cr); - cairo_restore(cr); - } + cairo_region_subtract(dirty_region, canvas->_clean_region); // Render the dirty portion in the background - if (!cairo_region_is_empty(draw_dirty)) { + if (!cairo_region_is_empty(dirty_region)) { canvas->addIdle(); } - cairo_region_destroy(draw_region); - cairo_region_destroy(draw_dirty); + cairo_region_destroy(dirty_region); return TRUE; } -- cgit v1.2.3 From dd318b73edb6989587be9f70f2ee6dacd5bd139b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 14:56:53 +0100 Subject: font-selector: Gtk+ 3 theming #Hackfest2016 (bzr r14830) --- src/widgets/font-selector.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 943434868..aefcb2e81 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -159,9 +159,24 @@ static void sp_font_selector_init(SPFontSelector *fsel) /* Muck with style, see text-toolbar.cpp */ gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" ); + +#if GTK_CHECK_VERSION(3,0,0) + GtkCssProvider *css_provider = gtk_css_provider_new(); + gtk_css_provider_load_from_data(css_provider, + "#font_selector_family {\n" + " -GtkWidget-wide-separators: true;\n" + " -GtkWidget-separator-height: 6;\n" + "}\n", + -1, NULL); + + GdkScreen *screen = gdk_screen_get_default(); + gtk_style_context_add_provider_for_screen(screen, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); +#else gtk_rc_parse_string ( "widget \"*font_selector_family\" style \"fontfamily-separator-style\""); - +#endif Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); Glib::RefPtr store = fontlister->get_font_list(); -- cgit v1.2.3 From af72bed26b283d07ab91b147d5b8791edef64cc5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 15:19:07 +0100 Subject: Fix artifacts at the border when panning the canvas. #Hackfest2016 (bzr r14831) --- src/display/sp-canvas.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3a801826b..36fea767e 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1544,20 +1544,11 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect buf.rect = paint_rect; buf.visible_rect = canvas_rect; buf.is_empty = true; - //buf.ct = gdk_cairo_create(widget->window); // create temporary surface cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height()); buf.ct = cairo_create(imgs); - // fix coordinates, clip all drawing to the tile and clear the background - //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); - //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rect.height()); - //cairo_set_line_width(buf.ct, 3); - //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); - //cairo_stroke_preserve(buf.ct); - //cairo_clip(buf.ct); - cairo_save(buf.ct); cairo_translate(buf.ct, -paint_rect.left(), -paint_rect.top()); cairo_set_source(buf.ct, _background); @@ -1984,11 +1975,6 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll Geom::IntRect old_area = getViewboxIntegers(); Geom::IntRect new_area = old_area + Geom::IntPoint(dx, dy); - - _dx0 = cx; // here the 'd' stands for double, not delta! - _dy0 = cy; - _x0 = ix; - _y0 = iy; gtk_widget_get_allocation(&_widget, &allocation); @@ -1997,15 +1983,26 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); cairo_t *cr = cairo_create(new_backing_store); - cairo_set_source_rgb(cr, 1, 1, 1); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + // Paint the background + cairo_translate(cr, -ix, -iy); + cairo_set_source(cr, _background); cairo_paint(cr); - cairo_set_source_surface(cr, _backing_store, -dx, -dy); + // Copy the old backing store contents + cairo_set_source_surface(cr, _backing_store, _x0, _y0); + cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height); + cairo_clip(cr); cairo_paint(cr); cairo_destroy(cr); cairo_surface_destroy(_backing_store); _backing_store = new_backing_store; + _dx0 = cx; // here the 'd' stands for double, not delta! + _dy0 = cy; + _x0 = ix; + _y0 = iy; + + // Adjust the clean region if (clear) { dirtyAll(); } else { -- cgit v1.2.3 From d18eee586af65f913c7f614c9c9548ebf2594f3e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 15:38:06 +0100 Subject: Hopefully fix "invalid state when picking" warnings. #Hackfest2016 (bzr r14832) --- src/display/canvas-arena.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index ec99eca9a..366b3c7d1 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -250,7 +250,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->crossing.x, event->crossing.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK, 0); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, + DrawingItem::STATE_PICK | DrawingItem::STATE_BBOX, 0); arena->active = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky); ret = sp_canvas_arena_send_event (arena, event); } @@ -269,7 +270,8 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->c = Geom::Point(event->motion.x, event->motion.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ - arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, + DrawingItem::STATE_PICK | DrawingItem::STATE_BBOX); new_arena = arena->drawing.pick(arena->c, arena->drawing.delta, arena->sticky); if (new_arena != arena->active) { GdkEventCrossing ec; -- cgit v1.2.3 From b9212ef6bdf7172f053bb8821d6579c9ab5e14cb Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 15:40:55 +0100 Subject: Remove unused variable in sp-canvas.cpp (bzr r14833) --- src/display/sp-canvas.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 36fea767e..decb14184 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1536,8 +1536,6 @@ int SPCanvas::handle_motion(GtkWidget *widget, GdkEventMotion *event) void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/) { - GtkWidget *widget = GTK_WIDGET (this); - SPCanvasBuf buf; buf.buf = NULL; buf.buf_rowstride = 0; -- cgit v1.2.3 From 4530a577992a0289d74885d5135ed44d3365a572 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 15:55:31 +0100 Subject: Fix a few more pick calls not preceded by update (bzr r14834) --- src/document.cpp | 13 +++++++++---- src/trace/trace.cpp | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index ae03b1ba1..7086fc0be 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -46,6 +46,7 @@ #include "widgets/desktop-widget.h" #include "desktop.h" #include "dir-util.h" +#include "display/drawing.h" #include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" @@ -1316,6 +1317,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro if ( SP_IS_ITEM(o) ) { SPItem *item = SP_ITEM(o); Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); + arenaitem->drawing().update(); if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { if (find(list.begin(),list.end(),item)!=list.end() ) { @@ -1380,10 +1382,12 @@ static SPItem *find_item_at_point(std::deque *nodes, unsigned int dkey, continue; } Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); - - if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) { - seen = child; - break; + if (arenaitem) { + arenaitem->drawing().update(); + if (arenaitem->pick(p, delta, 1) != NULL) { + seen = child; + break; + } } } @@ -1413,6 +1417,7 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { SPItem *child = SP_ITEM(o); Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); + arenaitem->drawing().update(); // seen remembers the last (topmost) of groups pickable at this point if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) { diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 18f03aa1b..379682668 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -274,6 +274,7 @@ Glib::RefPtr Tracer::sioxProcessImage(SPImage *img, Glib::RefPtrdrawing().update(); if (arenaItem->pick(point, 1.0f, 1)) { weHaveAHit = true; -- cgit v1.2.3 From f5a95a0c8e4080b59d43cdcdcc1ea6b717f3d3f3 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 13 Apr 2016 17:02:57 +0200 Subject: Remove no longer needed warning about feTile rendering. (bzr r14835) --- src/display/nr-filter-tile.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 7172f88ee..c151c8537 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -32,18 +32,6 @@ FilterTile::~FilterTile() void FilterTile::render_cairo(FilterSlot &slot) { - // FIX ME! - static bool tile_warning = false; - if (!tile_warning) { - g_warning("Renderer for feTile has non-optimal implementation, expect slowness and bugs."); - tile_warning = true; - } - - // Fixing isn't so easy as the Inkscape renderer breaks the canvas into "rendering" tiles for - // faster rendering. (The "rendering" tiles are not the same as the tiles in this primitive.) - // Only if the the feTile tile source falls inside the current "rendering" tile will the tile - // image be available. - // This input source contains only the "rendering" tile. cairo_surface_t *in = slot.getcairo(_input); -- cgit v1.2.3 From a18ef5710791412d906f09ed04f89d98d4952b9e Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 13 Apr 2016 17:27:54 +0200 Subject: using cpp limits values (bzr r14836) --- src/libnrtype/Layout-TNG-Compute.cpp | 5 +++-- src/libnrtype/Layout-TNG-Scanline-Makers.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index e862f0657..337d2a656 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -14,6 +14,7 @@ #include "svg/svg-length.h" #include "sp-object.h" #include "Layout-TNG-Scanline-Maker.h" +#include namespace Inkscape { namespace Text { @@ -1569,8 +1570,8 @@ bool Layout::Calculator::_buildChunksInScanRun(ParagraphInfo const ¶, new_span_height.computeEffective( new_span.start.iter_span->line_height_multiplier ); /* floating point 80-bit/64-bit rounding problems require epsilon. See discussion http://inkscape.gristle.org/2005-03-16.txt around 22:00 */ - if ( new_span_height.ascent > line_height->ascent + FLT_EPSILON || - new_span_height.descent > line_height->descent + FLT_EPSILON) { + if ( new_span_height.ascent > line_height->ascent + std::numeric_limits::epsilon() || + new_span_height.descent > line_height->descent + std::numeric_limits::epsilon() ) { // Take larger of each of the two ascents and two descents per CSS line_height->max(new_span_height); if (!_scanline_maker->canExtendCurrentScanline(*line_height)) { diff --git a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp index dcc973a24..0d6112d19 100644 --- a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp +++ b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp @@ -11,6 +11,7 @@ #include "Layout-TNG-Scanline-Maker.h" #include "livarot/Shape.h" #include "livarot/float-line.h" +#include namespace Inkscape { namespace Text { @@ -43,7 +44,7 @@ std::vector Layout::InfiniteScanlineMaker::makeS { std::vector runs(1); runs[0].x_start = _x; - runs[0].x_end = FLT_MAX; // we could use DBL_MAX, but this just seems safer + runs[0].x_end = std::numeric_limits::max(); // we could use DBL_MAX, but this just seems safer runs[0].y = _y; _current_line_height = line_height; return runs; -- cgit v1.2.3 From 90c039450593f045361112648e4ec2dfcff91f0e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 16:44:26 +0100 Subject: Rm shrink_wrap_button - Not needed & uses deprecated GtkStyle features #Hackfest2016 (bzr r14837) --- src/ui/widget/layer-selector.cpp | 3 -- src/widgets/CMakeLists.txt | 2 -- src/widgets/Makefile_insert | 2 -- src/widgets/shrink-wrap-button.cpp | 65 -------------------------------------- src/widgets/shrink-wrap-button.h | 35 -------------------- 5 files changed, 107 deletions(-) delete mode 100644 src/widgets/shrink-wrap-button.cpp delete mode 100644 src/widgets/shrink-wrap-button.h diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index dc89d233f..2a1fa352b 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -32,7 +32,6 @@ #include "util/reverse-list.h" #include "verbs.h" #include "widgets/icon.h" -#include "widgets/shrink-wrap-button.h" #include "xml/node-event-vector.h" #include "widgets/gradient-vector.h" @@ -114,7 +113,6 @@ LayerSelector::LayerSelector(SPDesktop *desktop) ); _visibility_toggle.set_relief(Gtk::RELIEF_NONE); - shrink_wrap_button(_visibility_toggle); _visibility_toggle.set_tooltip_text(_("Toggle current layer visibility")); pack_start(_visibility_toggle, Gtk::PACK_EXPAND_PADDING); @@ -135,7 +133,6 @@ LayerSelector::LayerSelector(SPDesktop *desktop) ); _lock_toggle.set_relief(Gtk::RELIEF_NONE); - shrink_wrap_button(_lock_toggle); _lock_toggle.set_tooltip_text(_("Lock or unlock current layer")); pack_start(_lock_toggle, Gtk::PACK_EXPAND_PADDING); diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 8cb6e947f..225afe317 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -38,7 +38,6 @@ set(widgets_SRC paint-selector.cpp ruler.cpp select-toolbar.cpp - shrink-wrap-button.cpp sp-attribute-widget.cpp sp-color-selector.cpp sp-widget.cpp @@ -94,7 +93,6 @@ set(widgets_SRC paint-selector.h ruler.h select-toolbar.h - shrink-wrap-button.h sp-attribute-widget.h sp-color-selector.h sp-widget.h diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert index 2ee0f7002..c9f04de14 100644 --- a/src/widgets/Makefile_insert +++ b/src/widgets/Makefile_insert @@ -72,8 +72,6 @@ ink_common_sources += \ widgets/ruler.h \ widgets/select-toolbar.cpp \ widgets/select-toolbar.h \ - widgets/shrink-wrap-button.cpp \ - widgets/shrink-wrap-button.h \ widgets/spray-toolbar.cpp \ widgets/spray-toolbar.h \ widgets/spiral-toolbar.cpp \ diff --git a/src/widgets/shrink-wrap-button.cpp b/src/widgets/shrink-wrap-button.cpp deleted file mode 100644 index 941a0466c..000000000 --- a/src/widgets/shrink-wrap-button.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Inkscape::Widgets::shrink_wrap_button - shrink a button to minimum size - * - * Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "shrink-wrap-button.h" - -namespace Inkscape { -namespace Widgets { - -void shrink_wrap_button(Gtk::Button &button) { - button.set_border_width(0); - button.set_can_focus(false); - button.set_can_default(false); - - Gtk::Widget* child = button.get_child(); - Gtk::Requisition req_min; - - if (child) { -#if WITH_GTKMM_3_0 - Gtk::Requisition req_nat; - child->get_preferred_size(req_min, req_nat); -#else - req_min = child->size_request(); -#endif - } else { - req_min.width = 0; - req_min.height = 0; - } - - // TODO: Use Gtk::StyleContext instead - GtkStyle* style = gtk_widget_get_style(GTK_WIDGET(button.gobj())); - - req_min.width += 2 + 2 * std::max(2, style->xthickness); - req_min.height += 2 + 2 * std::max(2, style->ythickness); - - button.set_size_request(req_min.width, req_min.height); -} - -} -} - -/* - 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/widgets/shrink-wrap-button.h b/src/widgets/shrink-wrap-button.h deleted file mode 100644 index ca9153aea..000000000 --- a/src/widgets/shrink-wrap-button.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Inkscape::Widgets::shrink_wrap_button - shrink a button to minimum size - * - * Authors: - * MenTaLguY - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_WIDGETS_SHRINK_WRAP_BUTTON_H -#define SEEN_INKSCAPE_WIDGETS_SHRINK_WRAP_BUTTON_H - -namespace Gtk { class Button; } - -namespace Inkscape { -namespace Widgets { - -void shrink_wrap_button(Gtk::Button &button); - -} -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From d75d7879cea0a018fab78e006197ae0bcba09bef Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 13 Apr 2016 16:51:44 +0100 Subject: Move page border below the drawing. (bzr r14838) --- src/desktop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/desktop.cpp b/src/desktop.cpp index 5cd9ef32f..d482d0d7f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1745,7 +1745,7 @@ static void _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) } // place in the z-order stack if (nv->borderlayer == SP_BORDER_LAYER_BOTTOM) { - sp_canvas_item_move_to_z (desktop->page_border, 2); + sp_canvas_item_move_to_z (desktop->page_border, 1); } else { int order = sp_canvas_item_order (desktop->page_border); int morder = sp_canvas_item_order (desktop->drawing); -- cgit v1.2.3 From 24397ca99c5807898ee423669bb2a089f51bc787 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 16:59:14 +0100 Subject: icon: Fix deprecated gtk_widget_get_requisition() #Hackfest2016 (bzr r14839) --- src/widgets/icon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index f998cd66d..010b3a6fb 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -280,7 +280,13 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) GtkAllocation allocation; GtkRequisition requisition; gtk_widget_get_allocation(widget, &allocation); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(widget, &requisition, NULL); +#else gtk_widget_get_requisition(widget, &requisition); +#endif + int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5)); int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5)); int width = gdk_pixbuf_get_width(image); -- cgit v1.2.3 From 956b51fdbf47877371055dde874967ada810f519 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Wed, 13 Apr 2016 12:08:17 -0400 Subject: icons.svg can be reduced in size (re-use gradients) Fixed bugs: - https://launchpad.net/bugs/1113302 (bzr r14840) --- share/icons/icons.svg | 532 ++++++++++++++++---------------------------------- 1 file changed, 169 insertions(+), 363 deletions(-) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index ea89282df..f3df06b6f 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -4,10 +4,6 @@ - - - - @@ -16,54 +12,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -102,13 +54,13 @@ - - + + - - + + @@ -116,11 +68,6 @@ - - - - - @@ -130,12 +77,12 @@ - - + + - - + + @@ -143,14 +90,14 @@ - + - + - + @@ -158,121 +105,101 @@ - - - - - + - - + + - - - - - - + + - - - - - - - - - - + + - - + + - - - - - - + + - + - + - - + + - + - - + + - - - - - - - - + + + + + + + + - + - + - + - + - - - + + + - - - + + + - + - + - - - - + + + + @@ -280,20 +207,20 @@ - - - - + + + + - + - - + + - + @@ -329,7 +256,7 @@ - + @@ -338,7 +265,7 @@ - + @@ -366,17 +293,17 @@ - + - - + + - - + + @@ -394,9 +321,9 @@ - + - + @@ -418,17 +345,17 @@ - - + + - - - + + + - + @@ -446,7 +373,7 @@ - + @@ -454,8 +381,8 @@ - - + + @@ -465,11 +392,7 @@ - - - - - + @@ -478,8 +401,8 @@ - - + + @@ -492,7 +415,7 @@ - + @@ -513,8 +436,8 @@ - - + + @@ -531,48 +454,27 @@ - - + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - + + + @@ -657,161 +559,89 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - + + + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + - - - - - - - - - - - - - + + + + + + - - - - - + - - - - - - - - - - - + + + @@ -819,56 +649,32 @@ - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - + + + - - - - - - - - + + + + - + - + - - - - - - - - + + + + + + + + - + -- cgit v1.2.3 From e3d2f6b9ddf84b68c690dc750a1b3e12f22af4a4 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Wed, 13 Apr 2016 20:35:29 -0400 Subject: icons.svg can be reduced in size (fix missing radial gradients) Fixed bugs: - https://launchpad.net/bugs/1113302 (bzr r14841) --- share/icons/icons.svg | 1 + 1 file changed, 1 insertion(+) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index f3df06b6f..ac9ddd651 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -164,6 +164,7 @@ + -- cgit v1.2.3 From ff7d0a611e38ba0415bef8c22a4ca9c81b3a584a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 14 Apr 2016 01:50:01 +0100 Subject: Upgrade barcodes, more pylint, new Ean2 code and extended Ean13 with automatic Ean2 and Ean5 additions (bzr r14842) --- share/extensions/Barcode/Base.py | 140 +++++++++++++++++++++-------------- share/extensions/Barcode/BaseEan.py | 107 ++++++++++++++------------ share/extensions/Barcode/Code128.py | 130 ++++++++++++++++---------------- share/extensions/Barcode/Code25i.py | 57 ++++++-------- share/extensions/Barcode/Code39.py | 116 ++++++++++++++--------------- share/extensions/Barcode/Code93.py | 120 ++++++++++++++---------------- share/extensions/Barcode/Ean13.py | 13 ++-- share/extensions/Barcode/Ean2.py | 38 ++++++++++ share/extensions/Barcode/Ean5.py | 37 +++++---- share/extensions/Barcode/Ean8.py | 14 ++-- share/extensions/Barcode/Makefile.am | 1 + share/extensions/Barcode/Rm4scc.py | 7 +- share/extensions/Barcode/Upca.py | 16 ++-- share/extensions/Barcode/Upce.py | 66 ++++++++--------- share/extensions/Barcode/__init__.py | 16 ++-- share/extensions/render_barcode.inx | 5 +- share/extensions/render_barcode.py | 57 +++++++++----- 17 files changed, 505 insertions(+), 435 deletions(-) create mode 100644 share/extensions/Barcode/Ean2.py diff --git a/share/extensions/Barcode/Base.py b/share/extensions/Barcode/Base.py index 1aa1f8415..bfa0a774f 100644 --- a/share/extensions/Barcode/Base.py +++ b/share/extensions/Barcode/Base.py @@ -13,7 +13,7 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Base module for rendering barcodes for Inkscape. @@ -23,114 +23,140 @@ import itertools import sys from lxml import etree +(TEXT_POS_BOTTOM, TEXT_POS_TOP) = range(2) (WHITE_BAR, BLACK_BAR, TALL_BAR) = range(3) TEXT_TEMPLATE = 'font-size:%dpx;text-align:center;text-anchor:middle;' +SVG_URI = u'http://www.w3.org/2000/svg' +# pylint: disable=abstract-class-not-used class Barcode(object): """Provide a base class for all barcode renderers""" + default_height = 30 + font_size = 9 name = None - def error(self, bar, msg): + def error(self, text, msg): """Cause an error to be reported""" sys.stderr.write( - "Error encoding '%s' as %s barcode: %s\n" % (bar, self.name, msg)) + "Error encoding '%s' as %s barcode: %s\n" % (text, self.name, msg)) return "ERROR" - def __init__(self, param={}): + def encode(self, text): + """ + Replace this with the encoding function, it should return + a string of ones and zeros + """ + raise NotImplementedError("You need to write an encode() function.") + + def __init__(self, param): + param = param or {} self.document = param.get('document', None) - self.x = int(param.get('x', 0)) - self.y = int(param.get('y', 0)) - self.scale = param.get('scale', 1) - self.height = param.get('height', 30) - self.label = param.get('text', None) - self.string = self.encode( self.label ) - - if not self.string: - return + self.known_ids = [] + self._extra = [] - self.width = len(self.string) - self.data = self.graphicalArray(self.string) + self.pos_x = int(param.get('x', 0)) + self.pos_y = int(param.get('y', 0)) + self.text = param.get('text', None) + self.scale = param.get('scale', 1) + self.height = param.get('height', self.default_height) + self.pos_text = param.get('text_pos', TEXT_POS_BOTTOM) - def get_id(self): - """Get the next useful id""" - if not self.document: - return "barcode" - doc_ids = {} - docIdNodes = self.document.xpath('//@id') - for m in docIdNodes: - doc_ids[m] = 1 + if self.document: + self.known_ids = list(self.document.xpath('//@id')) - name = 'barcode' + if not self.text: + raise ValueError("No string specified for barcode.") + def get_id(self, name='element'): + """Get the next useful id (and claim it)""" index = 0 - while (doc_ids.has_key(name)): + while name in self.known_ids: index += 1 name = 'barcode%d' % index + self.known_ids.append(name) return name + def add_extra_barcode(self, barcode, **kw): + """Add an extra barcode along side this one, used for ean13 extras""" + from . import getBarcode + kw['height'] = self.height + kw['document'] = self.document + kw['scale'] = None + self._extra.append(getBarcode(barcode, **kw).generate()) + def generate(self): """Generate the actual svg from the coding""" - svg_uri = u'http://www.w3.org/2000/svg' - if self.string == 'ERROR': + string = self.encode(self.text) + + if string == 'ERROR': return - if not self.string or not self.data: - raise ValueError("No string specified for barcode.") - data = self.data - name = self.get_id() + name = self.get_id('barcode') # use an svg group element to contain the barcode - barcode = etree.Element('{%s}%s' % (svg_uri,'g')) + barcode = etree.Element('{%s}g' % SVG_URI) barcode.set('id', name) barcode.set('style', 'fill: black;') - barcode.set('transform', 'translate(%d,%d) scale(%f)' % (self.x, self.y, self.scale)) - + if self.scale: + barcode.set('transform', 'translate(%d,%d) scale(%f)' % ( + self.pos_x, self.pos_y, self.scale)) + else: + barcode.set('transform', 'translate(%d,%d)' % ( + self.pos_x, self.pos_y)) + + bar_id = 1 bar_offset = 0 - bar_id = 1 + tops = set() - for datum in data: + for datum in self.graphical_array(string): # Datum 0 tells us what style of bar is to come next - style = self.getStyle(int(datum[0])) + style = self.get_style(int(datum[0])) # Datum 1 tells us what width in units, # style tells us how wide a unit is width = int(datum[1]) * int(style['width']) if style['write']: - rect = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'rect')) - rect.set('x', str(bar_offset)) - rect.set('y', str(style['top'])) - rect.set('width', str(width)) + tops.add(style['top']) + rect = etree.SubElement(barcode, '{%s}rect' % SVG_URI) + rect.set('x', str(bar_offset)) + rect.set('y', str(style['top'])) + if self.pos_text == TEXT_POS_TOP: + rect.set('y', str(style['top'] + self.font_size)) + rect.set('id', "%s_bar%d" % (name, bar_id)) + rect.set('width', str(width)) rect.set('height', str(style['height'])) - rect.set('id', "%s_bar%d" % (name, bar_id)) bar_offset += width bar_id += 1 + for extra in self._extra: + if extra is not None: + barcode.append(extra) + bar_width = bar_offset # Add text at the bottom of the barcode - text = etree.SubElement(barcode,'{%s}%s' % (svg_uri,'text')) - text.set( 'x', str(int(bar_width / 2))) - text.set( 'y', str(self.height + self.fontSize() )) - text.set( 'style', TEXT_TEMPLATE % self.fontSize() ) - text.set( '{http://www.w3.org/XML/1998/namespace}space', 'preserve' ) - text.set( 'id', '%s_text' % name ) - text.text = str(self.label) + text = etree.SubElement(barcode, '{%s}text' % SVG_URI) + text.set('x', str(int(bar_width / 2))) + text.set('y', str(min(tops) + self.font_size - 1)) + if self.pos_text == TEXT_POS_BOTTOM: + text.set('y', str(self.height + max(tops) + self.font_size)) + text.set('style', TEXT_TEMPLATE % self.font_size) + text.set('{http://www.w3.org/XML/1998/namespace}space', 'preserve') + text.set('id', '%s_text' % name) + text.text = str(self.text) return barcode - def graphicalArray(self, code): + def graphical_array(self, code): """Converts black and white markets into a space array""" - return [(x,len(list(y))) for x, y in itertools.groupby(code)] + return [(x, len(list(y))) for x, y in itertools.groupby(code)] - def getStyle(self, index): + def get_style(self, index): """Returns the styles that should be applied to each bar""" - result = { 'width' : 1, 'top' : 0, 'write' : True } + result = {'width' : 1, 'top' : 0, 'write' : True} if index == BLACK_BAR: result['height'] = int(self.height) if index == TALL_BAR: - result['height'] = int(self.height) + int(self.fontSize() / 2) + result['height'] = int(self.height) + int(self.font_size / 2) if index == WHITE_BAR: result['write'] = False return result - def fontSize(self): - """Return the ideal font size, defaults to 9px""" - return 9 diff --git a/share/extensions/Barcode/BaseEan.py b/share/extensions/Barcode/BaseEan.py index 4ceaeed4a..2c3ab0c09 100644 --- a/share/extensions/Barcode/BaseEan.py +++ b/share/extensions/Barcode/BaseEan.py @@ -13,40 +13,39 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Some basic common code shared between EAN and UCP generators. """ -from Base import Barcode -import sys +from .Base import Barcode, TEXT_POS_TOP MAPPING = [ # Left side of barcode Family '0' - [ "0001101", "0011001", "0010011", "0111101", "0100011", - "0110001", "0101111", "0111011", "0110111", "0001011" ], + ["0001101", "0011001", "0010011", "0111101", "0100011", + "0110001", "0101111", "0111011", "0110111", "0001011"], # Left side of barcode Family '1' and flipped to right side. - [ "0100111", "0110011", "0011011", "0100001", "0011101", - "0111001", "0000101", "0010001", "0001001", "0010111" ], + ["0100111", "0110011", "0011011", "0100001", "0011101", + "0111001", "0000101", "0010001", "0001001", "0010111"], ] # This chooses which of the two encodings above to use. -FAMILIES = [ '000000', '001011', '001101', '001110', '010011', - '011001', '011100', '010101', '010110', '011010' ] - -GUARD_BAR = '202' -CENTER_BAR = '02020' +FAMILIES = ('000000', '001011', '001101', '001110', '010011', + '011001', '011100', '010101', '010110', '011010') class EanBarcode(Barcode): """Simple base class for all EAN type barcodes""" - length = None lengths = None - checks = [] + length = None + checks = [] + extras = {} + magic = 10 + guard_bar = '202' + center_bar = '02020' def intarray(self, number): """Convert a string of digits into an array of ints""" - return [ int(i) for i in number ] - + return [int(i) for i in number] def encode_interleaved(self, family, number, fams=FAMILIES): """Encode any side of the barcode, interleaved""" @@ -54,27 +53,24 @@ class EanBarcode(Barcode): encset = self.intarray(fams[family]) for i in range(len(number)): thismap = MAPPING[encset[i]] - result.append( thismap[number[i]] ) + result.append(thismap[number[i]]) return result - def encode_right(self, number): """Encode the right side of the barcode, non-interleaved""" result = [] - for n in number: + for num in number: # The right side is always the reverse of the left's family '1' - result.append( MAPPING[1][n][::-1] ) + result.append(MAPPING[1][num][::-1]) return result - def encode_left(self, number): """Encode the left side of the barcode, non-interleaved""" result = [] - for n in number: - result.append( MAPPING[0][n] ) + for num in number: + result.append(MAPPING[0][num]) return result - def space(self, *spacing): """Space out an array of numbers""" result = '' @@ -86,60 +82,75 @@ class EanBarcode(Barcode): result += ' ' * space return result - - def getLengths(self): + def get_lengths(self): """Return a list of acceptable lengths""" if self.length: - return [ self.length ] + return [self.length] return self.lengths[:] - def encode(self, code): """Encode any EAN barcode""" + code = code.replace(' ', '').strip() + if not code.isdigit(): return self.error(code, 'Not a Number, must be digits 0-9 only') - lengths = self.getLengths() + self.checks + lengths = self.get_lengths() + self.checks + # Allow extra barcodes after the first one if len(code) not in lengths: - return self.error(code, 'Wrong size, must be %s digits' % - (', '.join(self.space(lengths)))) + for extra in self.extras: + sep = len(code) - extra + if sep in lengths: + # Generate a barcode along side this one. + self.add_extra_barcode(self.extras[extra], text=code[sep:], + x=self.pos_x + 400 * self.scale, text_pos=TEXT_POS_TOP) + code = code[:sep] + + if len(code) not in lengths: + return self.error(code, 'Wrong size %d, must be %s digits' % + (len(code), ', '.join([str(length) for length in lengths]))) if self.checks: if len(code) not in self.checks: - code = self.appendChecksum(code) - elif not self.verifyChecksum(code): + code = self.append_checksum(code) + elif not self.verify_checksum(code): return self.error(code, 'Checksum failed, omit for new sum') return self._encode(self.intarray(code)) - - def _encode(self, n): + def _encode(self, num): + """ + Write your EAN encoding function, it's passed in an array of int and + it should return a string on 1 and 0 for black and white parts + """ raise NotImplementedError("_encode should be provided by parent EAN") - def enclose(self, left, right=[], guard=GUARD_BAR, center=CENTER_BAR): + def enclose(self, left, right=()): """Standard Enclosure""" - parts = [ guard ] + left + [ center ] + right + [ guard ] - return ''.join( parts ) + parts = [self.guard_bar] + left + parts.append(self.center_bar) + parts += list(right) + [self.guard_bar] + return ''.join(parts) - def getChecksum(self, number, magic=10): + def get_checksum(self, number): """Generate a UPCA/EAN13/EAN8 Checksum""" - weight = [3,1] * len(number) + weight = [3, 1] * len(number) result = 0 # We need to work from left to right so reverse number = number[::-1] # checksum based on first digits. for i in range(len(number)): - result += int(number[i]) * weight[i] + result += int(number[i]) * weight[i] # Modulous result to a single digit checksum - checksum = magic - (result % magic) - if checksum < 0 or checksum >= magic: - return '0' + checksum = self.magic - (result % self.magic) + if checksum < 0 or checksum >= self.magic: + return '0' return str(checksum) - def appendChecksum(self, number): + def append_checksum(self, number): """Apply the checksum to a short number""" - return number + self.getChecksum(number) + return number + self.get_checksum(number) - def verifyChecksum(self, number): + def verify_checksum(self, number): """Verify any checksum""" - return self.getChecksum(number[:-1]) == number[-1] + return self.get_checksum(number[:-1]) == number[-1] diff --git a/share/extensions/Barcode/Code128.py b/share/extensions/Barcode/Code128.py index 7ff92088f..b90e3bcf6 100644 --- a/share/extensions/Barcode/Code128.py +++ b/share/extensions/Barcode/Code128.py @@ -17,42 +17,42 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ -Python barcode renderer for Code128/EAN128 barcodes. Designed for use with Inkscape. +Renderer for Code128/EAN128 codes. Designed for use with Inkscape. """ -from Base import Barcode -import math +from .Base import Barcode import re -codeMap = [ - '11011001100','11001101100','11001100110','10010011000','10010001100', - '10001001100','10011001000','10011000100','10001100100','11001001000', - '11001000100','11000100100','10110011100','10011011100','10011001110', - '10111001100','10011101100','10011100110','11001110010','11001011100', - '11001001110','11011100100','11001110100','11101101110','11101001100', - '11100101100','11100100110','11101100100','11100110100','11100110010', - '11011011000','11011000110','11000110110','10100011000','10001011000', - '10001000110','10110001000','10001101000','10001100010','11010001000', - '11000101000','11000100010','10110111000','10110001110','10001101110', - '10111011000','10111000110','10001110110','11101110110','11010001110', - '11000101110','11011101000','11011100010','11011101110','11101011000', - '11101000110','11100010110','11101101000','11101100010','11100011010', - '11101111010','11001000010','11110001010','10100110000','10100001100', - '10010110000','10010000110','10000101100','10000100110','10110010000', - '10110000100','10011010000','10011000010','10000110100','10000110010', - '11000010010','11001010000','11110111010','11000010100','10001111010', - '10100111100','10010111100','10010011110','10111100100','10011110100', - '10011110010','11110100100','11110010100','11110010010','11011011110', - '11011110110','11110110110','10101111000','10100011110','10001011110', - '10111101000','10111100010','11110101000','11110100010','10111011110', - '10111101110','11101011110','11110101110','11010000100','11010010000', - '11010011100','11000111010','11' ] - -def mapExtra(sd, chars): - result = list(sd) +CODE_MAP = [ + '11011001100', '11001101100', '11001100110', '10010011000', '10010001100', + '10001001100', '10011001000', '10011000100', '10001100100', '11001001000', + '11001000100', '11000100100', '10110011100', '10011011100', '10011001110', + '10111001100', '10011101100', '10011100110', '11001110010', '11001011100', + '11001001110', '11011100100', '11001110100', '11101101110', '11101001100', + '11100101100', '11100100110', '11101100100', '11100110100', '11100110010', + '11011011000', '11011000110', '11000110110', '10100011000', '10001011000', + '10001000110', '10110001000', '10001101000', '10001100010', '11010001000', + '11000101000', '11000100010', '10110111000', '10110001110', '10001101110', + '10111011000', '10111000110', '10001110110', '11101110110', '11010001110', + '11000101110', '11011101000', '11011100010', '11011101110', '11101011000', + '11101000110', '11100010110', '11101101000', '11101100010', '11100011010', + '11101111010', '11001000010', '11110001010', '10100110000', '10100001100', + '10010110000', '10010000110', '10000101100', '10000100110', '10110010000', + '10110000100', '10011010000', '10011000010', '10000110100', '10000110010', + '11000010010', '11001010000', '11110111010', '11000010100', '10001111010', + '10100111100', '10010111100', '10010011110', '10111100100', '10011110100', + '10011110010', '11110100100', '11110010100', '11110010010', '11011011110', + '11011110110', '11110110110', '10101111000', '10100011110', '10001011110', + '10111101000', '10111100010', '11110101000', '11110100010', '10111011110', + '10111101110', '11101011110', '11110101110', '11010000100', '11010010000', + '11010011100', '11000111010', '11'] + +def map_extra(data, chars): + """Maps the data into the chars""" + result = list(data) for char in chars: result.append(chr(char)) result.append('FNC3') @@ -60,18 +60,18 @@ def mapExtra(sd, chars): result.append('SHIFT') return result -# The mapExtra method is used to slim down the amount +# The map_extra method is used to slim down the amount # of pre code and instead we generate the lists -charAB = list(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_') -charA = mapExtra(charAB, range(0, 31)) # Offset 64 -charB = mapExtra(charAB, range(96, 125)) # Offset -32 +CHAR_AB = list(" !\"#$%&\'()*+,-./0123456789:;<=>?@" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_") +CHAR_A = map_extra(CHAR_AB, range(0, 31)) # Offset 64 +CHAR_B = map_extra(CHAR_AB, range(96, 125)) # Offset -32 class Code128(Barcode): """Main barcode object, generates the encoding bits here""" def encode(self, text): - result = '' blocks = [] - block = '' + block = '' # Split up into sections of numbers, or charicters # This makes sure that all the charicters are encoded @@ -81,42 +81,42 @@ class Code128(Barcode): block = block + datum else: if block: - blocks.append(self.bestBlock(block)) + blocks.append(self.best_block(block)) block = '' - blocks.append( [ 'C', datum ] ) + blocks.append(['C', datum]) if block: - blocks.append(self.bestBlock(block)) - block = ''; + blocks.append(self.best_block(block)) + block = '' - self.inclabel = text - return self.encodeBlocks(blocks) + return self.encode_blocks(blocks) - def bestBlock(self, block): - # If this has lower case then select B over A + def best_block(self, block): + """If this has lower case then select B over A""" if block.upper() == block: - return [ 'A', block ] - return [ 'B', block ] + return ['A', block] + return ['B', block] - def encodeBlocks(self, blocks): - total = 0 - pos = 0 - encode = ''; + def encode_blocks(self, blocks): + """Encode the given blocks into A, B or C codes""" + encode = '' + total = 0 + pos = 0 for block in blocks: - set = block[0] + b_set = block[0] datum = block[1] # POS : 0, 1 # A : 101, 103 # B : 100, 104 # C : 99, 105 - num = 0; - if set == 'A': + num = 0 + if b_set == 'A': num = 103 - elif set == 'B': + elif b_set == 'B': num = 104 - elif set == 'C': + elif b_set == 'C': num = 105 i = pos @@ -126,28 +126,28 @@ class Code128(Barcode): i = 1 total = total + num * i - encode = encode + codeMap[num] + encode = encode + CODE_MAP[num] pos = pos + 1 - if set == 'A' or set == 'B': - chars = charB - if set == 'A': - chars = charA + if b_set == 'A' or b_set == 'B': + chars = CHAR_B + if b_set == 'A': + chars = CHAR_A for char in datum: total = total + (chars.index(char) * pos) - encode = encode + codeMap[chars.index(char)] + encode = encode + CODE_MAP[chars.index(char)] pos = pos + 1 else: for char in (datum[i:i+2] for i in range(0, len(datum), 2)): total = total + (int(char) * pos) - encode = encode + codeMap[int(char)] + encode = encode + CODE_MAP[int(char)] pos = pos + 1 checksum = total % 103 - encode = encode + codeMap[checksum] - encode = encode + codeMap[106] - encode = encode + codeMap[107] + encode = encode + CODE_MAP[checksum] + encode = encode + CODE_MAP[106] + encode = encode + CODE_MAP[107] return encode diff --git a/share/extensions/Barcode/Code25i.py b/share/extensions/Barcode/Code25i.py index 9812d8598..2c751559c 100644 --- a/share/extensions/Barcode/Code25i.py +++ b/share/extensions/Barcode/Code25i.py @@ -13,53 +13,48 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Generate barcodes for Code25-interleaved 2 of 5, for Inkscape. """ -from Base import Barcode -import sys +from .Base import Barcode # 1 means thick, 0 means thin -encoding = { - '0' : '00110', - '1' : '10001', - '2' : '01001', - '3' : '11000', - '4' : '00101', - '5' : '10100', - '6' : '01100', - '7' : '00011', - '8' : '10010', - '9' : '01010', +ENCODE = { + '0': '00110', + '1': '10001', + '2': '01001', + '3': '11000', + '4': '00101', + '5': '10100', + '6': '01100', + '7': '00011', + '8': '10010', + '9': '01010', } -# Start and stop code are already encoded into white (0) and black(1) bars -start_code = '1010' -stop_code = '1101' class Code25i(Barcode): - # Convert a text into string binary of black and white markers + """Convert a text into string binary of black and white markers""" + # Start and stop code are already encoded into white (0) and black(1) bars def encode(self, number): - self.label = number - if not number.isdigit(): - sys.stderr.write("CODE25 can only encode numbers.\n") - return + return self.error(number, "CODE25 can only encode numbers.") - # Number of figures to encode must be even, a 0 is added to the left in case it's odd. - if len(number) % 2 > 0 : + # Number of figures to encode must be even, + # a 0 is added to the left in case it's odd. + if len(number) % 2 > 0: number = '0' + number # Number is encoded by pairs of 2 figures - size = len(number) / 2; - encoded = start_code; + size = len(number) / 2 + encoded = '1010' for i in range(size): # First in the pair is encoded in black (1), second in white (0) - black = encoding[number[i*2]] - white = encoding[number[i*2+1]] + black = ENCODE[number[i*2]] + white = ENCODE[number[i*2+1]] for j in range(5): if black[j] == '1': encoded += '11' @@ -69,9 +64,5 @@ class Code25i(Barcode): encoded += '00' else: encoded += '0' - - encoded += stop_code - - self.inclabel = number - return encoded; + return encoded + '1101' diff --git a/share/extensions/Barcode/Code39.py b/share/extensions/Barcode/Code39.py index 3cd8467a8..0d4d445b1 100644 --- a/share/extensions/Barcode/Code39.py +++ b/share/extensions/Barcode/Code39.py @@ -13,7 +13,7 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for Code39 barcodes. Designed for use with Inkscape. @@ -21,73 +21,70 @@ Python barcode renderer for Code39 barcodes. Designed for use with Inkscape. from Base import Barcode -encoding = { - '0' : '000110100', - '1' : '100100001', - '2' : '001100001', - '3' : '101100000', - '4' : '000110001', - '5' : '100110000', - '6' : '001110000', - '7' : '000100101', - '8' : '100100100', - '9' : '001100100', - 'A' : '100001001', - 'B' : '001001001', - 'C' : '101001000', - 'D' : '000011001', - 'E' : '100011000', - 'F' : '001011000', - 'G' : '000001101', - 'H' : '100001100', - 'I' : '001001100', - 'J' : '000011100', - 'K' : '100000011', - 'L' : '001000011', - 'M' : '101000010', - 'N' : '000010011', - 'O' : '100010010', - 'P' : '001010010', - 'Q' : '000000111', - 'R' : '100000110', - 'S' : '001000110', - 'T' : '000010110', - 'U' : '110000001', - 'V' : '011000001', - 'W' : '111000000', - 'X' : '010010001', - 'Y' : '110010000', - 'Z' : '011010000', - '-' : '010000101', - '*' : '010010100', - '+' : '010001010', - '$' : '010101000', - '%' : '000101010', - '/' : '010100010', - '.' : '110000100', - ' ' : '011000100', +ENCODE = { + '0': '000110100', + '1': '100100001', + '2': '001100001', + '3': '101100000', + '4': '000110001', + '5': '100110000', + '6': '001110000', + '7': '000100101', + '8': '100100100', + '9': '001100100', + 'A': '100001001', + 'B': '001001001', + 'C': '101001000', + 'D': '000011001', + 'E': '100011000', + 'F': '001011000', + 'G': '000001101', + 'H': '100001100', + 'I': '001001100', + 'J': '000011100', + 'K': '100000011', + 'L': '001000011', + 'M': '101000010', + 'N': '000010011', + 'O': '100010010', + 'P': '001010010', + 'Q': '000000111', + 'R': '100000110', + 'S': '001000110', + 'T': '000010110', + 'U': '110000001', + 'V': '011000001', + 'W': '111000000', + 'X': '010010001', + 'Y': '110010000', + 'Z': '011010000', + '-': '010000101', + '*': '010010100', + '+': '010001010', + '$': '010101000', + '%': '000101010', + '/': '010100010', + '.': '110000100', + ' ': '011000100', } class Code39(Barcode): - # Convert a text into string binary of black and white markers + """Convert a text into string binary of black and white markers""" def encode(self, text): - text = text.upper() - self.label = text - text = '*' + text + '*' - result = '' + self.text = text.upper() + result = '' # It isposible for us to encode code39 # into full ascii, but this feature is # not enabled here - for char in text: - if not encoding.has_key(char): - char = '-'; - - result = result + encoding[char] + '0'; + for char in '*' + self.text + '*': + if not ENCODE.has_key(char): + char = '-' + result = result + ENCODE[char] + '0' # Now we need to encode the code39, best read # the code to understand what it's up to: - encoded = ''; - colour = '1'; # 1 = Black, 0 = White + encoded = '' + colour = '1' # 1 = Black, 0 = White for data in result: if data == '1': encoded = encoded + colour + colour @@ -95,6 +92,5 @@ class Code39(Barcode): encoded = encoded + colour colour = colour == '1' and '0' or '1' - self.inclabel = text - return encoded; + return encoded diff --git a/share/extensions/Barcode/Code93.py b/share/extensions/Barcode/Code93.py index 2b90fdda1..939a739dd 100644 --- a/share/extensions/Barcode/Code93.py +++ b/share/extensions/Barcode/Code93.py @@ -13,109 +13,101 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for Code93 barcodes. Designed for use with Inkscape. """ -from Base import Barcode +from .Base import Barcode -chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%' -encode = list(chars) -encode.append('($)') -encode.append('(/)') -encode.append('(+)') -encode.append('(%)') -encode.append('MARKER') +PALLET = list('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%') +PALLET.append('($)') +PALLET.append('(/)') +PALLET.append('(+)') +PALLET.append('(%)') +PALLET.append('MARKER') -map = {} - -i = 0 -for char in encode: - map[char] = i - i = i + 1 - -# Extended encoding maps for full ASCII Code93 -def getMap(array): +MAP = dict((PALLET[i], i) for i in range(len(PALLET))) +def get_map(array): + """Extended ENCODE maps for full ASCII Code93""" result = {} - y = 10 - - for x in array: - result[chr(x)] = encode[y] - y = y + 1 - - return result; + pos = 10 + for char in array: + result[chr(char)] = PALLET[pos] + pos = pos + 1 + return result # MapA is eclectic, but B, C, D are all ASCII ranges -mapA = getMap([27,28,29,30,31,59,60,61,62,63,91,92,93,94,95,123,124,125,126,127,0,64,96,127,127,127]) # % -mapB = getMap(range(1, 26)) # $ -mapC = getMap(range(33, 58)) # / -mapD = getMap(range(97, 122)) # + - -encoding = '100010100 101001000 101000100 101000010 100101000 100100100 100100010 101010000 100010010 100001010 110101000 110100100 110100010 110010100 110010010 110001010 101101000 101100100 101100010 100110100 100011010 101011000 101001100 101000110 100101100 100010110 110110100 110110010 110101100 110100110 110010110 110011010 101101100 101100110 100110110 100111010 100101110 111010100 111010010 111001010 101101110 101110110 110101110 100100110 111011010 111010110 100110010 101011110'.split() +MAP_A = get_map([27, 28, 29, 30, 31, 59, 60, 61, 62, 63, 91, 92, 93, 94, 95, + 123, 124, 125, 126, 127, 0, 64, 96, 127, 127, 127]) # % +MAP_B = get_map(range(1, 26)) # $ +MAP_C = get_map(range(33, 58)) # / +MAP_D = get_map(range(97, 122)) # + + +ENCODE = [ + '100010100', '101001000', '101000100', '101000010', '100101000', + '100100100', '100100010', '101010000', '100010010', '100001010', + '110101000', '110100100', '110100010', '110010100', '110010010', + '110001010', '101101000', '101100100', '101100010', '100110100', + '100011010', '101011000', '101001100', '101000110', '100101100', + '100010110', '110110100', '110110010', '110101100', '110100110', + '110010110', '110011010', '101101100', '101100110', '100110110', + '100111010', '100101110', '111010100', '111010010', '111001010', + '101101110', '101110110', '110101110', '100100110', '111011010', + '111010110', '100110010', '101011110', '' +] class Code93(Barcode): def encode(self, text): - # start marker - bits = self.encode93('MARKER') + # start marker + bits = ENCODE[MAP.get('MARKER', -1)] # Extend to ASCII charset ( return Array ) - text = self.encodeAscii(text) + text = self.encode_ascii(text) # Calculate the checksums text.append(self.checksum(text, 20)) # C text.append(self.checksum(text, 15)) # K - # Now convert text into the encoding bits (black and white stripes) + # Now convert text into the ENCODE bits (black and white stripes) for char in text: - bits = bits + self.encode93(char) - - # end marker - bits = bits + self.encode93('MARKER') + bits = bits + ENCODE[MAP.get(char, -1)] - # termination bar - bits = bits + '1' - - self.inclabel = text - return bits + # end marker and termination bar + return bits + ENCODE[MAP.get('MARKER', -1)] + '1' def checksum(self, text, mod): + """Generate a code 93 checksum""" weight = len(text) % mod - check = 0 + check = 0 for char in text: - check = check + (map[char] * weight) + check = check + (MAP[char] * weight) # Reset the weight is required weight = weight - 1 if weight == 0: weight = mod - return encode[check % 47] + return PALLET[check % 47] - # Some charicters need re-encoding into the code93 specification - def encodeAscii(self, text): + # Some charicters need re-ENCODE into the code93 specification + def encode_ascii(self, text): result = [] for char in text: - if map.has_key(char): + if MAP.has_key(char): result.append(char) - elif mapA.has_key(char): + elif MAP_A.has_key(char): result.append('(%)') - result.append(mapA[char]) - elif mapB.has_key(char): + result.append(MAP_A[char]) + elif MAP_B.has_key(char): result.append('($)') - result.append(mapB[char]) - elif mapC.has_key(char): + result.append(MAP_B[char]) + elif MAP_C.has_key(char): result.append('(/)') - result.append(mapC[char]) - elif mapD.has_key(char): + result.append(MAP_C[char]) + elif MAP_D.has_key(char): result.append('(+)') - result.append(mapD[char]) - + result.append(MAP_D[char]) return result - def encode93(self, char): - if map.has_key(char): - return encoding[map[char]] - return '' - diff --git a/share/extensions/Barcode/Ean13.py b/share/extensions/Barcode/Ean13.py index 7e138f25a..41f4df826 100644 --- a/share/extensions/Barcode/Ean13.py +++ b/share/extensions/Barcode/Ean13.py @@ -15,24 +15,25 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for EAN13 barcodes. Designed for use with Inkscape. """ -from BaseEan import EanBarcode +from .BaseEan import EanBarcode class Ean13(EanBarcode): """Provide an Ean13 barcode generator""" name = 'ean13' - lengths = [ 12 ] - checks = [ 13 ] + extras = {2: 'Ean2', 5: 'Ean5'} + checks = [13] + lengths = [12] def _encode(self, n): """Encode an ean13 barcode""" - self.label = self.space(n[0:1], 4, n[1:7], 5, n[7:], 7) + self.text = self.space(n[0:1], 4, n[1:7], 5, n[7:], 7) return self.enclose( - self.encode_interleaved(n[0], n[1:7]), self.encode_right(n[7:]) ) + self.encode_interleaved(n[0], n[1:7]), self.encode_right(n[7:])) diff --git a/share/extensions/Barcode/Ean2.py b/share/extensions/Barcode/Ean2.py new file mode 100644 index 000000000..9aec06a27 --- /dev/null +++ b/share/extensions/Barcode/Ean2.py @@ -0,0 +1,38 @@ +# +# Copyright (C) 2016 Martin Owens +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. +# +""" +Python barcode renderer for EAN2 barcodes. Designed for use with Inkscape. +""" + +from .BaseEan import EanBarcode + +FAMS = ['00', '01', '10', '11'] +START = '01011' + +class Ean2(EanBarcode): + """Provide an Ean5 barcode generator""" + length = 2 + name = 'ean5' + + def _encode(self, number): + if len(number) != 2: + number = ([0, 0] + number)[-2:] + self.text = ' '.join(self.space(number)) + family = ((number[0] * 10) + number[1]) % 4 + return START + '01'.join(self.encode_interleaved(family, number, FAMS)) + diff --git a/share/extensions/Barcode/Ean5.py b/share/extensions/Barcode/Ean5.py index d2e38a063..c6f8555fb 100644 --- a/share/extensions/Barcode/Ean5.py +++ b/share/extensions/Barcode/Ean5.py @@ -1,39 +1,38 @@ -# +# # Copyright (C) 2009 Aaron C Spike # 2010 Martin Owens # -# 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 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. +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for EAN5 barcodes. Designed for use with Inkscape. """ -from BaseEan import EanBarcode +from .BaseEan import EanBarcode -FAMS = [ '11000','10100','10010','10001','01100','00110','00011','01010','01001','00101' ] +FAMS = ['11000', '10100', '10010', '10001', '01100', + '00110', '00011', '01010', '01001', '00101'] START = '01011' class Ean5(EanBarcode): """Provide an Ean5 barcode generator""" - name = 'ean5' + name = 'ean5' length = 5 def _encode(self, number): - self.x += 110.0*self.scale # horiz offset so it does not overlap EAN13 - self.y -= (self.height + 5)*self.scale # move the text to the top - self.label = ' '.join(self.space(number)) - family = sum([int(n)*int(m) for n,m in zip(number, '39393')]) % 10 + self.text = ' '.join(self.space(number)) + family = sum([int(n)*int(m) for n, m in zip(number, '39393')]) % 10 return START + '01'.join(self.encode_interleaved(family, number, FAMS)) diff --git a/share/extensions/Barcode/Ean8.py b/share/extensions/Barcode/Ean8.py index 010dff03e..562952e42 100644 --- a/share/extensions/Barcode/Ean8.py +++ b/share/extensions/Barcode/Ean8.py @@ -13,22 +13,22 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for EAN8 barcodes. Designed for use with Inkscape. """ -from BaseEan import EanBarcode +from .BaseEan import EanBarcode class Ean8(EanBarcode): """Provide an EAN8 barcode generator""" - name = 'ean8' - lengths = [ 7 ] - checks = [ 8 ] + name = 'ean8' + checks = [8] + lengths = [7] def _encode(self, n): """Encode an ean8 barcode""" - self.label = self.space(n[:4], 3, n[4:]) - return self.enclose( self.encode_left(n[:4]), self.encode_right(n[4:]) ) + self.text = self.space(n[:4], 3, n[4:]) + return self.enclose(self.encode_left(n[:4]), self.encode_right(n[4:])) diff --git a/share/extensions/Barcode/Makefile.am b/share/extensions/Barcode/Makefile.am index 7a1e889c0..08e2f58b4 100644 --- a/share/extensions/Barcode/Makefile.am +++ b/share/extensions/Barcode/Makefile.am @@ -12,6 +12,7 @@ barcode_DATA = \ Ean13.py \ Ean8.py \ Ean5.py \ + Ean2.py \ __init__.py \ Rm4scc.py \ Upca.py \ diff --git a/share/extensions/Barcode/Rm4scc.py b/share/extensions/Barcode/Rm4scc.py index d40cd2435..7c36f26ee 100644 --- a/share/extensions/Barcode/Rm4scc.py +++ b/share/extensions/Barcode/Rm4scc.py @@ -66,10 +66,11 @@ check = ['ZUVWXY','501234','B6789A','HCDEFG','NIJKLM','TOPQRS'] (BAR_TRACK, BAR_DOWN, BAR_UP, BAR_FULL, BAR_NONE, WHITE_SPACE) = range(6) class Rm4scc(Barcode): + default_height = 18 + def encode(self, text): result = '' - self.height = 18 text = text.upper() text.replace('(', '') text.replace(')', '') @@ -80,10 +81,8 @@ class Rm4scc(Barcode): for char in text: if map.has_key(char): result = result + map[char] - i = i + 1 - self.inclabel = text return result; # given a string of data, return the check character @@ -117,7 +116,7 @@ class Rm4scc(Barcode): checkchar = check[total_upper][total_lower] return checkchar - def getStyle(self, index): + def get_style(self, index): """Royal Mail Barcodes use a completely different style""" result = { 'width' : 2, 'write' : True, 'top' : 0 } if index == BAR_TRACK: # Track Bar diff --git a/share/extensions/Barcode/Upca.py b/share/extensions/Barcode/Upca.py index bc6ffdf29..32ecc0aa6 100644 --- a/share/extensions/Barcode/Upca.py +++ b/share/extensions/Barcode/Upca.py @@ -13,25 +13,23 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for UPCA barcodes. Designed for use with Inkscape. """ -from BaseEan import EanBarcode +from .BaseEan import EanBarcode class Upca(EanBarcode): """Provides a renderer for EAN12 aka UPC-A Barcodes""" - name = 'upca' - lengths = [ 11 ] - checks = [ 12 ] + name = 'upca' + font_size = 10 + lengths = [11] + checks = [12] def _encode(self, n): """Encode for a UPC-A Barcode""" - self.label = self.space(n[0:1], 3, n[1:6], 4, n[6:11], 3, n[11:]) + self.text = self.space(n[0:1], 3, n[1:6], 4, n[6:11], 3, n[11:]) return self.enclose(self.encode_left(n[0:6]), self.encode_right(n[6:12])) - def fontSize(self): - """We need a bigger barcode""" - return 10 diff --git a/share/extensions/Barcode/Upce.py b/share/extensions/Barcode/Upce.py index d25c9c6cc..193d605a0 100644 --- a/share/extensions/Barcode/Upce.py +++ b/share/extensions/Barcode/Upce.py @@ -13,79 +13,75 @@ # # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Python barcode renderer for UPCE barcodes. Designed for use with Inkscape. """ -from BaseEan import EanBarcode -import sys +from .BaseEan import EanBarcode # This is almost exactly the same as the standard FAMILIES # But flipped around and with the first 111000 instead of 000000. -FAMS = [ '111000', '110100', '110010', '110001', '101100', - '100110', '100011', '101010', '101001', '100101' ] +FAMS = ['111000', '110100', '110010', '110001', '101100', + '100110', '100011', '101010', '101001', '100101'] class Upce(EanBarcode): """Generate EAN6/UPC-E barcode generator""" - name = 'upce' - lengths = [ 6, 11 ] - checks = [ 7, 12 ] + name = 'upce' + font_size = 10 + lengths = [6, 11] + checks = [7, 12] + center_bar = '020' def _encode(self, n): """Generate a UPC-E Barcode""" - self.label = self.space(['0'], 2, n[:6], 2, n[-1]) + self.text = self.space(['0'], 2, n[:6], 2, n[-1]) code = self.encode_interleaved(n[-1], n[:6], FAMS) - # 202(guard) + code + 020(center) + 202(guard) - return self.enclose(code, center='020') + return self.enclose(code) - def appendChecksum(self, number): + def append_checksum(self, number): """Generate a UPCE Checksum""" if len(number) == 6: - number = self.ConvertEtoA(number) - result = self.getChecksum(number) - return self.ConvertAtoE(number) + result + number = self.convert_e2a(number) + result = self.get_checksum(number) + return self.convert_a2e(number) + result - def fontSize(self): - """We need a font size of 10""" - return 10 - - def ConvertAtoE(self, number): + def convert_a2e(self, number): """Converting UPC-A to UPC-E, may cause errors.""" # All UPC-E Numbers use number system 0 - if number[0] != '0' or len(number)!=11: + if number[0] != '0' or len(number) != 11: # If not then the code is invalid raise ValueError("Invalid UPC Number") # Most of the conversions deal # with the specific code parts - manufacturer = number[1:6] + maker = number[1:6] product = number[6:11] # There are 4 cases to convert: - if manufacturer[2:] == '000' or manufacturer[2:] == '100' or manufacturer[2:] == '200': + if maker[2:] == '000' or maker[2:] == '100' or maker[2:] == '200': # Maxium number product code digits can be encoded - if product[:2]=='00': - return manufacturer[:2] + product[2:] + manufacturer[2] - elif manufacturer[3:5] == '00': + if product[:2] == '00': + return maker[:2] + product[2:] + maker[2] + elif maker[3:5] == '00': # Now only 2 product code digits can be used - if product[:3]=='000': - return manufacturer[:3] + product[3:] + '3' - elif manufacturer[4] == '0': - # With even more manufacturer code we have less room for product code - if product[:4]=='0000': - return manufacturer[0:4] + product[4] + '4' - elif product[:4]=='0000' and int(product[4]) > 4: + if product[:3] == '000': + return maker[:3] + product[3:] + '3' + elif maker[4] == '0': + # With even more maker code we have less room for product code + if product[:4] == '0000': + return maker[0:4] + product[4] + '4' + elif product[:4] == '0000' and int(product[4]) > 4: # The last recorse is to try and squeeze it in the last 5 numbers # so long as the product is 00005-00009 so as not to conflict with # the 0-4 used above. - return manufacturer + product[4] + return maker + product[4] else: # Invalid UPC-A Numbe raise ValueError("Invalid UPC Number") - def ConvertEtoA(self, number): + def convert_e2a(self, number): """Convert UPC-E to UPC-A by padding with zeros""" # It's more likly to convert this without fault # But we still must be mindful of the 4 conversions diff --git a/share/extensions/Barcode/__init__.py b/share/extensions/Barcode/__init__.py index 9ad412448..fcfcfdbad 100644 --- a/share/extensions/Barcode/__init__.py +++ b/share/extensions/Barcode/__init__.py @@ -39,19 +39,23 @@ For supported barcodes see Barcode module directory. import sys -def getBarcode(code, **kwargs): +class NoBarcode(object): + """Simple class for no barcode""" + def generate(self): + return None + +def getBarcode(code, **kw): """Gets a barcode from a list of available barcode formats""" if not code: return sys.stderr.write("No barcode format given!\n") - code = str(code).replace('-', '').strip() + mod = 'Barcode' try: - barcode = getattr(__import__('Barcode.'+code, fromlist=['Barcode']), code) - return barcode(kwargs) + return getattr(__import__(mod+'.'+code, fromlist=[mod]), code)(kw) except ImportError: sys.stderr.write("Invalid type of barcode: %s\n" % code) except AttributeError: - raise - sys.stderr.write("Barcode module is missing the barcode class: %s\n" % code) + sys.stderr.write("Barcode module is missing barcode class: %s\n" % code) + return NoBarcode() diff --git a/share/extensions/render_barcode.inx b/share/extensions/render_barcode.inx index debefadad..890ffb1bd 100644 --- a/share/extensions/render_barcode.inx +++ b/share/extensions/render_barcode.inx @@ -5,9 +5,10 @@ inkex.py render_barcode.py - EAN5 + EAN2 Extension + EAN5 Extension + EAN13 +Extensions EAN8 - EAN13 UPC-A UPC-E Code25 Interleaved 2 of 5 diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py index 381f3fc76..63436f03c 100755 --- a/share/extensions/render_barcode.py +++ b/share/extensions/render_barcode.py @@ -11,10 +11,10 @@ # 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. # """ Inkscape's general barcode extension. Run from within inkscape or use the @@ -27,6 +27,9 @@ from Barcode import getBarcode from simpletransform import computePointInNode class InsertBarcode(inkex.Effect): + """ + Raw barcode Effect class, see Barcode base class. + """ def __init__(self): inkex.Effect.__init__(self) self.OptionParser.add_option("-l", "--height", @@ -43,29 +46,44 @@ class InsertBarcode(inkex.Effect): help="Text to print on barcode") def effect(self): - x, y = computePointInNode(list(self.view_center), self.current_layer) - bargen = getBarcode( self.options.type, + (pos_x, pos_y) = computePointInNode( + list(self.view_center), self.current_layer) + + barcode = getBarcode(self.options.type, text=self.options.text, height=self.options.height, document=self.document, - x=x, y=y, + x=pos_x, y=pos_y, scale=self.unittouu('1px'), - ) - if bargen is not None: - barcode = bargen.generate() - if barcode is not None: - self.current_layer.append(barcode) - else: - sys.stderr.write("No barcode was generated\n") + ).generate() + if barcode is not None: + self.current_layer.append(barcode) else: - sys.stderr.write("Unable to make barcode with: " + str(self.options) + "\n") + sys.stderr.write("No barcode was generated\n") def test_barcode(): - bargen = getBarcode("Ean13", text="123456789101") - if bargen is not None: - barcode = bargen.generate() - if barcode: - print inkex.etree.tostring(barcode, pretty_print=True) + """Run from command line""" + for (kind, text) in ( + ('Ean2', '55'), + ('Ean5', '54321'), + ('Ean8', '0123456'), + ('Ean13', '123456789101'), + ('Ean13', '12345678910155'), + ('Ean13', '12345678910154321'), + ('Code128', 'Martin is Great'), + ('Code25i', '3242322'), + ('Code39', '4443322888'), + ('Code93', '3332222'), + ('Rm4scc', 'ROYAL POINT'), + ('Upca', '12345678911'), + ('Upce', '123456'), + ): + print "RENDER TEST: %s" % kind + bargen = getBarcode(kind, text=text) + if bargen is not None: + barcode = bargen.generate() + if barcode is not None: + print inkex.etree.tostring(barcode, pretty_print=True) if __name__ == '__main__': @@ -73,6 +91,5 @@ if __name__ == '__main__': # Debug mode without inkex test_barcode() exit(0) - e = InsertBarcode() - e.affect() + InsertBarcode().affect() -- cgit v1.2.3 From 6f18a0e9e22d9d9f79b447bed833fdcef1bdef42 Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 14 Apr 2016 09:53:53 +0200 Subject: Fix for make check (bzr r14843) --- generate_POTFILES.sh | 1 + po/POTFILES.in | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/generate_POTFILES.sh b/generate_POTFILES.sh index 04ea931b5..87c769ea4 100755 --- a/generate_POTFILES.sh +++ b/generate_POTFILES.sh @@ -21,6 +21,7 @@ rm -f po/POTFILES.in.new echo "# Please keep this file sorted alphabetically." echo "# Generated by $prog at `date`" echo "[encoding: UTF-8]" + echo "inkscape.appdata.xml.in" echo "inkscape.desktop.in" echo "share/filters/filters.svg.h" echo "share/palettes/palettes.h" diff --git a/po/POTFILES.in b/po/POTFILES.in index ee168fb74..057114bd0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,6 @@ # List of source files containing translatable strings. # Please keep this file sorted alphabetically. -# Generated by ./generate_POTFILES.sh at Tue Sep 22 20:20:22 CEST 2015 +# Generated by ./generate_POTFILES.sh at Thu Apr 14 04:25:58 CEST 2016 [encoding: UTF-8] inkscape.appdata.xml.in inkscape.desktop.in @@ -340,6 +340,7 @@ src/widgets/font-selector.cpp src/widgets/gradient-selector.cpp src/widgets/gradient-toolbar.cpp src/widgets/gradient-vector.cpp +src/widgets/image-menu-item.c src/widgets/lpe-toolbar.cpp src/widgets/measure-toolbar.cpp src/widgets/mesh-toolbar.cpp @@ -532,6 +533,7 @@ share/extensions/wireframe_sphere.py [type: gettext/xml] share/extensions/motion.inx [type: gettext/xml] share/extensions/new_glyph_layer.inx [type: gettext/xml] share/extensions/next_glyph_layer.inx +[type: gettext/xml] share/extensions/nicechart.inx [type: gettext/xml] share/extensions/param_curves.inx [type: gettext/xml] share/extensions/pathalongpath.inx [type: gettext/xml] share/extensions/pathscatter.inx -- cgit v1.2.3 From 2b635a500e8844e5788d8178d13887c2b5ace640 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 14 Apr 2016 16:58:56 +0200 Subject: Fix c++11 flag when required on non-debian-based systems (bzr r14844) --- CMakeScripts/DefineDependsandFlags.cmake | 3 +++ CMakeScripts/Modules/FindSigC++.cmake | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 4429758c0..00c2131e2 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -368,6 +368,9 @@ if(WITH_NLS) endif(GETTEXT_FOUND) endif(WITH_NLS) +#sets c++11 for newer sigc++ if required when pkg-config does not detect it +find_package(SigC++ REQUIRED) + pkg_check_modules(SIGC++ REQUIRED sigc++-2.0 ) list(APPEND INKSCAPE_LIBS ${SIGC++_LDFLAGS}) diff --git a/CMakeScripts/Modules/FindSigC++.cmake b/CMakeScripts/Modules/FindSigC++.cmake index 8046410b5..14cbf47f7 100644 --- a/CMakeScripts/Modules/FindSigC++.cmake +++ b/CMakeScripts/Modules/FindSigC++.cmake @@ -106,10 +106,12 @@ endif (SIGC++_LIBRARIES AND SIGC++_INCLUDE_DIRS) # https://bugs.launchpad.net/inkscape/+bug/1488079 macro (sigcpp_compile extra_cppflags) + set(sigcpp_compile_output "") try_compile(SIGCPP_COMPILES_FINE "${CMAKE_BINARY_DIR}/sigcpp-bindir" SOURCES "${CMAKE_SOURCE_DIR}/CMakeScripts/Modules/sigcpp_test.cpp" COMPILE_DEFINITIONS ${_SIGC++_CFLAGS} ${extra_cppflags} - LINK_LIBRARIES ${SIGC++_LIBRARIES}) + LINK_LIBRARIES ${SIGC++_LIBRARIES} + OUTPUT_VARIABLE sigcpp_compile_output) endmacro() @@ -120,7 +122,7 @@ if (NOT "${SIGCPP_COMPILES_FINE}") if ("${SIGCPP_COMPILES_FINE}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cppflag}") else() - message(FATAL_ERROR "Could not compile against SIGC++") + message(FATAL_ERROR "Could not compile against SIGC++ - output is <<${sigcpp_compile_output}>>") endif() endif() -- cgit v1.2.3 From 1dfba12bc394644560de7d2560aa03061237d0b8 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Thu, 14 Apr 2016 14:19:03 -0400 Subject: function to release object from group Fixed bugs: - https://launchpad.net/bugs/484041 (bzr r14845) --- src/menus-skeleton.h | 1 + src/selection-chemistry.cpp | 32 ++++++++++++++++++++++++++++++++ src/selection-chemistry.h | 1 + src/ui/interface.cpp | 12 ++++++++++++ src/ui/interface.h | 1 + src/verbs.cpp | 5 +++++ src/verbs.h | 1 + 7 files changed, 53 insertions(+) diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 8cdfbeb05..9e1c5c9f6 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -188,6 +188,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index e9a3af83a..7d32477a1 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -791,6 +791,38 @@ static gint clone_depth_descending(gconstpointer a, gconstpointer b) { return -1; } } + +void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("No objects selected to pop out of group.")); + return; + } + std::vector selection_list = selection->itemList(); + + std::vector::const_iterator item = selection_list.begin(); // leaving this because it will be useful for + // future implementation of complex pop ungrouping + SPItem *obj = *item; + SPItem *parent_group = static_cast(obj->parent); + if (!SP_IS_GROUP(parent_group) || SP_IS_LAYER(parent_group)) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Selection not in a group.")); + return; + } + if (parent_group->firstChild()->getNext() == NULL) { + std::vector children; + sp_item_group_ungroup(static_cast(parent_group), children, false); + } + else { + sp_selection_to_next_layer(desktop, 1); // suppress done + } + + parent_group->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP_POP_SELECTION, + _("Pop selection from group")); + +} + void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 4bfa2c0aa..82b91c617 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -76,6 +76,7 @@ void sp_selection_untile(SPDesktop *desktop); void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index a16bbc472..3e2a2004c 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1523,6 +1523,12 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup)); MIParent.show(); append(MIParent); + + /* Pop selection out of group */ + Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1)); + miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection)); + miu->show(); + append(*miu); } } } @@ -1920,6 +1926,12 @@ void ContextMenu::ActivateUngroup(void) sp_item_group_ungroup(static_cast(_item), children); _desktop->selection->setList(children); } + +void ContextMenu::ActivateUngroupPopSelection(void) +{ + sp_selection_ungroup_pop_selection(_desktop->selection, _desktop); +} + void ContextMenu::MakeAnchorMenu(void) { diff --git a/src/ui/interface.h b/src/ui/interface.h index 6fb74046f..52074f0f0 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -194,6 +194,7 @@ class ContextMenu : public Gtk::Menu /** * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry */ + void ActivateUngroupPopSelection(void); void ActivateUngroup(void); void ActivateGroup(void); diff --git a/src/verbs.cpp b/src/verbs.cpp index 7b128c172..e3ba82e46 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1150,6 +1150,9 @@ void SelectionVerb::perform(SPAction *action, void *data) case SP_VERB_SELECTION_UNGROUP: sp_selection_ungroup(selection, dt); break; + case SP_VERB_SELECTION_UNGROUP_POP_SELECTION: + sp_selection_ungroup_pop_selection(selection, dt); + break; default: handled = false; break; @@ -2559,6 +2562,8 @@ Verb *Verb::_base_verbs[] = { N_("Group selected objects"), INKSCAPE_ICON("object-group")), new SelectionVerb(SP_VERB_SELECTION_UNGROUP, "SelectionUnGroup", N_("_Ungroup"), N_("Ungroup selected groups"), INKSCAPE_ICON("object-ungroup")), + new SelectionVerb(SP_VERB_SELECTION_UNGROUP_POP_SELECTION, "SelectionUnGroupPopSelection", N_("_Pop selected objects out of group"), + N_("Pop selected objects out of group"), INKSCAPE_ICON("object-ungroup-pop-selection")), new SelectionVerb(SP_VERB_SELECTION_TEXTTOPATH, "SelectionTextToPath", N_("_Put on Path"), N_("Put text on path"), INKSCAPE_ICON("text-put-on-path")), diff --git a/src/verbs.h b/src/verbs.h index 4f453761e..ffb9b23d8 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -116,6 +116,7 @@ enum { SP_VERB_SELECTION_LOWER, SP_VERB_SELECTION_GROUP, SP_VERB_SELECTION_UNGROUP, + SP_VERB_SELECTION_UNGROUP_POP_SELECTION, SP_VERB_SELECTION_TEXTTOPATH, SP_VERB_SELECTION_TEXTFROMPATH, SP_VERB_SELECTION_REMOVE_KERNS, -- cgit v1.2.3 From 2f83e893435604a0af0dafbb7b8f96648703667a Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Thu, 14 Apr 2016 14:56:59 -0400 Subject: Filter editor: effect description not entirely readable Fixed bugs: - https://launchpad.net/bugs/1436180 (bzr r14846) --- src/ui/dialog/filter-effects-dialog.cpp | 51 ++++++++++++++++++++++----------- src/ui/dialog/filter-effects-dialog.h | 9 +++++- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 7e9d8481a..b70cfcdd4 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1364,6 +1364,7 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) _list.append_column("#", _columns.count); _list.get_column(2)->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE); _list.get_column(2)->set_expand(false); + _list.get_column(2)->set_reorderable(true); sw->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _list.get_column(1)->set_resizable(true); @@ -1868,7 +1869,7 @@ void FilterEffectsDialog::PrimitiveList::update() if(f) { bool active_found = false; - _dialog._primitive_box.set_sensitive(true); + _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); for(SPObject *prim_obj = f->children; prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj); @@ -1913,7 +1914,7 @@ void FilterEffectsDialog::PrimitiveList::update() } } else { - _dialog._primitive_box.set_sensitive(false); + _dialog._primitive_box->set_sensitive(false); set_size_request(-1, -1); } } @@ -2760,8 +2761,10 @@ FilterEffectsDialog::FilterEffectsDialog() // Initialize widget hierarchy #if WITH_GTKMM_3_0 Gtk::Paned* hpaned = Gtk::manage(new Gtk::Paned); + _primitive_box = Gtk::manage(new Gtk::Paned); #else Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned); + _primitive_box = Gtk::manage(new Gtk::VPaned); #endif Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); @@ -2769,25 +2772,40 @@ FilterEffectsDialog::FilterEffectsDialog() Gtk::HBox* infobox = Gtk::manage(new Gtk::HBox(/*homogeneous:*/false, /*spacing:*/4)); Gtk::HBox* hb_prims = Gtk::manage(new Gtk::HBox); Gtk::VBox* vb_prims = Gtk::manage(new Gtk::VBox); + Gtk::VBox* vb_desc = Gtk::manage(new Gtk::VBox); + + Gtk::VBox* prim_vbox_p = Gtk::manage(new Gtk::VBox); + Gtk::VBox* prim_vbox_i = Gtk::manage(new Gtk::VBox); + _primitive_box->pack1(*prim_vbox_p); + _primitive_box->pack2(*prim_vbox_i); + _getContents()->add(*hpaned); hpaned->pack1(_filter_modifier); - hpaned->pack2(_primitive_box); - _primitive_box.pack_start(*sw_prims); - _primitive_box.pack_start(*sw_infobox, false, false); + hpaned->pack2(*_primitive_box); + prim_vbox_p->pack_start(*sw_prims, true, true); + prim_vbox_i->pack_start(*vb_prims, true, true); + sw_prims->add(_primitive_list); - sw_infobox->add(*vb_prims); - infobox->pack_start(_infobox_icon, false, false); - infobox->pack_start(_infobox_desc, false, false); + sw_infobox->add(*infobox); + + _infobox_icon.set_alignment(0, 0); + _infobox_desc.set_alignment(0, 0); + _infobox_desc.set_justify(Gtk::JUSTIFY_LEFT); _infobox_desc.set_line_wrap(true); - _infobox_desc.set_size_request(250, -1); - - vb_prims->pack_start(*hb_prims); - vb_prims->pack_start(*infobox); + _infobox_desc.set_size_request(200, -1); + + infobox->pack_start(_infobox_icon, false, false); + vb_desc->pack_start(_infobox_desc, true, true); + infobox->pack_start(*vb_desc, true, true); + + vb_prims->pack_start(*hb_prims, false, false); + vb_prims->pack_start(*sw_infobox, true, true); hb_prims->pack_start(_add_primitive, false, false); - hb_prims->pack_start(_add_primitive_type, false, false); - _getContents()->pack_start(_settings_tabs, false, false); + + hb_prims->pack_start(_add_primitive_type, true, true); + _getContents()->pack_start(_settings_tabs, true, true); _settings_tabs.append_page(_settings_tab1, _("Effect parameters")); _settings_tabs.append_page(_settings_tab2, _("Filter General Settings")); @@ -2801,7 +2819,7 @@ FilterEffectsDialog::FilterEffectsDialog() sw_prims->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); sw_prims->set_shadow_type(Gtk::SHADOW_IN); - sw_infobox->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER); + sw_infobox->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); // al_settings->set_padding(0, 0, 12, 0); // fr_settings->set_shadow_type(Gtk::SHADOW_NONE); @@ -3026,7 +3044,8 @@ void FilterEffectsDialog::update_primitive_infobox() g_assert(false); break; } - _infobox_icon.set_pixel_size(96); + //_infobox_icon.set_pixel_size(96); + _infobox_icon.set_pixel_size(64); } void FilterEffectsDialog::duplicate_primitive() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 283abb5b0..90bde23cf 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -28,6 +28,8 @@ #include #include +#include + namespace Inkscape { namespace UI { namespace Dialog { @@ -279,7 +281,12 @@ private: Gtk::Image _infobox_icon; // View/add primitives - Gtk::VBox _primitive_box; +#if WITH_GTKMM_3_0 + Gtk::Paned* _primitive_box; +#else + Gtk::VPaned* _primitive_box; +#endif + UI::Widget::ComboBoxEnum _add_primitive_type; Gtk::Button _add_primitive; -- cgit v1.2.3 From 051bd8baba5fd0909ab412fbe2938b22e3c18385 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Thu, 14 Apr 2016 15:09:11 -0400 Subject: no icon for 'pop selection' Fixed bugs: - https://launchpad.net/bugs/1570542 (bzr r14847) --- share/icons/icons.svg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index ac9ddd651..8323795bc 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -175,6 +175,9 @@ + + + @@ -4206,4 +4209,15 @@ http://www.inkscape.org/ + + + + + + + + + + + -- cgit v1.2.3 From 6572b29914475c769c035265b089e9668c47a974 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 14 Apr 2016 15:33:35 -0400 Subject: Change idle priority back to high (bzr r14848) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index decb14184..46be95518 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -126,7 +126,7 @@ struct SPCanvasClass { namespace { -gint const UPDATE_PRIORITY = G_PRIORITY_DEFAULT_IDLE; +gint const UPDATE_PRIORITY = G_PRIORITY_HIGH_IDLE; GdkWindow *getWindow(SPCanvas *canvas) { -- cgit v1.2.3 From 50a770bd6f47f27d8a45894e2ff19cf630b4c9f8 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 14 Apr 2016 20:35:13 -0400 Subject: Priority is so high it blocks blitting the canvas (bzr r14849) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 46be95518..decb14184 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -126,7 +126,7 @@ struct SPCanvasClass { namespace { -gint const UPDATE_PRIORITY = G_PRIORITY_HIGH_IDLE; +gint const UPDATE_PRIORITY = G_PRIORITY_DEFAULT_IDLE; GdkWindow *getWindow(SPCanvas *canvas) { -- cgit v1.2.3 From 2ab73707c1214a5b44c8b505eb98cbf56de21061 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 15 Apr 2016 15:39:49 +0100 Subject: Add a Resize to Page with Keyboard Shortcut (bzr r14850) --- share/keys/default.xml | 6 ++++-- src/menus-skeleton.h | 2 ++ src/verbs.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/share/keys/default.xml b/share/keys/default.xml index 07192cb37..f16be0689 100644 --- a/share/keys/default.xml +++ b/share/keys/default.xml @@ -297,8 +297,7 @@ override) the bindings in the main default.xml. - - + @@ -384,6 +383,9 @@ override) the bindings in the main default.xml. + + + diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 9e1c5c9f6..9c7c65140 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -86,6 +86,8 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/verbs.cpp b/src/verbs.cpp index e3ba82e46..299cfe8e7 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -3005,7 +3005,7 @@ Verb *Verb::_base_verbs[] = { N_("Fit the page to the current selection"), NULL), new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_DRAWING, "FitCanvasToDrawing", N_("Fit Page to Drawing"), N_("Fit the page to the drawing"), NULL), - new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("Fit Page to Selection or Drawing"), + new FitCanvasVerb(SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, "FitCanvasToSelectionOrDrawing", N_("_Resize Page to Selection"), N_("Fit the page to the current selection or the drawing if there is no selection"), NULL), // LockAndHide new LockAndHideVerb(SP_VERB_UNLOCK_ALL, "UnlockAll", N_("Unlock All"), -- cgit v1.2.3 From 47af1985a797019dd1f2539a2d00f8473688765d Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 15 Apr 2016 19:25:39 +0200 Subject: Fix CMake make check to without a global gtest (bzr r14851) --- test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f31b0bc04..ab73b9e37 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,8 @@ set(CMAKE_CTEST_COMMAND ctest -V) add_subdirectory(${GMOCK_DIR} ${CMAKE_BINARY_DIR}/gmock) include_directories(SYSTEM ${GMOCK_DIR}/gtest/include - ${GMOCK_DIR}/include) + ${GMOCK_DIR}/include + ${CMAKE_SOURCE_DIR}/gtest/gtest/include) set_source_files_properties( ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp -- cgit v1.2.3 From 8047a376e9e79ab45bb6eb97c5d234c5a5247175 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 16 Apr 2016 15:31:28 +0100 Subject: CMake: Disable broken pseudo-option for GTKSPELL - determined automatically by pkg-config, and fix a couple of typos (bzr r14852) --- CMakeLists.txt | 1 - CMakeScripts/DefineDependsandFlags.cmake | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0eb0e5cd..6545ac44e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,6 @@ option(WITH_OPENMP "Compile with OpenMP support" ON) option(WITH_PROFILING "Turn on profiling" OFF) # Set to true if compiler/linker should enable profiling -option(WITH_GTKSPELL "Compile with support for GTK spelling widget" ON) option(ENABLE_POPPLER "Compile with support of libpoppler" ON) option(ENABLE_POPPLER_CAIRO "Compile with support of libpoppler-cairo for rendering PDF preview (depends on ENABLE_POPPLER)" ON) option(WITH_IMAGE_MAGICK "Compile with support of ImageMagick for raster extensions and image import resolution" ON) diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 00c2131e2..204f96c02 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -239,7 +239,7 @@ if("${WITH_GTK3_EXPERIMENTAL}") pkg_check_modules(GDL_3_6 gdl-3.0>=3.6) if("${GDL_3_6_FOUND}") - message("Using Gdl 3.6 or higher") + message("Using GDL 3.6 or higher") set (WITH_GDL_3_6 1) endif() @@ -247,7 +247,7 @@ if("${WITH_GTK3_EXPERIMENTAL}") pkg_check_modules(GTKSPELL3 gtkspell3-3.0) if("${GTKSPELL3_FOUND}") - message("Using GtkSpell3") + message("Using GtkSpell 3") set (WITH_GTKSPELL 1) else() unset(WITH_GTKSPELL) -- cgit v1.2.3 From eeed7483385d14192bb11ef501bc729c286da7c5 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 16 Apr 2016 16:39:29 +0200 Subject: CMake build: builds with WITH_DBUS (bzr r14853) --- CMakeScripts/ConfigChecks.cmake | 3 +-- CMakeScripts/DefineDependsandFlags.cmake | 10 ++++++---- src/CMakeLists.txt | 4 ++++ src/extension/CMakeLists.txt | 15 +-------------- src/extension/dbus/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 src/extension/dbus/CMakeLists.txt diff --git a/CMakeScripts/ConfigChecks.cmake b/CMakeScripts/ConfigChecks.cmake index 926dc3ad3..34396ef28 100644 --- a/CMakeScripts/ConfigChecks.cmake +++ b/CMakeScripts/ConfigChecks.cmake @@ -65,7 +65,6 @@ if(HAVE_CAIRO_PDF) set(RENDER_WITH_PANGO_CAIRO TRUE) endif() -# Create the two configuration files: config.h and inkscape_version.h -# Create them in the binary root dir +# Create the configuration files config.h in the binary root dir configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/include/config.h) add_definitions(-DHAVE_CONFIG_H) diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake index 204f96c02..8e1cf2826 100644 --- a/CMakeScripts/DefineDependsandFlags.cmake +++ b/CMakeScripts/DefineDependsandFlags.cmake @@ -183,11 +183,13 @@ else(POTRACE_FOUND) endif() if(WITH_DBUS) - find_package(DBus REQUIRED) + pkg_check_modules(DBUS dbus-1 dbus-glib-1) if(DBUS_FOUND) - list(APPEND INKSCAPE_INCS_SYS ${DBUS_INCLUDE_DIR}) - list(APPEND INKSCAPE_INCS_SYS ${DBUS_ARCH_INCLUDE_DIR}) - list(APPEND INKSCAPE_LIBS ${DBUS_LIBRARIES}) + list(APPEND INKSCAPE_LIBS ${DBUS_LDFLAGS}) + list(APPEND INKSCAPE_INCS_SYS ${DBUS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/src/extension/dbus/) + list(APPEND INKSCAPE_LIBS ${DBUS_LIBRARIES}) + add_definitions(${DBUS_CFLAGS_OTHER}) + else() set(WITH_DBUS OFF) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c436cefb..e97ea8489 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -526,6 +526,10 @@ endif() add_dependencies(inkscape inkscape_version) +if(WITH_DBUS) + add_dependencies(inkscape inkscape_dbus) +endif() + if (NOT "${WITH_EXT_GDL}") list (APPEND INKSCAPE_LIBS "gdl_LIB") endif() diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 21e652563..86a192f47 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -244,20 +244,7 @@ if(WITH_IMAGE_MAGICK) endif() if(WITH_DBUS) - list(APPEND extension_SRC - dbus/application-interface.cpp - dbus/dbus-init.cpp - dbus/document-interface.cpp - - # ------ - # Header - dbus/application-interface.h - dbus/dbus-init.h - dbus/document-interface.h - dbus/wrapper/inkscape-dbus-wrapper.h - ) - - include_directories(dbus) + add_subdirectory(dbus) endif() # add_inkscape_lib(extension_LIB "${extension_SRC}") diff --git a/src/extension/dbus/CMakeLists.txt b/src/extension/dbus/CMakeLists.txt new file mode 100644 index 000000000..ad9e1fd7d --- /dev/null +++ b/src/extension/dbus/CMakeLists.txt @@ -0,0 +1,29 @@ +if(WITH_DBUS) +include_directories(${CMAKE_BINARY_DIR}/src/extension/dbus) +set(dbus_SRC "") + list(APPEND dbus_SRC + application-interface.cpp + dbus-init.cpp + document-interface.cpp + ) + add_custom_target(inkscape_dbus + DEPENDS ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h + ) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h + DEPENDS ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml + COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h --prefix=application_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/application-interface.xml + COMMAND dbus-binding-tool --mode=glib-server --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml + COMMAND dbus-binding-tool --mode=glib-client --output=${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h --prefix=document_interface ${CMAKE_SOURCE_DIR}/src/extension/dbus/document-interface.xml + ) + set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/extension/dbus/application-server-glue.h + PROPERTIES GENERATED TRUE) + set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/extension/dbus/document-server-glue.h + PROPERTIES GENERATED TRUE) + set_source_files_properties( + ${CMAKE_BINARY_DIR}/src/extension/dbus/document-client-glue.h + PROPERTIES GENERATED TRUE) +add_inkscape_source("${dbus_SRC}") +endif() -- cgit v1.2.3