summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMoritz Eberl <moritz@semiodesk.com>2016-04-13 10:22:31 +0000
committerMoritz Eberl <moritz@semiodesk.com>2016-04-13 10:22:31 +0000
commit9dc9b855edf5f891856ad1c9a63eae2266bb9cfa (patch)
tree45c8c6d192dbf72c2e543f6e4b5716999c3bb3af /src
parentModified the windows build to integrate gmodule-2.0 and loader.cpp/.h (diff)
parentFixed FIXMEs in Cmake build (set flags when needed) (diff)
downloadinkscape-9dc9b855edf5f891856ad1c9a63eae2266bb9cfa.tar.gz
inkscape-9dc9b855edf5f891856ad1c9a63eae2266bb9cfa.zip
Merge
(bzr r14761.1.4)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/Makefile_insert1
-rw-r--r--src/2geom/sbasis-to-bezier.cpp2
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/desktop-events.cpp49
-rw-r--r--src/desktop.cpp7
-rw-r--r--src/display/nr-filter-tile.cpp7
-rw-r--r--src/display/sp-canvas.cpp898
-rw-r--r--src/display/sp-canvas.h183
-rw-r--r--src/extension/dbus/document-interface.cpp4
-rw-r--r--src/extension/execution-env.cpp2
-rw-r--r--src/extension/internal/image-resolution.cpp78
-rw-r--r--src/inkscape-version.cpp.in7
-rw-r--r--src/inkview.cpp5
-rw-r--r--src/io/inkjar.h8
-rw-r--r--src/livarot/LivarotDefs.h12
-rw-r--r--src/livarot/PathOutline.cpp9
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp7
-rw-r--r--src/live_effects/lpe-patternalongpath.h2
-rw-r--r--src/path-chemistry.cpp14
-rw-r--r--src/selection-chemistry.cpp4
-rw-r--r--src/sp-item.cpp1
-rw-r--r--src/svg-view-widget.cpp16
-rw-r--r--src/svg-view.cpp3
-rw-r--r--src/ui/clipboard.cpp43
-rw-r--r--src/ui/dialog/aboutbox.cpp12
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp5
-rw-r--r--src/ui/dialog/ocaldialogs.cpp4
-rw-r--r--src/ui/dialog/ocaldialogs.h6
-rw-r--r--src/ui/dialog/tags.cpp12
-rw-r--r--src/ui/interface.cpp4
-rw-r--r--src/ui/tool/event-utils.cpp8
-rw-r--r--src/ui/tools/connector-tool.cpp4
-rw-r--r--src/ui/widget/gimpcolorwheel.c2
-rw-r--r--src/ui/widget/selected-style.cpp24
-rw-r--r--src/widgets/button.cpp20
-rw-r--r--src/widgets/desktop-widget.cpp16
-rw-r--r--src/widgets/eek-preview.cpp34
-rw-r--r--src/widgets/icon.cpp8
-rw-r--r--src/widgets/ruler.cpp19
-rw-r--r--src/widgets/toolbox.cpp3
40 files changed, 749 insertions, 799 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/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp
index 8a18cfd4a..64c07f35e 100644
--- a/src/2geom/sbasis-to-bezier.cpp
+++ b/src/2geom/sbasis-to-bezier.cpp
@@ -197,6 +197,8 @@ void sbasis_to_cubic_bezier (std::vector<Point> & bz, D2<SBasis> const& sb)
}
sbasis_to_bezier(bz, sb, 4); // zeroth-order estimate
+ if ((sb[X].size() < 3) && (sb[Y].size() < 3))
+ return; // cubic bezier estimate is exact
Geom::ConvexHull bezhull(bz);
// calculate first derivatives of x and y wrt t
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 30af55925..5c436cefb 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}
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..331ab3351 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -501,7 +501,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 +522,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 +1446,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);
diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp
index 913812828..7172f88ee 100644
--- a/src/display/nr-filter-tile.cpp
+++ b/src/display/nr-filter-tile.cpp
@@ -126,11 +126,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..df84e379c 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -173,159 +173,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 +305,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 +327,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 +426,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 +463,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 +476,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 +512,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 +525,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 +554,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 +579,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 +594,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 +629,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 +648,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 +714,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 +804,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 +833,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 +898,117 @@ 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->_tiles=NULL;
+ canvas->_tLeft=canvas->_tTop=canvas->_tRight=canvas->_tBottom=0;
+ canvas->_tile_h=canvas->_tile_h=0;
- 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;
+ 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;
-
- if (canvas->grabbed_item) {
- canvas->grabbed_item = NULL;
+ _need_redraw = FALSE;
+ if (_tiles) g_free(_tiles);
+ _tiles = NULL;
+ _tLeft = _tTop = _tRight = _tBottom = 0;
+ _tile_h = _tile_h = 0;
+
+ 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;
}
- 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 +1034,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 +1095,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 +1111,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,7 +1135,7 @@ 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;
@@ -1314,25 +1145,25 @@ void SPCanvasImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
// Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0,
// widg_allocation.width, widg_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);
-
+ canvas->resizeTiles(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,
+ canvas->requestRedraw(canvas->_x0 + widg_allocation.width,
0,
- canvas->x0 + allocation->width,
- canvas->y0 + allocation->height);
+ 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);
+ canvas->_y0 + widg_allocation.height,
+ canvas->_x0 + allocation->width,
+ canvas->_y0 + allocation->height);
}
gtk_widget_set_allocation (widget, allocation);
@@ -1344,11 +1175,11 @@ void SPCanvasImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation)
}
}
-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 +1215,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 +1226,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 +1253,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 +1285,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 +1310,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 +1426,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 +1458,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 +1484,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 +1500,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 +1511,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,12 +1524,12 @@ 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);
+ GtkWidget *widget = GTK_WIDGET (this);
// Mark the region clean
- sp_canvas_mark_rect(canvas, paint_rect, 0);
+ markRect(paint_rect, 0);
SPCanvasBuf buf;
buf.buf = NULL;
@@ -1709,16 +1539,6 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect
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);
@@ -1749,20 +1569,20 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect
cairo_paint(buf.ct);
cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER);
- 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();
}
@@ -1781,7 +1601,7 @@ 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_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);
@@ -1789,26 +1609,16 @@ void SPCanvasImpl::sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect
cairo_paint(xct);
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);
}
-namespace {
-
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 +1641,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 +1671,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 +1703,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 +1719,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 +1746,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 +1755,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,41 +1778,41 @@ 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);
+gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) {
+ SPCanvas *canvas = SP_CANVAS(widget);
- cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr);
+ cairo_rectangle_list_t *rects = cairo_copy_clip_rectangle_list(cr);
- for (int i = 0; i < rects->num_rectangles; i++) {
- cairo_rectangle_t rectangle = rects->rectangles[i];
+ for (int i = 0; i < rects->num_rectangles; i++) {
+ cairo_rectangle_t rectangle = rects->rectangles[i];
- Geom::IntRect r = Geom::IntRect::from_xywh(rectangle.x + canvas->x0, rectangle.y + canvas->y0,
- rectangle.width, rectangle.height);
+ 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());
- }
+ canvas->requestRedraw(r.left(), r.top(), r.right(), r.bottom());
+ }
- cairo_rectangle_list_destroy(rects);
+ cairo_rectangle_list_destroy(rects);
return FALSE;
}
#else
-gboolean SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event)
+gboolean SPCanvas::handle_expose(GtkWidget *widget, GdkEventExpose *event)
{
SPCanvas *canvas = SP_CANVAS(widget);
@@ -2024,7 +1831,7 @@ gboolean SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event)
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,
+ 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());
@@ -2035,12 +1842,12 @@ gboolean SPCanvasImpl::handleExpose(GtkWidget *widget, GdkEventExpose *event)
#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,57 +1855,56 @@ 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) {
+ if (!_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;
+ for (int j = _tTop; j < _tBottom; ++j) {
+ for (int i = _tLeft; i < _tRight; ++i) {
+ int tile_index = (i - _tLeft) + (j - _tTop) * _tile_h;
- if ( canvas->tiles[tile_index] ) { // if this tile is dirtied (nonzero)
+ if (_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);
}
-
}
}
@@ -2111,77 +1917,80 @@ int SPCanvasImpl::paint(SPCanvas *canvas)
int y0 = rect.y;
int x1 = x0 + rect.width;
int y1 = y0 + rect.height;
- if (!sp_canvas_paint_rect(canvas, x0, y0, x1, y1)) {
+ if (!paintRect(x0, y0, x1, y1)) {
// Aborted
return FALSE;
};
}
}
- canvas->need_redraw = FALSE;
+ _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 (_idle_id == 0) {
+ _idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, this, NULL);
+ }
+}
+void SPCanvas::removeIdle()
{
- if (canvas->idle_id == 0) {
- canvas->idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, canvas, NULL);
+ 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,28 +1999,28 @@ 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;
+ _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);
- 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);
+ resizeTiles(_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 (!clear) {
// scrolling without zoom; redraw only the newly exposed areas
if ((dx != 0) || (dy != 0)) {
- this->is_scrolling = is_scrolling;
+ this->_is_scrolling = is_scrolling;
if (gtk_widget_get_realized(GTK_WIDGET(this))) {
gdk_window_scroll(getWindow(this), -dx, -dy);
}
@@ -2223,15 +2032,15 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll
void SPCanvas::updateNow()
{
- if (need_update || need_redraw) {
- SPCanvasImpl::do_update(this);
+ if (_need_update || _need_redraw) {
+ 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)
@@ -2248,13 +2057,13 @@ void SPCanvas::requestRedraw(int x0, int y0, int x1, int y1)
Geom::IntRect bbox(x0, y0, x1, y1);
gtk_widget_get_allocation(GTK_WIDGET(this), &allocation);
- Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(this->x0, this->y0,
+ 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);
+ dirtyRect(*clip);
+ addIdle();
}
}
@@ -2266,8 +2075,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 +2087,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 +2099,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 +2110,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 +2126,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 +2140,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 +2153,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,63 +2168,62 @@ 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)
+void SPCanvas::resizeTiles(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;
+ if (_tiles) g_free(_tiles);
+ _tLeft = _tTop = _tRight = _tBottom = 0;
+ _tile_h = _tile_h = 0;
+ _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 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++) {
+ 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
+ if ( i >= _tLeft && i < _tRight && j >= _tTop && j < _tBottom ) {
+ ntiles[ind] = _tiles[(i - _tLeft) + (j - _tTop) * _tile_h]; // copy from the old tile
} else {
- ntiles[ind]=0; // newly exposed areas get 0
+ 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;
+ if (_tiles) g_free(_tiles);
+ _tiles = ntiles;
+ _tLeft = tl;
+ _tTop = tt;
+ _tRight = tr;
+ _tBottom = tb;
+ _tile_h = nh;
+ _tile_h = nv;
}
-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::dirtyRect(Geom::IntRect const &area) {
+ _need_redraw = TRUE;
+ markRect(area, 1);
}
-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;
+ 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 >= _tRight || tr <= _tLeft || tt >= _tBottom || tb <= _tTop ) return;
+ if ( tl < _tLeft ) tl = _tLeft;
+ if ( tr > _tRight ) tr = _tRight;
+ if ( tt < _tTop ) tt = _tTop;
+ if ( tb > _tBottom ) tb = _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;
+ _tiles[(i - _tLeft) + (j - _tTop) * _tile_h] = val;
}
}
}
diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h
index 65b06ade8..1a13250b3 100644
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
@@ -60,7 +60,7 @@ G_END_DECLS
// SPCanvas -------------------------------------------------
-class SPCanvasImpl;
+struct PaintRectSetup;
GType sp_canvas_get_type() G_GNUC_CONST;
@@ -68,123 +68,178 @@ 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);
+ /// Returns new canvas as widget.
+ static GtkWidget *createAA();
+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);
- /**
- * Updates canvas if necessary.
- */
- void updateNow();
+ /// 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();
- /**
- * Forces redraw of rectangular canvas area.
- */
- void requestRedraw(int x1, int y1, int x2, int y2);
+ /// 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 specific canvas rectangle as clean (val == 0) or dirty (otherwise)
+ 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);
+#if GTK_CHECK_VERSION(3,0,0)
+ static gboolean handle_draw(GtkWidget *widget, cairo_t *cr);
+#else
+ 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;
- int y0;
+ bool _is_dragging;
+ double _dx0;
+ double _dy0;
+ int _x0;
+ int _y0;
/* Area that needs redrawing, stored as a microtile array */
- int tLeft, tTop, tRight, tBottom;
- int tileH, tileV;
- uint8_t *tiles;
+ int _tLeft, _tTop, _tRight, _tBottom;
+ int _tile_w, _tile_h;
+ uint8_t *_tiles;
/** Last known modifier state, for deferred repick when a button is down. */
- int state;
+ 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_redraw : 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/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/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/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/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/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index e146bb908..1c42301da 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -471,8 +471,13 @@ void Path::SubContractOutline(int off, int num_pd,
// test de nullité du segment
if (IsNulCurve (descr_cmd, curD, curX))
{
- stTgt = dest->descr_cmd.size() ? Geom::Point(1, 0) : Geom::Point(-1, 0); // reverse direction
- enTgt = stTgt;
+ if (descr_cmd.size() == 2) { // single point, see LP Bug 1006666
+ stTgt = dest->descr_cmd.size() ? Geom::Point(1, 0) : Geom::Point(-1, 0); // reverse direction
+ enTgt = stTgt;
+ } else {
+ curP++;
+ continue;
+ }
}
stNor=stTgt.cw();
enNor=enTgt.cw();
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/path-chemistry.cpp b/src/path-chemistry.cpp
index 15d3f0f99..1a345b565 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -1,4 +1,4 @@
-/*
+ /*
* Here are handlers for modifying selections, specific to paths
*
* Authors:
@@ -217,7 +217,6 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
if (curve == NULL) {
continue;
}
-
did = true;
Inkscape::XML::Node *parent = item->getRepr()->parent();
@@ -228,16 +227,10 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
gchar *style = g_strdup(item->getRepr()->attribute("style"));
// XML Tree being used directly here while it shouldn't be...
gchar *path_effect = g_strdup(item->getRepr()->attribute("inkscape:path-effect"));
-
- Geom::PathVector apv = curve->get_pathvector() * path->transform;
-
- curve->unref();
-
+ Geom::Affine transform = path->transform;
// it's going to resurrect as one of the pieces, so we delete without advertisement
item->deleteObject(false);
- curve = new SPCurve(apv);
- g_assert(curve != NULL);
GSList *list = curve->split();
@@ -258,7 +251,8 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
else
repr->setAttribute("d", str);
g_free(str);
-
+ repr->setAttribute("transform", sp_svg_transform_write(transform));
+
// add the new repr to the parent
parent->appendChild(repr);
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e6d5f174e..e9a3af83a 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -1126,7 +1126,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 +1137,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/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/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/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 81f48e6ef..b653a630d 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -120,10 +120,22 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
label->set_selectable(true);
label->show();
+ Gtk::Label *link = new Gtk::Label();
+ const gchar *website_link =
+ "<a href=\"https://www.inkscape.org\"> https://www.inkscape.org</a>";
+
+ link->set_markup(website_link);
+ link->set_alignment(Gtk::ALIGN_END);
+ link->set_padding(5,5);
+ link->set_selectable(true);
+ link->show();
+
#if WITH_GTKMM_3_0
get_content_area()->pack_start(*manage(label), false, false);
+ get_content_area()->pack_start(*manage(link), false, false);
#else
get_vbox()->pack_start(*manage(label), false, false);
+ get_vbox()->pack_start(*manage(link), false, false);
#endif
Gtk::Requisition requisition;
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/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..8639861f8 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -1018,7 +1018,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 +1141,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));
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/widget/gimpcolorwheel.c b/src/ui/widget/gimpcolorwheel.c
index c857cfa8a..3642848df 100644
--- a/src/ui/widget/gimpcolorwheel.c
+++ b/src/ui/widget/gimpcolorwheel.c
@@ -1246,7 +1246,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/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/widgets/button.cpp b/src/widgets/button.cpp
index 1776e28c4..54f073c01 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,18 @@ 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;
+
+ gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &padding);
+
+ *minimal_width += 2 + 2 * MAX(2, padding.left + padding.right);
+ *natural_width += 2 + 2 * MAX(2, padding.left + padding.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 +124,13 @@ 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;
+
+ gtk_style_context_get_border(context, static_cast<GtkStateFlags>(0), &padding);
+
+ *minimal_height += 2 + 2 * MAX(2, padding.top + padding.bottom);
+ *natural_height += 2 + 2 * MAX(2, padding.top + padding.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..3fa607820 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -564,7 +564,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);
@@ -746,8 +746,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)
@@ -1035,7 +1035,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 +1054,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 +1092,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);
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/icon.cpp b/src/widgets/icon.cpp
index 542d16797..f998cd66d 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -257,6 +257,14 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr)
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,
+ // name,
+ // 32,
+ // 0,
+ // NULL);
#else
image = gtk_style_render_icon(gtk_widget_get_style(widget), source,
gtk_widget_get_direction(widget),
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index 3a5e76277..fe851d592 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -284,17 +284,10 @@ sp_ruler_init (SPRuler *ruler)
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)),
@@ -1425,7 +1418,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 +1432,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/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) );