diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-05-08 10:19:13 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-05-08 10:19:13 +0000 |
| commit | 1556c1a3619c415b3a7abacfdabd89398e411a91 (patch) | |
| tree | d7718e5873db4b2c25cb3bed94fcc4c3ba87fea4 /src | |
| parent | remove a waring on compile (diff) | |
| parent | add missing POTFILES.in line in mirror symmetry LPE (diff) | |
| download | inkscape-1556c1a3619c415b3a7abacfdabd89398e411a91.tar.gz inkscape-1556c1a3619c415b3a7abacfdabd89398e411a91.zip | |
update to trunk
(bzr r13645.1.127)
Diffstat (limited to 'src')
106 files changed, 4106 insertions, 1559 deletions
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index b56942caa..4d41de297 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -45,7 +45,6 @@ 2geom/curves.h \ 2geom/d2.h \ 2geom/d2-sbasis.cpp \ - 2geom/d2-sbasis.h \ 2geom/ellipse.cpp \ 2geom/ellipse.h \ 2geom/elliptical-arc.cpp \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 30af55925..df25728f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -443,11 +443,6 @@ endif() # a custom target that is always built add_custom_target( inkscape_version ALL - DEPENDS ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp) - -# creates inkscape-version.cpp using cmake script -add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/src/inkscape-version.cpp COMMAND ${CMAKE_COMMAND} -DINKSCAPE_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DINKSCAPE_BINARY_DIR=${CMAKE_BINARY_DIR} @@ -511,14 +506,14 @@ set(inkscape_SRC #add_inkscape_lib(sp_LIB "${sp_SRC}") #add_inkscape_lib(inkscape_LIB "${inkscape_SRC}") -# Build everything except main and inkview.c in a CMake "object" library. -# An object library is just a bunch of .o files. Linking them with main.c or inkview.c -# we get the inkscape and inkview executables respectively. -add_library(inkscape_base OBJECT ${inkscape_SRC} ${sp_SRC}) +# Build everything except main and inkview.c in a shared library. +add_library(inkscape_base SHARED ${inkscape_SRC} ${sp_SRC}) # make executables for inkscape and inkview -add_executable(inkscape ${main_SRC} $<TARGET_OBJECTS:inkscape_base>) -add_executable(inkview inkview.cpp $<TARGET_OBJECTS:inkscape_base>) +add_executable(inkscape ${main_SRC} ) +add_executable(inkview inkview.cpp ) + + if(UNIX) # message after building. @@ -531,8 +526,8 @@ endif() add_dependencies(inkscape inkscape_version) -if (NOT "${WITH_EXT_GDL}") - list (APPEND INKSCAPE_LIBS "gdl_LIB") +if(WITH_DBUS) + add_dependencies(inkscape inkscape_dbus) endif() set(INKSCAPE_TARGET_LIBS @@ -557,5 +552,27 @@ set(INKSCAPE_TARGET_LIBS ${INKSCAPE_LIBS} ) -target_link_libraries(inkscape ${INKSCAPE_TARGET_LIBS}) -target_link_libraries(inkview ${INKSCAPE_TARGET_LIBS}) +if (NOT "${WITH_EXT_GDL}") + # Insert it at the beginning of the list as the windows build fails otherwise + list (INSERT INKSCAPE_TARGET_LIBS 0 "gdl_LIB") +endif() + + + + +# Link the inkscape_base library against all external dependencies +target_link_libraries(inkscape_base ${INKSCAPE_TARGET_LIBS}) + +# Link inkscape and inkview against inkscape_base +target_link_libraries(inkscape inkscape_base ) +target_link_libraries(inkview inkscape_base) + +#Define the installation +install( + TARGETS inkscape_base inkscape inkview + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib/inkscape + ARCHIVE DESTINATION lib/inkscape + ) + + diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index 99bc4f7ae..b9bd949ff 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -519,34 +519,29 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) if (!guide->getLocked()) { sp_guideline_set_color(SP_GUIDELINE(item), guide->getHiColor()); } + // set move or rotate cursor Geom::Point const event_w(event->crossing.x, event->crossing.y); + GdkDisplay *display = gdk_display_get_default(); + GdkCursorType cursor_type; + if ((event->crossing.state & GDK_SHIFT_MASK) && (drag_type != SP_DRAG_MOVE_ORIGIN)) { - GdkCursor *guide_cursor; - guide_cursor = gdk_cursor_new (GDK_EXCHANGE); - if(guide->getLocked()){ - guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1); - } - gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); -#if GTK_CHECK_VERSION(3,0,0) - g_object_unref(guide_cursor); -#else - gdk_cursor_unref(guide_cursor); -#endif + cursor_type = GDK_EXCHANGE; } else { - GdkCursor *guide_cursor; - guide_cursor = gdk_cursor_new (GDK_HAND1); - if(guide->getLocked()){ - guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1); - } - gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); + cursor_type = GDK_HAND1; + } + + GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, cursor_type); + if(guide->getLocked()){ + guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1); + } + gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); #if GTK_CHECK_VERSION(3,0,0) - g_object_unref(guide_cursor); + g_object_unref(guide_cursor); #else - gdk_cursor_unref(guide_cursor); + gdk_cursor_unref(guide_cursor); #endif - } char *guide_description = guide->description(); desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description); @@ -577,11 +572,11 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: if (drag_type != SP_DRAG_MOVE_ORIGIN) { - GdkCursor *guide_cursor; - guide_cursor = gdk_cursor_new (GDK_EXCHANGE); + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); #if GTK_CHECK_VERSION(3,0,0) - g_object_unref(guide_cursor); + g_object_unref(guide_cursor); #else gdk_cursor_unref(guide_cursor); #endif @@ -598,15 +593,17 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - GdkCursor *guide_cursor; - guide_cursor = gdk_cursor_new (GDK_EXCHANGE); + { + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); #if GTK_CHECK_VERSION(3,0,0) - g_object_unref(guide_cursor); + g_object_unref(guide_cursor); #else gdk_cursor_unref(guide_cursor); #endif break; + } default: // do nothing; break; diff --git a/src/desktop.cpp b/src/desktop.cpp index f099ba39f..d482d0d7f 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); @@ -501,7 +496,7 @@ void SPDesktop::redrawDesktop() { void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) { SP_CANVAS_ARENA (drawing)->drawing.setRenderMode(mode); - canvas->rendermode = mode; + canvas->_rendermode = mode; _display_mode = mode; redrawDesktop(); _widget->setTitle( this->getDocument()->getName() ); @@ -522,7 +517,7 @@ void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) { } SP_CANVAS_ARENA (drawing)->drawing.setColorMode(mode); - canvas->colorrendermode = mode; + canvas->_colorrendermode = mode; _display_color_mode = mode; redrawDesktop(); _widget->setTitle( this->getDocument()->getName() ); @@ -1446,7 +1441,8 @@ void SPDesktop::disableInteraction() void SPDesktop::setWaitingCursor() { - GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(getCanvas())), waiting); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(waiting); @@ -1732,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) { @@ -1755,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); 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/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; diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 2a943d16c..e23c89c59 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -118,14 +118,14 @@ unsigned DrawingImage::_renderItem(DrawingContext &dc, Geom::IntRect const &/*ar // http://www.w3.org/TR/css4-images/#the-image-rendering // style.h/style.cpp switch (_style->image_rendering.computed) { - case SP_CSS_COLOR_RENDERING_AUTO: + case SP_CSS_IMAGE_RENDERING_AUTO: // Do nothing break; - case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY: + case SP_CSS_IMAGE_RENDERING_OPTIMIZEQUALITY: // In recent Cairo, BEST used Lanczos3, which is prohibitively slow dc.patternSetFilter( CAIRO_FILTER_GOOD ); break; - case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED: + case SP_CSS_IMAGE_RENDERING_OPTIMIZESPEED: default: dc.patternSetFilter( CAIRO_FILTER_NEAREST ); break; diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 913812828..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); @@ -126,11 +114,8 @@ void FilterTile::render_cairo(FilterSlot &slot) void FilterTile::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { - // We need to enlarge enough to get tile source... we don't the area of the source tile in this - // function so we guess. This is VERY inefficient. - Geom::Point enlarge(200, 200); - enlarge *= trans; - area.expandBy( enlarge[Geom::X] < 100 ? 100: enlarge[Geom::X] ); + // Set to infinite rectangle so we get tile source. It will be clipped later. + area = Geom::IntRect::infinite(); } double FilterTile::complexity(Geom::Affine const &) diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 81ea7d142..7d76fa043 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -8,9 +8,11 @@ * fred * bbyak * Jon A. Cruz <jon@joncruz.org> + * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> * * Copyright (C) 1998 The Free Software Foundation * Copyright (C) 2002-2006 authors + * Copyright (C) 2016 Google Inc. * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -25,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" @@ -35,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; @@ -122,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) { @@ -173,159 +177,8 @@ bool is_descendant(SPCanvasItem const *item, SPCanvasItem const *parent); guint item_signals[ITEM_LAST_SIGNAL] = { 0 }; -struct PaintRectSetup; - } // namespace -class SPCanvasImpl -{ -public: - - /** - * Helper that emits an event for an item in the canvas, be it the current - * item, grabbed item, or focused item, as appropriate. - */ - static int emitEvent(SPCanvas *canvas, GdkEvent *event); - - /** - * Helper that re-picks the current item in the canvas, based on the event's - * coordinates and emits enter/leave events for items as appropriate. - */ - static int pickCurrentItem(SPCanvas *canvas, GdkEvent *event); - - /** - * The canvas widget's realize callback. - */ - static void realize(GtkWidget *widget); - - /** - * The canvas widget's unrealize callback. - */ - static void unrealize(GtkWidget *widget); - - /** - * The canvas widget's size request callback. - */ -#if GTK_CHECK_VERSION(3,0,0) - static void getPreferredWidth(GtkWidget *widget, gint *min_w, gint *nat_w); - static void getPreferredHeight(GtkWidget *widget, gint *min_h, gint *nat_h); -#else - static void sizeRequest(GtkWidget *widget, GtkRequisition *req); -#endif - - /** - * The canvas widget's size allocate callback. - */ - static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation); - - /** - * Button event handler for the canvas. - */ - static gint button(GtkWidget *widget, GdkEventButton *event); - - /** - * Scroll event handler for the canvas. - * - * @todo FIXME: generate motion events to re-select items. - */ - static gint handleScroll(GtkWidget *widget, GdkEventScroll *event); - - /** - * Motion event handler for the canvas. - */ - static gint handleMotion(GtkWidget *widget, GdkEventMotion *event); - - /** - * The canvas widget's expose callback. - * - * @todo FIXME: function allways retruns false. - */ -#if GTK_CHECK_VERSION(3,0,0) - static gboolean handleDraw(GtkWidget *widget, cairo_t *cr); -#else - static gboolean handleExpose(GtkWidget *widget, GdkEventExpose *event); -#endif - - /** - * The canvas widget's keypress callback. - */ - static gint handleKeyEvent(GtkWidget *widget, GdkEventKey *event); - - /** - * Crossing event handler for the canvas. - */ - static gint handleCrossing(GtkWidget *widget, GdkEventCrossing *event); - - /** - * Focus in handler for the canvas. - */ - static gint handleFocusIn(GtkWidget *widget, GdkEventFocus *event); - - /** - * Focus out handler for the canvas. - */ - static gint handleFocusOut(GtkWidget *widget, GdkEventFocus *event); - - /** - * Helper that allocates a new tile array for the canvas, copying overlapping tiles from the old array - */ - static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb); - - /** - * Helper that queues a canvas rectangle for redraw - */ - static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area); - - /** - * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise) - */ - static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val); - - /** - * Helper that invokes update, paint, and repick on canvas. - */ - static int do_update(SPCanvas *canvas); - - static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int sw); - - /** - * Paint the given rect, recursively subdividing the region until it is the size of a single - * buffer. - * - * @return true if the drawing completes - */ - static int sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect); - - /** - * Helper that draws a specific rectangular part of the canvas. - * - * @return true if the rectangle painting succeeds. - */ - static bool sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1); - - /** - * Helper that repaints the areas in the canvas that need it. - * - * @return true if all the dirty parts have been redrawn - */ - static int paint(SPCanvas *canvas); - - /** - * Idle handler for the canvas that deals with pending updates and redraws. - */ - static gint idle_handler(gpointer data); - - /** - * Convenience function to add an idle handler to a canvas. - */ - static void add_idle(SPCanvas *canvas); - - /** - * Update callback for canvas widget. - */ - static void requestCanvasUpdate(SPCanvas *canvas); -}; - G_DEFINE_TYPE(SPCanvasItem, sp_canvas_item, G_TYPE_INITIALLY_UNOWNED); static void @@ -456,18 +309,18 @@ void sp_canvas_item_dispose(GObject *object) } item->visible = FALSE; - if (item == item->canvas->current_item) { - item->canvas->current_item = NULL; - item->canvas->need_repick = TRUE; + if (item == item->canvas->_current_item) { + item->canvas->_current_item = NULL; + item->canvas->_need_repick = TRUE; } - if (item == item->canvas->new_current_item) { - item->canvas->new_current_item = NULL; - item->canvas->need_repick = TRUE; + if (item == item->canvas->_new_current_item) { + item->canvas->_new_current_item = NULL; + item->canvas->_need_repick = TRUE; } - if (item == item->canvas->grabbed_item) { - item->canvas->grabbed_item = NULL; + if (item == item->canvas->_grabbed_item) { + item->canvas->_grabbed_item = NULL; #if GTK_CHECK_VERSION(3,0,0) GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); @@ -478,8 +331,8 @@ void sp_canvas_item_dispose(GObject *object) #endif } - if (item == item->canvas->focused_item) { - item->canvas->focused_item = NULL; + if (item == item->canvas->_focused_item) { + item->canvas->_focused_item = NULL; } if (item->parent) { @@ -577,11 +430,11 @@ void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Affine const &affi if (item->parent != NULL) { sp_canvas_item_request_update (item->parent); } else { - SPCanvasImpl::requestCanvasUpdate(item->canvas); + item->canvas->requestUpdate(); } } - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } /** @@ -614,7 +467,7 @@ void sp_canvas_item_raise(SPCanvasItem *item, int positions) parent->items.insert(l, item); redraw_if_visible (item); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } void sp_canvas_item_raise_to_top(SPCanvasItem *item) @@ -627,7 +480,7 @@ void sp_canvas_item_raise_to_top(SPCanvasItem *item) parent->items.remove(item); parent->items.push_back(item); redraw_if_visible (item); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } @@ -663,7 +516,7 @@ void sp_canvas_item_lower(SPCanvasItem *item, int positions) parent->items.insert(l, item); redraw_if_visible (item); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } void sp_canvas_item_lower_to_bottom(SPCanvasItem *item) @@ -676,7 +529,7 @@ void sp_canvas_item_lower_to_bottom(SPCanvasItem *item) parent->items.remove(item); parent->items.push_front(item); redraw_if_visible (item); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } bool sp_canvas_item_is_visible(SPCanvasItem *item) @@ -705,7 +558,7 @@ void sp_canvas_item_show(SPCanvasItem *item) if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) { item->canvas->requestRedraw((int)(item->x1), (int)(item->y1), (int)(item->x2 + 1), (int)(item->y2 + 1)); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } } @@ -730,7 +583,7 @@ void sp_canvas_item_hide(SPCanvasItem *item) if (x0 !=0 || x1 !=0 || y0 !=0 || y1 !=0) { item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)(item->x2 + 1), (int)(item->y2 + 1)); - item->canvas->need_repick = TRUE; + item->canvas->_need_repick = TRUE; } } @@ -745,7 +598,7 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1); g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1); - if (item->canvas->grabbed_item) { + if (item->canvas->_grabbed_item) { return -1; } @@ -780,9 +633,9 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, NULL, cursor, etime); #endif - item->canvas->grabbed_item = item; - item->canvas->grabbed_event_mask = event_mask; - item->canvas->current_item = item; // So that events go to the grabbed item + item->canvas->_grabbed_item = item; + item->canvas->_grabbed_event_mask = event_mask; + item->canvas->_current_item = item; // So that events go to the grabbed item return 0; } @@ -799,11 +652,11 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime) g_return_if_fail (item != NULL); g_return_if_fail (SP_IS_CANVAS_ITEM (item)); - if (item->canvas->grabbed_item != item) { + if (item->canvas->_grabbed_item != item) { return; } - item->canvas->grabbed_item = NULL; + item->canvas->_grabbed_item = NULL; #if GTK_CHECK_VERSION(3,0,0) GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); @@ -865,7 +718,7 @@ void sp_canvas_item_request_update(SPCanvasItem *item) sp_canvas_item_request_update (item->parent); } else { // Have reached the top of the tree, make sure the update call gets scheduled. - SPCanvasImpl::requestCanvasUpdate(item->canvas); + item->canvas->requestUpdate(); } } @@ -955,10 +808,10 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac SPCanvasGroup const *group = SP_CANVAS_GROUP(item); double const x = p[Geom::X]; double const y = p[Geom::Y]; - int x1 = (int)(x - item->canvas->close_enough); - int y1 = (int)(y - item->canvas->close_enough); - int x2 = (int)(x + item->canvas->close_enough); - int y2 = (int)(y + item->canvas->close_enough); + int x1 = (int)(x - item->canvas->_close_enough); + int y1 = (int)(y - item->canvas->_close_enough); + int x2 = (int)(x + item->canvas->_close_enough); + int y2 = (int)(y + item->canvas->_close_enough); double best = 0.0; *actual_item = NULL; @@ -984,7 +837,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac // of the item to be focused, and have that one selected. Of course this will only work if the // centers are not coincident, but at least it's better than what we have now. // See the extensive comment in Inkscape::SelTrans::_updateHandles() - if (pickable && point_item && ((int) (dist + 0.5) <= item->canvas->close_enough)) { + if (pickable && point_item && ((int) (dist + 0.5) <= item->canvas->_close_enough)) { best = dist; *actual_item = point_item; } @@ -1049,135 +902,119 @@ void SPCanvasGroup::remove(SPCanvasItem *item) } -static void sp_canvas_dispose (GObject *object); -static void sp_canvas_shutdown_transients(SPCanvas *canvas); - G_DEFINE_TYPE(SPCanvas, sp_canvas, GTK_TYPE_WIDGET); -static void -sp_canvas_class_init(SPCanvasClass *klass) +void sp_canvas_class_init(SPCanvasClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); - object_class->dispose = sp_canvas_dispose; + object_class->dispose = SPCanvas::dispose; - widget_class->realize = SPCanvasImpl::realize; - widget_class->unrealize = SPCanvasImpl::unrealize; + widget_class->realize = SPCanvas::handle_realize; + widget_class->unrealize = SPCanvas::handle_unrealize; #if GTK_CHECK_VERSION(3,0,0) - widget_class->get_preferred_width = SPCanvasImpl::getPreferredWidth; - widget_class->get_preferred_height = SPCanvasImpl::getPreferredHeight; - widget_class->draw = SPCanvasImpl::handleDraw; + widget_class->get_preferred_width = SPCanvas::handle_get_preferred_width; + widget_class->get_preferred_height = SPCanvas::handle_get_preferred_height; + widget_class->draw = SPCanvas::handle_draw; #else - widget_class->size_request = SPCanvasImpl::sizeRequest; - widget_class->expose_event = SPCanvasImpl::handleExpose; + widget_class->size_request = SPCanvas::handle_size_request; + widget_class->expose_event = SPCanvas::handle_expose; #endif - widget_class->size_allocate = SPCanvasImpl::sizeAllocate; - widget_class->button_press_event = SPCanvasImpl::button; - widget_class->button_release_event = SPCanvasImpl::button; - widget_class->motion_notify_event = SPCanvasImpl::handleMotion; - widget_class->scroll_event = SPCanvasImpl::handleScroll; - widget_class->key_press_event = SPCanvasImpl::handleKeyEvent; - widget_class->key_release_event = SPCanvasImpl::handleKeyEvent; - widget_class->enter_notify_event = SPCanvasImpl::handleCrossing; - widget_class->leave_notify_event = SPCanvasImpl::handleCrossing; - widget_class->focus_in_event = SPCanvasImpl::handleFocusIn; - widget_class->focus_out_event = SPCanvasImpl::handleFocusOut; + widget_class->size_allocate = SPCanvas::handle_size_allocate; + widget_class->button_press_event = SPCanvas::handle_button; + widget_class->button_release_event = SPCanvas::handle_button; + widget_class->motion_notify_event = SPCanvas::handle_motion; + widget_class->scroll_event = SPCanvas::handle_scroll; + widget_class->key_press_event = SPCanvas::handle_key_event; + widget_class->key_release_event = SPCanvas::handle_key_event; + widget_class->enter_notify_event = SPCanvas::handle_crossing; + widget_class->leave_notify_event = SPCanvas::handle_crossing; + widget_class->focus_in_event = SPCanvas::handle_focus_in; + widget_class->focus_out_event = SPCanvas::handle_focus_out; } -static void -sp_canvas_init(SPCanvas *canvas) +static void sp_canvas_init(SPCanvas *canvas) { gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); - gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); - canvas->pick_event.type = GDK_LEAVE_NOTIFY; - canvas->pick_event.crossing.x = 0; - canvas->pick_event.crossing.y = 0; + canvas->_pick_event.type = GDK_LEAVE_NOTIFY; + canvas->_pick_event.crossing.x = 0; + canvas->_pick_event.crossing.y = 0; // Create the root item as a special case - canvas->root = SP_CANVAS_ITEM(g_object_new(SP_TYPE_CANVAS_GROUP, NULL)); - canvas->root->canvas = canvas; + canvas->_root = SP_CANVAS_ITEM(g_object_new(SP_TYPE_CANVAS_GROUP, NULL)); + canvas->_root->canvas = canvas; - g_object_ref (canvas->root); - g_object_ref_sink (canvas->root); + g_object_ref (canvas->_root); + g_object_ref_sink (canvas->_root); - canvas->need_repick = TRUE; + canvas->_need_repick = TRUE; // See comment at in sp-canvas.h. - canvas->gen_all_enter_events = false; + canvas->_gen_all_enter_events = false; - canvas->drawing_disabled = false; + canvas->_drawing_disabled = false; - canvas->tiles=NULL; - canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0; - canvas->tileH=canvas->tileV=0; + 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; + canvas->_forced_redraw_count = 0; + canvas->_forced_redraw_limit = -1; #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - canvas->enable_cms_display_adj = false; - new (&canvas->cms_key) Glib::ustring(""); + canvas->_enable_cms_display_adj = false; + new (&canvas->_cms_key) Glib::ustring(""); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - - canvas->is_scrolling = false; } -static void sp_canvas_remove_idle(SPCanvas *canvas) -{ - if (canvas->idle_id) { - g_source_remove (canvas->idle_id); - canvas->idle_id = 0; - } -} - -static void -sp_canvas_shutdown_transients(SPCanvas *canvas) +void SPCanvas::shutdownTransients() { - // We turn off the need_redraw flag, since if the canvas is mapped again - // it will request a redraw anyways. We do not turn off the need_update - // flag, though, because updates are not queued when the canvas remaps - // itself. - // - if (canvas->need_redraw) { - canvas->need_redraw = FALSE; - } - if ( canvas->tiles ) g_free(canvas->tiles); - canvas->tiles=NULL; - canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0; - canvas->tileH=canvas->tileV=0; + // Reset the clean region + dirtyAll(); - if (canvas->grabbed_item) { - canvas->grabbed_item = NULL; + if (_grabbed_item) { + _grabbed_item = NULL; #if GTK_CHECK_VERSION(3,0,0) GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); GdkDevice *device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, GDK_CURRENT_TIME); #else - gdk_pointer_ungrab (GDK_CURRENT_TIME); + gdk_pointer_ungrab(GDK_CURRENT_TIME); #endif } - - sp_canvas_remove_idle(canvas); + removeIdle(); } -static void -sp_canvas_dispose(GObject *object) +void SPCanvas::dispose(GObject *object) { SPCanvas *canvas = SP_CANVAS(object); - if (canvas->root) { - g_object_unref (canvas->root); - canvas->root = NULL; + if (canvas->_root) { + g_object_unref (canvas->_root); + canvas->_root = NULL; + } + if (canvas->_backing_store) { + cairo_surface_destroy(canvas->_backing_store); + canvas->_backing_store = NULL; + } + if (canvas->_clean_region) { + cairo_region_destroy(canvas->_clean_region); + canvas->_clean_region = NULL; + } + if (canvas->_background) { + cairo_pattern_destroy(canvas->_background); + canvas->_background = NULL; } - sp_canvas_shutdown_transients(canvas); + canvas->shutdownTransients(); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - canvas->cms_key.~ustring(); + canvas->_cms_key.~ustring(); #endif if (G_OBJECT_CLASS(sp_canvas_parent_class)->dispose) { (* G_OBJECT_CLASS(sp_canvas_parent_class)->dispose)(object); @@ -1203,7 +1040,7 @@ GtkWidget *SPCanvas::createAA() return GTK_WIDGET(canvas); } -void SPCanvasImpl::realize(GtkWidget *widget) +void SPCanvas::handle_realize(GtkWidget *widget) { GdkWindowAttr attributes; GtkAllocation allocation; @@ -1264,15 +1101,15 @@ void SPCanvasImpl::realize(GtkWidget *widget) gtk_widget_set_realized (widget, TRUE); } -void SPCanvasImpl::unrealize(GtkWidget *widget) +void SPCanvas::handle_unrealize(GtkWidget *widget) { SPCanvas *canvas = SP_CANVAS (widget); - canvas->current_item = NULL; - canvas->grabbed_item = NULL; - canvas->focused_item = NULL; + canvas->_current_item = NULL; + canvas->_grabbed_item = NULL; + canvas->_focused_item = NULL; - sp_canvas_shutdown_transients(canvas); + canvas->shutdownTransients(); if (GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize) (* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget); @@ -1280,21 +1117,21 @@ void SPCanvasImpl::unrealize(GtkWidget *widget) #if GTK_CHECK_VERSION(3,0,0) -void SPCanvasImpl::getPreferredWidth(GtkWidget *widget, gint *minimum_width, gint *natural_width) +void SPCanvas::handle_get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width) { static_cast<void>(SP_CANVAS (widget)); *minimum_width = 256; *natural_width = 256; } -void SPCanvasImpl::getPreferredHeight(GtkWidget *widget, gint *minimum_height, gint *natural_height) +void SPCanvas::handle_get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height) { static_cast<void>(SP_CANVAS (widget)); *minimum_height = 256; *natural_height = 256; } #else -void SPCanvasImpl::sizeRequest(GtkWidget *widget, GtkRequisition *req) +void SPCanvas::handle_size_request(GtkWidget *widget, GtkRequisition *req) { static_cast<void>(SP_CANVAS (widget)); @@ -1304,51 +1141,58 @@ void SPCanvasImpl::sizeRequest(GtkWidget *widget, GtkRequisition *req) #endif -void SPCanvasImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) +void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { SPCanvas *canvas = SP_CANVAS (widget); - GtkAllocation widg_allocation; + GtkAllocation old_allocation; - gtk_widget_get_allocation (widget, &widg_allocation); + gtk_widget_get_allocation(widget, &old_allocation); -// Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, -// widg_allocation.width, widg_allocation.height); +// Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->_x0, canvas->_y0, +// old_allocation.width, old_allocation.height); - Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->_x0, canvas->_y0, allocation->width, allocation->height); - // Schedule redraw of new region - sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height); - if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed) - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area); - - if (allocation->width > widg_allocation.width) { - canvas->requestRedraw(canvas->x0 + widg_allocation.width, - 0, - canvas->x0 + allocation->width, - canvas->y0 + allocation->height); - } - if (allocation->height > widg_allocation.height) { - canvas->requestRedraw(0, - canvas->y0 + widg_allocation.height, - canvas->x0 + allocation->width, - canvas->y0 + allocation->height); - } + // resize backing store + cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, + allocation->width, allocation->height); + if (canvas->_backing_store) { + cairo_t *cr = cairo_create(new_backing_store); + cairo_translate(cr, -canvas->_x0, -canvas->_y0); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source(cr, canvas->_background); + cairo_paint(cr); + cairo_set_source_surface(cr, canvas->_backing_store, canvas->_x0, canvas->_y0); + cairo_paint(cr); + cairo_destroy(cr); + cairo_surface_destroy(canvas->_backing_store); + } + 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); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->_root)->viewbox_changed (canvas->_root, new_area); + if (gtk_widget_get_realized (widget)) { gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y, allocation->width, allocation->height); } + // Schedule redraw of any newly exposed regions + canvas->addIdle(); } -int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) +int SPCanvas::emitEvent(GdkEvent *event) { guint mask; - if (canvas->grabbed_item) { + if (_grabbed_item) { switch (event->type) { case GDK_ENTER_NOTIFY: mask = GDK_ENTER_NOTIFY_MASK; @@ -1384,7 +1228,7 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) break; } - if (!(mask & canvas->grabbed_event_mask)) return FALSE; + if (!(mask & _grabbed_event_mask)) return FALSE; } // Convert to world coordinates -- we have two cases because of different @@ -1395,25 +1239,25 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) switch (ev->type) { case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: - ev->crossing.x += canvas->x0; - ev->crossing.y += canvas->y0; + ev->crossing.x += _x0; + ev->crossing.y += _y0; break; case GDK_MOTION_NOTIFY: case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: case GDK_BUTTON_RELEASE: - ev->motion.x += canvas->x0; - ev->motion.y += canvas->y0; + ev->motion.x += _x0; + ev->motion.y += _y0; break; default: break; } // Block Undo and Redo while we drag /anything/ if(event->type == GDK_BUTTON_PRESS && event->button.button == 1) - canvas->is_dragging = true; + _is_dragging = true; else if(event->type == GDK_BUTTON_RELEASE) - canvas->is_dragging = false; + _is_dragging = false; // Choose where we send the event @@ -1422,17 +1266,17 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) // Lauris applied to SP to get around the problem. // SPCanvasItem* item = NULL; - if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) { - item = canvas->grabbed_item; + if (_grabbed_item && !is_descendant(_current_item, _grabbed_item)) { + item = _grabbed_item; } else { - item = canvas->current_item; + item = _current_item; } - if (canvas->focused_item && + if (_focused_item && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE))) { - item = canvas->focused_item; + item = _focused_item; } // The event is propagated up the hierarchy (for if someone connected to @@ -1454,24 +1298,24 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) return finished; } -int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event) +int SPCanvas::pickCurrentItem(GdkEvent *event) { int button_down = 0; - if (!canvas->root) // canvas may have already be destroyed by closing desktop during interrupted display! + if (!_root) // canvas may have already be destroyed by closing desktop during interrupted display! return FALSE; int retval = FALSE; - if (canvas->gen_all_enter_events == false) { + if (_gen_all_enter_events == false) { // If a button is down, we'll perform enter and leave events on the // current item, but not enter on any other item. This is more or // less like X pointer grabbing for canvas items. // - button_down = canvas->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | + button_down = _state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK); - if (!button_down) canvas->left_grabbed_item = FALSE; + if (!button_down) _left_grabbed_item = FALSE; } // Save the event in the canvas. This is used to synthesize enter and @@ -1479,116 +1323,115 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event) // re-pick the current item if the current one gets deleted. Also, // synthesize an enter event. - if (event != &canvas->pick_event) { + if (event != &_pick_event) { if ((event->type == GDK_MOTION_NOTIFY) || (event->type == GDK_BUTTON_RELEASE)) { // these fields have the same offsets in both types of events - canvas->pick_event.crossing.type = GDK_ENTER_NOTIFY; - canvas->pick_event.crossing.window = event->motion.window; - canvas->pick_event.crossing.send_event = event->motion.send_event; - canvas->pick_event.crossing.subwindow = NULL; - canvas->pick_event.crossing.x = event->motion.x; - canvas->pick_event.crossing.y = event->motion.y; - canvas->pick_event.crossing.mode = GDK_CROSSING_NORMAL; - canvas->pick_event.crossing.detail = GDK_NOTIFY_NONLINEAR; - canvas->pick_event.crossing.focus = FALSE; - canvas->pick_event.crossing.state = event->motion.state; + _pick_event.crossing.type = GDK_ENTER_NOTIFY; + _pick_event.crossing.window = event->motion.window; + _pick_event.crossing.send_event = event->motion.send_event; + _pick_event.crossing.subwindow = NULL; + _pick_event.crossing.x = event->motion.x; + _pick_event.crossing.y = event->motion.y; + _pick_event.crossing.mode = GDK_CROSSING_NORMAL; + _pick_event.crossing.detail = GDK_NOTIFY_NONLINEAR; + _pick_event.crossing.focus = FALSE; + _pick_event.crossing.state = event->motion.state; // these fields don't have the same offsets in both types of events if (event->type == GDK_MOTION_NOTIFY) { - canvas->pick_event.crossing.x_root = event->motion.x_root; - canvas->pick_event.crossing.y_root = event->motion.y_root; + _pick_event.crossing.x_root = event->motion.x_root; + _pick_event.crossing.y_root = event->motion.y_root; } else { - canvas->pick_event.crossing.x_root = event->button.x_root; - canvas->pick_event.crossing.y_root = event->button.y_root; + _pick_event.crossing.x_root = event->button.x_root; + _pick_event.crossing.y_root = event->button.y_root; } } else { - canvas->pick_event = *event; + _pick_event = *event; } } // Don't do anything else if this is a recursive call - if (canvas->in_repick) { + if (_in_repick) { return retval; } // LeaveNotify means that there is no current item, so we don't look for one - if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) { + if (_pick_event.type != GDK_LEAVE_NOTIFY) { // these fields don't have the same offsets in both types of events double x, y; - if (canvas->pick_event.type == GDK_ENTER_NOTIFY) { - x = canvas->pick_event.crossing.x; - y = canvas->pick_event.crossing.y; + if (_pick_event.type == GDK_ENTER_NOTIFY) { + x = _pick_event.crossing.x; + y = _pick_event.crossing.y; } else { - x = canvas->pick_event.motion.x; - y = canvas->pick_event.motion.y; + x = _pick_event.motion.x; + y = _pick_event.motion.y; } // world coords - x += canvas->x0; - y += canvas->y0; + x += _x0; + y += _y0; // find the closest item - if (canvas->root->visible) { - sp_canvas_item_invoke_point (canvas->root, Geom::Point(x, y), &canvas->new_current_item); + if (_root->visible) { + sp_canvas_item_invoke_point (_root, Geom::Point(x, y), &_new_current_item); } else { - canvas->new_current_item = NULL; + _new_current_item = NULL; } } else { - canvas->new_current_item = NULL; + _new_current_item = NULL; } - if ((canvas->new_current_item == canvas->current_item) && !canvas->left_grabbed_item) { + if ((_new_current_item == _current_item) && !_left_grabbed_item) { return retval; // current item did not change } // Synthesize events for old and new current items - if ((canvas->new_current_item != canvas->current_item) - && (canvas->current_item != NULL) - && !canvas->left_grabbed_item) { + if ((_new_current_item != _current_item) && + _current_item != NULL && !_left_grabbed_item) + { GdkEvent new_event; - new_event = canvas->pick_event; + new_event = _pick_event; new_event.type = GDK_LEAVE_NOTIFY; new_event.crossing.detail = GDK_NOTIFY_ANCESTOR; new_event.crossing.subwindow = NULL; - canvas->in_repick = TRUE; - retval = emitEvent(canvas, &new_event); - canvas->in_repick = FALSE; + _in_repick = TRUE; + retval = emitEvent(&new_event); + _in_repick = FALSE; } - if (canvas->gen_all_enter_events == false) { + if (_gen_all_enter_events == false) { // new_current_item may have been set to NULL during the call to // emitEvent() above - if ((canvas->new_current_item != canvas->current_item) && button_down) { - canvas->left_grabbed_item = TRUE; + if ((_new_current_item != _current_item) && button_down) { + _left_grabbed_item = TRUE; return retval; } } // Handle the rest of cases + _left_grabbed_item = FALSE; + _current_item = _new_current_item; - canvas->left_grabbed_item = FALSE; - canvas->current_item = canvas->new_current_item; - - if (canvas->current_item != NULL) { + if (_current_item != NULL) { GdkEvent new_event; - new_event = canvas->pick_event; + new_event = _pick_event; new_event.type = GDK_ENTER_NOTIFY; new_event.crossing.detail = GDK_NOTIFY_ANCESTOR; new_event.crossing.subwindow = NULL; - retval = emitEvent(canvas, &new_event); + retval = emitEvent(&new_event); } return retval; } -gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event) +gint SPCanvas::handle_button(GtkWidget *widget, GdkEventButton *event) { SPCanvas *canvas = SP_CANVAS (widget); @@ -1596,7 +1439,7 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event) // dispatch normally regardless of the event's window if an item // has a pointer grab in effect - if (!canvas->grabbed_item && + if (!canvas->_grabbed_item && event->window != getWindow(canvas)) return retval; @@ -1628,21 +1471,21 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event) // Pick the current item as if the button were not pressed, and // then process the event. // - canvas->state = event->state; - pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event)); - canvas->state ^= mask; - retval = emitEvent(canvas, (GdkEvent *) event); + canvas->_state = event->state; + canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event)); + canvas->_state ^= mask; + retval = canvas->emitEvent((GdkEvent *) event); break; case GDK_BUTTON_RELEASE: // Process the event as if the button were pressed, then repick // after the button has been released // - canvas->state = event->state; - retval = emitEvent(canvas, (GdkEvent *) event); + canvas->_state = event->state; + retval = canvas->emitEvent((GdkEvent *) event); event->state ^= mask; - canvas->state = event->state; - pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event)); + canvas->_state = event->state; + canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event)); event->state ^= mask; break; @@ -1654,9 +1497,9 @@ gint SPCanvasImpl::button(GtkWidget *widget, GdkEventButton *event) return retval; } -gint SPCanvasImpl::handleScroll(GtkWidget *widget, GdkEventScroll *event) +gint SPCanvas::handle_scroll(GtkWidget *widget, GdkEventScroll *event) { - return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event)); + return SP_CANVAS(widget)->emitEvent(reinterpret_cast<GdkEvent *>(event)); } static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { @@ -1670,7 +1513,7 @@ static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_event_request_motions(event); } -int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event) +int SPCanvas::handle_motion(GtkWidget *widget, GdkEventMotion *event) { int status; SPCanvas *canvas = SP_CANVAS (widget); @@ -1681,12 +1524,12 @@ int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event) return FALSE; } - if (canvas->root == NULL) // canvas being deleted + if (canvas->_root == NULL) // canvas being deleted return FALSE; - canvas->state = event->state; - pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event)); - status = emitEvent(canvas, reinterpret_cast<GdkEvent *>(event)); + canvas->_state = event->state; + canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event)); + status = canvas->emitEvent(reinterpret_cast<GdkEvent *>(event)); if (event->is_hint) { request_motions(gtk_widget_get_window (widget), event); } @@ -1694,75 +1537,40 @@ int SPCanvasImpl::handleMotion(GtkWidget *widget, GdkEventMotion *event) return status; } -void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/) +void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/) { - GtkWidget *widget = GTK_WIDGET (canvas); - - // Mark the region clean - sp_canvas_mark_rect(canvas, paint_rect, 0); - SPCanvasBuf buf; buf.buf = NULL; buf.buf_rowstride = 0; buf.rect = paint_rect; buf.visible_rect = canvas_rect; buf.is_empty = true; - //buf.ct = gdk_cairo_create(widget->window); - - /* - cairo_t *xctt = gdk_cairo_create(widget->window); - cairo_translate(xctt, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); - cairo_set_source_rgb(xctt, 1,0,0); - cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height()); - cairo_fill(xctt); - cairo_destroy(xctt); - // - */ // 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); - //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); - -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *context = gtk_widget_get_style_context(widget); - GdkRGBA color; - gtk_style_context_get_background_color(context, - gtk_widget_get_state_flags(widget), - &color); - gdk_cairo_set_source_rgba(buf.ct, &color); -#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 (canvas->root->visible) { - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); + if (_root->visible) { + SP_CANVAS_ITEM_GET_CLASS(_root)->render(_root, &buf); } // output to X cairo_destroy(buf.ct); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - if (canvas->enable_cms_display_adj) { + if (_enable_cms_display_adj) { cmsHTRANSFORM transf = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ); + transf = Inkscape::CMSSystem::getDisplayPer(_cms_key); } else { transf = Inkscape::CMSSystem::getDisplayTransform(); } @@ -1780,8 +1588,9 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - cairo_t *xct = gdk_cairo_create(gtk_widget_get_window (widget)); - cairo_translate(xct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); + //cairo_t *xct = gdk_cairo_create(gtk_widget_get_window (widget)); + cairo_t *xct = cairo_create(_backing_store); + cairo_translate(xct, paint_rect.left() - _x0, paint_rect.top() - _y0); cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height()); cairo_clip(xct); cairo_set_source_surface(xct, imgs, 0, 0); @@ -1790,25 +1599,21 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect cairo_destroy(xct); cairo_surface_destroy(imgs); - //cairo_surface_t *cst = cairo_get_target(buf.ct); - //cairo_destroy (buf.ct); - //cairo_surface_finish (cst); - //cairo_surface_destroy (cst); -} + // Mark the painted rectangle clean + markRect(paint_rect, 0); -namespace { + gtk_widget_queue_draw_area(GTK_WIDGET(this), paint_rect.left() -_x0, paint_rect.top() - _y0, + paint_rect.width(), paint_rect.height()); +} struct PaintRectSetup { - SPCanvas* canvas; Geom::IntRect big_rect; GTimeVal start_time; int max_pixels; Geom::Point mouse_loc; }; -}// namespace - -int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geom::IntRect const &this_rect) +int SPCanvas::paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const &this_rect) { GTimeVal now; g_get_current_time (&now); @@ -1831,11 +1636,11 @@ int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geo // If this limit is set, and if we have aborted redraw more times than is allowed, // interrupting is blocked and we're forced to redraw full screen once // (after which we can again interrupt forced_redraw_limit times). - if (setup->canvas->forced_redraw_limit < 0 || - setup->canvas->forced_redraw_count < setup->canvas->forced_redraw_limit) { + if (_forced_redraw_limit < 0 || + _forced_redraw_count < _forced_redraw_limit) { - if (setup->canvas->forced_redraw_limit != -1) { - setup->canvas->forced_redraw_count++; + if (_forced_redraw_limit != -1) { + _forced_redraw_count++; } return false; @@ -1861,8 +1666,7 @@ int SPCanvasImpl::sp_canvas_paint_rect_internal(PaintRectSetup const *setup, Geo gdk_window_begin_paint_rect(window, &r); */ - sp_canvas_paint_single_buffer (setup->canvas, - this_rect, setup->big_rect, bw); + paintSingleBuffer(this_rect, setup->big_rect, bw); //gdk_window_end_paint(window); return 1; } @@ -1894,11 +1698,11 @@ The default for now is the strips mode. if (setup->mouse_loc[Geom::X] < mid) { // Always paint towards the mouse first - return sp_canvas_paint_rect_internal(setup, lo) - && sp_canvas_paint_rect_internal(setup, hi); + return paintRectInternal(setup, lo) + && paintRectInternal(setup, hi); } else { - return sp_canvas_paint_rect_internal(setup, hi) - && sp_canvas_paint_rect_internal(setup, lo); + return paintRectInternal(setup, hi) + && paintRectInternal(setup, lo); } } else { int mid = this_rect[Geom::Y].middle(); @@ -1910,24 +1714,24 @@ The default for now is the strips mode. if (setup->mouse_loc[Geom::Y] < mid) { // Always paint towards the mouse first - return sp_canvas_paint_rect_internal(setup, lo) - && sp_canvas_paint_rect_internal(setup, hi); + return paintRectInternal(setup, lo) + && paintRectInternal(setup, hi); } else { - return sp_canvas_paint_rect_internal(setup, hi) - && sp_canvas_paint_rect_internal(setup, lo); + return paintRectInternal(setup, hi) + && paintRectInternal(setup, lo); } } } -bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) +bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) { GtkAllocation allocation; - g_return_val_if_fail (!canvas->need_update, false); + g_return_val_if_fail (!_need_update, false); - gtk_widget_get_allocation (GTK_WIDGET (canvas), &allocation); + gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); - Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(_x0, _y0, allocation.width, allocation.height); Geom::IntRect paint_rect(xx0, yy0, xx1, yy1); @@ -1937,8 +1741,6 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int paint_rect = *area; PaintRectSetup setup; - - setup.canvas = canvas; setup.big_rect = paint_rect; // Save the mouse location @@ -1948,16 +1750,16 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); GdkDevice *device = gdk_device_manager_get_client_pointer(dm); - gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(canvas)), + gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)), device, &x, &y, NULL); #else - gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET(canvas)), &x, &y, NULL); + gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(this)), &x, &y, NULL); #endif - setup.mouse_loc = sp_canvas_window_to_world (canvas, Geom::Point(x,y)); + setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); - if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { + if (_rendermode != Inkscape::RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients // 256K is the cached buffer and we need 4 channels setup.max_pixels = 65536; // 256K/4 @@ -1971,76 +1773,73 @@ bool SPCanvasImpl::sp_canvas_paint_rect(SPCanvas *canvas, int xx0, int yy0, int g_get_current_time(&(setup.start_time)); // Go - return sp_canvas_paint_rect_internal(&setup, paint_rect); + return paintRectInternal(&setup, paint_rect); } void SPCanvas::forceFullRedrawAfterInterruptions(unsigned int count) { - forced_redraw_limit = count; - forced_redraw_count = 0; + _forced_redraw_limit = count; + _forced_redraw_count = 0; } void SPCanvas::endForcedFullRedraws() { - forced_redraw_limit = -1; + _forced_redraw_limit = -1; } -#if GTK_CHECK_VERSION(3,0,0) -gboolean SPCanvasImpl::handleDraw(GtkWidget *widget, cairo_t *cr) { - SPCanvas *canvas = SP_CANVAS(widget); - - cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr); +gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { + SPCanvas *canvas = SP_CANVAS(widget); - for (int i = 0; i < rects->num_rectangles; i++) { - cairo_rectangle_t rectangle = rects->rectangles[i]; + // 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); - Geom::IntRect r = Geom::IntRect::from_xywh(rectangle.x + canvas->x0, rectangle.y + canvas->y0, - rectangle.width, rectangle.height); + cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr); + cairo_region_t *dirty_region = cairo_region_create(); - canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom()); - } + for (int i = 0; i < rects->num_rectangles; i++) { + cairo_rectangle_t rectangle = rects->rectangles[i]; + Geom::Rect dr = Geom::Rect::from_xywh(rectangle.x + canvas->_x0, rectangle.y + canvas->_y0, + 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(dirty_region, &irect); + } + cairo_rectangle_list_destroy(rects); + cairo_region_subtract(dirty_region, canvas->_clean_region); - cairo_rectangle_list_destroy(rects); + // Render the dirty portion in the background + if (!cairo_region_is_empty(dirty_region)) { + canvas->addIdle(); + } + cairo_region_destroy(dirty_region); - return FALSE; + return TRUE; } -#else -gboolean SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event) +#if !GTK_CHECK_VERSION(3,0,0) +gboolean SPCanvas::handle_expose(GtkWidget *widget, GdkEventExpose *event) { - SPCanvas *canvas = SP_CANVAS(widget); + cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); - if (!gtk_widget_is_drawable (widget) || - (event->window != getWindow(canvas))) { - return FALSE; - } + gdk_cairo_region (cr, event->region); + cairo_clip (cr); + gboolean result = SPCanvas::handle_draw(widget, cr); - int n_rects = 0; - GdkRectangle *rects = NULL; - gdk_region_get_rectangles(event->region, &rects, &n_rects); + cairo_destroy (cr); - if(rects == NULL) - return FALSE; - - for (int i = 0; i < n_rects; i++) { - GdkRectangle rectangle = rects[i]; - - Geom::IntRect r = Geom::IntRect::from_xywh(rectangle.x + canvas->x0, rectangle.y + canvas->y0, - rectangle.width, rectangle.height); - - canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom()); - } - - return FALSE; + return result; } #endif -gint SPCanvasImpl::handleKeyEvent(GtkWidget *widget, GdkEventKey *event) +gint SPCanvas::handle_key_event(GtkWidget *widget, GdkEventKey *event) { - return emitEvent(SP_CANVAS(widget), reinterpret_cast<GdkEvent *>(event)); + return SP_CANVAS(widget)->emitEvent(reinterpret_cast<GdkEvent *>(event)); } -gint SPCanvasImpl::handleCrossing(GtkWidget *widget, GdkEventCrossing *event) +gint SPCanvas::handle_crossing(GtkWidget *widget, GdkEventCrossing *event) { SPCanvas *canvas = SP_CANVAS (widget); @@ -2048,140 +1847,122 @@ gint SPCanvasImpl::handleCrossing(GtkWidget *widget, GdkEventCrossing *event) return FALSE; } - canvas->state = event->state; - return pickCurrentItem(canvas, reinterpret_cast<GdkEvent *>(event)); + canvas->_state = event->state; + return canvas->pickCurrentItem(reinterpret_cast<GdkEvent *>(event)); } -gint SPCanvasImpl::handleFocusIn(GtkWidget *widget, GdkEventFocus *event) +gint SPCanvas::handle_focus_in(GtkWidget *widget, GdkEventFocus *event) { gtk_widget_grab_focus (widget); SPCanvas *canvas = SP_CANVAS (widget); - if (canvas->focused_item) { - return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event)); + if (canvas->_focused_item) { + return canvas->emitEvent(reinterpret_cast<GdkEvent *>(event)); } else { return FALSE; } } -gint SPCanvasImpl::handleFocusOut(GtkWidget *widget, GdkEventFocus *event) +gint SPCanvas::handle_focus_out(GtkWidget *widget, GdkEventFocus *event) { SPCanvas *canvas = SP_CANVAS(widget); - if (canvas->focused_item) { - return emitEvent(canvas, reinterpret_cast<GdkEvent *>(event)); + if (canvas->_focused_item) { + return canvas->emitEvent(reinterpret_cast<GdkEvent *>(event)); } else { return FALSE; } } -int SPCanvasImpl::paint(SPCanvas *canvas) +int SPCanvas::paint() { - if (canvas->need_update) { - sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0); - canvas->need_update = FALSE; + if (_need_update) { + sp_canvas_item_invoke_update(_root, Geom::identity(), 0); + _need_update = FALSE; } - if (!canvas->need_redraw) { - return TRUE; - } - - Cairo::RefPtr<Cairo::Region> to_paint = Cairo::Region::create(); - - for (int j=canvas->tTop; j<canvas->tBottom; j++) { - for (int i=canvas->tLeft; i<canvas->tRight; i++) { - int tile_index = (i - canvas->tLeft) + (j - canvas->tTop)*canvas->tileH; - - if ( canvas->tiles[tile_index] ) { // if this tile is dirtied (nonzero) - Cairo::RectangleInt rect = {i*TILE_SIZE, j*TILE_SIZE, - TILE_SIZE, TILE_SIZE}; - to_paint->do_union(rect); - } - - } - } - - int n_rect = to_paint->get_num_rectangles(); + GtkAllocation allocation; + gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); + cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height }; + cairo_region_t *to_draw = cairo_region_create_rectangle(&crect); + cairo_region_subtract(to_draw, _clean_region); - if (n_rect > 0) { - for (int i=0; i < n_rect; i++) { - Cairo::RectangleInt rect = to_paint->get_rectangle(i); - int x0 = rect.x; - int y0 = rect.y; - int x1 = x0 + rect.width; - int y1 = y0 + rect.height; - if (!sp_canvas_paint_rect(canvas, x0, y0, x1, y1)) { - // Aborted - return FALSE; - }; - } + int n_rects = cairo_region_num_rectangles(to_draw); + for (int i = 0; i < n_rects; ++i) { + cairo_rectangle_int_t crect; + cairo_region_get_rectangle(to_draw, i, &crect); + if (!paintRect(crect.x, crect.y, crect.x + crect.width, crect.y + crect.height)) { + // Aborted + return FALSE; + }; } - canvas->need_redraw = FALSE; - // we've had a full unaborted redraw, reset the full redraw counter - if (canvas->forced_redraw_limit != -1) { - canvas->forced_redraw_count = 0; + if (_forced_redraw_limit != -1) { + _forced_redraw_count = 0; } return TRUE; } -int SPCanvasImpl::do_update(SPCanvas *canvas) +int SPCanvas::doUpdate() { - if (!canvas->root) { // canvas may have already be destroyed by closing desktop during interrupted display! + if (!_root) { // canvas may have already be destroyed by closing desktop during interrupted display! return TRUE; } - - if (canvas->drawing_disabled) { + if (_drawing_disabled) { return TRUE; } // Cause the update if necessary - if (canvas->need_update) { - sp_canvas_item_invoke_update(canvas->root, Geom::identity(), 0); - canvas->need_update = FALSE; + if (_need_update) { + sp_canvas_item_invoke_update(_root, Geom::identity(), 0); + _need_update = FALSE; } // Paint if able to - if (gtk_widget_is_drawable( GTK_WIDGET(canvas) )) { - return paint(canvas); + if (gtk_widget_is_drawable(GTK_WIDGET(this))) { + return paint(); } // Pick new current item - while (canvas->need_repick) { - canvas->need_repick = FALSE; - pickCurrentItem(canvas, &canvas->pick_event); + while (_need_repick) { + _need_repick = FALSE; + pickCurrentItem(&_pick_event); } return TRUE; } -gint SPCanvasImpl::idle_handler(gpointer data) +gint SPCanvas::idle_handler(gpointer data) { SPCanvas *canvas = SP_CANVAS (data); - - int const ret = do_update (canvas); - + int const ret = canvas->doUpdate(); if (ret) { // Reset idle id - canvas->idle_id = 0; + canvas->_idle_id = 0; } - return !ret; } -void SPCanvasImpl::add_idle(SPCanvas *canvas) +void SPCanvas::addIdle() { - if (canvas->idle_id == 0) { - canvas->idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, canvas, NULL); + if (_idle_id == 0) { + _idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, this, NULL); + } +} +void SPCanvas::removeIdle() +{ + if (_idle_id) { + g_source_remove(_idle_id); + _idle_id = 0; } } SPCanvasGroup *SPCanvas::getRoot() { - return SP_CANVAS_GROUP(root); + return SP_CANVAS_GROUP(_root); } void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling) @@ -2190,72 +1971,115 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll int ix = (int) round(cx); // ix and iy are the new canvas coordinates (integer screen pixels) int iy = (int) round(cy); // cx might be negative, so (int)(cx + 0.5) will not do! - int dx = ix - x0; // dx and dy specify the displacement (scroll) of the - int dy = iy - y0; // canvas w.r.t its previous position + int dx = ix - _x0; // dx and dy specify the displacement (scroll) of the + int dy = iy - _y0; // canvas w.r.t its previous position 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); + 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); + cairo_t *cr = cairo_create(new_backing_store); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + // Paint the background + cairo_translate(cr, -ix, -iy); + cairo_set_source(cr, _background); + cairo_paint(cr); + // 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 { + cairo_rectangle_int_t crect = { _x0, _y0, allocation.width, allocation.height }; + cairo_region_intersect_rectangle(_clean_region, &crect); + } - SPCanvasImpl::sp_canvas_resize_tiles(this, x0, y0, x0 + allocation.width, y0 + allocation.height); - if (SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed) { - SP_CANVAS_ITEM_GET_CLASS(root)->viewbox_changed(root, new_area); + if (SP_CANVAS_ITEM_GET_CLASS(_root)->viewbox_changed) { + SP_CANVAS_ITEM_GET_CLASS(_root)->viewbox_changed(_root, new_area); } if (!clear) { // scrolling without zoom; redraw only the newly exposed areas if ((dx != 0) || (dy != 0)) { - this->is_scrolling = is_scrolling; if (gtk_widget_get_realized(GTK_WIDGET(this))) { gdk_window_scroll(getWindow(this), -dx, -dy); } } - } else { - // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw } + addIdle(); } void SPCanvas::updateNow() { - if (need_update || need_redraw) { - SPCanvasImpl::do_update(this); + if (_need_update) { + doUpdate(); } } -void SPCanvasImpl::requestCanvasUpdate(SPCanvas *canvas) +void SPCanvas::requestUpdate() { - canvas->need_update = TRUE; - add_idle(canvas); + _need_update = TRUE; + addIdle(); } void SPCanvas::requestRedraw(int x0, int y0, int x1, int y1) { - GtkAllocation allocation; - if (!gtk_widget_is_drawable( GTK_WIDGET(this) )) { return; } - if ((x0 >= x1) || (y0 >= y1)) { + if (x0 >= x1 || y0 >= y1) { return; } Geom::IntRect bbox(x0, y0, x1, y1); - gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); + dirtyRect(bbox); + addIdle(); +} - Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(this->x0, this->y0, - allocation.width, allocation.height); - - Geom::OptIntRect clip = bbox & canvas_rect; - if (clip) { - SPCanvasImpl::sp_canvas_dirty_rect(this, *clip); - SPCanvasImpl::add_idle(this); +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(); } /** @@ -2266,8 +2090,8 @@ void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); - if (worldx) *worldx = canvas->x0 + winx; - if (worldy) *worldy = canvas->y0 + winy; + if (worldx) *worldx = canvas->_x0 + winx; + if (worldy) *worldy = canvas->_y0 + winy; } /** @@ -2278,8 +2102,8 @@ void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double wor g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); - if (winx) *winx = worldx - canvas->x0; - if (winy) *winy = worldy - canvas->y0; + if (winx) *winx = worldx - canvas->_x0; + if (winy) *winy = worldy - canvas->_y0; } /** @@ -2290,7 +2114,7 @@ Geom::Point sp_canvas_window_to_world(SPCanvas const *canvas, Geom::Point const g_assert (canvas != NULL); g_assert (SP_IS_CANVAS (canvas)); - return Geom::Point(canvas->x0 + win[0], canvas->y0 + win[1]); + return Geom::Point(canvas->_x0 + win[0], canvas->_y0 + win[1]); } /** @@ -2301,7 +2125,7 @@ Geom::Point sp_canvas_world_to_window(SPCanvas const *canvas, Geom::Point const g_assert (canvas != NULL); g_assert (SP_IS_CANVAS (canvas)); - return Geom::Point(world[0] - canvas->x0, world[1] - canvas->y0); + return Geom::Point(world[0] - canvas->_x0, world[1] - canvas->_y0); } /** @@ -2317,10 +2141,10 @@ bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const GtkWidget *w = GTK_WIDGET(canvas); gtk_widget_get_allocation (w, &allocation); - return ( ( canvas->x0 <= world[Geom::X] ) && - ( canvas->y0 <= world[Geom::Y] ) && - ( world[Geom::X] < canvas->x0 + allocation.width ) && - ( world[Geom::Y] < canvas->y0 + allocation.height ) ); + return ( ( canvas->_x0 <= world[Geom::X] ) && + ( canvas->_y0 <= world[Geom::Y] ) && + ( world[Geom::X] < canvas->_x0 + allocation.width ) && + ( world[Geom::Y] < canvas->_y0 + allocation.height ) ); } /** @@ -2331,8 +2155,8 @@ Geom::Rect SPCanvas::getViewbox() const GtkAllocation allocation; gtk_widget_get_allocation (GTK_WIDGET (this), &allocation); - return Geom::Rect(Geom::Point(dx0, dy0), - Geom::Point(dx0 + allocation.width, dy0 + allocation.height)); + return Geom::Rect(Geom::Point(_dx0, _dy0), + Geom::Point(_dx0 + allocation.width, _dy0 + allocation.height)); } /** @@ -2344,8 +2168,8 @@ Geom::IntRect SPCanvas::getViewboxIntegers() const gtk_widget_get_allocation (GTK_WIDGET(this), &allocation); Geom::IntRect ret; - ret.setMin(Geom::IntPoint(x0, y0)); - ret.setMax(Geom::IntPoint(x0 + allocation.width, y0 + allocation.height)); + ret.setMin(Geom::IntPoint(_x0, _y0)); + ret.setMax(Geom::IntPoint(_x0 + allocation.width, _y0 + allocation.height)); return ret; } @@ -2359,64 +2183,24 @@ inline int sp_canvas_tile_ceil(int x) return ((x + (TILE_SIZE - 1)) & (~(TILE_SIZE - 1))) / TILE_SIZE; } -void SPCanvasImpl::sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb) -{ - if ( nl >= nr || nt >= nb ) { - if ( canvas->tiles ) g_free(canvas->tiles); - canvas->tLeft=canvas->tTop=canvas->tRight=canvas->tBottom=0; - canvas->tileH=canvas->tileV=0; - canvas->tiles=NULL; - return; - } - int tl=sp_canvas_tile_floor(nl); - int tt=sp_canvas_tile_floor(nt); - int tr=sp_canvas_tile_ceil(nr); - int tb=sp_canvas_tile_ceil(nb); - - int nh = tr-tl, nv = tb-tt; - uint8_t* ntiles = (uint8_t*)g_malloc(nh*nv*sizeof(uint8_t)); - for (int i=tl; i<tr; i++) { - for (int j=tt; j<tb; j++) { - int ind = (i-tl) + (j-tt)*nh; - if ( i >= canvas->tLeft && i < canvas->tRight && j >= canvas->tTop && j < canvas->tBottom ) { - ntiles[ind]=canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH]; // copy from the old tile - } else { - ntiles[ind]=0; // newly exposed areas get 0 - } - } - } - if ( canvas->tiles ) g_free(canvas->tiles); - canvas->tiles=ntiles; - canvas->tLeft=tl; - canvas->tTop=tt; - canvas->tRight=tr; - canvas->tBottom=tb; - canvas->tileH=nh; - canvas->tileV=nv; +void SPCanvas::dirtyRect(Geom::IntRect const &area) { + markRect(area, 1); } -void SPCanvasImpl::sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) { - canvas->need_redraw = TRUE; - - sp_canvas_mark_rect(canvas, 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 SPCanvasImpl::sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val) +void SPCanvas::markRect(Geom::IntRect const &area, uint8_t val) { - int tl=sp_canvas_tile_floor(area.left()); - int tt=sp_canvas_tile_floor(area.top()); - int tr=sp_canvas_tile_ceil(area.right()); - int tb=sp_canvas_tile_ceil(area.bottom()); - if ( tl >= canvas->tRight || tr <= canvas->tLeft || tt >= canvas->tBottom || tb <= canvas->tTop ) return; - if ( tl < canvas->tLeft ) tl=canvas->tLeft; - if ( tr > canvas->tRight ) tr=canvas->tRight; - if ( tt < canvas->tTop ) tt=canvas->tTop; - if ( tb > canvas->tBottom ) tb=canvas->tBottom; - - for (int i=tl; i<tr; i++) { - for (int j=tt; j<tb; j++) { - canvas->tiles[(i-canvas->tLeft)+(j-canvas->tTop)*canvas->tileH] = val; - } + cairo_rectangle_int_t crect = { area.left(), area.top(), area.width(), area.height() }; + if (val) { + cairo_region_subtract_rectangle(_clean_region, &crect); + } else { + cairo_region_union_rectangle(_clean_region, &crect); } } diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 65b06ade8..171fdaf67 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -11,9 +11,11 @@ * Raph Levien <raph@gimp.org> * Lauris Kaplinski <lauris@kaplinski.com> * Jon A. Cruz <jon@joncruz.org> + * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> * * Copyright (C) 1998 The Free Software Foundation * Copyright (C) 2002 Lauris Kaplinski + * Copyright (C) 2016 Google Inc. * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -60,7 +62,7 @@ G_END_DECLS // SPCanvas ------------------------------------------------- -class SPCanvasImpl; +struct PaintRectSetup; GType sp_canvas_get_type() G_GNUC_CONST; @@ -68,123 +70,183 @@ GType sp_canvas_get_type() G_GNUC_CONST; * Port of GnomeCanvas for inkscape needs. */ struct SPCanvas { - friend class SPCanvasImpl; + /// Scrolls canvas to specific position (cx and cy are measured in screen pixels). + void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false); - /** - * Returns new canvas as widget. - */ - static GtkWidget *createAA(); + /// Synchronously updates the canvas if necessary. + void updateNow(); - /** - * Returns the root group of the specified canvas. - */ + /// Queues a redraw of rectangular canvas area. + void requestRedraw(int x1, int y1, int x2, int y2); + void requestUpdate(); + + void forceFullRedrawAfterInterruptions(unsigned int count); + void endForcedFullRedraws(); + + Geom::Rect getViewbox() const; + Geom::IntRect getViewboxIntegers() const; SPCanvasGroup *getRoot(); - /** - * Scrolls canvas to specific position (cx and cy are measured in screen pixels). - */ - void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false); + void setBackgroundColor(guint32 rgba); + void setBackgroundCheckerboard(); + /// Returns new canvas as widget. + static GtkWidget *createAA(); - /** - * Updates canvas if necessary. - */ - void updateNow(); +private: + /// Emits an event for an item in the canvas, be it the current + /// item, grabbed item, or focused item, as appropriate. + int emitEvent(GdkEvent *event); - /** - * Forces redraw of rectangular canvas area. - */ - void requestRedraw(int x1, int y1, int x2, int y2); + /// Re-picks the current item in the canvas, based on the event's + /// coordinates and emits enter/leave events for items as appropriate. + int pickCurrentItem(GdkEvent *event); + void shutdownTransients(); + + /// Allocates a new tile array for the canvas, copying overlapping tiles from the old array + void resizeTiles(int nl, int nt, int nr, int nb); + + /// Marks the specified area as dirty (requiring redraw) + void dirtyRect(Geom::IntRect const &area); + /// Marks the whole widget for redraw + void dirtyAll(); + void markRect(Geom::IntRect const &area, uint8_t val); + + /// Invokes update, paint, and repick on canvas. + int doUpdate(); + + void paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int sw); /** - * Force a full redraw after a specified number of interrupted redraws. + * Paint the given rect, recursively subdividing the region until it is the size of a single + * buffer. + * + * @return true if the drawing completes */ - void forceFullRedrawAfterInterruptions(unsigned int count); + int paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const &this_rect); + + /// Draws a specific rectangular part of the canvas. + /// @return true if the rectangle painting succeeds. + bool paintRect(int xx0, int yy0, int xx1, int yy1); + + /// Repaints the areas in the canvas that need it. + /// @return true if all the dirty parts have been redrawn + int paint(); + + /// Idle handler for the canvas that deals with pending updates and redraws. + static gint idle_handler(gpointer data); + + /// Convenience function to add an idle handler to a canvas. + void addIdle(); + void removeIdle(); + +public: + // GTK virtual functions. + static void dispose(GObject *object); + static void handle_realize(GtkWidget *widget); + static void handle_unrealize(GtkWidget *widget); +#if GTK_CHECK_VERSION(3,0,0) + static void handle_get_preferred_width(GtkWidget *widget, gint *min_w, gint *nat_w); + static void handle_get_preferred_height(GtkWidget *widget, gint *min_h, gint *nat_h); +#else + static void handle_size_request(GtkWidget *widget, GtkRequisition *req); +#endif + static void handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation); + static gint handle_button(GtkWidget *widget, GdkEventButton *event); /** - * End forced full redraw requests. + * Scroll event handler for the canvas. + * + * @todo FIXME: generate motion events to re-select items. */ - void endForcedFullRedraws(); - + static gint handle_scroll(GtkWidget *widget, GdkEventScroll *event); + static gint handle_motion(GtkWidget *widget, GdkEventMotion *event); + static gboolean handle_draw(GtkWidget *widget, cairo_t *cr); +#if !GTK_CHECK_VERSION(3,0,0) + static gboolean handle_expose(GtkWidget *widget, GdkEventExpose *event); +#endif + static gint handle_key_event(GtkWidget *widget, GdkEventKey *event); + static gint handle_crossing(GtkWidget *widget, GdkEventCrossing *event); + static gint handle_focus_in(GtkWidget *widget, GdkEventFocus *event); + static gint handle_focus_out(GtkWidget *widget, GdkEventFocus *event); +public: // Data members: ---------------------------------------------------------- + GtkWidget _widget; - GtkWidget widget; + guint _idle_id; - guint idle_id; + SPCanvasItem *_root; - SPCanvasItem *root; + bool _is_dragging; + double _dx0; + double _dy0; + int _x0; ///< World coordinate of the leftmost pixels + int _y0; ///< World coordinate of the topmost pixels - bool is_dragging; - double dx0; - double dy0; - int x0; - int y0; + /// 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; - /* Area that needs redrawing, stored as a microtile array */ - int tLeft, tTop, tRight, tBottom; - int tileH, tileV; - uint8_t *tiles; - - /** Last known modifier state, for deferred repick when a button is down. */ - int state; + /// Last known modifier state, for deferred repick when a button is down. + int _state; /** The item containing the mouse pointer, or NULL if none. */ - SPCanvasItem *current_item; + SPCanvasItem *_current_item; /** Item that is about to become current (used to track deletions and such). */ - SPCanvasItem *new_current_item; + SPCanvasItem *_new_current_item; /** Item that holds a pointer grab, or NULL if none. */ - SPCanvasItem *grabbed_item; + SPCanvasItem *_grabbed_item; /** Event mask specified when grabbing an item. */ - guint grabbed_event_mask; + guint _grabbed_event_mask; /** If non-NULL, the currently focused item. */ - SPCanvasItem *focused_item; + SPCanvasItem *_focused_item; /** Event on which selection of current item is based. */ - GdkEvent pick_event; + GdkEvent _pick_event; - int close_enough; + int _close_enough; - unsigned int need_update : 1; - unsigned int need_redraw : 1; - unsigned int need_repick : 1; + unsigned int _need_update : 1; + unsigned int _need_repick : 1; - int forced_redraw_count; - int forced_redraw_limit; + int _forced_redraw_count; + int _forced_redraw_limit; /** For use by internal pick_current_item() function. */ - unsigned int left_grabbed_item : 1; + unsigned int _left_grabbed_item : 1; /** For use by internal pick_current_item() function. */ - unsigned int in_repick : 1; + unsigned int _in_repick : 1; // In most tools Inkscape only generates enter and leave events // on the current item, but no other enter events if a mouse button - // is depressed -- see function pick_current_item(). Some tools + // is depressed -- see function pickCurrentItem(). Some tools // may wish the canvas to generate to all enter events, (e.g., the // connector tool). If so, they may temporarily set this flag to // 'true'. - bool gen_all_enter_events; + bool _gen_all_enter_events; /** For scripting, sometimes we want to delay drawing. */ - bool drawing_disabled; + bool _drawing_disabled; - int rendermode; - int colorrendermode; + int _rendermode; + int _colorrendermode; #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - bool enable_cms_display_adj; - Glib::ustring cms_key; + bool _enable_cms_display_adj; + Glib::ustring _cms_key; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - bool is_scrolling; - - Geom::Rect getViewbox() const; - Geom::IntRect getViewboxIntegers() const; + bool _is_scrolling; }; bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world); 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<SPItem*> *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/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 21e652563..a5352d0ba 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -14,6 +14,7 @@ set(extension_SRC print.cpp system.cpp timer.cpp + loader.cpp implementation/implementation.cpp implementation/xslt.cpp @@ -90,6 +91,7 @@ set(extension_SRC print.h system.h timer.h + loader.h implementation/implementation.h implementation/script.h @@ -244,21 +246,10 @@ 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}") add_inkscape_source("${extension_SRC}") + +add_subdirectory( plugins ) diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert index 4e75de13a..fb9713904 100644 --- a/src/extension/Makefile_insert +++ b/src/extension/Makefile_insert @@ -13,6 +13,8 @@ ink_common_sources += \ extension/execution-env.h \ extension/init.cpp \ extension/init.h \ + extension/loader.h \ + extension/loader.cpp \ extension/param/parameter.h \ extension/param/parameter.cpp \ extension/param/notebook.h \ 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() diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 121a49a25..d0a2e81aa 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1052,7 +1052,7 @@ void document_interface_pause_updates(DocumentInterface *doc_interface, GError * SPDesktop *desk = doc_interface->target.getDesktop(); g_return_if_fail(ensure_desktop_valid(desk, error)); doc_interface->updates = FALSE; - desk->canvas->drawing_disabled = 1; + desk->canvas->_drawing_disabled = 1; } void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error) @@ -1060,7 +1060,7 @@ void document_interface_resume_updates(DocumentInterface *doc_interface, GError SPDesktop *desk = doc_interface->target.getDesktop(); g_return_if_fail(ensure_desktop_valid(desk, error)); doc_interface->updates = TRUE; - desk->canvas->drawing_disabled = 0; + desk->canvas->_drawing_disabled = 0; //FIXME: use better verb than rect. Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions"); } diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index e46b6fbd2..624be12f9 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -235,6 +235,18 @@ bool Dependency::check (void) const } /** + \brief Accessor to the name attribute. + \return A string containing the name of the dependency. + + Returns the name of the dependency as found in the configuration file. + +*/ +const gchar* Dependency::get_name() +{ + return _string; +} + +/** \brief Print out a dependency to a string. */ std::ostream & diff --git a/src/extension/dependency.h b/src/extension/dependency.h index 829912dc3..8f5dcc0c8 100644 --- a/src/extension/dependency.h +++ b/src/extension/dependency.h @@ -58,6 +58,7 @@ public: Dependency (Inkscape::XML::Node * in_repr); virtual ~Dependency (void); bool check (void) const; + const gchar* get_name(); Glib::ustring &get_help (void) const; Glib::ustring &get_link (void) const; diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 31491605b..d5c80f26e 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) { } SPDesktop *desktop = (SPDesktop *)_doc; - GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget)); + GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(desktop->canvas)); if (!toplevel || !gtk_widget_is_toplevel (toplevel)) return; Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false); diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index e96fd6437..57142bbdd 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -34,6 +34,18 @@ #include <Magick++.h> #endif +#define noIMAGE_RESOLUTION_DEBUG + +#ifdef IMAGE_RESOLUTION_DEBUG +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /* */ +#endif + namespace Inkscape { namespace Extension { namespace Internal { @@ -118,17 +130,38 @@ void ImageResolution::readpng(char const *fn) { png_read_info(png_ptr, info_ptr); png_uint_32 res_x, res_y; +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED + debug("PNG_INCH_CONVERSIONS_SUPPORTED"); + res_x = png_get_x_pixels_per_inch(png_ptr, info_ptr); + res_y = png_get_y_pixels_per_inch(png_ptr, info_ptr); + if (res_x != 0 && res_y != 0) { + ok_ = true; + x_ = res_x * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok? + y_ = res_y * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok? + } +#else + debug("PNG_RESOLUTION_METER"); int unit_type; + // FIXME: png_get_pHYs() fails to return expected values + // with clang (based on LLVM 3.2svn) from Xcode 4.6.3 (OS X 10.7.5) png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - fclose(fp); - if (unit_type == PNG_RESOLUTION_METER) { ok_ = true; x_ = res_x * 2.54 / 100; y_ = res_y * 2.54 / 100; } +#endif + + png_destroy_read_struct(&png_ptr, &info_ptr, 0); + fclose(fp); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -206,6 +239,13 @@ void ImageResolution::readexif(char const *fn) { ok_ = true; } exif_data_free(ed); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -256,6 +296,13 @@ void ImageResolution::readexiv(char const *fn) { } } ok_ = havex && havey; + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -312,6 +359,7 @@ void ImageResolution::readjfif(char const *fn) { jpeg_stdio_src(&cinfo, ifd); jpeg_read_header(&cinfo, TRUE); + debug("cinfo.[XY]_density"); if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen if ( cinfo.density_unit == 1 ) { // dots/inch x_ = cinfo.X_density; @@ -331,6 +379,13 @@ void ImageResolution::readjfif(char const *fn) { } jpeg_destroy_decompress(&cinfo); fclose(ifd); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -344,16 +399,17 @@ void ImageResolution::readjfif(char const *) { #ifdef WITH_IMAGE_MAGICK void ImageResolution::readmagick(char const *fn) { Magick::Image image; + debug("Trying image.read"); try { image.read(fn); } catch (Magick::Error & err) { - g_warning("ImageMagick error: %s", err.what()); + debug("ImageMagick error: %s", err.what()); return; - } catch (...) { - g_warning("ImageResolution::readmagick: Unknown error"); + } catch (std::exception & err) { + debug("ImageResolution::readmagick: %s", err.what()); return; } - + debug("image.[xy]Resolution"); std::string const type = image.magick(); x_ = image.xResolution(); y_ = image.yResolution(); @@ -367,6 +423,14 @@ void ImageResolution::readmagick(char const *fn) { if (x_ != 0 && y_ != 0) { ok_ = true; } + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + debug("Using default Inkscape import resolution"); + } } #else diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp new file mode 100644 index 000000000..863a176ca --- /dev/null +++ b/src/extension/loader.cpp @@ -0,0 +1,137 @@ +/* + * Loader for external plug-ins. + * + * Authors: + * Moritz Eberl <moritz@semiodesk.com> + * + * Copyright (C) 2016 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "loader.h" +#include "system.h" +#include <exception> +#include <string.h> +#include "dependency.h" +#include "inkscape-version.h" + +namespace Inkscape { +namespace Extension { + +typedef Implementation::Implementation *(*_getImplementation)(void); +typedef const gchar *(*_getInkscapeVersion)(void); + +bool Loader::load_dependency(Dependency *dep) +{ + GModule *module = NULL; + module = g_module_open(dep->get_name(), (GModuleFlags)0); + if (module == NULL) { + return false; + } + return true; +} + +/** + * @brief Load the actual implementation of a plugin supplied by the plugin. + * @param doc The xml representation of the INX extension configuration. + * @return The implementation of the extension loaded from the plugin. + */ +Implementation::Implementation *Loader::load_implementation(Inkscape::XML::Document *doc) +{ + try { + + Inkscape::XML::Node *repr = doc->root(); + Inkscape::XML::Node *child_repr = repr->firstChild(); + + // Iterate over the xml content + while (child_repr != NULL) { + char const *chname = child_repr->name(); + if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + chname += strlen(INKSCAPE_EXTENSION_NS); + } + + // Deal with dependencies if we have them + if (!strcmp(chname, "dependency")) { + Dependency dep = Dependency(child_repr); + // try to load it + bool success = load_dependency(&dep); + if( !success ){ + // Could not load dependency, we abort + const char *res = g_module_error(); + g_warning("Unable to load dependency %s of plugin %s.\nDetails: %s\n", dep.get_name(), "<todo>", res); + return NULL; + } + } + + // Found a plugin to load + if (!strcmp(chname, "plugin")) { + + // The name of the plugin is actually the library file we want to load + if (const gchar *name = child_repr->attribute("name")) { + GModule *module = NULL; + _getImplementation GetImplementation = NULL; + _getInkscapeVersion GetInkscapeVersion = NULL; + + // build the path where to look for the plugin + gchar *path = g_build_filename(_baseDirectory.c_str(), name, (char *) NULL); + module = g_module_open(path, G_MODULE_BIND_LOCAL); + g_free(path); + + if (module == NULL) { + // we were not able to load the plugin, write warning and abort + const char *res = g_module_error(); + g_warning("Unable to load extension %s.\nDetails: %s\n", name, res); + return NULL; + } + + // Get a handle to the version function of the module + if (g_module_symbol(module, "GetInkscapeVersion", (gpointer *) &GetInkscapeVersion) == FALSE) { + // This didn't work, write warning and abort + const char *res = g_module_error(); + g_warning("Unable to load extension %s.\nDetails: %s\n", name, res); + return NULL; + } + + // Get a handle to the function that delivers the implementation + if (g_module_symbol(module, "GetImplementation", (gpointer *) &GetImplementation) == FALSE) { + // This didn't work, write warning and abort + const char *res = g_module_error(); + g_warning("Unable to load extension %s.\nDetails: %s\n", name, res); + return NULL; + } + + // Get version and test against this version + const gchar* version = GetInkscapeVersion(); + if( strcmp(version, version_string) != 0) { + // The versions are different, display warning. + g_warning("Plugin was built against Inkscape version %s, this is %s. The plugin might not be compatible.", version, version_string); + } + + + Implementation::Implementation *i = GetImplementation(); + return i; + } + } + + child_repr = child_repr->next(); + } + } catch (std::exception &e) { + g_warning("Unable to load extension."); + } + return NULL; +} + +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99: diff --git a/src/extension/loader.h b/src/extension/loader.h new file mode 100644 index 000000000..0d3a69061 --- /dev/null +++ b/src/extension/loader.h @@ -0,0 +1,73 @@ +/** @file + * Loader for external plug-ins. + *//* + * + * Authors: + * Moritz Eberl <moritz@semiodesk.com> + * + * Copyright (C) 2016 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_EXTENSION_LOADER_H_ +#define INKSCAPE_EXTENSION_LOADER_H_ + +#include "extension.h" +#include "implementation/implementation.h" +#include <gmodule.h> + + +namespace Inkscape { +namespace Extension { + +/** This class contains the mechanism to load c++ plugins dynamically. +*/ +class Loader { + +public: + /** + * Sets a base directory where to look for the actual plugin to load. + * + * @param dir is the path where the plugin should be loaded from. + */ + void set_base_directory(std::string dir) { + _baseDirectory = dir; + } + + /** + * Loads plugin dependencies which are needed for the plugin to load. + * + * @param dep + */ + bool load_dependency(Dependency *dep); + + /** + * Load the actual implementation of a plugin supplied by the plugin. + * + * @param doc The xml representation of the INX extension configuration. + * @return The implementation of the extension loaded from the plugin. + */ + Implementation::Implementation *load_implementation(Inkscape::XML::Document *doc); + +private: + std::string _baseDirectory; /**< The base directory to load a plugin from */ + + +}; + +} // namespace Extension +} // namespace Inkscape */ + +#endif // _LOADER_H_ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace .0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99: diff --git a/src/extension/plugins/CMakeLists.txt b/src/extension/plugins/CMakeLists.txt new file mode 100644 index 000000000..78f268c6b --- /dev/null +++ b/src/extension/plugins/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(grid2) diff --git a/src/extension/plugins/grid2/CMakeLists.txt b/src/extension/plugins/grid2/CMakeLists.txt new file mode 100644 index 000000000..f39e259de --- /dev/null +++ b/src/extension/plugins/grid2/CMakeLists.txt @@ -0,0 +1,8 @@ +set(grid_PART_SRCS grid.cpp) + +include_directories( ${CMAKE_BINARY_DIR}/src ) + +add_library(grid2 SHARED ${grid_PART_SRCS}) + +target_link_libraries(grid2 inkscape_base) + diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp new file mode 100644 index 000000000..3a2ed7867 --- /dev/null +++ b/src/extension/plugins/grid2/grid.cpp @@ -0,0 +1,220 @@ +/** + \file grid.cpp + + A plug-in to add a grid creation effect into Inkscape. +*/ +/* + * Copyright (C) 2004-2005 Ted Gould <ted@gould.cx> + * Copyright (C) 2007 MenTaLguY <mental@rydia.net> + * Abhishek Sharma + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <gtkmm/box.h> +#include <gtkmm/adjustment.h> +#include <gtkmm/spinbutton.h> + +#include "desktop.h" + +#include "document.h" +#include "selection.h" +#include "sp-object.h" +#include "2geom/geom.h" + +#include "svg/path-string.h" + +#include "extension/effect.h" +#include "extension/system.h" + +#include "util/units.h" + +#include "grid.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +/** + \brief A function to allocated anything -- just an example here + \param module Unused + \return Whether the load was sucessful +*/ +bool +Grid::load (Inkscape::Extension::Extension */*module*/) +{ + // std::cout << "Hey, I'm Grid, I'm loading!" << std::endl; + return TRUE; +} + +namespace { + +Glib::ustring build_lines(Geom::Rect bounding_area, + Geom::Point const &offset, Geom::Point const &spacing) +{ + + std::cout << "Building lines" << std::endl; + + Geom::Point point_offset(0.0, 0.0); + + SVG::PathString path_data; + + for ( int axis = Geom::X ; axis <= Geom::Y ; ++axis ) { + point_offset[axis] = offset[axis]; + + for (Geom::Point start_point = bounding_area.min(); + start_point[axis] + offset[axis] <= (bounding_area.max())[axis]; + start_point[axis] += spacing[axis]) { + Geom::Point end_point = start_point; + end_point[1-axis] = (bounding_area.max())[1-axis]; + + path_data.moveTo(start_point + point_offset) + .lineTo(end_point + point_offset); + } + } + std::cout << "Path data:" << path_data.c_str() << std::endl; + return path_data; +} + +} // namespace + +/** + \brief This actually draws the grid. + \param module The effect that was called (unused) + \param document What should be edited. +*/ +void +Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/) +{ + + std::cout << "Executing effect" << std::endl; + + Inkscape::Selection * selection = ((SPDesktop *)document)->selection; + + Geom::Rect bounding_area = Geom::Rect(Geom::Point(0,0), Geom::Point(100,100)); + if (selection->isEmpty()) { + /* get page size */ + SPDocument * doc = document->doc(); + bounding_area = Geom::Rect( Geom::Point(0,0), + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) ); + } else { + Geom::OptRect bounds = selection->visualBounds(); + if (bounds) { + bounding_area = *bounds; + } + + gdouble doc_height = (document->doc())->getHeight().value("px"); + Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]), + Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y])); + + bounding_area = temprec; + } + + gdouble scale = Inkscape::Util::Quantity::convert(1, "px", &document->doc()->getSVGUnit()); + bounding_area *= Geom::Scale(scale); + Geom::Point spacings( scale * module->get_param_float("xspacing"), + scale * module->get_param_float("yspacing") ); + gdouble line_width = scale * module->get_param_float("lineWidth"); + Geom::Point offsets( scale * module->get_param_float("xoffset"), + scale * module->get_param_float("yoffset") ); + + Glib::ustring path_data(""); + + path_data = build_lines(bounding_area, offsets, spacings); + Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc(); + + //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr(); + Inkscape::XML::Node * path = xml_doc->createElement("svg:path"); + + path->setAttribute("d", path_data.c_str()); + + Glib::ustring style("fill:none;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"); + style += ";stroke-width:"; + gchar floatstring[64]; + std::ostringstream stringstream; + stringstream << line_width; + sprintf(floatstring, "%s", stringstream.str().c_str()); + style += floatstring; + style += "pt"; + path->setAttribute("style", style.c_str()); + + current_layer->appendChild(path); + Inkscape::GC::release(path); +} + +/** \brief A class to make an adjustment that uses Extension params */ +class PrefAdjustment : public Gtk::Adjustment { + /** Extension that this relates to */ + Inkscape::Extension::Extension * _ext; + /** The string which represents the parameter */ + char * _pref; +public: + /** \brief Make the adjustment using an extension and the string + describing the parameter. */ + PrefAdjustment(Inkscape::Extension::Extension * ext, char * pref) : + Gtk::Adjustment(0.0, 0.0, 10.0, 0.1), _ext(ext), _pref(pref) { + this->set_value(_ext->get_param_float(_pref)); + this->signal_value_changed().connect(sigc::mem_fun(this, &PrefAdjustment::val_changed)); + return; + }; + + void val_changed (void); +}; /* class PrefAdjustment */ + +/** \brief A function to respond to the value_changed signal from the + adjustment. + + This function just grabs the value from the adjustment and writes + it to the parameter. Very simple, but yet beautiful. +*/ +void +PrefAdjustment::val_changed (void) +{ + // std::cout << "Value Changed to: " << this->get_value() << std::endl; + _ext->set_param_float(_pref, this->get_value()); + return; +} + +/** \brief A function to get the prefences for the grid + \param moudule Module which holds the params + \param view Unused today - may get style information in the future. + + Uses AutoGUI for creating the GUI. +*/ +Gtk::Widget * +Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/) +{ + SPDocument * current_document = view->doc(); + + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + Inkscape::XML::Node * first_select = NULL; + if (!selected.empty()) { + first_select = selected[0]->getRepr(); + } + + return module->autogui(current_document, first_select, changeSignal); +} + + + + +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/plugins/grid2/grid.h b/src/extension/plugins/grid2/grid.h new file mode 100644 index 000000000..b4997bb18 --- /dev/null +++ b/src/extension/plugins/grid2/grid.h @@ -0,0 +1,58 @@ +/* + * Authors: + * Ted Gould <ted@gould.cx> + * + * Copyright (C) 2004-2005 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef __GRID_H + +#include "extension/implementation/implementation.h" + + +#include <glib.h> +#include <gmodule.h> +#include "inkscape-version.cpp" + + + +namespace Inkscape { +namespace Extension { + +class Effect; +class Extension; + +namespace Internal { + +/** \brief Implementation class of the GIMP gradient plugin. This mostly + just creates a namespace for the GIMP gradient plugin today. +*/ +class Grid : public Inkscape::Extension::Implementation::Implementation { + +public: + bool load(Inkscape::Extension::Extension *module); + void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); + Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); + +}; + +}; /* namespace Internal */ +}; /* namespace Extension */ +}; /* namespace Inkscape */ + +extern "C" G_MODULE_EXPORT Inkscape::Extension::Implementation::Implementation* GetImplementation() { return new Inkscape::Extension::Internal::Grid(); } +extern "C" G_MODULE_EXPORT const gchar* GetInkscapeVersion() { return Inkscape::version_string; } +#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 : diff --git a/src/extension/plugins/grid2/libgrid2.inx b/src/extension/plugins/grid2/libgrid2.inx new file mode 100644 index 000000000..0360d37e3 --- /dev/null +++ b/src/extension/plugins/grid2/libgrid2.inx @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> +<_name>Grid2</_name> +<id>org.inkscape.effect.grid2</id> +<param name="lineWidth" _gui-text="Line Width:" type="float">1.0</param> +<param name="xspacing" _gui-text="Horizontal Spacing:" type="float" min="0.1" max="1000">10.0</param> +<param name="yspacing" _gui-text="Vertical Spacing:" type="float" min="0.1" max="1000">10.0</param> +<param name="xoffset" _gui-text="Horizontal Offset:" type="float" min="0.0" max="1000">0.0</param> +<param name="yoffset" _gui-text="Vertical Offset:" type="float" min="0.0" max="1000">0.0</param> +<effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Render" > + <submenu _name="Grids" /> + </submenu> + </effects-menu> +<_menu-tip>Draw a path which is a grid</_menu-tip> +</effect> +<plugin name="libgrid2" /> +</inkscape-extension> diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 6a95717f2..3c623455a 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -39,6 +39,7 @@ #include "io/sys.h" #include "inkscape.h" #include "document-undo.h" +#include "loader.h" namespace Inkscape { @@ -46,7 +47,7 @@ namespace Extension { static void open_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data); static void save_internal(Inkscape::Extension::Extension *in_plug, gpointer in_data); -static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp); +static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir); /** * \return A new document created from the filename passed in @@ -421,12 +422,12 @@ get_print(gchar const *key) * case could apply to modules that are built in (like the SVG load/save functions). */ static Extension * -build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp) +build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation *in_imp, std::string* baseDir) { enum { MODULE_EXTENSION, MODULE_XSLT, - /* MODULE_PLUGIN, */ + MODULE_PLUGIN, MODULE_UNKNOWN_IMP } module_implementation_type = MODULE_UNKNOWN_IMP; enum { @@ -465,10 +466,8 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation module_implementation_type = MODULE_EXTENSION; } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "xslt")) { module_implementation_type = MODULE_XSLT; -#if 0 - } else if (!strcmp(element_name, "plugin")) { + } else if (!strcmp(element_name, INKSCAPE_EXTENSION_NS "plugin")) { module_implementation_type = MODULE_PLUGIN; -#endif } //Inkscape::XML::Node *old_repr = child_repr; @@ -489,13 +488,14 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation imp = static_cast<Implementation::Implementation *>(xslt); break; } -#if 0 case MODULE_PLUGIN: { - Implementation::Plugin *plugin = new Implementation::Plugin(); - imp = static_cast<Implementation::Implementation *>(plugin); + Inkscape::Extension::Loader loader = Inkscape::Extension::Loader(); + if( baseDir != NULL){ + loader.set_base_directory ( *baseDir ); + } + imp = loader.load_implementation(doc); break; } -#endif default: { imp = NULL; break; @@ -528,6 +528,7 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation break; } default: { + module = new Extension(repr, imp); break; } } @@ -547,7 +548,8 @@ Extension * build_from_file(gchar const *filename) { Inkscape::XML::Document *doc = sp_repr_read_file(filename, INKSCAPE_EXTENSION_URI); - Extension *ext = build_from_reprdoc(doc, NULL); + std::string dir = Glib::path_get_dirname(filename); + Extension *ext = build_from_reprdoc(doc, NULL, &dir); if (ext != NULL) Inkscape::GC::release(doc); else @@ -569,7 +571,7 @@ build_from_mem(gchar const *buffer, Implementation::Implementation *in_imp) { Inkscape::XML::Document *doc = sp_repr_read_mem(buffer, strlen(buffer), INKSCAPE_EXTENSION_URI); g_return_val_if_fail(doc != NULL, NULL); - Extension *ext = build_from_reprdoc(doc, in_imp); + Extension *ext = build_from_reprdoc(doc, in_imp, NULL); Inkscape::GC::release(doc); return ext; } diff --git a/src/inkscape-version.cpp.in b/src/inkscape-version.cpp.in new file mode 100644 index 000000000..b4ea5028d --- /dev/null +++ b/src/inkscape-version.cpp.in @@ -0,0 +1,7 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +namespace Inkscape { + char const *version_string = VERSION " " "${INKSCAPE_REVISION}"; +} diff --git a/src/inkview.cpp b/src/inkview.cpp index 3fcd9ed8a..db4b1aeb0 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -428,7 +428,8 @@ static int sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data) static void sp_svgview_waiting_cursor(struct SPSlideShow *ss) { - GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), waiting); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(waiting); @@ -436,7 +437,7 @@ static void sp_svgview_waiting_cursor(struct SPSlideShow *ss) gdk_cursor_unref(waiting); #endif if (ctrlwin) { - GdkCursor *waiting = gdk_cursor_new(GDK_WATCH); + GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ctrlwin)), waiting); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(waiting); diff --git a/src/io/inkjar.h b/src/io/inkjar.h index 637c05d80..d7de9ff4a 100644 --- a/src/io/inkjar.h +++ b/src/io/inkjar.h @@ -18,13 +18,7 @@ # include <zlib.h> #endif -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#else -# ifdef HAVE_STDINT_H -# include <stdint.h> -# endif -#endif +#include <stdint.h> #include <glib.h> #include <cstdio> 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/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 <limits> 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<float>::epsilon() || + new_span_height.descent > line_height->descent + std::numeric_limits<float>::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 <limits> namespace Inkscape { namespace Text { @@ -43,7 +44,7 @@ std::vector<Layout::ScanlineMaker::ScanRun> Layout::InfiniteScanlineMaker::makeS { std::vector<ScanRun> 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<float>::max(); // we could use DBL_MAX, but this just seems safer runs[0].y = _y; _current_line_height = line_height; return runs; diff --git a/src/livarot/LivarotDefs.h b/src/livarot/LivarotDefs.h index 49f954586..abeff3861 100644 --- a/src/livarot/LivarotDefs.h +++ b/src/livarot/LivarotDefs.h @@ -9,21 +9,11 @@ #ifndef my_defs #define my_defs -#if defined(WIN32) || defined(__WIN32__) -# include <inttypes.h> -#endif - #ifdef HAVE_CONFIG_H # include "config.h" #endif -#ifdef HAVE_INTTYPES_H -# include <inttypes.h> -#else -# ifdef HAVE_STDINT_H -# include <stdint.h> -# endif -#endif +#include <stdint.h> // error codes (mostly obsolete) enum diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index c6ecba30a..437aed5bd 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -104,7 +104,6 @@ const Util::EnumData<EffectType> LPETypeData[] = { {EXTRUDE, N_("Extrude"), "extrude"}, {LATTICE, N_("Lattice Deformation"), "lattice"}, {LINE_SEGMENT, N_("Line Segment"), "line_segment"}, - {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, {OFFSET, N_("Offset"), "offset"}, {PARALLEL, N_("Parallel"), "parallel"}, {PATH_LENGTH, N_("Path length"), "path_length"}, @@ -144,6 +143,7 @@ const Util::EnumData<EffectType> LPETypeData[] = { {BSPLINE, N_("BSpline"), "bspline"}, {JOIN_TYPE, N_("Join type"), "join_type"}, {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, + {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, /* Ponyscape -> Inkscape 0.92*/ {ATTACH_PATH, N_("Attach path"), "attach_path"}, diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp index 2eef315dd..fe42932be 100644 --- a/src/live_effects/lpe-jointype.cpp +++ b/src/live_effects/lpe-jointype.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2014 Authors * -* Released under GNU GPL v2, read the file 'COPYING' for more information +* Released under GNU GPL v2+, read the file 'COPYING' for more information */ #include "live_effects/parameter/enum.h" diff --git a/src/live_effects/lpe-jointype.h b/src/live_effects/lpe-jointype.h index fddaeb619..ef7abdcc7 100644 --- a/src/live_effects/lpe-jointype.h +++ b/src/live_effects/lpe-jointype.h @@ -3,7 +3,7 @@ *
* Copyright (C) 2014 Authors
*
- * Released under GNU GPL v2, read the file COPYING for more information
+ * Released under GNU GPL v2+, read the file COPYING for more information
*/
#ifndef INKSCAPE_LPE_JOINTYPE_H
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index c13cffb6a..88fee4c47 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -6,36 +6,84 @@ * Maximilian Albert * Johan Engelen * Abhishek Sharma + * Jabiertxof * * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com> * * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include <gtkmm.h> #include <glibmm/i18n.h> #include "live_effects/lpe-mirror_symmetry.h" #include <sp-path.h> #include <display/curve.h> #include <svg/path-string.h> - +#include "helper/geom.h" #include <2geom/path.h> +#include <2geom/path-intersection.h> #include <2geom/transforms.h> #include <2geom/affine.h> +#include "knot-holder-entity.h" +#include "knotholder.h" +#include "inkscape.h" namespace Inkscape { namespace LivePathEffect { +static const Util::EnumData<ModeType> ModeTypeData[MT_END] = { + { MT_V, N_("Vertical Page Center"), "Vertical Page Center, use select tool to move item instead line" }, + { MT_H, N_("Horizontal Page Center"), "Horizontal Page Center, use select tool to move item instead line" }, + { MT_FREE, N_("Free from reflection line"), "Free from path" }, + { MT_X, N_("X from middle knot"), "X from middle knot" }, + { MT_Y, N_("Y from middle knot"), "Y from middle knot" } +}; +static const Util::EnumDataConverter<ModeType> +MTConverter(ModeTypeData, MT_END); + +namespace MS { + +class KnotHolderEntityCenterMirrorSymmetry : public LPEKnotHolderEntity { +public: + KnotHolderEntityCenterMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){}; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; +}; + +class KnotHolderEntityStartMirrorSymmetry : public LPEKnotHolderEntity { +public: + KnotHolderEntityStartMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){}; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; +}; + +class KnotHolderEntityEndMirrorSymmetry : public LPEKnotHolderEntity { +public: + KnotHolderEntityEndMirrorSymmetry(LPEMirrorSymmetry *effect) : LPEKnotHolderEntity(effect){}; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; +}; + +} // namespace MS + LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : Effect(lpeobject), + mode(_("Mode"), _("Symmetry move mode"), "mode", MTConverter, &wr, this, MT_FREE), discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false), - reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") + fuse_paths(_("Fuse paths"), _("Fuse original and the reflection into a single path"), "fuse_paths", &wr, this, false), + oposite_fuse(_("Oposite fuse"), _("Picks the other side of the mirror as the original"), "oposite_fuse", &wr, this, false), + start_point(_("Start mirror line"), _("Start mirror line"), "start_point", &wr, this, "Adjust the start of mirroring"), + end_point(_("End mirror line"), _("End mirror line"), "end_point", &wr, this, "Adjust end of mirroring") { show_orig_path = true; + registerParameter(&mode); + registerParameter( &discard_orig_path); + registerParameter( &fuse_paths); + registerParameter( &oposite_fuse); + registerParameter( &start_point); + registerParameter( &end_point); apply_to_clippath_and_mask = true; - registerParameter( dynamic_cast<Parameter *>(&discard_orig_path) ); - registerParameter( dynamic_cast<Parameter *>(&reflection_line) ); } LPEMirrorSymmetry::~LPEMirrorSymmetry() @@ -43,60 +91,276 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() } void + +LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) +{ + using namespace Geom; + + Point point_a(boundingbox_X.max(), boundingbox_Y.min()); + Point point_b(boundingbox_X.max(), boundingbox_Y.max()); + Point point_c(boundingbox_X.max(), boundingbox_Y.middle()); + if (mode == MT_Y) { + point_a = Geom::Point(boundingbox_X.min(),center_point[Y]); + point_b = Geom::Point(boundingbox_X.max(),center_point[Y]); + } + if (mode == MT_X) { + point_a = Geom::Point(center_point[X],boundingbox_Y.min()); + point_b = Geom::Point(center_point[X],boundingbox_Y.max()); + } + line_separation.setPoints(point_a, point_b); + if ( mode == MT_X || mode == MT_Y ) { + start_point.param_setValue(point_a); + end_point.param_setValue(point_b); + center_point = Geom::middle_point(point_a, point_b); + } else if ( mode == MT_FREE) { + if(!are_near(previous_center,center_point, 0.01)) { + Geom::Point trans = center_point - previous_center; + start_point.param_setValue(start_point * trans); + end_point.param_setValue(end_point * trans); + line_separation.setPoints(start_point, end_point); + } else { + center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); + line_separation.setPoints(start_point, end_point); + } + } else if ( mode == MT_V){ + if(SP_ACTIVE_DESKTOP){ + SPDocument * doc = SP_ACTIVE_DESKTOP->getDocument(); + Geom::Rect view_box_rect = doc->getViewBox(); + Geom::Point sp = Geom::Point(view_box_rect.width()/2.0, 0); + sp *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse(); + start_point.param_setValue(sp); + Geom::Point ep = Geom::Point(view_box_rect.width()/2.0, view_box_rect.height()); + ep *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse(); + end_point.param_setValue(ep); + center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); + line_separation.setPoints(start_point, end_point); + } + } else { //horizontal page + if(SP_ACTIVE_DESKTOP){ + SPDocument * doc = SP_ACTIVE_DESKTOP->getDocument(); + Geom::Rect view_box_rect = doc->getViewBox(); + Geom::Point sp = Geom::Point(0, view_box_rect.height()/2.0); + sp *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse(); + start_point.param_setValue(sp); + Geom::Point ep = Geom::Point(view_box_rect.width(), view_box_rect.height()/2.0); + ep *= i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(SP_ACTIVE_DESKTOP->currentLayer()->parent)) .inverse(); + end_point.param_setValue(ep); + center_point = Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point); + line_separation.setPoints(start_point, end_point); + } + } + previous_center = center_point; +} + +void LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; - // fixme: what happens if the bbox is empty? - // fixme: this is probably wrong - Geom::Affine t = lpeitem->i2dt_affine(); - Geom::Rect bbox = *lpeitem->desktopVisualBounds(); - - Point A(bbox.left(), bbox.bottom()); - Point B(bbox.left(), bbox.top()); - A *= t; - B *= t; - Piecewise<D2<SBasis> > rline = Piecewise<D2<SBasis> >(D2<SBasis>(SBasis(A[X], B[X]), SBasis(A[Y], B[Y]))); - reflection_line.set_new_value(rline, true); + original_bbox(lpeitem); + + Point point_a(boundingbox_X.max(), boundingbox_Y.min()); + Point point_b(boundingbox_X.max(), boundingbox_Y.max()); + Point point_c(boundingbox_X.max(), boundingbox_Y.middle()); + start_point.param_setValue(point_a); + start_point.param_update_default(point_a); + end_point.param_setValue(point_b); + end_point.param_update_default(point_b); + center_point = point_c; + previous_center = center_point; } + Geom::PathVector LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) { - // Don't allow empty path parameter: - if ( reflection_line.get_pathvector().empty() ) { - return path_in; - } - + Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(path_in); Geom::PathVector path_out; - if (!discard_orig_path) { - path_out = path_in; + + if (!discard_orig_path && !fuse_paths) { + path_out = pathv_to_linear_and_cubic_beziers(path_in); } - Geom::PathVector mline(reflection_line.get_pathvector()); - Geom::Point A(mline.front().initialPoint()); - Geom::Point B(mline.back().finalPoint()); + Geom::Point point_a(line_separation.initialPoint()); + Geom::Point point_b(line_separation.finalPoint()); - Geom::Affine m1(1.0, 0.0, 0.0, 1.0, A[0], A[1]); - double hyp = Geom::distance(A, B); - double c = (B[0] - A[0]) / hyp; // cos(alpha) - double s = (B[1] - A[1]) / hyp; // sin(alpha) + Geom::Translate m1(point_a[0], point_a[1]); + double hyp = Geom::distance(point_a, point_b); + double c = (point_b[0] - point_a[0]) / hyp; // cos(alpha) + double s = (point_b[1] - point_a[1]) / hyp; // sin(alpha) Geom::Affine m2(c, -s, s, c, 0.0, 0.0); - Geom::Affine sca(1.0, 0.0, 0.0, -1.0, 0.0, 0.0); + Geom::Scale sca(1.0, -1.0); Geom::Affine m = m1.inverse() * m2; m = m * sca; m = m * m2.inverse(); m = m * m1; - for (int i = 0; i < static_cast<int>(path_in.size()); ++i) { - path_out.push_back(path_in[i] * m); + if (fuse_paths && !discard_orig_path) { + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) + { + if (path_it->empty()) { + continue; + } + Geom::PathVector tmp_path; + double time_start = 0.0; + int position = 0; + bool end_open = false; + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + if (!are_near(closingline.initialPoint(), closingline.finalPoint())) { + end_open = true; + } + } + Geom::Path original = *path_it; + if (end_open && path_it->closed()) { + original.close(false); + original.appendNew<Geom::LineSegment>( original.initialPoint() ); + original.close(true); + } + Geom::Point s = start_point; + Geom::Point e = end_point; + double dir = line_separation.angle(); + double diagonal = Geom::distance(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max())); + Geom::Rect bbox(Geom::Point(boundingbox_X.min(),boundingbox_Y.min()),Geom::Point(boundingbox_X.max(),boundingbox_Y.max())); + double size_divider = Geom::distance(center_point, bbox) + diagonal; + s = Geom::Point::polar(dir,size_divider) + center_point; + e = Geom::Point::polar(dir + Geom::rad_from_deg(180),size_divider) + center_point; + Geom::Path divider = Geom::Path(s); + divider.appendNew<Geom::LineSegment>(e); + Geom::Crossings cs = crossings(original, divider); + std::vector<double> crossed; + for(unsigned int i = 0; i < cs.size(); i++) { + crossed.push_back(cs[i].ta); + } + std::sort(crossed.begin(), crossed.end()); + for (unsigned int i = 0; i < crossed.size(); i++) { + double time_end = crossed[i]; + if (time_start != time_end && time_end - time_start > Geom::EPSILON) { + Geom::Path portion = original.portion(time_start, time_end); + if (!portion.empty()) { + Geom::Point middle = portion.pointAt((double)portion.size()/2.0); + position = Geom::sgn(Geom::cross(e - s, middle - s)); + if (!oposite_fuse) { + position *= -1; + } + if (position == 1) { + Geom::Path mirror = portion.reversed() * m; + mirror.setInitial(portion.finalPoint()); + portion.append(mirror); + if(i!=0) { + portion.setFinal(portion.initialPoint()); + portion.close(); + } + tmp_path.push_back(portion); + } + portion.clear(); + } + } + time_start = time_end; + } + position = Geom::sgn(Geom::cross(e - s, original.finalPoint() - s)); + if (!oposite_fuse) { + position *= -1; + } + if (cs.size()!=0 && position == 1) { + if (time_start != original.size() && original.size() - time_start > Geom::EPSILON) { + Geom::Path portion = original.portion(time_start, original.size()); + if (!portion.empty()) { + portion = portion.reversed(); + Geom::Path mirror = portion.reversed() * m; + mirror.setInitial(portion.finalPoint()); + portion.append(mirror); + portion = portion.reversed(); + if (!original.closed()) { + tmp_path.push_back(portion); + } else { + if (cs.size() > 1 && tmp_path.size() > 0 && tmp_path[0].size() > 0 ) { + portion.setFinal(tmp_path[0].initialPoint()); + portion.setInitial(tmp_path[0].finalPoint()); + tmp_path[0].append(portion); + } else { + tmp_path.push_back(portion); + } + tmp_path[0].close(); + } + portion.clear(); + } + } + } + if (cs.size() == 0 && position == 1) { + tmp_path.push_back(original); + tmp_path.push_back(original * m); + } + path_out.insert(path_out.end(), tmp_path.begin(), tmp_path.end()); + tmp_path.clear(); + } + } + + if (!fuse_paths || discard_orig_path) { + for (int i = 0; i < static_cast<int>(path_in.size()); ++i) { + path_out.push_back(path_in[i] * m); + } } return path_out; } +void +LPEMirrorSymmetry::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +{ + using namespace Geom; + hp_vec.clear(); + Geom::Path path; + Geom::Point s = start_point; + Geom::Point e = end_point; + path.start( s ); + path.appendNew<Geom::LineSegment>( e ); + Geom::PathVector helper; + helper.push_back(path); + hp_vec.push_back(helper); +} + +void +LPEMirrorSymmetry::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + SPKnotShapeType knot_shape = SP_KNOT_SHAPE_CIRCLE; + SPKnotModeType knot_mode = SP_KNOT_MODE_XOR; + guint32 knot_color = 0x0000ff00; + { + KnotHolderEntity *c = new MS::KnotHolderEntityCenterMirrorSymmetry(this); + c->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the center"), knot_shape, knot_mode, knot_color ); + knotholder->add(c); + } +}; + +namespace MS { + +using namespace Geom; + +void +KnotHolderEntityCenterMirrorSymmetry::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) +{ + LPEMirrorSymmetry* lpe = dynamic_cast<LPEMirrorSymmetry *>(_effect); + Geom::Point const s = snap_knot_position(p, state); + lpe->center_point = s; + + // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); +} + +Geom::Point +KnotHolderEntityCenterMirrorSymmetry::knot_get() const +{ + LPEMirrorSymmetry const *lpe = dynamic_cast<LPEMirrorSymmetry const*>(_effect); + return lpe->center_point; +} + +} // namespace CR + } //namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index 64a72d7b3..3a244cb7e 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -8,6 +8,7 @@ * Authors: * Maximilian Albert * Johan Engelen + * Jabiertxof * * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com> @@ -19,22 +20,50 @@ #include "live_effects/parameter/parameter.h" #include "live_effects/parameter/point.h" #include "live_effects/parameter/path.h" +#include "live_effects/parameter/enum.h" +#include "live_effects/lpegroupbbox.h" namespace Inkscape { namespace LivePathEffect { -class LPEMirrorSymmetry : public Effect { +namespace MS { +// we need a separate namespace to avoid clashes with LPEPerpBisector +class KnotHolderEntityCenterMirrorSymmetry; +} + +enum ModeType { + MT_V, + MT_H, + MT_FREE, + MT_X, + MT_Y, + MT_END +}; + +class LPEMirrorSymmetry : public Effect, GroupBBoxEffect { public: LPEMirrorSymmetry(LivePathEffectObject *lpeobject); virtual ~LPEMirrorSymmetry(); - virtual void doOnApply (SPLPEItem const* lpeitem); - + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); + /* the knotholder entity classes must be declared friends */ + friend class MS::KnotHolderEntityCenterMirrorSymmetry; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + +protected: + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: + EnumParam<ModeType> mode; BoolParam discard_orig_path; - PathParam reflection_line; + BoolParam fuse_paths; + BoolParam oposite_fuse; + PointParam start_point; + PointParam end_point; + Geom::Line line_separation; + Geom::Point previous_center; + Geom::Point center_point; LPEMirrorSymmetry(const LPEMirrorSymmetry&); LPEMirrorSymmetry& operator=(const LPEMirrorSymmetry&); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 9397d848f..911c410f9 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -259,9 +259,16 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) // overriding the Effect class default method, disabling transform forwarding to the parameters. // only take translations into account + // Check if proportional stroke-width scaling is on + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true; + if (transform_stroke && !scale_y_rel) { + prop_scale.param_set_value(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2)); + } if (postmul.isTranslation()) { pattern.param_transform_multiply(postmul, set); } + sp_lpe_item_update_patheffect (sp_lpe_item, false, true); } void diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index 3b9a17ab0..3d7fc02bc 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -42,7 +42,7 @@ public: virtual void transform_multiply(Geom::Affine const& postmul, bool set); void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec); - + virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item); PathParam pattern; 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/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index ade83dfda..496c16d5d 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -4,7 +4,7 @@ * * Copyright (C) 2007 Authors * - * Released under GNU GPL v2, read the file 'COPYING' for more information + * Released under GNU GPL v2+, read the file 'COPYING' for more information */ #include <ui/view/view.h> diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h index c8ef64f10..b8ec4403b 100644 --- a/src/main-cmdlineact.h +++ b/src/main-cmdlineact.h @@ -12,7 +12,7 @@ * * Copyright (C) 2007 Authors * - * Released under GNU GPL v2.x, read the file 'COPYING' for more information + * Released under GNU GPL v2+, read the file 'COPYING' for more information */ namespace Inkscape { diff --git a/src/main.cpp b/src/main.cpp index 840643a90..99e3ccfe6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,6 +52,11 @@ #include <glib-object.h> #include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3,0,0) +#include <gtkmm/cssprovider.h> +#include <gdkmm/screen.h> +#endif + #include "inkgc/gc-core.h" #ifdef AND @@ -1051,6 +1056,35 @@ sp_main_gui(int argc, char const **argv) #endif g_free(usericondir); + +#if GTK_CHECK_VERSION(3,0,0) + // Add style sheet (GTK3) + Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default(); + + Glib::ustring inkscape_style = INKSCAPE_UIDIR; + inkscape_style += "/style.css"; + // std::cout << "CSS Stylesheet Inkscape: " << inkscape_style << std::endl; + Glib::RefPtr<Gtk::CssProvider> provider = Gtk::CssProvider::create(); + try { + provider->load_from_path (inkscape_style); + } + catch (const Gtk::CssProviderError& ex) + { + std::cerr << "CSSProviderError::load_from_path(): failed to load: " << inkscape_style << "\n (" << ex.what() << ")" << std::endl; + } + Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + + Glib::ustring user_style = Inkscape::Application::profile_path("ui/style.css"); + // std::cout << "CSS Stylesheet User: " << user_style << std::endl; + Glib::RefPtr<Gtk::CssProvider> provider2 = Gtk::CssProvider::create(); + try { + provider2->load_from_path (user_style); + } + catch (const Gtk::CssProviderError& ex) + {} + Gtk::StyleContext::add_provider_for_screen (screen, provider2, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +#endif + gdk_event_handler_set((GdkEventFunc)snooper, NULL, NULL); Inkscape::Debug::log_display_config(); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 8cdfbeb05..9c7c65140 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -86,6 +86,8 @@ static char const menus_skeleton[] = " <verb verb-id=\"EditInvert\" />\n" " <verb verb-id=\"EditDeselect\" />\n" " <separator/>\n" +" <verb verb-id=\"FitCanvasToSelectionOrDrawing\" />\n" +" <separator/>\n" " <verb verb-id=\"EditGuidesAroundPage\" />\n" " <verb verb-id=\"EditGuidesToggleLock\" check=\"yes\" />\n" " <verb verb-id=\"EditRemoveAllGuides\" />\n" @@ -188,6 +190,7 @@ static char const menus_skeleton[] = " <separator/>\n" " <verb verb-id=\"SelectionGroup\" />\n" " <verb verb-id=\"SelectionUnGroup\" />\n" +" <verb verb-id=\"SelectionUnGroupPopSelection\" />\n" " <separator/>\n" " <submenu name=\"" N_("Cli_p") "\">\n" " <verb verb-id=\"ObjectSetClipPath\" />\n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index e6d5f174e..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, _("<b>No objects selected</b> to pop out of group.")); + return; + } + std::vector<SPItem*> selection_list = selection->itemList(); + + std::vector<SPItem*>::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<SPItem*>(obj->parent); + if (!SP_IS_GROUP(parent_group) || SP_IS_LAYER(parent_group)) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Selection <b>not in a group</b>.")); + return; + } + if (parent_group->firstChild()->getNext() == NULL) { + std::vector<SPItem*> children; + sp_item_group_ungroup(static_cast<SPGroup*>(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) { @@ -1126,7 +1158,7 @@ void sp_undo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. - if(desktop->getCanvas()->is_dragging) return; + if(desktop->getCanvas()->_is_dragging) return; if (!DocumentUndo::undo(desktop->getDocument())) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); @@ -1137,7 +1169,7 @@ void sp_redo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. - if(desktop->getCanvas()->is_dragging) return; + if(desktop->getCanvas()->_is_dragging) return; if (!DocumentUndo::redo(desktop->getDocument())) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); 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/sp-item.cpp b/src/sp-item.cpp index 4937e6c76..af81194c2 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -568,6 +568,7 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 461445ee0..c37df151c 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -862,7 +862,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = stroke_scale * tr; } - + // total marker transform tr = marker_item->transform * marker->c2p * tr * transform; @@ -1153,7 +1153,9 @@ sp_selected_path_outline(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>stroked path(s)</b> to convert stroke to path.")); return; } - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool scale_stroke = prefs->getBool("/options/transform/stroke", true); + prefs->setBool("/options/transform/stroke", true); bool did = false; std::vector<SPItem*> il(selection->itemList()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ @@ -1503,7 +1505,7 @@ sp_selected_path_outline(SPDesktop *desktop) delete res; delete orig; } - + prefs->setBool("/options/transform/stroke", scale_stroke); if (did) { DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_OUTLINE, _("Convert stroke to path")); diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index c568d3ca7..b1fddd7e6 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -91,8 +91,18 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) vw->canvas = SPCanvas::createAA(); #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA white = {1,1,1,0}; - gtk_widget_override_background_color(vw->canvas, GTK_STATE_FLAG_NORMAL, &white); + GtkCssProvider *css_provider = gtk_css_provider_new(); + GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(vw->canvas)); + + gtk_css_provider_load_from_data(css_provider, + "SPCanvas {\n" + " background-color: white;\n" + "}\n", + -1, NULL); + + gtk_style_context_add_provider(style_context, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); #else gtk_widget_pop_colormap (); GtkStyle *style = gtk_style_copy (gtk_widget_get_style (vw->canvas)); @@ -100,7 +110,7 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) gtk_widget_set_style (vw->canvas, style); #endif -#if GTK_CHECK_VERSION(3,8,0) +#if GTK_CHECK_VERSION(3,0,0) gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas); #else gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (vw->sw), vw->canvas); diff --git a/src/svg-view.cpp b/src/svg-view.cpp index f52608420..53fa8633f 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -103,7 +103,8 @@ void SPSVGView::doRescale(bool event) void SPSVGView::mouseover() { - GdkCursor *cursor = gdk_cursor_new(GDK_HAND2); + GdkDisplay *display = gdk_display_get_default(); + GdkCursor *cursor = gdk_cursor_new_for_display(display, GDK_HAND2); GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)); gdk_window_set_cursor(window, cursor); #if GTK_CHECK_VERSION(3,0,0) 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<Gdk::Pixbuf> Tracer::sioxProcessImage(SPImage *img, Glib::RefPtr<Gd for (aIter = arenaItems.begin() ; aIter!=arenaItems.end() ; ++aIter) { Inkscape::DrawingItem *arenaItem = *aIter; + arenaItem->drawing().update(); if (arenaItem->pick(point, 1.0f, 1)) { weHaveAHit = true; diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index f1d6304cb..eeb99e045 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -1,5 +1,5 @@ /** \file - * SPIcon: Generic icon widget + * SVGPreview: Preview cache */ /* * Authors: diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f0dc33740..d581dbf7e 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -146,8 +146,6 @@ private: void _setClipboardColor(guint32); void _userWarn(SPDesktop *, char const *); - void _inkscape_wait_for_targets(std::list<Glib::ustring> &); - // private properites SPDocument *_clipboardSPDoc; ///< Document that stores the clipboard until someone requests it Inkscape::XML::Node *_defs; ///< Reference to the clipboard document's defs node @@ -1302,9 +1300,11 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons */ Glib::ustring ClipboardManagerImpl::_getBestTarget() { - // GTKmm's wait_for_targets() is broken, see the comment in _inkscape_wait_for_targets() - std::list<Glib::ustring> targets; // = _clipboard->wait_for_targets(); - _inkscape_wait_for_targets(targets); +#if WITH_GTKMM_3_0 + std::vector<Glib::ustring> targets = _clipboard->wait_for_targets(); +#else + std::list<Glib::ustring> targets = _clipboard->wait_for_targets(); +#endif // clipboard target debugging snippet /* @@ -1456,39 +1456,6 @@ void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg); } - -// GTKMM's clipboard::wait_for_targets is buggy and might return bogus, see -// -// https://bugs.launchpad.net/inkscape/+bug/296778 -// http://mail.gnome.org/archives/gtk-devel-list/2009-June/msg00062.html -// -// for details. Until this has been fixed upstream we will use our own implementation -// of this method, as copied from /gtkmm-2.16.0/gtk/gtkmm/clipboard.cc. -void ClipboardManagerImpl::_inkscape_wait_for_targets(std::list<Glib::ustring> &listTargets) -{ - //Get a newly-allocated array of atoms: - GdkAtom* targets = NULL; - gint n_targets = 0; - gboolean test = gtk_clipboard_wait_for_targets( gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), &targets, &n_targets ); - if (!test || (targets == NULL)) { - return; - } - - //Add the targets to the C++ container: - for (int i = 0; i < n_targets; i++) - { - //Convert the atom to a string: - gchar* const atom_name = gdk_atom_name(targets[i]); - - Glib::ustring target; - if (atom_name) { - target = Glib::ScopedPtr<char>(atom_name).get(); //This frees the gchar*. - } - - listTargets.push_back(target); - } -} - /* ####################################### ClipboardManager class ####################################### */ diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index b653a630d..1a87a9718 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -618,288 +618,629 @@ void AboutBox::initStrings() { * This text is copied from the COPYING file */ license_text = - " GNU GENERAL PUBLIC LICENSE\n" - " Version 2, June 1991\n" + " GNU GENERAL PUBLIC LICENSE\n" + " Version 3, 29 June 2007\n" "\n" - " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n" - " 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" + " Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n" " Everyone is permitted to copy and distribute verbatim copies\n" " of this license document, but changing it is not allowed.\n" "\n" - " Preamble\n" + " Preamble\n" "\n" - " The licenses for most software are designed to take away your\n" - "freedom to share and change it. By contrast, the GNU General Public\n" - "License is intended to guarantee your freedom to share and change free\n" - "software--to make sure the software is free for all its users. This\n" - "General Public License applies to most of the Free Software\n" - "Foundation's software and to any other program whose authors commit to\n" - "using it. (Some other Free Software Foundation software is covered by\n" - "the GNU Library General Public License instead.) You can apply it to\n" + " The GNU General Public License is a free, copyleft license for\n" + "software and other kinds of works.\n" + "\n" + " The licenses for most software and other practical works are designed\n" + "to take away your freedom to share and change the works. By contrast,\n" + "the GNU General Public License is intended to guarantee your freedom to\n" + "share and change all versions of a program--to make sure it remains free\n" + "software for all its users. We, the Free Software Foundation, use the\n" + "GNU General Public License for most of our software; it applies also to\n" + "any other work released this way by its authors. You can apply it to\n" "your programs, too.\n" "\n" " When we speak of free software, we are referring to freedom, not\n" "price. Our General Public Licenses are designed to make sure that you\n" "have the freedom to distribute copies of free software (and charge for\n" - "this service if you wish), that you receive source code or can get it\n" - "if you want it, that you can change the software or use pieces of it\n" - "in new free programs; and that you know you can do these things.\n" + "them if you wish), that you receive source code or can get it if you\n" + "want it, that you can change the software or use pieces of it in new\n" + "free programs, and that you know you can do these things.\n" "\n" - " To protect your rights, we need to make restrictions that forbid\n" - "anyone to deny you these rights or to ask you to surrender the rights.\n" - "These restrictions translate to certain responsibilities for you if you\n" - "distribute copies of the software, or if you modify it.\n" + " To protect your rights, we need to prevent others from denying you\n" + "these rights or asking you to surrender the rights. Therefore, you have\n" + "certain responsibilities if you distribute copies of the software, or if\n" + "you modify it: responsibilities to respect the freedom of others.\n" "\n" " For example, if you distribute copies of such a program, whether\n" - "gratis or for a fee, you must give the recipients all the rights that\n" - "you have. You must make sure that they, too, receive or can get the\n" - "source code. And you must show them these terms so they know their\n" - "rights.\n" - "\n" - " We protect your rights with two steps: (1) copyright the software, and\n" - "(2) offer you this license which gives you legal permission to copy,\n" - "distribute and/or modify the software.\n" - "\n" - " Also, for each author's protection and ours, we want to make certain\n" - "that everyone understands that there is no warranty for this free\n" - "software. If the software is modified by someone else and passed on, we\n" - "want its recipients to know that what they have is not the original, so\n" - "that any problems introduced by others will not reflect on the original\n" - "authors' reputations.\n" - "\n" - " Finally, any free program is threatened constantly by software\n" - "patents. We wish to avoid the danger that redistributors of a free\n" - "program will individually obtain patent licenses, in effect making the\n" - "program proprietary. To prevent this, we have made it clear that any\n" - "patent must be licensed for everyone's free use or not licensed at all.\n" + "gratis or for a fee, you must pass on to the recipients the same\n" + "freedoms that you received. You must make sure that they, too, receive\n" + "or can get the source code. And you must show them these terms so they\n" + "know their rights.\n" + "\n" + " Developers that use the GNU GPL protect your rights with two steps:\n" + "(1) assert copyright on the software, and (2) offer you this License\n" + "giving you legal permission to copy, distribute and/or modify it.\n" + "\n" + " For the developers' and authors' protection, the GPL clearly explains\n" + "that there is no warranty for this free software. For both users' and\n" + "authors' sake, the GPL requires that modified versions be marked as\n" + "changed, so that their problems will not be attributed erroneously to\n" + "authors of previous versions.\n" + "\n" + " Some devices are designed to deny users access to install or run\n" + "modified versions of the software inside them, although the manufacturer\n" + "can do so. This is fundamentally incompatible with the aim of\n" + "protecting users' freedom to change the software. The systematic\n" + "pattern of such abuse occurs in the area of products for individuals to\n" + "use, which is precisely where it is most unacceptable. Therefore, we\n" + "have designed this version of the GPL to prohibit the practice for those\n" + "products. If such problems arise substantially in other domains, we\n" + "stand ready to extend this provision to those domains in future versions\n" + "of the GPL, as needed to protect the freedom of users.\n" + "\n" + " Finally, every program is threatened constantly by software patents.\n" + "States should not allow patents to restrict development and use of\n" + "software on general-purpose computers, but in those that do, we wish to\n" + "avoid the special danger that patents applied to a free program could\n" + "make it effectively proprietary. To prevent this, the GPL assures that\n" + "patents cannot be used to render the program non-free.\n" "\n" " The precise terms and conditions for copying, distribution and\n" "modification follow.\n" "\n" - " GNU GENERAL PUBLIC LICENSE\n" - " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n" - "\n" - " 0. This License applies to any program or other work which contains\n" - "a notice placed by the copyright holder saying it may be distributed\n" - "under the terms of this General Public License. The \"Program\", below,\n" - "refers to any such program or work, and a \"work based on the Program\"\n" - "means either the Program or any derivative work under copyright law:\n" - "that is to say, a work containing the Program or a portion of it,\n" - "either verbatim or with modifications and/or translated into another\n" - "language. (Hereinafter, translation is included without limitation in\n" - "the term \"modification\".) Each licensee is addressed as \"you\".\n" - "\n" - "Activities other than copying, distribution and modification are not\n" - "covered by this License; they are outside its scope. The act of\n" - "running the Program is not restricted, and the output from the Program\n" - "is covered only if its contents constitute a work based on the\n" - "Program (independent of having been made by running the Program).\n" - "Whether that is true depends on what the Program does.\n" - "\n" - " 1. You may copy and distribute verbatim copies of the Program's\n" - "source code as you receive it, in any medium, provided that you\n" - "conspicuously and appropriately publish on each copy an appropriate\n" - "copyright notice and disclaimer of warranty; keep intact all the\n" - "notices that refer to this License and to the absence of any warranty;\n" - "and give any other recipients of the Program a copy of this License\n" - "along with the Program.\n" - "\n" - "You may charge a fee for the physical act of transferring a copy, and\n" - "you may at your option offer warranty protection in exchange for a fee.\n" - "\n" - " 2. You may modify your copy or copies of the Program or any portion\n" - "of it, thus forming a work based on the Program, and copy and\n" - "distribute such modifications or work under the terms of Section 1\n" - "above, provided that you also meet all of these conditions:\n" - "\n" - " a) You must cause the modified files to carry prominent notices\n" - " stating that you changed the files and the date of any change.\n" - "\n" - " b) You must cause any work that you distribute or publish, that in\n" - " whole or in part contains or is derived from the Program or any\n" - " part thereof, to be licensed as a whole at no charge to all third\n" - " parties under the terms of this License.\n" - "\n" - " c) If the modified program normally reads commands interactively\n" - " when run, you must cause it, when started running for such\n" - " interactive use in the most ordinary way, to print or display an\n" - " announcement including an appropriate copyright notice and a\n" - " notice that there is no warranty (or else, saying that you provide\n" - " a warranty) and that users may redistribute the program under\n" - " these conditions, and telling the user how to view a copy of this\n" - " License. (Exception: if the Program itself is interactive but\n" - " does not normally print such an announcement, your work based on\n" - " the Program is not required to print an announcement.)\n" - "\n" - "These requirements apply to the modified work as a whole. If\n" - "identifiable sections of that work are not derived from the Program,\n" - "and can be reasonably considered independent and separate works in\n" - "themselves, then this License, and its terms, do not apply to those\n" - "sections when you distribute them as separate works. But when you\n" - "distribute the same sections as part of a whole which is a work based\n" - "on the Program, the distribution of the whole must be on the terms of\n" - "this License, whose permissions for other licensees extend to the\n" - "entire whole, and thus to each and every part regardless of who wrote it.\n" - "\n" - "Thus, it is not the intent of this section to claim rights or contest\n" - "your rights to work written entirely by you; rather, the intent is to\n" - "exercise the right to control the distribution of derivative or\n" - "collective works based on the Program.\n" - "\n" - "In addition, mere aggregation of another work not based on the Program\n" - "with the Program (or with a work based on the Program) on a volume of\n" - "a storage or distribution medium does not bring the other work under\n" - "the scope of this License.\n" - "\n" - " 3. You may copy and distribute the Program (or a work based on it,\n" - "under Section 2) in object code or executable form under the terms of\n" - "Sections 1 and 2 above provided that you also do one of the following:\n" - "\n" - " a) Accompany it with the complete corresponding machine-readable\n" - " source code, which must be distributed under the terms of Sections\n" - " 1 and 2 above on a medium customarily used for software interchange; or,\n" - "\n" - " b) Accompany it with a written offer, valid for at least three\n" - " years, to give any third party, for a charge no more than your\n" - " cost of physically performing source distribution, a complete\n" - " machine-readable copy of the corresponding source code, to be\n" - " distributed under the terms of Sections 1 and 2 above on a medium\n" - " customarily used for software interchange; or,\n" - "\n" - " c) Accompany it with the information you received as to the offer\n" - " to distribute corresponding source code. (This alternative is\n" - " allowed only for noncommercial distribution and only if you\n" - " received the program in object code or executable form with such\n" - " an offer, in accord with Subsection b above.)\n" - "\n" - "The source code for a work means the preferred form of the work for\n" - "making modifications to it. For an executable work, complete source\n" - "code means all the source code for all modules it contains, plus any\n" - "associated interface definition files, plus the scripts used to\n" - "control compilation and installation of the executable. However, as a\n" - "special exception, the source code distributed need not include\n" - "anything that is normally distributed (in either source or binary\n" - "form) with the major components (compiler, kernel, and so on) of the\n" - "operating system on which the executable runs, unless that component\n" - "itself accompanies the executable.\n" - "\n" - "If distribution of executable or object code is made by offering\n" - "access to copy from a designated place, then offering equivalent\n" - "access to copy the source code from the same place counts as\n" - "distribution of the source code, even though third parties are not\n" - "compelled to copy the source along with the object code.\n" - "\n" - " 4. You may not copy, modify, sublicense, or distribute the Program\n" - "except as expressly provided under this License. Any attempt\n" - "otherwise to copy, modify, sublicense or distribute the Program is\n" - "void, and will automatically terminate your rights under this License.\n" - "However, parties who have received copies, or rights, from you under\n" - "this License will not have their licenses terminated so long as such\n" - "parties remain in full compliance.\n" - "\n" - " 5. You are not required to accept this License, since you have not\n" - "signed it. However, nothing else grants you permission to modify or\n" - "distribute the Program or its derivative works. These actions are\n" - "prohibited by law if you do not accept this License. Therefore, by\n" - "modifying or distributing the Program (or any work based on the\n" - "Program), you indicate your acceptance of this License to do so, and\n" - "all its terms and conditions for copying, distributing or modifying\n" - "the Program or works based on it.\n" - "\n" - " 6. Each time you redistribute the Program (or any work based on the\n" - "Program), the recipient automatically receives a license from the\n" - "original licensor to copy, distribute or modify the Program subject to\n" - "these terms and conditions. You may not impose any further\n" - "restrictions on the recipients' exercise of the rights granted herein.\n" - "You are not responsible for enforcing compliance by third parties to\n" + " TERMS AND CONDITIONS\n" + "\n" + " 0. Definitions.\n" + "\n" + " \"This License\" refers to version 3 of the GNU General Public License.\n" + "\n" + " \"Copyright\" also means copyright-like laws that apply to other kinds of\n" + "works, such as semiconductor masks.\n" + "\n" + " \"The Program\" refers to any copyrightable work licensed under this\n" + "License. Each licensee is addressed as \"you\". \"Licensees\" and\n" + "\"recipients\" may be individuals or organizations.\n" + "\n" + " To \"modify\" a work means to copy from or adapt all or part of the work\n" + "in a fashion requiring copyright permission, other than the making of an\n" + "exact copy. The resulting work is called a \"modified version\" of the\n" + "earlier work or a work \"based on\" the earlier work.\n" + "\n" + " A \"covered work\" means either the unmodified Program or a work based\n" + "on the Program.\n" + "\n" + " To \"propagate\" a work means to do anything with it that, without\n" + "permission, would make you directly or secondarily liable for\n" + "infringement under applicable copyright law, except executing it on a\n" + "computer or modifying a private copy. Propagation includes copying,\n" + "distribution (with or without modification), making available to the\n" + "public, and in some countries other activities as well.\n" + "\n" + " To \"convey\" a work means any kind of propagation that enables other\n" + "parties to make or receive copies. Mere interaction with a user through\n" + "a computer network, with no transfer of a copy, is not conveying.\n" + "\n" + " An interactive user interface displays \"Appropriate Legal Notices\"\n" + "to the extent that it includes a convenient and prominently visible\n" + "feature that (1) displays an appropriate copyright notice, and (2)\n" + "tells the user that there is no warranty for the work (except to the\n" + "extent that warranties are provided), that licensees may convey the\n" + "work under this License, and how to view a copy of this License. If\n" + "the interface presents a list of user commands or options, such as a\n" + "menu, a prominent item in the list meets this criterion.\n" + "\n" + " 1. Source Code.\n" + "\n" + " The \"source code\" for a work means the preferred form of the work\n" + "for making modifications to it. \"Object code\" means any non-source\n" + "form of a work.\n" + "\n" + " A \"Standard Interface\" means an interface that either is an official\n" + "standard defined by a recognized standards body, or, in the case of\n" + "interfaces specified for a particular programming language, one that\n" + "is widely used among developers working in that language.\n" + "\n" + " The \"System Libraries\" of an executable work include anything, other\n" + "than the work as a whole, that (a) is included in the normal form of\n" + "packaging a Major Component, but which is not part of that Major\n" + "Component, and (b) serves only to enable use of the work with that\n" + "Major Component, or to implement a Standard Interface for which an\n" + "implementation is available to the public in source code form. A\n" + "\"Major Component\", in this context, means a major essential component\n" + "(kernel, window system, and so on) of the specific operating system\n" + "(if any) on which the executable work runs, or a compiler used to\n" + "produce the work, or an object code interpreter used to run it.\n" + "\n" + " The \"Corresponding Source\" for a work in object code form means all\n" + "the source code needed to generate, install, and (for an executable\n" + "work) run the object code and to modify the work, including scripts to\n" + "control those activities. However, it does not include the work's\n" + "System Libraries, or general-purpose tools or generally available free\n" + "programs which are used unmodified in performing those activities but\n" + "which are not part of the work. For example, Corresponding Source\n" + "includes interface definition files associated with source files for\n" + "the work, and the source code for shared libraries and dynamically\n" + "linked subprograms that the work is specifically designed to require,\n" + "such as by intimate data communication or control flow between those\n" + "subprograms and other parts of the work.\n" + "\n" + " The Corresponding Source need not include anything that users\n" + "can regenerate automatically from other parts of the Corresponding\n" + "Source.\n" + "\n" + " The Corresponding Source for a work in source code form is that\n" + "same work.\n" + "\n" + " 2. Basic Permissions.\n" + "\n" + " All rights granted under this License are granted for the term of\n" + "copyright on the Program, and are irrevocable provided the stated\n" + "conditions are met. This License explicitly affirms your unlimited\n" + "permission to run the unmodified Program. The output from running a\n" + "covered work is covered by this License only if the output, given its\n" + "content, constitutes a covered work. This License acknowledges your\n" + "rights of fair use or other equivalent, as provided by copyright law.\n" + "\n" + " You may make, run and propagate covered works that you do not\n" + "convey, without conditions so long as your license otherwise remains\n" + "in force. You may convey covered works to others for the sole purpose\n" + "of having them make modifications exclusively for you, or provide you\n" + "with facilities for running those works, provided that you comply with\n" + "the terms of this License in conveying all material for which you do\n" + "not control copyright. Those thus making or running the covered works\n" + "for you must do so exclusively on your behalf, under your direction\n" + "and control, on terms that prohibit them from making any copies of\n" + "your copyrighted material outside their relationship with you.\n" + "\n" + " Conveying under any other circumstances is permitted solely under\n" + "the conditions stated below. Sublicensing is not allowed; section 10\n" + "makes it unnecessary.\n" + "\n" + " 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n" + "\n" + " No covered work shall be deemed part of an effective technological\n" + "measure under any applicable law fulfilling obligations under article\n" + "11 of the WIPO copyright treaty adopted on 20 December 1996, or\n" + "similar laws prohibiting or restricting circumvention of such\n" + "measures.\n" + "\n" + " When you convey a covered work, you waive any legal power to forbid\n" + "circumvention of technological measures to the extent such circumvention\n" + "is effected by exercising rights under this License with respect to\n" + "the covered work, and you disclaim any intention to limit operation or\n" + "modification of the work as a means of enforcing, against the work's\n" + "users, your or third parties' legal rights to forbid circumvention of\n" + "technological measures.\n" + "\n" + " 4. Conveying Verbatim Copies.\n" + "\n" + " You may convey verbatim copies of the Program's source code as you\n" + "receive it, in any medium, provided that you conspicuously and\n" + "appropriately publish on each copy an appropriate copyright notice;\n" + "keep intact all notices stating that this License and any\n" + "non-permissive terms added in accord with section 7 apply to the code;\n" + "keep intact all notices of the absence of any warranty; and give all\n" + "recipients a copy of this License along with the Program.\n" + "\n" + " You may charge any price or no price for each copy that you convey,\n" + "and you may offer support or warranty protection for a fee.\n" + "\n" + " 5. Conveying Modified Source Versions.\n" + "\n" + " You may convey a work based on the Program, or the modifications to\n" + "produce it from the Program, in the form of source code under the\n" + "terms of section 4, provided that you also meet all of these conditions:\n" + "\n" + " a) The work must carry prominent notices stating that you modified\n" + " it, and giving a relevant date.\n" + "\n" + " b) The work must carry prominent notices stating that it is\n" + " released under this License and any conditions added under section\n" + " 7. This requirement modifies the requirement in section 4 to\n" + " \"keep intact all notices\".\n" + "\n" + " c) You must license the entire work, as a whole, under this\n" + " License to anyone who comes into possession of a copy. This\n" + " License will therefore apply, along with any applicable section 7\n" + " additional terms, to the whole of the work, and all its parts,\n" + " regardless of how they are packaged. This License gives no\n" + " permission to license the work in any other way, but it does not\n" + " invalidate such permission if you have separately received it.\n" + "\n" + " d) If the work has interactive user interfaces, each must display\n" + " Appropriate Legal Notices; however, if the Program has interactive\n" + " interfaces that do not display Appropriate Legal Notices, your\n" + " work need not make them do so.\n" + "\n" + " A compilation of a covered work with other separate and independent\n" + "works, which are not by their nature extensions of the covered work,\n" + "and which are not combined with it such as to form a larger program,\n" + "in or on a volume of a storage or distribution medium, is called an\n" + "\"aggregate\" if the compilation and its resulting copyright are not\n" + "used to limit the access or legal rights of the compilation's users\n" + "beyond what the individual works permit. Inclusion of a covered work\n" + "in an aggregate does not cause this License to apply to the other\n" + "parts of the aggregate.\n" + "\n" + " 6. Conveying Non-Source Forms.\n" + "\n" + " You may convey a covered work in object code form under the terms\n" + "of sections 4 and 5, provided that you also convey the\n" + "machine-readable Corresponding Source under the terms of this License,\n" + "in one of these ways:\n" + "\n" + " a) Convey the object code in, or embodied in, a physical product\n" + " (including a physical distribution medium), accompanied by the\n" + " Corresponding Source fixed on a durable physical medium\n" + " customarily used for software interchange.\n" + "\n" + " b) Convey the object code in, or embodied in, a physical product\n" + " (including a physical distribution medium), accompanied by a\n" + " written offer, valid for at least three years and valid for as\n" + " long as you offer spare parts or customer support for that product\n" + " model, to give anyone who possesses the object code either (1) a\n" + " copy of the Corresponding Source for all the software in the\n" + " product that is covered by this License, on a durable physical\n" + " medium customarily used for software interchange, for a price no\n" + " more than your reasonable cost of physically performing this\n" + " conveying of source, or (2) access to copy the\n" + " Corresponding Source from a network server at no charge.\n" + "\n" + " c) Convey individual copies of the object code with a copy of the\n" + " written offer to provide the Corresponding Source. This\n" + " alternative is allowed only occasionally and noncommercially, and\n" + " only if you received the object code with such an offer, in accord\n" + " with subsection 6b.\n" + "\n" + " d) Convey the object code by offering access from a designated\n" + " place (gratis or for a charge), and offer equivalent access to the\n" + " Corresponding Source in the same way through the same place at no\n" + " further charge. You need not require recipients to copy the\n" + " Corresponding Source along with the object code. If the place to\n" + " copy the object code is a network server, the Corresponding Source\n" + " may be on a different server (operated by you or a third party)\n" + " that supports equivalent copying facilities, provided you maintain\n" + " clear directions next to the object code saying where to find the\n" + " Corresponding Source. Regardless of what server hosts the\n" + " Corresponding Source, you remain obligated to ensure that it is\n" + " available for as long as needed to satisfy these requirements.\n" + "\n" + " e) Convey the object code using peer-to-peer transmission, provided\n" + " you inform other peers where the object code and Corresponding\n" + " Source of the work are being offered to the general public at no\n" + " charge under subsection 6d.\n" + "\n" + " A separable portion of the object code, whose source code is excluded\n" + "from the Corresponding Source as a System Library, need not be\n" + "included in conveying the object code work.\n" + "\n" + " A \"User Product\" is either (1) a \"consumer product\", which means any\n" + "tangible personal property which is normally used for personal, family,\n" + "or household purposes, or (2) anything designed or sold for incorporation\n" + "into a dwelling. In determining whether a product is a consumer product,\n" + "doubtful cases shall be resolved in favor of coverage. For a particular\n" + "product received by a particular user, \"normally used\" refers to a\n" + "typical or common use of that class of product, regardless of the status\n" + "of the particular user or of the way in which the particular user\n" + "actually uses, or expects or is expected to use, the product. A product\n" + "is a consumer product regardless of whether the product has substantial\n" + "commercial, industrial or non-consumer uses, unless such uses represent\n" + "the only significant mode of use of the product.\n" + "\n" + " \"Installation Information\" for a User Product means any methods,\n" + "procedures, authorization keys, or other information required to install\n" + "and execute modified versions of a covered work in that User Product from\n" + "a modified version of its Corresponding Source. The information must\n" + "suffice to ensure that the continued functioning of the modified object\n" + "code is in no case prevented or interfered with solely because\n" + "modification has been made.\n" + "\n" + " If you convey an object code work under this section in, or with, or\n" + "specifically for use in, a User Product, and the conveying occurs as\n" + "part of a transaction in which the right of possession and use of the\n" + "User Product is transferred to the recipient in perpetuity or for a\n" + "fixed term (regardless of how the transaction is characterized), the\n" + "Corresponding Source conveyed under this section must be accompanied\n" + "by the Installation Information. But this requirement does not apply\n" + "if neither you nor any third party retains the ability to install\n" + "modified object code on the User Product (for example, the work has\n" + "been installed in ROM).\n" + "\n" + " The requirement to provide Installation Information does not include a\n" + "requirement to continue to provide support service, warranty, or updates\n" + "for a work that has been modified or installed by the recipient, or for\n" + "the User Product in which it has been modified or installed. Access to a\n" + "network may be denied when the modification itself materially and\n" + "adversely affects the operation of the network or violates the rules and\n" + "protocols for communication across the network.\n" + "\n" + " Corresponding Source conveyed, and Installation Information provided,\n" + "in accord with this section must be in a format that is publicly\n" + "documented (and with an implementation available to the public in\n" + "source code form), and must require no special password or key for\n" + "unpacking, reading or copying.\n" + "\n" + " 7. Additional Terms.\n" + "\n" + " \"Additional permissions\" are terms that supplement the terms of this\n" + "License by making exceptions from one or more of its conditions.\n" + "Additional permissions that are applicable to the entire Program shall\n" + "be treated as though they were included in this License, to the extent\n" + "that they are valid under applicable law. If additional permissions\n" + "apply only to part of the Program, that part may be used separately\n" + "under those permissions, but the entire Program remains governed by\n" + "this License without regard to the additional permissions.\n" + "\n" + " When you convey a copy of a covered work, you may at your option\n" + "remove any additional permissions from that copy, or from any part of\n" + "it. (Additional permissions may be written to require their own\n" + "removal in certain cases when you modify the work.) You may place\n" + "additional permissions on material, added by you to a covered work,\n" + "for which you have or can give appropriate copyright permission.\n" + "\n" + " Notwithstanding any other provision of this License, for material you\n" + "add to a covered work, you may (if authorized by the copyright holders of\n" + "that material) supplement the terms of this License with terms:\n" + "\n" + " a) Disclaiming warranty or limiting liability differently from the\n" + " terms of sections 15 and 16 of this License; or\n" + "\n" + " b) Requiring preservation of specified reasonable legal notices or\n" + " author attributions in that material or in the Appropriate Legal\n" + " Notices displayed by works containing it; or\n" + "\n" + " c) Prohibiting misrepresentation of the origin of that material, or\n" + " requiring that modified versions of such material be marked in\n" + " reasonable ways as different from the original version; or\n" + "\n" + " d) Limiting the use for publicity purposes of names of licensors or\n" + " authors of the material; or\n" + "\n" + " e) Declining to grant rights under trademark law for use of some\n" + " trade names, trademarks, or service marks; or\n" + "\n" + " f) Requiring indemnification of licensors and authors of that\n" + " material by anyone who conveys the material (or modified versions of\n" + " it) with contractual assumptions of liability to the recipient, for\n" + " any liability that these contractual assumptions directly impose on\n" + " those licensors and authors.\n" + "\n" + " All other non-permissive additional terms are considered \"further\n" + "restrictions\" within the meaning of section 10. If the Program as you\n" + "received it, or any part of it, contains a notice stating that it is\n" + "governed by this License along with a term that is a further\n" + "restriction, you may remove that term. If a license document contains\n" + "a further restriction but permits relicensing or conveying under this\n" + "License, you may add to a covered work material governed by the terms\n" + "of that license document, provided that the further restriction does\n" + "not survive such relicensing or conveying.\n" + "\n" + " If you add terms to a covered work in accord with this section, you\n" + "must place, in the relevant source files, a statement of the\n" + "additional terms that apply to those files, or a notice indicating\n" + "where to find the applicable terms.\n" + "\n" + " Additional terms, permissive or non-permissive, may be stated in the\n" + "form of a separately written license, or stated as exceptions;\n" + "the above requirements apply either way.\n" + "\n" + " 8. Termination.\n" + "\n" + " You may not propagate or modify a covered work except as expressly\n" + "provided under this License. Any attempt otherwise to propagate or\n" + "modify it is void, and will automatically terminate your rights under\n" + "this License (including any patent licenses granted under the third\n" + "paragraph of section 11).\n" + "\n" + " However, if you cease all violation of this License, then your\n" + "license from a particular copyright holder is reinstated (a)\n" + "provisionally, unless and until the copyright holder explicitly and\n" + "finally terminates your license, and (b) permanently, if the copyright\n" + "holder fails to notify you of the violation by some reasonable means\n" + "prior to 60 days after the cessation.\n" + "\n" + " Moreover, your license from a particular copyright holder is\n" + "reinstated permanently if the copyright holder notifies you of the\n" + "violation by some reasonable means, this is the first time you have\n" + "received notice of violation of this License (for any work) from that\n" + "copyright holder, and you cure the violation prior to 30 days after\n" + "your receipt of the notice.\n" + "\n" + " Termination of your rights under this section does not terminate the\n" + "licenses of parties who have received copies or rights from you under\n" + "this License. If your rights have been terminated and not permanently\n" + "reinstated, you do not qualify to receive new licenses for the same\n" + "material under section 10.\n" + "\n" + " 9. Acceptance Not Required for Having Copies.\n" + "\n" + " You are not required to accept this License in order to receive or\n" + "run a copy of the Program. Ancillary propagation of a covered work\n" + "occurring solely as a consequence of using peer-to-peer transmission\n" + "to receive a copy likewise does not require acceptance. However,\n" + "nothing other than this License grants you permission to propagate or\n" + "modify any covered work. These actions infringe copyright if you do\n" + "not accept this License. Therefore, by modifying or propagating a\n" + "covered work, you indicate your acceptance of this License to do so.\n" + "\n" + " 10. Automatic Licensing of Downstream Recipients.\n" + "\n" + " Each time you convey a covered work, the recipient automatically\n" + "receives a license from the original licensors, to run, modify and\n" + "propagate that work, subject to this License. You are not responsible\n" + "for enforcing compliance by third parties with this License.\n" + "\n" + " An \"entity transaction\" is a transaction transferring control of an\n" + "organization, or substantially all assets of one, or subdividing an\n" + "organization, or merging organizations. If propagation of a covered\n" + "work results from an entity transaction, each party to that\n" + "transaction who receives a copy of the work also receives whatever\n" + "licenses to the work the party's predecessor in interest had or could\n" + "give under the previous paragraph, plus a right to possession of the\n" + "Corresponding Source of the work from the predecessor in interest, if\n" + "the predecessor has it or can get it with reasonable efforts.\n" + "\n" + " You may not impose any further restrictions on the exercise of the\n" + "rights granted or affirmed under this License. For example, you may\n" + "not impose a license fee, royalty, or other charge for exercise of\n" + "rights granted under this License, and you may not initiate litigation\n" + "(including a cross-claim or counterclaim in a lawsuit) alleging that\n" + "any patent claim is infringed by making, using, selling, offering for\n" + "sale, or importing the Program or any portion of it.\n" + "\n" + " 11. Patents.\n" + "\n" + " A \"contributor\" is a copyright holder who authorizes use under this\n" + "License of the Program or a work on which the Program is based. The\n" + "work thus licensed is called the contributor's \"contributor version\".\n" + "\n" + " A contributor's \"essential patent claims\" are all patent claims\n" + "owned or controlled by the contributor, whether already acquired or\n" + "hereafter acquired, that would be infringed by some manner, permitted\n" + "by this License, of making, using, or selling its contributor version,\n" + "but do not include claims that would be infringed only as a\n" + "consequence of further modification of the contributor version. For\n" + "purposes of this definition, \"control\" includes the right to grant\n" + "patent sublicenses in a manner consistent with the requirements of\n" "this License.\n" "\n" - " 7. If, as a consequence of a court judgment or allegation of patent\n" - "infringement or for any other reason (not limited to patent issues),\n" - "conditions are imposed on you (whether by court order, agreement or\n" + " Each contributor grants you a non-exclusive, worldwide, royalty-free\n" + "patent license under the contributor's essential patent claims, to\n" + "make, use, sell, offer for sale, import and otherwise run, modify and\n" + "propagate the contents of its contributor version.\n" + "\n" + " In the following three paragraphs, a \"patent license\" is any express\n" + "agreement or commitment, however denominated, not to enforce a patent\n" + "(such as an express permission to practice a patent or covenant not to\n" + "sue for patent infringement). To \"grant\" such a patent license to a\n" + "party means to make such an agreement or commitment not to enforce a\n" + "patent against the party.\n" + "\n" + " If you convey a covered work, knowingly relying on a patent license,\n" + "and the Corresponding Source of the work is not available for anyone\n" + "to copy, free of charge and under the terms of this License, through a\n" + "publicly available network server or other readily accessible means,\n" + "then you must either (1) cause the Corresponding Source to be so\n" + "available, or (2) arrange to deprive yourself of the benefit of the\n" + "patent license for this particular work, or (3) arrange, in a manner\n" + "consistent with the requirements of this License, to extend the patent\n" + "license to downstream recipients. \"Knowingly relying\" means you have\n" + "actual knowledge that, but for the patent license, your conveying the\n" + "covered work in a country, or your recipient's use of the covered work\n" + "in a country, would infringe one or more identifiable patents in that\n" + "country that you have reason to believe are valid.\n" + "\n" + " If, pursuant to or in connection with a single transaction or\n" + "arrangement, you convey, or propagate by procuring conveyance of, a\n" + "covered work, and grant a patent license to some of the parties\n" + "receiving the covered work authorizing them to use, propagate, modify\n" + "or convey a specific copy of the covered work, then the patent license\n" + "you grant is automatically extended to all recipients of the covered\n" + "work and works based on it.\n" + "\n" + " A patent license is \"discriminatory\" if it does not include within\n" + "the scope of its coverage, prohibits the exercise of, or is\n" + "conditioned on the non-exercise of one or more of the rights that are\n" + "specifically granted under this License. You may not convey a covered\n" + "work if you are a party to an arrangement with a third party that is\n" + "in the business of distributing software, under which you make payment\n" + "to the third party based on the extent of your activity of conveying\n" + "the work, and under which the third party grants, to any of the\n" + "parties who would receive the covered work from you, a discriminatory\n" + "patent license (a) in connection with copies of the covered work\n" + "conveyed by you (or copies made from those copies), or (b) primarily\n" + "for and in connection with specific products or compilations that\n" + "contain the covered work, unless you entered into that arrangement,\n" + "or that patent license was granted, prior to 28 March 2007.\n" + "\n" + " Nothing in this License shall be construed as excluding or limiting\n" + "any implied license or other defenses to infringement that may\n" + "otherwise be available to you under applicable patent law.\n" + "\n" + " 12. No Surrender of Others' Freedom.\n" + "\n" + " If conditions are imposed on you (whether by court order, agreement or\n" "otherwise) that contradict the conditions of this License, they do not\n" - "excuse you from the conditions of this License. If you cannot\n" - "distribute so as to satisfy simultaneously your obligations under this\n" - "License and any other pertinent obligations, then as a consequence you\n" - "may not distribute the Program at all. For example, if a patent\n" - "license would not permit royalty-free redistribution of the Program by\n" - "all those who receive copies directly or indirectly through you, then\n" - "the only way you could satisfy both it and this License would be to\n" - "refrain entirely from distribution of the Program.\n" - "\n" - "If any portion of this section is held invalid or unenforceable under\n" - "any particular circumstance, the balance of the section is intended to\n" - "apply and the section as a whole is intended to apply in other\n" - "circumstances.\n" - "\n" - "It is not the purpose of this section to induce you to infringe any\n" - "patents or other property right claims or to contest validity of any\n" - "such claims; this section has the sole purpose of protecting the\n" - "integrity of the free software distribution system, which is\n" - "implemented by public license practices. Many people have made\n" - "generous contributions to the wide range of software distributed\n" - "through that system in reliance on consistent application of that\n" - "system; it is up to the author/donor to decide if he or she is willing\n" - "to distribute software through any other system and a licensee cannot\n" - "impose that choice.\n" - "\n" - "This section is intended to make thoroughly clear what is believed to\n" - "be a consequence of the rest of this License.\n" - "\n" - " 8. If the distribution and/or use of the Program is restricted in\n" - "certain countries either by patents or by copyrighted interfaces, the\n" - "original copyright holder who places the Program under this License\n" - "may add an explicit geographical distribution limitation excluding\n" - "those countries, so that distribution is permitted only in or among\n" - "countries not thus excluded. In such case, this License incorporates\n" - "the limitation as if written in the body of this License.\n" - "\n" - " 9. The Free Software Foundation may publish revised and/or new versions\n" - "of the General Public License from time to time. Such new versions will\n" + "excuse you from the conditions of this License. If you cannot convey a\n" + "covered work so as to satisfy simultaneously your obligations under this\n" + "License and any other pertinent obligations, then as a consequence you may\n" + "not convey it at all. For example, if you agree to terms that obligate you\n" + "to collect a royalty for further conveying from those to whom you convey\n" + "the Program, the only way you could satisfy both those terms and this\n" + "License would be to refrain entirely from conveying the Program.\n" + "\n" + " 13. Use with the GNU Affero General Public License.\n" + "\n" + " Notwithstanding any other provision of this License, you have\n" + "permission to link or combine any covered work with a work licensed\n" + "under version 3 of the GNU Affero General Public License into a single\n" + "combined work, and to convey the resulting work. The terms of this\n" + "License will continue to apply to the part which is the covered work,\n" + "but the special requirements of the GNU Affero General Public License,\n" + "section 13, concerning interaction through a network will apply to the\n" + "combination as such.\n" + "\n" + " 14. Revised Versions of this License.\n" + "\n" + " The Free Software Foundation may publish revised and/or new versions of\n" + "the GNU General Public License from time to time. Such new versions will\n" "be similar in spirit to the present version, but may differ in detail to\n" "address new problems or concerns.\n" "\n" - "Each version is given a distinguishing version number. If the Program\n" - "specifies a version number of this License which applies to it and \"any\n" - "later version\", you have the option of following the terms and conditions\n" - "either of that version or of any later version published by the Free\n" - "Software Foundation. If the Program does not specify a version number of\n" - "this License, you may choose any version ever published by the Free Software\n" - "Foundation.\n" - "\n" - " 10. If you wish to incorporate parts of the Program into other free\n" - "programs whose distribution conditions are different, write to the author\n" - "to ask for permission. For software which is copyrighted by the Free\n" - "Software Foundation, write to the Free Software Foundation; we sometimes\n" - "make exceptions for this. Our decision will be guided by the two goals\n" - "of preserving the free status of all derivatives of our free software and\n" - "of promoting the sharing and reuse of software generally.\n" - "\n" - " NO WARRANTY\n" - "\n" - " 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n" - "FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n" - "OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n" - "PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n" - "OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n" - "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n" - "TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n" - "PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n" - "REPAIR OR CORRECTION.\n" - "\n" - " 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n" - "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n" - "REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n" - "INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n" - "OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n" - "TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n" - "YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n" - "PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n" - "POSSIBILITY OF SUCH DAMAGES.\n" - "\n" - " END OF TERMS AND CONDITIONS\n" - "\n" - " How to Apply These Terms to Your New Programs\n" + " Each version is given a distinguishing version number. If the\n" + "Program specifies that a certain numbered version of the GNU General\n" + "Public License \"or any later version\" applies to it, you have the\n" + "option of following the terms and conditions either of that numbered\n" + "version or of any later version published by the Free Software\n" + "Foundation. If the Program does not specify a version number of the\n" + "GNU General Public License, you may choose any version ever published\n" + "by the Free Software Foundation.\n" + "\n" + " If the Program specifies that a proxy can decide which future\n" + "versions of the GNU General Public License can be used, that proxy's\n" + "public statement of acceptance of a version permanently authorizes you\n" + "to choose that version for the Program.\n" + "\n" + " Later license versions may give you additional or different\n" + "permissions. However, no additional obligations are imposed on any\n" + "author or copyright holder as a result of your choosing to follow a\n" + "later version.\n" + "\n" + " 15. Disclaimer of Warranty.\n" + "\n" + " THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n" + "APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\n" + "HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\n" + "OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\n" + "THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n" + "PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\n" + "IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\n" + "ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n" + "\n" + " 16. Limitation of Liability.\n" + "\n" + " IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n" + "WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\n" + "THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\n" + "GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\n" + "USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\n" + "DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\n" + "PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\n" + "EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\n" + "SUCH DAMAGES.\n" + "\n" + " 17. Interpretation of Sections 15 and 16.\n" + "\n" + " If the disclaimer of warranty and limitation of liability provided\n" + "above cannot be given local legal effect according to their terms,\n" + "reviewing courts shall apply local law that most closely approximates\n" + "an absolute waiver of all civil liability in connection with the\n" + "Program, unless a warranty or assumption of liability accompanies a\n" + "copy of the Program in return for a fee.\n" + "\n" + " END OF TERMS AND CONDITIONS\n" + "\n" + " How to Apply These Terms to Your New Programs\n" "\n" " If you develop a new program, and you want it to be of the greatest\n" "possible use to the public, the best way to achieve this is to make it\n" @@ -907,15 +1248,15 @@ void AboutBox::initStrings() { "\n" " To do so, attach the following notices to the program. It is safest\n" "to attach them to the start of each source file to most effectively\n" - "convey the exclusion of warranty; and each file should have at least\n" + "state the exclusion of warranty; and each file should have at least\n" "the \"copyright\" line and a pointer to where the full notice is found.\n" "\n" " <one line to give the program's name and a brief idea of what it does.>\n" " Copyright (C) <year> <name of author>\n" "\n" - " This program is free software; you can redistribute it and/or modify\n" + " This program is free software: you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" - " the Free Software Foundation; either version 2 of the License, or\n" + " the Free Software Foundation, either version 3 of the License, or\n" " (at your option) any later version.\n" "\n" " This program is distributed in the hope that it will be useful,\n" @@ -924,40 +1265,33 @@ void AboutBox::initStrings() { " GNU General Public License for more details.\n" "\n" " You should have received a copy of the GNU General Public License\n" - " along with this program; if not, write to the Free Software\n" - " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n" - "\n" + " along with this program. If not, see <http://www.gnu.org/licenses/>.\n" "\n" "Also add information on how to contact you by electronic and paper mail.\n" "\n" - "If the program is interactive, make it output a short notice like this\n" - "when it starts in an interactive mode:\n" + " If the program does terminal interaction, make it output a short\n" + "notice like this when it starts in an interactive mode:\n" "\n" - " Gnomovision version 69, Copyright (C) year name of author\n" - " Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n" + " <program> Copyright (C) <year> <name of author>\n" + " This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n" " This is free software, and you are welcome to redistribute it\n" " under certain conditions; type `show c' for details.\n" "\n" "The hypothetical commands `show w' and `show c' should show the appropriate\n" - "parts of the General Public License. Of course, the commands you use may\n" - "be called something other than `show w' and `show c'; they could even be\n" - "mouse-clicks or menu items--whatever suits your program.\n" - "\n" - "You should also get your employer (if you work as a programmer) or your\n" - "school, if any, to sign a \"copyright disclaimer\" for the program, if\n" - "necessary. Here is a sample; alter the names:\n" - "\n" - " Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n" - " `Gnomovision' (which makes passes at compilers) written by James Hacker.\n" + "parts of the General Public License. Of course, your program's commands\n" + "might be different; for a GUI interface, you would use an \"about box\".\n" "\n" - " <signature of Ty Coon>, 1 April 1989\n" - " Ty Coon, President of Vice\n" + " You should also get your employer (if you work as a programmer) or school,\n" + "if any, to sign a \"copyright disclaimer\" for the program, if necessary.\n" + "For more information on this, and how to apply and follow the GNU GPL, see\n" + "<http://www.gnu.org/licenses/>.\n" "\n" - "This General Public License does not permit incorporating your program into\n" - "proprietary programs. If your program is a subroutine library, you may\n" - "consider it more useful to permit linking proprietary applications with the\n" - "library. If this is what you want to do, use the GNU Library General\n" - "Public License instead of this License.\n" + " The GNU General Public License does not permit incorporating your program\n" + "into proprietary programs. If your program is a subroutine library, you\n" + "may consider it more useful to permit linking proprietary applications with\n" + "the library. If this is what you want to do, use the GNU Lesser General\n" + "Public License instead of this License. But first, please read\n" + "<http://www.gnu.org/philosophy/why-not-lgpl.html>." ; } diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index fbd050f8e..9656878e0 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1061,7 +1061,11 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_END); +#else gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); +#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } @@ -1135,7 +1139,11 @@ CloneTiler::CloneTiler () : { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), "×"); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_END); +#else gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); +#endif gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); } @@ -2777,7 +2785,12 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), suffix); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_END); + gtk_widget_set_valign(l, GTK_ALIGN_START); +#else gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0); +#endif gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } @@ -2853,14 +2866,13 @@ void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { - GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); - gtk_container_add(GTK_CONTAINER(a), widget); - #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_halign(table, GTK_ALIGN_FILL); - gtk_widget_set_valign(table, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(table), a, col, row, 1, 1); + gtk_widget_set_halign(widget, GTK_ALIGN_FILL); + gtk_widget_set_valign(widget, GTK_ALIGN_START); + gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); #else + GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); + gtk_container_add(GTK_CONTAINER(a), widget); gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 ); #endif } diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 7e9d8481a..ce08ed1f7 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,37 +2761,61 @@ 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 + _sw_infobox = Gtk::manage(new Gtk::ScrolledWindow); Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); - Gtk::ScrolledWindow* sw_infobox = Gtk::manage(new Gtk::ScrolledWindow); 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); - _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); sw_prims->add(_primitive_list); - sw_infobox->add(*vb_prims); - infobox->pack_start(_infobox_icon, false, false); - infobox->pack_start(_infobox_desc, false, false); + + prim_vbox_p->pack_start(*sw_prims, true, true); + prim_vbox_i->pack_start(*vb_prims, true, true); + + _primitive_box->pack1(*prim_vbox_p); + _primitive_box->pack2(*prim_vbox_i, false, false); + + hpaned->pack1(_filter_modifier); + hpaned->pack2(*_primitive_box); + _getContents()->add(*hpaned); + + _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); - - hb_prims->pack_start(_add_primitive, false, false); - hb_prims->pack_start(_add_primitive_type, false, false); + _infobox_desc.set_size_request(200, -1); + + vb_desc->pack_start(_infobox_desc, true, true); + + infobox->pack_start(_infobox_icon, false, false); + infobox->pack_start(*vb_desc, true, true); + + //_sw_infobox->set_size_request(-1, -1); + _sw_infobox->set_size_request(200, -1); + _sw_infobox->add(*infobox); + + //vb_prims->set_size_request(-1, 50); + 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, true, true); _getContents()->pack_start(_settings_tabs, false, false); _settings_tabs.append_page(_settings_tab1, _("Effect parameters")); _settings_tabs.append_page(_settings_tab2, _("Filter General Settings")); + + _primitive_list.signal_primitive_changed().connect( sigc::mem_fun(*this, &FilterEffectsDialog::update_settings_view)); _filter_modifier.signal_filter_changed().connect( @@ -2801,7 +2826,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); @@ -2951,11 +2976,9 @@ void FilterEffectsDialog::update_primitive_infobox() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/showfiltersinfobox/value", true)){ - _infobox_icon.show(); - _infobox_desc.show(); + _sw_infobox->show(); } else { - _infobox_icon.hide(); - _infobox_desc.hide(); + _sw_infobox->hide(); } switch(_add_primitive_type.get_active_data()->id){ case(NR_FILTER_BLEND): @@ -3026,7 +3049,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() @@ -3138,11 +3162,9 @@ void FilterEffectsDialog::update_settings_view() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/showfiltersinfobox/value", true)){ - _infobox_icon.show(); - _infobox_desc.show(); + _sw_infobox->show(); } else { - _infobox_icon.hide(); - _infobox_desc.hide(); + _sw_infobox->hide(); } SPFilterPrimitive* prim = _primitive_list.get_selected(); diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 283abb5b0..7c715327e 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -28,6 +28,9 @@ #include <gtkmm/notebook.h> #include <gtkmm/sizegroup.h> +#include <gtkmm/paned.h> +#include <gtkmm/scrolledwindow.h> + namespace Inkscape { namespace UI { namespace Dialog { @@ -277,9 +280,15 @@ private: // Primitives Info Box Gtk::Label _infobox_desc; Gtk::Image _infobox_icon; + Gtk::ScrolledWindow* _sw_infobox; // 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<Inkscape::Filters::FilterPrimitiveType> _add_primitive_type; Gtk::Button _add_primitive; diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 3d0571244..00c3ffa07 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -27,8 +27,6 @@ class font_instance; namespace Inkscape { namespace UI { -class PreviewHolder; - namespace Dialog { class GlyphColumns; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b20f71a6a..c7a168dee 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -613,8 +613,9 @@ void InkscapePreferences::initPageUI() _("Set the language for menus and number formats"), false); { - Glib::ustring sizeLabels[] = {C_("Icon size", "Large"), C_("Icon size", "Small"), C_("Icon size", "Smaller")}; - int sizeValues[] = {0, 1, 2}; + Glib::ustring sizeLabels[] = {C_("Icon size", "Larger"), C_("Icon size", "Large"), C_("Icon size", "Small"), C_("Icon size", "Smaller")}; + int sizeValues[] = {3, 0, 1, 2}; + // "Larger" is 3 to not break existing preference files. Should fix in GTK3 _misc_small_tools.init( "/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0 ); _page_ui.add_line( false, _("Toolbox icon size:"), _misc_small_tools, "", diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 75430ed44..be46129c4 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (C) 2012 Kris De Gussem <Kris.DeGussem@gmail.com> - * c++ version based on former C-version (GPL v2) with authors: + * c++ version based on former C-version (GPL v2+) with authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Johan Engelen <goejendaagh@zonnet.nl> diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index 093f273f6..dc28c0bad 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (C) 2012 Kris De Gussem <Kris.DeGussem@gmail.com> - * c++version based on former C-version (GPL v2) with authors: + * c++version based on former C-version (GPL v2+) with authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Johan Engelen <goejendaagh@zonnet.nl> 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/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index a1c7d41bd..f2ee79d06 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -573,7 +573,7 @@ void StatusWidget::end_process() clear(); } -#if !GTK_CHECK_VERSION(3,6,0) +#if !GTK_CHECK_VERSION(3,0,0) SearchEntry::SearchEntry() : Gtk::Entry() { signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed)); @@ -1222,7 +1222,7 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types label_not_found = new Gtk::Label(); label_description = new Gtk::Label(); -#if GTK_CHECK_VERSION(3,6,0) +#if GTK_CHECK_VERSION(3,0,0) entry_search = new Gtk::SearchEntry(); #else entry_search = new SearchEntry(); diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 6ceceb9ef..9de24d821 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -26,7 +26,7 @@ #include <cairomm/refptr.h> -#if GTK_CHECK_VERSION(3,6,0) +#if GTK_CHECK_VERSION(3,0,0) # include <gtkmm/searchentry.h> #endif @@ -336,7 +336,7 @@ public: Gtk::Label* label; }; -#if !GTK_CHECK_VERSION(3,6,0) +#if !GTK_CHECK_VERSION(3,0,0) /** * A Gtk::Entry with search & clear icons */ @@ -460,7 +460,7 @@ private: Glib::ustring filename_image; Glib::ustring filename_thumbnail; -#if GTK_CHECK_VERSION(3,6,0) +#if GTK_CHECK_VERSION(3,0,0) Gtk::SearchEntry *entry_search; #else SearchEntry *entry_search; diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index cbb2fb953..c99c1bff3 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -935,7 +935,17 @@ TagsPanel::TagsPanel() : _tree.set_headers_visible(false); _tree.set_reorderable(true); _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); - + + // This string is constructed to use already translated strings. + // The tooltip applies to the whole tree area. It would be better + // if the tooltip was split into parts and only applied to the + // icons but doing that is quite complicated. + Glib::ustring tooltip_string = "'+': "; + tooltip_string += (_("Add selection to set")); + tooltip_string += "; '×': "; + tooltip_string += (_("Remove from selection set")); + _tree.set_tooltip_text( tooltip_string ); + Inkscape::UI::Widget::AddToIcon * addRenderer = manage( new Inkscape::UI::Widget::AddToIcon()); int addColNum = _tree.append_column("type", *addRenderer) - 1; Gtk::TreeViewColumn *col = _tree.get_column(addColNum); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 531aa728d..3e2a2004c 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -79,6 +79,10 @@ #include "message-stack.h" #include "ui/dialog/layer-properties.h" +#if GTK_CHECK_VERSION(3,0,0) + #include "widgets/image-menu-item.h" +#endif + #include <gdk/gdkkeysyms.h> #include <glibmm/miscutils.h> @@ -413,7 +417,11 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name ); gtk_widget_show(icon); +#if GTK_CHECK_VERSION(3,0,0) + image_menu_item_set_image((ImageMenuItem *) item, icon); +#else gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon); +#endif } // end of sp_ui_menu_add_icon void @@ -467,7 +475,11 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb if (radio) { item = gtk_radio_menu_item_new_with_mnemonic(group, action->name); } else { +#if GTK_CHECK_VERSION(3,0,0) + item = image_menu_item_new_with_mnemonic(action->name); +#else item = gtk_image_menu_item_new_with_mnemonic(action->name); +#endif } gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name); @@ -1018,7 +1030,7 @@ sp_ui_drag_data_received(GtkWidget *widget, { int destX = 0; int destY = 0; - gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY ); + gtk_widget_translate_coordinates( widget, GTK_WIDGET(desktop->canvas), x, y, &destX, &destY ); Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) ); Geom::Point const button_dt(desktop->w2d(where)); Geom::Point const button_doc(desktop->dt2doc(button_dt)); @@ -1141,7 +1153,7 @@ sp_ui_drag_data_received(GtkWidget *widget, if ( worked ) { int destX = 0; int destY = 0; - gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY ); + gtk_widget_translate_coordinates( widget, GTK_WIDGET(desktop->canvas), x, y, &destX, &destY ); Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) ); Geom::Point const button_dt(desktop->w2d(where)); Geom::Point const button_doc(desktop->dt2doc(button_dt)); @@ -1511,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); } } } @@ -1908,6 +1926,12 @@ void ContextMenu::ActivateUngroup(void) sp_item_group_ungroup(static_cast<SPGroup*>(_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/ui/previewholder.cpp b/src/ui/previewholder.cpp index 21f3f38d7..beb83f35c 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -340,6 +340,12 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int& width = itemCount; height = 1; +#if GTK_CHECK_VERSION(3,16,0) + // Disable overlay scrolling as the scrollbar covers up swatches. + // For some reason this also makes the height 55px. + ((Gtk::ScrolledWindow *)_scroller)->set_overlay_scrolling(false); +#endif + if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) { Gtk::Requisition req; #if GTK_CHECK_VERSION(3,0,0) diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index f6d1985cc..28c0fd865 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -3,6 +3,7 @@ #define SEEN_PREVIEW_HOLDER_H /* * A simple interface for previewing representations. + * Used by Swatches * * Authors: * Jon A. Cruz diff --git a/src/ui/tool/event-utils.cpp b/src/ui/tool/event-utils.cpp index 079275d63..6b8d5f0dc 100644 --- a/src/ui/tool/event-utils.cpp +++ b/src/ui/tool/event-utils.cpp @@ -60,8 +60,8 @@ unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mas } GdkEvent *event_next; gint i = 0; - event.x -= canvas->x0; - event.y -= canvas->y0; + event.x -= canvas->_x0; + event.y -= canvas->_y0; event_next = gdk_event_get(); // while the next event is also a motion notify @@ -92,8 +92,8 @@ unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mas if (event_next) { gdk_event_put(event_next); } - event.x += canvas->x0; - event.y += canvas->y0; + event.x += canvas->_x0; + event.y += canvas->_y0; return i; } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index b84d16686..74f2664fe 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -247,7 +247,7 @@ void ConnectorTool::setup() { // Make sure we see all enter events for canvas items, // even if a mouse button is depressed. - this->desktop->canvas->gen_all_enter_events = true; + this->desktop->canvas->_gen_all_enter_events = true; } void ConnectorTool::set(const Inkscape::Preferences::Entry& val) { @@ -276,7 +276,7 @@ void ConnectorTool::finish() { this->cc_clear_active_conn(); // Restore the default event generating behaviour. - this->desktop->canvas->gen_all_enter_events = false; + this->desktop->canvas->_gen_all_enter_events = false; } //----------------------------------------------------------------------------- diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 07edf6039..287828d32 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1287,9 +1287,9 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, if(to_guides) { gchar *cross_number; if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true)) { - cross_number= g_strdup_printf(_("Crossing %u"), idx); + cross_number= g_strdup_printf(_("Crossing %lu"), static_cast<unsigned long>(idx)); } else { - cross_number= g_strdup_printf(_("Crossing %u"), idx + 1); + cross_number= g_strdup_printf(_("Crossing %lu"), static_cast<unsigned long>(idx + 1)); } if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true) && idx == 0) { setGuide(desktop->doc2dt(intersections[idx]), angle + Geom::rad_from_deg(90), ""); 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(); } diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 2fe4a0704..ec2e69fb3 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -377,7 +377,6 @@ void ColorICCSelector::init() (gpointer)_impl); gtk_widget_set_sensitive(_impl->_fixupBtn, FALSE); gtk_widget_set_tooltip_text(_impl->_fixupBtn, _("Fix RGB fallback to match icc-color() value.")); - // gtk_misc_set_alignment( GTK_MISC (_impl->_fixupBtn), 1.0, 0.5 ); gtk_widget_show(_impl->_fixupBtn); attachToGridOrTable(t, _impl->_fixupBtn, 0, row, 1, 1); @@ -431,7 +430,13 @@ void ColorICCSelector::init() #endif _impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str()); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END); +#else gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5); +#endif + gtk_widget_show(_impl->_compUI[i]._label); gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE); @@ -489,7 +494,13 @@ void ColorICCSelector::init() // Label _impl->_label = gtk_label_new_with_mnemonic(_("_A:")); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END); +#else gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5); +#endif + gtk_widget_show(_impl->_label); attachToGridOrTable(t, _impl->_label, 0, row, 1, 1); diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 60abf43bf..6d7ada734 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -210,7 +210,11 @@ void ColorNotebook::_initUI() /* Create RGBA entry and color preview */ _rgbal = gtk_label_new_with_mnemonic(_("RGBA_:")); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(_rgbal, GTK_ALIGN_END); +#else gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5); +#endif gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2); ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color)); diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index 170f83887..48a2693bc 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -92,7 +92,13 @@ void ColorScales::_initUI(SPColorScalesMode mode) for (i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) { /* Label */ _l[i] = gtk_label_new(""); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(_l[i], GTK_ALIGN_END); +#else gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5); +#endif + gtk_widget_show(_l[i]); #if GTK_CHECK_VERSION(3, 0, 0) diff --git a/src/ui/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c index c857cfa8a..d54486505 100644 --- a/src/ui/widget/gimpcolorwheel.c +++ b/src/ui/widget/gimpcolorwheel.c @@ -303,7 +303,9 @@ gimp_color_wheel_realize (GtkWidget *widget) priv->window = gdk_window_new (parent_window, &attr, attr_mask); gdk_window_set_user_data (priv->window, wheel); +#if !GTK_CHECK_VERSION(3,0,0) gtk_widget_style_attach (widget); +#endif } static void @@ -1246,7 +1248,7 @@ paint_triangle (GimpColorWheel *wheel, #endif } -#if GTK_CHECK_VERSION(3,2,0) +#if GTK_CHECK_VERSION(3,0,0) static gboolean gimp_color_wheel_draw (GtkWidget *widget, cairo_t *cr) 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/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 8a1e98a63..5d4a25a68 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -73,6 +73,9 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, _action_area(0), _fillable(0) { +#if WITH_GTKMM_3_0 + set_orientation( Gtk::ORIENTATION_VERTICAL ); +#endif _init(); } @@ -92,7 +95,6 @@ void Panel::_popper(GdkEventButton* event) void Panel::_init() { - Glib::ustring tmp("<"); _anchor = SP_ANCHOR_CENTER; guint panel_size = 0, panel_mode = 0, panel_ratio = 100, panel_border = 0; diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index a90060e17..7b2836fe8 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -64,7 +64,11 @@ namespace Widget { * @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications. * @see UI::Dialog::DialogManager manages the dialogs within inkscape. */ +#if WITH_GTKMM_3_0 +class Panel : public Gtk::Box { +#else class Panel : public Gtk::VBox { +#endif public: static void prep(); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 9e283fc64..87cf0b8c4 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -363,19 +363,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _popup_sw.show_all(); } - _fill_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click)); - _stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click)); - _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click)); - _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); - _stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); - - - _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu)); - _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed)); - // Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click - g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj()); - g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "focus-in-event", G_CALLBACK (spinbutton_focus_in), _opacity_sb.gobj()); - _fill_place.add(_na[SS_FILL]); _fill_place.set_tooltip_text(__na[SS_FILL]); @@ -452,6 +439,17 @@ SelectedStyle::SelectedStyle(bool /*layout*/) "drag_data_received", G_CALLBACK(dragDataReceived), _drop[SS_FILL]); + + _fill_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click)); + _stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click)); + _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click)); + _stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); + _stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click)); + _opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu)); + _opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed)); + // Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click + g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj()); + g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "focus-in-event", G_CALLBACK (spinbutton_focus_in), _opacity_sb.gobj()); } SelectedStyle::~SelectedStyle() diff --git a/src/unclump.cpp b/src/unclump.cpp index 2c6840425..5ec5cfce4 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -342,7 +342,9 @@ unclump (std::vector<SPItem*> &items) std::list<SPItem*> nei; std::list<SPItem*> rest; - for(int i=0;i<items.size();i++)rest.push_front(items[items.size()-i-1]); + for (int i=0; i < static_cast<int>(items.size()); i++) { + rest.push_front(items[items.size() - i - 1]); + } rest.remove(item); while (!rest.empty()) { @@ -352,7 +354,9 @@ unclump (std::vector<SPItem*> &items) rest.remove(closest); std::vector<SPItem*> new_rest = unclump_remove_behind (item, closest, rest); rest.clear(); - for(int i=0;i<new_rest.size();i++)rest.push_front(new_rest[new_rest.size()-i-1]); + for (int i=0; i < static_cast<int>(new_rest.size()); i++) { + rest.push_front(new_rest[new_rest.size() - i - 1]); + } } else { break; } diff --git a/src/verbs.cpp b/src/verbs.cpp index 7b128c172..299cfe8e7 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")), @@ -3000,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"), 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, diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index c38bde5cf..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 @@ -110,6 +108,11 @@ set(widgets_SRC widget-sizes.h ) +if(${WITH_GTK3_EXPERIMENTAL}) + set(image_menu_item_SRC image-menu-item.h image-menu-item.c) + add_inkscape_source("${image_menu_item_SRC}") +endif() + # add_inkscape_lib(widgets_LIB "${widgets_SRC}") add_inkscape_source("${widgets_SRC}") @@ -121,3 +124,6 @@ set ( widgets_paintbucket_SRC if ("${HAVE_POTRACE}") add_inkscape_source("${widgets_paintbucket_SRC}") endif() + + + diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert index 6913f4a58..c9f04de14 100644 --- a/src/widgets/Makefile_insert +++ b/src/widgets/Makefile_insert @@ -1,5 +1,11 @@ ## Makefile.am fragment sourced by src/Makefile.am. +if WITH_GTKMM_3_0 +ink_common_sources += \ + widgets/image-menu-item.c \ + widgets/image-menu-item.h +endif + ink_common_sources += \ widgets/arc-toolbar.cpp \ widgets/arc-toolbar.h \ @@ -66,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/button.cpp b/src/widgets/button.cpp index 1776e28c4..6ea8c1360 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -96,7 +96,6 @@ static void sp_button_dispose(GObject *object) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); - GtkStyle *style = gtk_widget_get_style(widget); if (child) { gtk_widget_get_preferred_width(GTK_WIDGET(child), minimal_width, natural_width); @@ -105,14 +104,20 @@ static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width *natural_width = 0; } - *minimal_width += 2 + 2 * MAX(2, style->xthickness); - *natural_width += 2 + 2 * MAX(2, style->xthickness); + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkBorder padding; + GtkBorder border; + + gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding); + gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border ); + + *minimal_width += MAX(2, padding.left + padding.right + border.left + border.right); + *natural_width += MAX(2, padding.left + padding.right + border.left + border.right); } static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) { GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); - GtkStyle *style = gtk_widget_get_style(widget); if (child) { gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); @@ -121,8 +126,15 @@ static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_heig *natural_height = 0; } - *minimal_height += 2 + 2 * MAX(2, style->ythickness); - *natural_height += 2 + 2 * MAX(2, style->ythickness); + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkBorder padding; + GtkBorder border; + + gtk_style_context_get_padding(context, GTK_STATE_FLAG_NORMAL, &padding); + gtk_style_context_get_border( context, GTK_STATE_FLAG_NORMAL, &border ); + + *minimal_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); + *natural_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); } #else static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 1fdd3ca6d..1a4fcccf4 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -404,6 +404,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Glib::RefPtr<Gtk::CssProvider> guides_lock_style_provider = Gtk::CssProvider::create(); guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }"); Gtk::Widget * wnd = Glib::wrap(dtw->guides_lock); + wnd->set_name("guides_lock"); Glib::RefPtr<Gtk::StyleContext> context = wnd->get_style_context(); context->add_provider(guides_lock_style_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); #endif @@ -564,7 +565,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) /* Canvas */ dtw->canvas = SP_CANVAS(SPCanvas::createAA()); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - dtw->canvas->enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable"); + dtw->canvas->_enable_cms_display_adj = prefs->getBool("/options/displayprofile/enable"); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) gtk_widget_set_can_focus (GTK_WIDGET (dtw->canvas), TRUE); @@ -572,10 +573,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas)); #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA white = {1,1,1,1}; - gtk_widget_override_background_color(GTK_WIDGET(dtw->canvas), - GTK_STATE_FLAG_NORMAL, - &white); + GtkCssProvider *css_provider = gtk_css_provider_new(); + GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas)); + + gtk_css_provider_load_from_data(css_provider, + "SPCanvas {\n" + " background-color: white;\n" + "}\n", + -1, NULL); + + gtk_style_context_add_provider(style_context, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); #else GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas))); style->bg[GTK_STATE_NORMAL] = style->white; @@ -692,38 +701,37 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_container_add (GTK_CONTAINER (eventbox), dtw->coord_status); gtk_widget_set_tooltip_text (eventbox, _("Cursor coordinates")); GtkWidget *label_x = gtk_label_new(_("X:")); - gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5); - -#if GTK_CHECK_VERSION(3,0,0) - gtk_grid_attach(GTK_GRID(dtw->coord_status), - label_x, 1, 0, 1, 1); -#else - gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0); -#endif - GtkWidget *label_y = gtk_label_new(_("Y:")); - gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5); #if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(label_x, GTK_ALIGN_START); + gtk_widget_set_halign(label_y, GTK_ALIGN_START); + gtk_grid_attach(GTK_GRID(dtw->coord_status), label_x, 1, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1); #else + gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5); + gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5); + gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), label_y, 1,2, 1,2, GTK_FILL, GTK_FILL, 0, 0); #endif dtw->coord_status_x = gtk_label_new(NULL); - gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" ); - gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5); dtw->coord_status_y = gtk_label_new(NULL); + gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" ); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" ); - gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); + GtkWidget* label_z = gtk_label_new(_("Z:")); #if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END); + gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END); gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2); gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2); #else + gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5); + gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0); @@ -746,8 +754,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) Glib::ustring id = Inkscape::CMSSystem::getDisplayId( 0, 0 ); bool enabled = false; - dtw->canvas->cms_key = id; - enabled = !dtw->canvas->cms_key.empty(); + dtw->canvas->_cms_key = id; + enabled = !dtw->canvas->_cms_key.empty(); cms_adjust_set_sensitive( dtw, enabled ); } #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -756,7 +764,13 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->select_status_eventbox = gtk_event_box_new (); dtw->select_status = gtk_label_new (NULL); gtk_label_set_ellipsize (GTK_LABEL(dtw->select_status), PANGO_ELLIPSIZE_END); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(dtw->select_status, GTK_ALIGN_START); +#else gtk_misc_set_alignment (GTK_MISC (dtw->select_status), 0.0, 0.5); +#endif + gtk_widget_set_size_request (dtw->select_status, 1, -1); // display the initial welcome message in the statusbar gtk_label_set_markup (GTK_LABEL (dtw->select_status), _("<b>Welcome to Inkscape!</b> Use shape or freehand tools to create objects; use selector (arrow) to move or transform them.")); @@ -1035,7 +1049,7 @@ sp_desktop_widget_event (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dt // current item on the canvas, because item events and all mouse events are caught // and passed on by the canvas acetate (I think). --bb if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) - && !dtw->canvas->current_item) { + && !dtw->canvas->_current_item) { return sp_desktop_root_handler (NULL, event, dtw->desktop); } } @@ -1054,9 +1068,9 @@ void sp_dtw_color_profile_event(EgeColorProfTracker */*tracker*/, SPDesktopWidge gint monitor = gdk_screen_get_monitor_at_window(screen, window); Glib::ustring id = Inkscape::CMSSystem::getDisplayId( screenNum, monitor ); bool enabled = false; - dtw->canvas->cms_key = id; + dtw->canvas->_cms_key = id; dtw->requestCanvasUpdate(); - enabled = !dtw->canvas->cms_key.empty(); + enabled = !dtw->canvas->_cms_key.empty(); cms_adjust_set_sensitive( dtw, enabled ); } #else @@ -1092,8 +1106,8 @@ void cms_adjust_toggled( GtkWidget */*button*/, gpointer data ) SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); bool down = SP_BUTTON_IS_DOWN(dtw->cms_adjust); - if ( down != dtw->canvas->enable_cms_display_adj ) { - dtw->canvas->enable_cms_display_adj = down; + if ( down != dtw->canvas->_enable_cms_display_adj ) { + dtw->canvas->_enable_cms_display_adj = down; dtw->requestCanvasUpdate(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/options/displayprofile/enable", down); @@ -1685,7 +1699,11 @@ void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionTyp case GTK_POS_TOP: case GTK_POS_BOTTOM: if ( gtk_widget_is_ancestor(toolbox, hbox) ) { - gtk_widget_reparent( toolbox, vbox ); + // Removing a widget can reduce ref count to zero + g_object_ref(G_OBJECT(toolbox)); + gtk_container_remove(GTK_CONTAINER(hbox), toolbox); + gtk_container_add(GTK_CONTAINER(vbox), 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); @@ -1693,7 +1711,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_widget_reparent( toolbox, hbox ); + g_object_ref(G_OBJECT(toolbox)); + gtk_container_remove(GTK_CONTAINER(vbox), toolbox); + gtk_container_add(GTK_CONTAINER(hbox), 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 ); diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 19dbb04ab..9951a8957 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -239,7 +239,7 @@ static gboolean eek_preview_draw(GtkWidget *widget, cairo_t *cr) { - GtkStyle *style = gtk_widget_get_style(widget); + EekPreview *preview = EEK_PREVIEW(widget); EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); @@ -284,7 +284,8 @@ gboolean eek_preview_draw(GtkWidget *widget, 0, 0, allocation.width, allocation.height); #else - GdkWindow* window = gtk_widget_get_window(widget); + GtkStyle *style = gtk_widget_get_style(widget); + GdkWindow *window = gtk_widget_get_window(widget); gtk_paint_flat_box( style, window, @@ -495,14 +496,11 @@ gboolean eek_preview_draw(GtkWidget *widget, otherArea.y = possible.y + (possible.height - otherArea.height) / 2; } #if GTK_CHECK_VERSION(3,0,0) - gtk_paint_diamond( style, - cr, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_OUT, - widget, - NULL, - otherArea.x, otherArea.y, - otherArea.width, otherArea.height ); + // This should be a diamond too? + gtk_render_check(context, + cr, + otherArea.x, otherArea.y, + otherArea.width, otherArea.height ); #else gtk_paint_diamond( style, window, @@ -549,7 +547,11 @@ static gboolean eek_preview_enter_cb( GtkWidget* widget, GdkEventCrossing* event EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->within = TRUE; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_state_flags( widget, priv->hot ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_PRELIGHT, false ); +#else gtk_widget_set_state( widget, priv->hot ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT ); +#endif } return FALSE; @@ -562,7 +564,11 @@ static gboolean eek_preview_leave_cb( GtkWidget* widget, GdkEventCrossing* event EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->within = FALSE; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false ); +#else gtk_widget_set_state( widget, GTK_STATE_NORMAL ); +#endif } return FALSE; @@ -587,7 +593,11 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton* if ( priv->within ) { +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_ACTIVE, false ); +#else gtk_widget_set_state( widget, GTK_STATE_ACTIVE ); +#endif } } } @@ -602,7 +612,11 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->hot = FALSE; +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false ); +#else gtk_widget_set_state( widget, GTK_STATE_NORMAL ); +#endif if ( priv->within && (event->button == PRIME_BUTTON_MAGIC_NUMBER || diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp index a91149f4c..272217aa4 100644 --- a/src/widgets/ege-adjustment-action.cpp +++ b/src/widgets/ege-adjustment-action.cpp @@ -865,7 +865,13 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); } else { GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(lbl, GTK_ALIGN_END); +#else gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); +#endif + gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); } } diff --git a/src/widgets/ege-select-one-action.cpp b/src/widgets/ege-select-one-action.cpp index ab86c49f8..2e106154e 100644 --- a/src/widgets/ege-select-one-action.cpp +++ b/src/widgets/ege-select-one-action.cpp @@ -818,9 +818,14 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 ); { +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(holder, GTK_ALIGN_START); + gtk_container_add(GTK_CONTAINER(item), holder); +#else GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); gtk_container_add( GTK_CONTAINER(align), holder); gtk_container_add( GTK_CONTAINER(item), align ); +#endif } } @@ -855,10 +860,14 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override ) GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) ); if ( children && children->data ) { gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" ); + +#if !GTK_CHECK_VERSION(3,0,0) if (!combodata && GTK_IS_ALIGNMENT(children->data)) { GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) ); combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" ); } +#endif + if ( GTK_IS_COMBO_BOX(combodata) ) { GtkComboBox* combo = GTK_COMBO_BOX(combodata); if ((active == -1) && (gtk_combo_box_get_has_entry(combo))) { @@ -915,10 +924,14 @@ void resync_sensitive( EgeSelectOneAction* act ) GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) ); if ( children && children->data ) { gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" ); + +#if !GTK_CHECK_VERSION(3,0,0) if (!combodata && GTK_IS_ALIGNMENT(children->data)) { GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) ); combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" ); } +#endif + if ( GTK_IS_COMBO_BOX(combodata) ) { /* Not implemented */ } else if ( GTK_IS_BOX(children->data) ) { 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<Gtk::ListStore> store = fontlister->get_font_list(); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 35c1e4a8d..3aa44c90a 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -914,7 +914,13 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s /* Label */ GtkWidget *l = gtk_label_new(C_("Gradient","Offset:")); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_END); +#else gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); +#endif + gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); gtk_widget_show(l); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 542d16797..f2031fe51 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -232,6 +232,7 @@ void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) } } +// GTK3 Only, Doesn't actually seem to be used. gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) { SPIcon *icon = SP_ICON(widget); @@ -247,24 +248,34 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) { #else if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { + std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; #endif + std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl; + +#if GTK_CHECK_VERSION(3,0,0) + // image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget), + // source, + // (GtkIconSize)-1); + + // gtk_render_icon_pixbuf deprecated, replaced by: + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + image = gtk_icon_theme_load_icon (icon_theme, + "gtk-image", + 32, + (GtkIconLookupFlags)0, + NULL); +#else GtkIconSource *source = gtk_icon_source_new(); gtk_icon_source_set_pixbuf(source, icon->pb); gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used gtk_icon_source_set_size_wildcarded(source, FALSE); - -#if GTK_CHECK_VERSION(3,0,0) - image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget), - source, - (GtkIconSize)-1); -#else image = gtk_style_render_icon(gtk_widget_get_style(widget), source, gtk_widget_get_direction(widget), (GtkStateType) gtk_widget_get_state(widget), (GtkIconSize)-1, widget, "gtk-image"); + gtk_icon_source_free(source); #endif - gtk_icon_source_free(source); unref_image = true; } @@ -272,7 +283,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); @@ -787,6 +804,10 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) GtkWidget *widget = NULL; gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) ); + if (trySize != lsize ) { + std::cerr << "GtkWidget *IconImple::newFull(): lsize != trySize: lsize: " << lsize + << " try Size: " << trySize << " " << (name?name:"NULL") << std::endl; + } if ( !sizeMapDone ) { injectCustomSize(); } @@ -814,6 +835,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) if ( Inkscape::Preferences::get()->getBool("/options/iconrender/named_nodelay") ) { int psize = getPhysSize(lsize); + // std::cout << " name: " << name << " size: " << psize << std::endl; prerenderIcon(name, mappedSize, psize); } else { addPreRender( mappedSize, name ); @@ -986,8 +1008,6 @@ int IconImpl::getPhysSize(int size) "inkscape-decoration" }; - GtkWidget *icon = GTK_WIDGET(g_object_new(SP_TYPE_ICON, NULL)); - for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes); ++i) { guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION; @@ -1012,7 +1032,12 @@ int IconImpl::getPhysSize(int size) // gtk_icon_size_lookup(), because themes are free to render the pixbuf however // they like, including changing the usual size." gchar const *id = INKSCAPE_ICON("document-open"); - GdkPixbuf *pb = gtk_widget_render_icon( icon, id, gtkSizes[i], NULL); + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + GdkPixbuf *pb = gtk_icon_theme_load_icon (icon_theme, + id, + vals[val_ix], + (GtkIconLookupFlags)0, + NULL); if (pb) { width = gdk_pixbuf_get_width(pb); height = gdk_pixbuf_get_height(pb); @@ -1028,7 +1053,6 @@ int IconImpl::getPhysSize(int size) g_object_unref(G_OBJECT(pb)); } } - //g_object_unref(icon); init = true; } diff --git a/src/widgets/image-menu-item.c b/src/widgets/image-menu-item.c new file mode 100644 index 000000000..2b9500ba0 --- /dev/null +++ b/src/widgets/image-menu-item.c @@ -0,0 +1,1071 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. + * Forked by . Icons in menus are important to us. + */ + +#include "config.h" + +#include <glib/gi18n-lib.h> +#include <gtk/gtk.h> + +#include "widgets/image-menu-item.h" + +/** + * SECTION:gtkimagemenuitem + * @Short_description: A menu item with an icon + * @Title: ImageMenuItem + * + * A ImageMenuItem is a menu item which has an icon next to the text label. + * + * Note that the user can disable display of menu icons, so make sure to still + * fill in the text label. + */ + + +struct _ImageMenuItemPrivate +{ + GtkWidget *image; + + gchar *label; + guint use_stock : 1; + guint toggle_size; +}; + +enum { + PROP_0, + PROP_IMAGE, + PROP_USE_STOCK, + PROP_ACCEL_GROUP, +}; + +static GtkActivatableIface *parent_activatable_iface; + +static void image_menu_item_destroy (GtkWidget *widget); +static void image_menu_item_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural); +static void image_menu_item_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural); +static void image_menu_item_get_preferred_height_for_width (GtkWidget *widget, + gint width, + gint *minimum, + gint *natural); +static void image_menu_item_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static void image_menu_item_map (GtkWidget *widget); +static void image_menu_item_remove (GtkContainer *container, + GtkWidget *child); +static void image_menu_item_toggle_size_request (GtkMenuItem *menu_item, + gint *requisition); +static void image_menu_item_set_label (GtkMenuItem *menu_item, + const gchar *label); +static const gchar * image_menu_item_get_label (GtkMenuItem *menu_item); + +static void image_menu_item_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); + +static void image_menu_item_finalize (GObject *object); +static void image_menu_item_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void image_menu_item_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void image_menu_item_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen); + +static void image_menu_item_recalculate (ImageMenuItem *image_menu_item); + +static void image_menu_item_activatable_interface_init (GtkActivatableIface *iface); +static void image_menu_item_update (GtkActivatable *activatable, + GtkAction *action, + const gchar *property_name); +static void image_menu_item_sync_action_properties (GtkActivatable *activatable, + GtkAction *action); + + +G_DEFINE_TYPE_WITH_CODE (ImageMenuItem, image_menu_item, GTK_TYPE_MENU_ITEM, + G_ADD_PRIVATE (ImageMenuItem) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, + image_menu_item_activatable_interface_init)) + + +static void +image_menu_item_class_init (ImageMenuItemClass *klass) +{ + GObjectClass *gobject_class = (GObjectClass*) klass; + GtkWidgetClass *widget_class = (GtkWidgetClass*) klass; + GtkMenuItemClass *menu_item_class = (GtkMenuItemClass*) klass; + GtkContainerClass *container_class = (GtkContainerClass*) klass; + + widget_class->destroy = image_menu_item_destroy; + widget_class->screen_changed = image_menu_item_screen_changed; + widget_class->get_preferred_width = image_menu_item_get_preferred_width; + widget_class->get_preferred_height = image_menu_item_get_preferred_height; + widget_class->get_preferred_height_for_width = image_menu_item_get_preferred_height_for_width; + widget_class->size_allocate = image_menu_item_size_allocate; + widget_class->map = image_menu_item_map; + + container_class->forall = image_menu_item_forall; + container_class->remove = image_menu_item_remove; + + menu_item_class->toggle_size_request = image_menu_item_toggle_size_request; + menu_item_class->set_label = image_menu_item_set_label; + menu_item_class->get_label = image_menu_item_get_label; + + gobject_class->finalize = image_menu_item_finalize; + gobject_class->set_property = image_menu_item_set_property; + gobject_class->get_property = image_menu_item_get_property; + + /** + * ImageMenuItem:image: + * + * Child widget to appear next to the menu text. + * + */ + g_object_class_install_property (gobject_class, + PROP_IMAGE, + g_param_spec_object ("image", + _("Image widget"), + _("Child widget to appear next to the menu text"), + GTK_TYPE_WIDGET, + GTK_PARAM_READWRITE | G_PARAM_DEPRECATED)); + /** + * ImageMenuItem:use-stock: + * + * If %TRUE, the label set in the menuitem is used as a + * stock id to select the stock item for the item. + * + * Since: 2.16 + * + */ + g_object_class_install_property (gobject_class, + PROP_USE_STOCK, + g_param_spec_boolean ("use-stock", + _("Use stock"), + _("Whether to use the label text to create a stock menu item"), + FALSE, + GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_DEPRECATED)); + + /** + * ImageMenuItem:accel-group: + * + * The Accel Group to use for stock accelerator keys + * + * Since: 2.16 + * + */ + g_object_class_install_property (gobject_class, + PROP_ACCEL_GROUP, + g_param_spec_object ("accel-group", + _("Accel Group"), + _("The Accel Group to use for stock accelerator keys"), + GTK_TYPE_ACCEL_GROUP, + GTK_PARAM_WRITABLE | G_PARAM_DEPRECATED)); + +} + +static void +image_menu_item_init (ImageMenuItem *image_menu_item) +{ + ImageMenuItemPrivate *priv; + + image_menu_item->priv = image_menu_item_get_instance_private (image_menu_item); + priv = image_menu_item->priv; + + priv->image = NULL; + priv->use_stock = FALSE; + priv->label = NULL; +} + +static void +image_menu_item_finalize (GObject *object) +{ + ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (object)->priv; + + g_free (priv->label); + priv->label = NULL; + + G_OBJECT_CLASS (image_menu_item_parent_class)->finalize (object); +} + +static void +image_menu_item_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (object); + + switch (prop_id) + { + case PROP_IMAGE: + image_menu_item_set_image (image_menu_item, (GtkWidget *) g_value_get_object (value)); + break; + case PROP_USE_STOCK: + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + image_menu_item_set_use_stock (image_menu_item, g_value_get_boolean (value)); + G_GNUC_END_IGNORE_DEPRECATIONS; + break; + case PROP_ACCEL_GROUP: + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + image_menu_item_set_accel_group (image_menu_item, g_value_get_object (value)); + G_GNUC_END_IGNORE_DEPRECATIONS; + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +image_menu_item_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (object); + + switch (prop_id) + { + case PROP_IMAGE: + g_value_set_object (value, image_menu_item_get_image (image_menu_item)); + break; + case PROP_USE_STOCK: + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + g_value_set_boolean (value, image_menu_item_get_use_stock (image_menu_item)); + G_GNUC_END_IGNORE_DEPRECATIONS; + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +image_menu_item_map (GtkWidget *widget) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + + GTK_WIDGET_CLASS (image_menu_item_parent_class)->map (widget); + + if (priv->image) + g_object_set (priv->image, "visible", TRUE, NULL); +} + +static void +image_menu_item_destroy (GtkWidget *widget) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + + if (priv->image) + gtk_container_remove (GTK_CONTAINER (image_menu_item), + priv->image); + + GTK_WIDGET_CLASS (image_menu_item_parent_class)->destroy (widget); +} + +static void +image_menu_item_toggle_size_request (GtkMenuItem *menu_item, + gint *requisition) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (menu_item); + ImageMenuItemPrivate *priv = image_menu_item->priv; + GtkPackDirection pack_dir; + GtkWidget *parent; + GtkWidget *widget = GTK_WIDGET (menu_item); + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); + else + pack_dir = GTK_PACK_DIRECTION_LTR; + + *requisition = 0; + + if (priv->image && gtk_widget_get_visible (priv->image)) + { + GtkRequisition image_requisition; + guint toggle_spacing; + + gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL); + + gtk_widget_style_get (GTK_WIDGET (menu_item), + "toggle-spacing", &toggle_spacing, + NULL); + + if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) + { + if (image_requisition.width > 0) + *requisition = image_requisition.width + toggle_spacing; + } + else + { + if (image_requisition.height > 0) + *requisition = image_requisition.height + toggle_spacing; + } + } +} + +static void +image_menu_item_recalculate (ImageMenuItem *image_menu_item) +{ + ImageMenuItemPrivate *priv = image_menu_item->priv; + GtkStockItem stock_item; + GtkWidget *image; + const gchar *resolved_label = priv->label; + + if (priv->use_stock && priv->label) + { + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + + if (!priv->image) + { + image = gtk_image_new_from_stock (priv->label, GTK_ICON_SIZE_MENU); + image_menu_item_set_image (image_menu_item, image); + } + + if (gtk_stock_lookup (priv->label, &stock_item)) + resolved_label = stock_item.label; + + gtk_menu_item_set_use_underline (GTK_MENU_ITEM (image_menu_item), TRUE); + + G_GNUC_END_IGNORE_DEPRECATIONS; + } + + GTK_MENU_ITEM_CLASS + (image_menu_item_parent_class)->set_label (GTK_MENU_ITEM (image_menu_item), resolved_label); + +} + +static void +image_menu_item_set_label (GtkMenuItem *menu_item, + const gchar *label) +{ + ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (menu_item)->priv; + + if (priv->label != label) + { + g_free (priv->label); + priv->label = g_strdup (label); + + image_menu_item_recalculate (IMAGE_MENU_ITEM (menu_item)); + + g_object_notify (G_OBJECT (menu_item), "label"); + + } +} + +static const gchar * +image_menu_item_get_label (GtkMenuItem *menu_item) +{ + ImageMenuItemPrivate *priv = IMAGE_MENU_ITEM (menu_item)->priv; + + return priv->label; +} + +static void +image_menu_item_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + GtkPackDirection pack_dir; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); + else + pack_dir = GTK_PACK_DIRECTION_LTR; + + GTK_WIDGET_CLASS (image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural); + + if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) && + priv->image && + gtk_widget_get_visible (priv->image)) + { + gint child_minimum, child_natural; + + gtk_widget_get_preferred_width (priv->image, &child_minimum, &child_natural); + + *minimum = MAX (*minimum, child_minimum); + *natural = MAX (*natural, child_natural); + } +} + +static void +image_menu_item_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + gint child_height = 0; + GtkPackDirection pack_dir; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); + else + pack_dir = GTK_PACK_DIRECTION_LTR; + + if (priv->image && gtk_widget_get_visible (priv->image)) + { + GtkRequisition child_requisition; + + gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); + + child_height = child_requisition.height; + } + + GTK_WIDGET_CLASS (image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural); + + if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR) + { + *minimum = MAX (*minimum, child_height); + *natural = MAX (*natural, child_height); + } +} + +static void +image_menu_item_get_preferred_height_for_width (GtkWidget *widget, + gint width, + gint *minimum, + gint *natural) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + gint child_height = 0; + GtkPackDirection pack_dir; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); + else + pack_dir = GTK_PACK_DIRECTION_LTR; + + if (priv->image && gtk_widget_get_visible (priv->image)) + { + GtkRequisition child_requisition; + + gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); + + child_height = child_requisition.height; + } + + GTK_WIDGET_CLASS + (image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural); + + if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR) + { + *minimum = MAX (*minimum, child_height); + *natural = MAX (*natural, child_height); + } +} + + +static void +image_menu_item_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (widget); + ImageMenuItemPrivate *priv = image_menu_item->priv; + GtkAllocation widget_allocation; + GtkPackDirection pack_dir; + GtkWidget *parent; + + parent = gtk_widget_get_parent (widget); + + if (GTK_IS_MENU_BAR (parent)) + pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent)); + else + pack_dir = GTK_PACK_DIRECTION_LTR; + + GTK_WIDGET_CLASS (image_menu_item_parent_class)->size_allocate (widget, allocation); + + if (priv->image && gtk_widget_get_visible (priv->image)) + { + gint x, y, offset; + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder padding; + GtkRequisition child_requisition; + GtkAllocation child_allocation; + guint horizontal_padding, toggle_spacing; + gint toggle_size; + + toggle_size = image_menu_item->priv->toggle_size; + gtk_widget_style_get (widget, + "horizontal-padding", &horizontal_padding, + "toggle-spacing", &toggle_spacing, + NULL); + + /* Man this is lame hardcoding action, but I can't + * come up with a solution that's really better. + */ + + gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); + + gtk_widget_get_allocation (widget, &widget_allocation); + + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + gtk_style_context_get_padding (context, state, &padding); + offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)); + + if (pack_dir == GTK_PACK_DIRECTION_LTR || + pack_dir == GTK_PACK_DIRECTION_RTL) + { + if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) == + (pack_dir == GTK_PACK_DIRECTION_LTR)) + x = offset + horizontal_padding + padding.left + + (toggle_size - toggle_spacing - child_requisition.width) / 2; + else + x = widget_allocation.width - offset - horizontal_padding - padding.right - + toggle_size + toggle_spacing + + (toggle_size - toggle_spacing - child_requisition.width) / 2; + + y = (widget_allocation.height - child_requisition.height) / 2; + } + else + { + if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) == + (pack_dir == GTK_PACK_DIRECTION_TTB)) + y = offset + horizontal_padding + padding.top + + (toggle_size - toggle_spacing - child_requisition.height) / 2; + else + y = widget_allocation.height - offset - horizontal_padding - padding.bottom - + toggle_size + toggle_spacing + + (toggle_size - toggle_spacing - child_requisition.height) / 2; + + x = (widget_allocation.width - child_requisition.width) / 2; + } + + child_allocation.width = child_requisition.width; + child_allocation.height = child_requisition.height; + child_allocation.x = widget_allocation.x + MAX (x, 0); + child_allocation.y = widget_allocation.y + MAX (y, 0); + + gtk_widget_size_allocate (priv->image, &child_allocation); + } +} + +static void +image_menu_item_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (container); + ImageMenuItemPrivate *priv = image_menu_item->priv; + + GTK_CONTAINER_CLASS (image_menu_item_parent_class)->forall (container, + include_internals, + callback, + callback_data); + + if (include_internals && priv->image) + (* callback) (priv->image, callback_data); +} + + +static void +image_menu_item_activatable_interface_init (GtkActivatableIface *iface) +{ + parent_activatable_iface = g_type_interface_peek_parent (iface); + iface->update = image_menu_item_update; + iface->sync_action_properties = image_menu_item_sync_action_properties; +} + +static gboolean +activatable_update_stock_id (ImageMenuItem *image_menu_item, GtkAction *action) +{ + GtkWidget *image; + const gchar *stock_id = gtk_action_get_stock_id (action); + + image = image_menu_item_get_image (image_menu_item); + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + + if (GTK_IS_IMAGE (image) && + stock_id && gtk_icon_factory_lookup_default (stock_id)) + { + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + gtk_image_set_from_stock (GTK_IMAGE (image), stock_id, GTK_ICON_SIZE_MENU); + G_GNUC_END_IGNORE_DEPRECATIONS; + return TRUE; + } + + G_GNUC_END_IGNORE_DEPRECATIONS; + + return FALSE; +} + +static gboolean +activatable_update_gicon (ImageMenuItem *image_menu_item, GtkAction *action) +{ + GtkWidget *image; + GIcon *icon = gtk_action_get_gicon (action); + const gchar *stock_id; + gboolean ret = FALSE; + + stock_id = gtk_action_get_stock_id (action); + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + + image = image_menu_item_get_image (image_menu_item); + + if (icon && GTK_IS_IMAGE (image) && + !(stock_id && gtk_icon_factory_lookup_default (stock_id))) + { + gtk_image_set_from_gicon (GTK_IMAGE (image), icon, GTK_ICON_SIZE_MENU); + ret = TRUE; + } + + G_GNUC_END_IGNORE_DEPRECATIONS; + + return ret; +} + +static void +activatable_update_icon_name (ImageMenuItem *image_menu_item, GtkAction *action) +{ + GtkWidget *image; + const gchar *icon_name = gtk_action_get_icon_name (action); + + image = image_menu_item_get_image (image_menu_item); + + if (GTK_IS_IMAGE (image) && + (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_EMPTY || + gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME)) + { + gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU); + } +} + +static void +image_menu_item_update (GtkActivatable *activatable, + GtkAction *action, + const gchar *property_name) +{ + ImageMenuItem *image_menu_item; + gboolean use_appearance; + + image_menu_item = IMAGE_MENU_ITEM (activatable); + + parent_activatable_iface->update (activatable, action, property_name); + + use_appearance = gtk_activatable_get_use_action_appearance (activatable); + if (!use_appearance) + return; + + if (strcmp (property_name, "stock-id") == 0) + activatable_update_stock_id (image_menu_item, action); + else if (strcmp (property_name, "gicon") == 0) + activatable_update_gicon (image_menu_item, action); + else if (strcmp (property_name, "icon-name") == 0) + activatable_update_icon_name (image_menu_item, action); +} + +static void +image_menu_item_sync_action_properties (GtkActivatable *activatable, + GtkAction *action) +{ + ImageMenuItem *image_menu_item; + GtkWidget *image; + gboolean use_appearance; + + image_menu_item = IMAGE_MENU_ITEM (activatable); + + parent_activatable_iface->sync_action_properties (activatable, action); + + if (!action) + return; + + use_appearance = gtk_activatable_get_use_action_appearance (activatable); + if (!use_appearance) + return; + + image = image_menu_item_get_image (image_menu_item); + if (image && !GTK_IS_IMAGE (image)) + { + image_menu_item_set_image (image_menu_item, NULL); + image = NULL; + } + + if (!image) + { + image = gtk_image_new (); + gtk_widget_show (image); + image_menu_item_set_image (IMAGE_MENU_ITEM (activatable), + image); + } + + if (!activatable_update_stock_id (image_menu_item, action) && + !activatable_update_gicon (image_menu_item, action)) + activatable_update_icon_name (image_menu_item, action); + +} + + +/** + * image_menu_item_new: + * + * Creates a new #ImageMenuItem with an empty label. + * + * Returns: a new #ImageMenuItem + * + */ +GtkWidget* +image_menu_item_new (void) +{ + return g_object_new (TYPE_IMAGE_MENU_ITEM, NULL); +} + +/** + * image_menu_item_new_with_label: + * @label: the text of the menu item. + * + * Creates a new #ImageMenuItem containing a label. + * + * Returns: a new #ImageMenuItem. + * + */ +GtkWidget* +image_menu_item_new_with_label (const gchar *label) +{ + return g_object_new (TYPE_IMAGE_MENU_ITEM, + "label", label, + NULL); +} + +/** + * image_menu_item_new_with_mnemonic: + * @label: the text of the menu item, with an underscore in front of the + * mnemonic character + * + * Creates a new #ImageMenuItem containing a label. The label + * will be created using gtk_label_new_with_mnemonic(), so underscores + * in @label indicate the mnemonic for the menu item. + * + * Returns: a new #ImageMenuItem + * + */ +GtkWidget* +image_menu_item_new_with_mnemonic (const gchar *label) +{ + return g_object_new (TYPE_IMAGE_MENU_ITEM, + "use-underline", TRUE, + "label", label, + NULL); +} + +/** + * image_menu_item_new_from_stock: + * @stock_id: the name of the stock item. + * @accel_group: (allow-none): the #GtkAccelGroup to add the menu items + * accelerator to, or %NULL. + * + * Creates a new #ImageMenuItem containing the image and text from a + * stock item. Some stock ids have preprocessor macros like #STOCK_OK + * and #STOCK_APPLY. + * + * If you want this menu item to have changeable accelerators, then pass in + * %NULL for accel_group. Next call gtk_menu_item_set_accel_path() with an + * appropriate path for the menu item, use gtk_stock_lookup() to look up the + * standard accelerator for the stock item, and if one is found, call + * gtk_accel_map_add_entry() to register it. + * + * Returns: a new #ImageMenuItem. + * + */ +GtkWidget* +image_menu_item_new_from_stock (const gchar *stock_id, + GtkAccelGroup *accel_group) +{ + return g_object_new (TYPE_IMAGE_MENU_ITEM, + "label", stock_id, + "use-stock", TRUE, + "accel-group", accel_group, + NULL); +} + +/** + * image_menu_item_set_use_stock: + * @image_menu_item: a #ImageMenuItem + * @use_stock: %TRUE if the menuitem should use a stock item + * + * If %TRUE, the label set in the menuitem is used as a + * stock id to select the stock item for the item. + * + * Since: 2.16 + * + */ +void +image_menu_item_set_use_stock (ImageMenuItem *image_menu_item, + gboolean use_stock) +{ + ImageMenuItemPrivate *priv; + + g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item)); + + priv = image_menu_item->priv; + + if (priv->use_stock != use_stock) + { + priv->use_stock = use_stock; + + image_menu_item_recalculate (image_menu_item); + + g_object_notify (G_OBJECT (image_menu_item), "use-stock"); + } +} + +/** + * image_menu_item_get_use_stock: + * @image_menu_item: a #ImageMenuItem + * + * Checks whether the label set in the menuitem is used as a + * stock id to select the stock item for the item. + * + * Returns: %TRUE if the label set in the menuitem is used as a + * stock id to select the stock item for the item + * + * Since: 2.16 + * + */ +gboolean +image_menu_item_get_use_stock (ImageMenuItem *image_menu_item) +{ + g_return_val_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item), FALSE); + + return image_menu_item->priv->use_stock; +} + +/** + * image_menu_item_set_accel_group: + * @image_menu_item: a #ImageMenuItem + * @accel_group: the #GtkAccelGroup + * + * Specifies an @accel_group to add the menu items accelerator to + * (this only applies to stock items so a stock item must already + * be set, make sure to call image_menu_item_set_use_stock() + * and gtk_menu_item_set_label() with a valid stock item first). + * + * If you want this menu item to have changeable accelerators then + * you shouldnt need this (see image_menu_item_new_from_stock()). + * + * Since: 2.16 + * + */ +void +image_menu_item_set_accel_group (ImageMenuItem *image_menu_item, + GtkAccelGroup *accel_group) +{ + ImageMenuItemPrivate *priv; + GtkStockItem stock_item; + + /* Silent return for the constructor */ + if (!accel_group) + return; + + g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item)); + g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group)); + + priv = image_menu_item->priv; + + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + + if (priv->use_stock && priv->label && gtk_stock_lookup (priv->label, &stock_item)) + if (stock_item.keyval) + { + gtk_widget_add_accelerator (GTK_WIDGET (image_menu_item), + "activate", + accel_group, + stock_item.keyval, + stock_item.modifier, + GTK_ACCEL_VISIBLE); + + g_object_notify (G_OBJECT (image_menu_item), "accel-group"); + } + + G_GNUC_END_IGNORE_DEPRECATIONS; + +} + +/** + * image_menu_item_set_image: + * @image_menu_item: a #ImageMenuItem. + * @image: (allow-none): a widget to set as the image for the menu item. + * + * Sets the image of @image_menu_item to the given widget. + * Note that it depends on the show-menu-images setting whether + * the image will be displayed or not. + * + */ +void +image_menu_item_set_image (ImageMenuItem *image_menu_item, + GtkWidget *image) +{ + ImageMenuItemPrivate *priv; + + g_return_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item)); + + priv = image_menu_item->priv; + + if (image == priv->image) + return; + + if (priv->image) + gtk_container_remove (GTK_CONTAINER (image_menu_item), + priv->image); + + priv->image = image; + + if (image == NULL) + return; + + gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item)); + g_object_set (image, "visible", TRUE, "no-show-all", TRUE, NULL); + + g_object_notify (G_OBJECT (image_menu_item), "image"); +} + +/** + * image_menu_item_get_image: + * @image_menu_item: a #ImageMenuItem + * + * Gets the widget that is currently set as the image of @image_menu_item. + * See image_menu_item_set_image(). + * + * Return value: (transfer none): the widget set as image of @image_menu_item + * + **/ +GtkWidget* +image_menu_item_get_image (ImageMenuItem *image_menu_item) +{ + g_return_val_if_fail (IS_IMAGE_MENU_ITEM (image_menu_item), NULL); + + return image_menu_item->priv->image; +} + +static void +image_menu_item_remove (GtkContainer *container, + GtkWidget *child) +{ + ImageMenuItem *image_menu_item = IMAGE_MENU_ITEM (container); + ImageMenuItemPrivate *priv = image_menu_item->priv; + + if (child == priv->image) + { + gboolean widget_was_visible; + + widget_was_visible = gtk_widget_get_visible (child); + + gtk_widget_unparent (child); + priv->image = NULL; + + if (widget_was_visible && + gtk_widget_get_visible (GTK_WIDGET (container))) + gtk_widget_queue_resize (GTK_WIDGET (container)); + + g_object_notify (G_OBJECT (image_menu_item), "image"); + } + else + { + GTK_CONTAINER_CLASS (image_menu_item_parent_class)->remove (container, child); + } +} + +static void +show_image_change_notify (ImageMenuItem *image_menu_item) +{ + ImageMenuItemPrivate *priv = image_menu_item->priv; + + if (priv->image) + { + gtk_widget_show (priv->image); + } +} + +static void +traverse_container (GtkWidget *widget, + gpointer data) +{ + if (IS_IMAGE_MENU_ITEM (widget)) + show_image_change_notify (IMAGE_MENU_ITEM (widget)); + else if (GTK_IS_CONTAINER (widget)) + gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL); +} + +static void +image_menu_item_setting_changed (GtkSettings *settings) +{ + GList *list, *l; + + list = gtk_window_list_toplevels (); + + for (l = list; l; l = l->next) + gtk_container_forall (GTK_CONTAINER (l->data), + traverse_container, NULL); + + g_list_free (list); +} + +static void +image_menu_item_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) +{ + GtkSettings *settings; + gulong show_image_connection; + + if (!gtk_widget_has_screen (widget)) + return; + + settings = gtk_widget_get_settings (widget); + + show_image_connection = + g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0, + NULL, image_menu_item_setting_changed, NULL); + + if (show_image_connection) + return; + + g_signal_connect (settings, "notify::gtk-menu-images", + G_CALLBACK (image_menu_item_setting_changed), NULL); + + show_image_change_notify (IMAGE_MENU_ITEM (widget)); +} diff --git a/src/widgets/image-menu-item.h b/src/widgets/image-menu-item.h new file mode 100644 index 000000000..61cc48f3a --- /dev/null +++ b/src/widgets/image-menu-item.h @@ -0,0 +1,81 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * Modified by the GTK+ Team and others 1997-2000. + * Forked for , icons in menus are important to us. + */ + +#ifndef __IMAGE_MENU_ITEM_H__ +#define __IMAGE_MENU_ITEM_H__ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define GTK_PARAM_READABLE G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB +#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB +#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB + +#define TYPE_IMAGE_MENU_ITEM (image_menu_item_get_type ()) +#define IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IMAGE_MENU_ITEM, ImageMenuItem)) +#define IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_IMAGE_MENU_ITEM, ImageMenuItemClass)) +#define IS_IMAGE_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IMAGE_MENU_ITEM)) +#define IS_IMAGE_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_IMAGE_MENU_ITEM)) +#define IMAGE_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_IMAGE_MENU_ITEM, ImageMenuItemClass)) + +typedef struct _ImageMenuItem ImageMenuItem; +typedef struct _ImageMenuItemPrivate ImageMenuItemPrivate; +typedef struct _ImageMenuItemClass ImageMenuItemClass; + +struct _ImageMenuItem +{ + GtkMenuItem menu_item; + + /*< private >*/ + ImageMenuItemPrivate *priv; +}; + +struct _ImageMenuItemClass +{ + GtkMenuItemClass parent_class; + + /* Padding for future expansion */ + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); + void (*_gtk_reserved4) (void); +}; + +GType image_menu_item_get_type (void) G_GNUC_CONST; +GtkWidget* image_menu_item_new (void); +GtkWidget* image_menu_item_new_with_label (const gchar *label); +GtkWidget* image_menu_item_new_with_mnemonic (const gchar *label); +GtkWidget* image_menu_item_new_from_stock (const gchar *stock_id, + GtkAccelGroup *accel_group); +void image_menu_item_set_image (ImageMenuItem *image_menu_item, + GtkWidget *image); +GtkWidget* image_menu_item_get_image (ImageMenuItem *image_menu_item); +void image_menu_item_set_use_stock (ImageMenuItem *image_menu_item, + gboolean use_stock); +gboolean image_menu_item_get_use_stock (ImageMenuItem *image_menu_item); +void image_menu_item_set_accel_group (ImageMenuItem *image_menu_item, + GtkAccelGroup *accel_group); + +G_END_DECLS + +#endif /* __IMAGE_MENU_ITEM_H__ */ diff --git a/src/widgets/ink-action.cpp b/src/widgets/ink-action.cpp index 5941c31e4..ace99d9aa 100644 --- a/src/widgets/ink-action.cpp +++ b/src/widgets/ink-action.cpp @@ -1,12 +1,20 @@ #include "widgets/icon.h" #include "icon-size.h" #include <glib/gi18n.h> -#include <gtk/gtk.h> + #include "widgets/ink-action.h" #include "widgets/button.h" +#include <gtk/gtk.h> + +#if GTK_CHECK_VERSION(3,0,0) + // Fork of gtk-imagemenuitem to continue support + #include "widgets/image-menu-item.h" + +#endif + static void ink_action_finalize( GObject* obj ); static void ink_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ink_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -158,7 +166,12 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) gchar* label = 0; g_object_get( G_OBJECT(act), "label", &label, NULL ); +#if GTK_CHECK_VERSION(3,0,0) + item = image_menu_item_new_with_mnemonic( label ); +#else item = gtk_image_menu_item_new_with_mnemonic( label ); +#endif + GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId ); // TODO this work-around is until SPIcon will live properly inside of a popup menu if ( SP_IS_ICON(child) ) { @@ -172,7 +185,12 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) } } gtk_widget_show_all( child ); + +#if GTK_CHECK_VERSION(3,0,0) + image_menu_item_set_image( IMAGE_MENU_ITEM(item), child ); +#else gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child ); +#endif g_free( label ); label = 0; @@ -374,9 +392,16 @@ static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) GtkToolButton* button = GTK_TOOL_BUTTON(item); if ( act->private_data->iconId ) { GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_tool_button_set_icon_widget(button, child); +#else GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); gtk_container_add( GTK_CONTAINER(align), child ); gtk_tool_button_set_icon_widget( button, align ); +#endif } else { gchar *label = 0; g_object_get( G_OBJECT(action), "short_label", &label, NULL ); @@ -405,10 +430,18 @@ static void ink_toggle_action_update_icon( InkToggleAction* action ) GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_widget_show_all(child); + gtk_tool_button_set_icon_widget(button, child); +#else GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); gtk_container_add( GTK_CONTAINER(align), child ); gtk_widget_show_all( align ); gtk_tool_button_set_icon_widget( button, align ); +#endif } } @@ -577,9 +610,16 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) GtkToolButton* button = GTK_TOOL_BUTTON(item); GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_tool_button_set_icon_widget(button, child); +#else GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); gtk_container_add( GTK_CONTAINER(align), child ); gtk_tool_button_set_icon_widget( button, align ); +#endif } else { // For now trigger a warning but don't do anything else GtkToolButton* button = GTK_TOOL_BUTTON(item); diff --git a/src/widgets/ink-comboboxentry-action.cpp b/src/widgets/ink-comboboxentry-action.cpp index 1114d2cdb..ec5e26cf5 100644 --- a/src/widgets/ink-comboboxentry-action.cpp +++ b/src/widgets/ink-comboboxentry-action.cpp @@ -371,9 +371,16 @@ GtkWidget* create_tool_item( GtkAction* action ) g_free( combobox_name ); { +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(comboBoxEntry, GTK_ALIGN_START); + gtk_widget_set_hexpand(comboBoxEntry, FALSE); + gtk_widget_set_vexpand(comboBoxEntry, FALSE); + gtk_container_add(GTK_CONTAINER(item), comboBoxEntry); +#else GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); gtk_container_add( GTK_CONTAINER(item), align ); +#endif } ink_comboboxentry_action->combobox = GTK_COMBO_BOX (comboBoxEntry); @@ -956,3 +963,14 @@ gboolean keypress_cb( GtkWidget * /*widget*/, GdkEventKey *event, gpointer data return wasConsumed; } + +/* + 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/ruler.cpp b/src/widgets/ruler.cpp index 3a5e76277..bcab535f9 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/ruler.cpp @@ -282,26 +282,6 @@ sp_ruler_init (SPRuler *ruler) priv->pos_redraw_idle_id = 0; priv->font_scale = DEFAULT_RULER_FONT_SCALE; - -#if GTK_CHECK_VERSION(3,0,0) - #if GTK_CHECK_VERSION(3,8,0) - const gchar *str = - "SPRuler {\n" - " background-color: @theme_bg_color;\n" - "}\n"; - #else - const gchar *str = - "SPRuler {\n" - " background-color: @bg_color;\n" - "}\n"; - #endif - GtkCssProvider *css = gtk_css_provider_new (); - gtk_css_provider_load_from_data (css, str, -1, NULL); - gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (ruler)), - GTK_STYLE_PROVIDER (css), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - g_object_unref (css); -#endif } static void @@ -1425,7 +1405,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler, gdouble position) { GtkWidget *widget = GTK_WIDGET (ruler); - GtkStyle *style = gtk_widget_get_style (widget); SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); GtkAllocation allocation; gint width, height; @@ -1440,8 +1419,19 @@ sp_ruler_get_pos_rect (SPRuler *ruler, gtk_widget_get_allocation (widget, &allocation); +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkBorder padding; + + gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &padding); + + xthickness = padding.left + padding.right; + ythickness = padding.top + padding.bottom; +#else + GtkStyle *style = gtk_widget_get_style (widget); xthickness = style->xthickness; ythickness = style->ythickness; +#endif if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { 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 <mental@rydia.net> - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gtkmm/button.h> -#include <gtk/gtk.h> - -#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 <mental@rydia.net> - * - * 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 : diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 7030753a5..5500e1068 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -84,12 +84,23 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) label_widget = gtk_label_new (label_text); g_assert(label_widget != NULL); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(label_widget, GTK_ALIGN_END); +#else gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5); +#endif + 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); +#else gtk_widget_set_margin_left(label_widget, 4); gtk_widget_set_margin_right(label_widget, 4); +#endif gtk_widget_set_hexpand(label_widget, TRUE); gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL); gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER); @@ -166,7 +177,13 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table, g_assert(table != NULL); GtkWidget *l = gtk_label_new (label); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_set_halign(l, GTK_ALIGN_END); +#else gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); +#endif + gtk_widget_show (l); #if GTK_CHECK_VERSION(3,0,0) @@ -238,12 +255,26 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font) { guint size = GPOINTER_TO_UINT (font); - PangoFontDescription* pan = pango_font_description_new (); - pango_font_description_set_size (pan, size); - #if GTK_CHECK_VERSION(3,0,0) - gtk_widget_override_font (w, pan); + GtkCssProvider *css_provider = gtk_css_provider_new(); + + const double pt_size = size / static_cast<double>(PANGO_SCALE); + std::ostringstream css_data; + css_data << "GtkWidget {\n" + << " font-size: " << pt_size << "pt;\n" + << "}\n"; + + gtk_css_provider_load_from_data(css_provider, + css_data.str().c_str(), + -1, NULL); + + GtkStyleContext *style_context = gtk_widget_get_style_context(w); + gtk_style_context_add_provider(style_context, + GTK_STYLE_PROVIDER(css_provider), + GTK_STYLE_PROVIDER_PRIORITY_USER); #else + PangoFontDescription* pan = pango_font_description_new (); + pango_font_description_set_size (pan, size); gtk_widget_modify_font (w, pan); #endif @@ -251,7 +282,11 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font) gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font); } +#if GTK_CHECK_VERSION(3,0,0) + g_object_unref(css_provider); +#else pango_font_description_free (pan); +#endif } void diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index e71c911bd..23acb74af 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -508,6 +508,10 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } +static bool is_relative( Unit const *unit ) { + return (unit->abbr == "" || unit->abbr == "em" || unit->abbr == "ex" || unit->abbr == "%"); +} + static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) { // quit if run by the _changed callbacks @@ -524,21 +528,22 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit so - // we can save it (allows us to adjust line height value when unit changes). - SPILength temp_length; - Inkscape::CSSOStringStream temp_stream; - temp_stream << 1 << unit->abbr; - temp_length.read(temp_stream.str().c_str()); - prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit); - g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit)); - + // Only save if not relative unit + if ( !is_relative(unit) ) { + // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit so + // we can save it (allows us to adjust line height value when unit changes). + SPILength temp_length; + Inkscape::CSSOStringStream temp_stream; + temp_stream << 1 << unit->abbr; + temp_length.read(temp_stream.str().c_str()); + prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit); + g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit)); + } // Set css line height. SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream osfs; - // We should handle unitless values as well as 'em' and 'ex' - if ((unit->abbr) == "em" || unit->abbr == "ex" || unit->abbr == "%") { + if ( is_relative(unit) ) { osfs << gtk_adjustment_get_value(adj) << unit->abbr; } else { // Inside SVG file, always use "px" for absolute units. @@ -601,13 +606,16 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) g_return_if_fail(unit != NULL); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit. - SPILength temp_length; - Inkscape::CSSOStringStream temp_stream; - temp_stream << 1 << unit->abbr; - temp_length.read(temp_stream.str().c_str()); - prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit); - g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit)); + // Only save if not relative unit + if ( !is_relative(unit) ) { + // This nonsense is to get SP_CSS_UNIT_xx value corresponding to unit. + SPILength temp_length; + Inkscape::CSSOStringStream temp_stream; + temp_stream << 1 << unit->abbr; + temp_length.read(temp_stream.str().c_str()); + prefs->setInt("/tools/text/lineheight/display_unit", temp_length.unit); + g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(temp_length.unit)); + } // Read current line height value EgeAdjustmentAction *line_height_act = @@ -620,19 +628,19 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) std::vector<SPItem*> itemlist=selection->itemList(); // Convert between units - if ((unit->abbr) == "em" && old_unit == SP_CSS_UNIT_EX) { + if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) { line_height *= 0.5; - } else if ((unit->abbr) == "ex" && old_unit == SP_CSS_UNIT_EM) { + } else if ((unit->abbr) == "ex" && (old_unit == SP_CSS_UNIT_EM || old_unit == SP_CSS_UNIT_NONE) ) { line_height *= 2.0; - } else if ((unit->abbr) == "em" && old_unit == SP_CSS_UNIT_PERCENT) { + } else if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_PERCENT) { line_height /= 100.0; - } else if ((unit->abbr) == "%" && old_unit == SP_CSS_UNIT_EM) { + } else if ((unit->abbr) == "%" && (old_unit == SP_CSS_UNIT_EM || old_unit == SP_CSS_UNIT_NONE) ) { line_height *= 100; } else if ((unit->abbr) == "ex" && old_unit == SP_CSS_UNIT_PERCENT) { line_height /= 50.0; } else if ((unit->abbr) == "%" && old_unit == SP_CSS_UNIT_EX) { line_height *= 50; - } else if ((unit->abbr) == "%" || (unit->abbr) == "em" || (unit->abbr) == "ex") { + } else if (is_relative(unit)) { // Convert absolute to relative... for the moment use average font-size double font_size = 0; int count = 0; @@ -648,7 +656,10 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) } else { font_size = 20; } + + if (old_unit == SP_CSS_UNIT_NONE) old_unit = SP_CSS_UNIT_EM; line_height = Quantity::convert(line_height, sp_style_get_css_unit_string(old_unit), "px"); + if (font_size > 0) { line_height /= font_size; } @@ -657,7 +668,8 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) } else if ((unit->abbr) == "ex") { line_height *= 2; } - } else if (old_unit==SP_CSS_UNIT_PERCENT || old_unit==SP_CSS_UNIT_EM || old_unit==SP_CSS_UNIT_EX) { + } else if (old_unit==SP_CSS_UNIT_NONE || old_unit==SP_CSS_UNIT_PERCENT || + old_unit==SP_CSS_UNIT_EM || old_unit==SP_CSS_UNIT_EX) { // Convert relative to absolute... for the moment use average font-size double font_size = 0; int count = 0; @@ -689,8 +701,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Set css line height. SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream osfs; - // We should handle unitless values as well as 'em' and 'ex' - if ((unit->abbr) == "em" || unit->abbr == "ex" || unit->abbr == "%") { + if ( is_relative(unit) ) { osfs << line_height << unit->abbr; } else { osfs << Quantity::convert(line_height, unit, "px") << "px"; @@ -1264,8 +1275,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ switch (line_height_unit) { case SP_CSS_UNIT_NONE: - // tracker can't show no unit... use 'em' - line_height_unit = SP_CSS_UNIT_EM; case SP_CSS_UNIT_EM: case SP_CSS_UNIT_EX: break; @@ -1276,7 +1285,9 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // If unit is set to 'px', use the preferred display unit (if absolute). line_height_unit = prefs->getInt("/tools/text/lineheight/display_unit", SP_CSS_UNIT_PT); - if (line_height_unit != SP_CSS_UNIT_EM && + // But not if prefered unit is relative + if (line_height_unit != SP_CSS_UNIT_NONE && + line_height_unit != SP_CSS_UNIT_EM && line_height_unit != SP_CSS_UNIT_EX && line_height_unit != SP_CSS_UNIT_PERCENT) { height = @@ -1299,7 +1310,13 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ gtk_adjustment_set_value( lineHeightAdjustment, height ); UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) ); - tracker->setActiveUnitByAbbr(sp_style_get_css_unit_string(line_height_unit)); + if( line_height_unit == SP_CSS_UNIT_NONE ) { + // Function 'sp_style_get_css_unit_string' returns 'px' for unit none. + // We need to avoid this. + tracker->setActiveUnitByAbbr(""); + } else { + tracker->setActiveUnitByAbbr(sp_style_get_css_unit_string(line_height_unit)); + } // Save unit so we can do convertions between new/old units. g_object_set_data( tbl, "lineheight_unit", GINT_TO_POINTER(line_height_unit)); @@ -1545,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" @@ -1557,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 */ @@ -1797,10 +1832,10 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Line height unit tracker */ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); + tracker->prependUnit(unit_table.getUnit("")); // No unit tracker->addUnit(unit_table.getUnit("%")); tracker->addUnit(unit_table.getUnit("em")); tracker->addUnit(unit_table.getUnit("ex")); - // tracker->addUnit(unit_table.getUnit("None")); tracker->setActiveUnit(unit_table.getUnit("%")); g_object_set_data( holder, "tracker", tracker ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3389f82f9..0697ff0fb 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -127,7 +127,8 @@ Inkscape::IconSize ToolboxFactory::prefToSize( Glib::ustring const &path, int ba static Inkscape::IconSize sizeChoices[] = { Inkscape::ICON_SIZE_LARGE_TOOLBAR, Inkscape::ICON_SIZE_SMALL_TOOLBAR, - Inkscape::ICON_SIZE_MENU + Inkscape::ICON_SIZE_MENU, + Inkscape::ICON_SIZE_DIALOG }; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int index = prefs->getIntLimited( path, base, 0, G_N_ELEMENTS(sizeChoices) ); |
