summaryrefslogtreecommitdiffstats
path: root/src/helper
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-29 22:40:05 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-29 22:40:05 +0000
commite9943b70c7bf507b9639ecb0a421bcee7ce93e33 (patch)
tree2d2fe7ee7a566e1ef1a5dcde18296d9f21188f35 /src/helper
parenti18n. Fixing untranslated strings. (diff)
parentMerge with trunk r13640 (diff)
downloadinkscape-e9943b70c7bf507b9639ecb0a421bcee7ce93e33.tar.gz
inkscape-e9943b70c7bf507b9639ecb0a421bcee7ce93e33.zip
Merge experimental
(bzr r13641)
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/action.h6
-rw-r--r--src/helper/geom.cpp53
-rw-r--r--src/helper/gnome-utils.cpp148
-rw-r--r--src/helper/gnome-utils.h14
-rw-r--r--src/helper/pixbuf-ops.cpp2
-rw-r--r--src/helper/png-write.cpp2
-rw-r--r--src/helper/stock-items.cpp2
-rw-r--r--src/helper/window.cpp62
-rw-r--r--src/helper/window.h19
9 files changed, 157 insertions, 151 deletions
diff --git a/src/helper/action.h b/src/helper/action.h
index 1f2de87b4..4b81ee7f9 100644
--- a/src/helper/action.h
+++ b/src/helper/action.h
@@ -13,12 +13,8 @@
#define SEEN_INKSCAPE_SP_ACTION_H
#include "helper/action-context.h"
-#include <sigc++/sigc++.h>
+#include <sigc++/signal.h>
#include <glibmm/ustring.h>
-#include <glib-object.h>
-
-struct SPAction;
-struct SPActionClass;
#define SP_TYPE_ACTION (sp_action_get_type())
#define SP_ACTION(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_ACTION, SPAction))
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index c9148a634..6eba6e949 100644
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
@@ -168,24 +168,25 @@ bounds_exact_transformed(Geom::PathVector const & pv, Geom::Affine const & t)
for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) {
Geom::Curve const &c = *cit;
- if( is_straight_curve(c) )
- {
- bbox.expandTo( c.finalPoint() * t );
- }
- else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&c))
- {
- Geom::Point c0 = (*cubic_bezier)[0] * t;
- Geom::Point c1 = (*cubic_bezier)[1] * t;
- Geom::Point c2 = (*cubic_bezier)[2] * t;
- Geom::Point c3 = (*cubic_bezier)[3] * t;
- cubic_bbox( c0[0], c0[1],
- c1[0], c1[1],
- c2[0], c2[1],
- c3[0], c3[1],
- bbox );
+ unsigned order = 0;
+ if (Geom::BezierCurve const* b = dynamic_cast<Geom::BezierCurve const*>(&c)) {
+ order = b->order();
}
- else
- {
+
+ if (order == 1) { // line segment
+ bbox.expandTo(c.finalPoint() * t);
+
+ // TODO: we can make the case for quadratics faster by degree elevating them to
+ // cubic and then taking the bbox of that.
+
+ } else if (order == 3) { // cubic bezier
+ Geom::CubicBezier const &cubic_bezier = static_cast<Geom::CubicBezier const&>(c);
+ Geom::Point c0 = cubic_bezier[0] * t;
+ Geom::Point c1 = cubic_bezier[1] * t;
+ Geom::Point c2 = cubic_bezier[2] * t;
+ Geom::Point c3 = cubic_bezier[3] * t;
+ cubic_bbox(c0[0], c0[1], c1[0], c1[1], c2[0], c2[1], c3[0], c3[1], bbox);
+ } else {
// should handle all not-so-easy curves:
Geom::Curve *ctemp = cit->transformed(t);
bbox.unionWith( ctemp->boundsExact());
@@ -356,8 +357,11 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Affine const &m,
Geom::Coord tolerance, Geom::Rect const *viewbox,
Geom::Point &p0) // pass p0 through as it represents the last endpoint added (the finalPoint of last curve)
{
- if( is_straight_curve(c) )
- {
+ unsigned order = 0;
+ if (Geom::BezierCurve const* b = dynamic_cast<Geom::BezierCurve const*>(&c)) {
+ order = b->order();
+ }
+ if (order == 1) {
Geom::Point pe = c.finalPoint() * m;
if (bbox) {
bbox->expandTo(pe);
@@ -373,10 +377,11 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Affine const &m,
}
p0 = pe;
}
- else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const *>(&c)) {
- Geom::Point p1 = (*cubic_bezier)[1] * m;
- Geom::Point p2 = (*cubic_bezier)[2] * m;
- Geom::Point p3 = (*cubic_bezier)[3] * m;
+ else if (order == 3) {
+ Geom::CubicBezier const& cubic_bezier = static_cast<Geom::CubicBezier const&>(c);
+ Geom::Point p1 = cubic_bezier[1] * m;
+ Geom::Point p2 = cubic_bezier[2] * m;
+ Geom::Point p3 = cubic_bezier[3] * m;
// get approximate bbox from handles (convex hull property of beziers):
Geom::Rect swept(p0, p3);
@@ -402,7 +407,7 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Affine const &m,
Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1);
//recurse to convert the new path resulting from the sbasis to svgd
- for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {
+ for (Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {
geom_curve_bbox_wind_distance(*iter, m, pt, bbox, wind, dist, tolerance, viewbox, p0);
}
}
diff --git a/src/helper/gnome-utils.cpp b/src/helper/gnome-utils.cpp
index 957b7ea5e..3d2b333a2 100644
--- a/src/helper/gnome-utils.cpp
+++ b/src/helper/gnome-utils.cpp
@@ -1,9 +1,7 @@
-#define __GNOME_UTILS_C__
-
-/*
+/**
* Helpers
*
- * Author:
+ * Authors:
* Mitsuru Oka
* Lauris Kaplinski <lauris@kaplinski.com>
*
@@ -25,49 +23,48 @@
* Returns a GList containing strings allocated with g_malloc
* that have been splitted from @uri-list.
*/
-GList*
-gnome_uri_list_extract_uris (const gchar* uri_list)
+GList *gnome_uri_list_extract_uris(const gchar *uri_list)
{
- const gchar *p, *q;
- gchar *retval;
- GList *result = NULL;
-
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- p = uri_list;
-
- /* We don't actually try to validate the URI according to RFC
- * 2396, or even check for allowed characters - we just ignore
- * comments and trim whitespace off the ends. We also
- * allow LF delimination as well as the specified CRLF.
- */
- while (p) {
- if (*p != '#') {
- while (isspace(*p))
- p++;
-
- q = p;
- while (*q && (*q != '\n') && (*q != '\r'))
- q++;
-
- if (q > p) {
- q--;
- while (q > p && isspace(*q))
- q--;
-
- retval = (gchar*)g_malloc (q - p + 2);
- strncpy (retval, p, q - p + 1);
- retval[q - p + 1] = '\0';
-
- result = g_list_prepend (result, retval);
- }
- }
- p = strchr (p, '\n');
- if (p)
- p++;
- }
-
- return g_list_reverse (result);
+ const gchar *p, *q;
+ gchar *retval;
+ GList *result = NULL;
+
+ g_return_val_if_fail(uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p) {
+ if (*p != '#') {
+ while (isspace(*p))
+ p++;
+
+ q = p;
+ while (*q && (*q != '\n') && (*q != '\r'))
+ q++;
+
+ if (q > p) {
+ q--;
+ while (q > p && isspace(*q))
+ q--;
+
+ retval = (gchar *)g_malloc(q - p + 2);
+ strncpy(retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ result = g_list_prepend(result, retval);
+ }
+ }
+ p = strchr(p, '\n');
+ if (p)
+ p++;
+ }
+
+ return g_list_reverse(result);
}
/**
@@ -80,29 +77,40 @@ gnome_uri_list_extract_uris (const gchar* uri_list)
* Note that unlike gnome_uri_list_extract_uris() function, this
* will discard any non-file uri from the result value.
*/
-GList*
-gnome_uri_list_extract_filenames (const gchar* uri_list)
+GList *gnome_uri_list_extract_filenames(const gchar *uri_list)
{
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- GList *result = gnome_uri_list_extract_uris (uri_list);
-
- GList *tmp_list = result;
- while (tmp_list) {
- gchar *s = (gchar*)tmp_list->data;
-
- GList *node = tmp_list;
- tmp_list = tmp_list->next;
-
- if (!strncmp (s, "file:", 5)) {
- node->data = g_filename_from_uri (s, NULL, NULL);
- /* not sure if this fallback is useful at all */
- if (!node->data) node->data = g_strdup (s+5);
- } else {
- result = g_list_remove_link(result, node);
- g_list_free_1 (node);
- }
- g_free (s);
- }
- return result;
+ g_return_val_if_fail(uri_list != NULL, NULL);
+
+ GList *result = gnome_uri_list_extract_uris(uri_list);
+
+ GList *tmp_list = result;
+ while (tmp_list) {
+ gchar *s = (gchar *)tmp_list->data;
+
+ GList *node = tmp_list;
+ tmp_list = tmp_list->next;
+
+ if (!strncmp(s, "file:", 5)) {
+ node->data = g_filename_from_uri(s, NULL, NULL);
+ /* not sure if this fallback is useful at all */
+ if (!node->data)
+ node->data = g_strdup(s + 5);
+ } else {
+ result = g_list_remove_link(result, node);
+ g_list_free_1(node);
+ }
+ g_free(s);
+ }
+ return result;
}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/gnome-utils.h b/src/helper/gnome-utils.h
index 3502b28df..6f2f28223 100644
--- a/src/helper/gnome-utils.h
+++ b/src/helper/gnome-utils.h
@@ -1,7 +1,7 @@
-/*
+/**
* GNOME Utils - Migration helper
*
- * Author:
+ * Authors:
* GNOME Developer
* Mitsuru Oka <oka326@parkcity.ne.jp>
* Lauris Kaplinski <lauris@ximian.com>
@@ -11,17 +11,15 @@
* Released under GNU GPL
*/
-
-#ifndef __GNOME_UTILS_H__
-#define __GNOME_UTILS_H__
+#ifndef SEEN_GNOME_UTILS_H
+#define SEEN_GNOME_UTILS_H
#include <glib.h>
GList *gnome_uri_list_extract_uris(gchar const *uri_list);
-
GList *gnome_uri_list_extract_filenames(gchar const *uri_list);
-#endif /* __GNOME_UTILS_H__ */
+#endif // !SEEN_GNOME_UTILS_H
/*
Local Variables:
@@ -32,4 +30,4 @@ GList *gnome_uri_list_extract_filenames(gchar const *uri_list);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index d44b2207b..acb2be4da 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -19,7 +19,7 @@
#include <boost/scoped_ptr.hpp>
#include <2geom/transforms.h>
-#include "interface.h"
+#include "ui/interface.h"
#include "helper/png-write.h"
#include "display/cairo-utils.h"
#include "display/drawing.h"
diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp
index a7ebe7423..32e50b537 100644
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
@@ -18,7 +18,7 @@
#endif
#include <png.h>
-#include "interface.h"
+#include "ui/interface.h"
#include <2geom/rect.h>
#include <2geom/transforms.h>
#include <glib.h>
diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp
index a12fa377a..582dcd2a8 100644
--- a/src/helper/stock-items.cpp
+++ b/src/helper/stock-items.cpp
@@ -28,7 +28,7 @@
#include "sp-gradient.h"
#include "document-private.h"
#include "sp-pattern.h"
-#include "marker.h"
+#include "sp-marker.h"
#include "desktop-handles.h"
#include "inkscape.h"
diff --git a/src/helper/window.cpp b/src/helper/window.cpp
index 98fbef170..98e886a38 100644
--- a/src/helper/window.cpp
+++ b/src/helper/window.cpp
@@ -1,6 +1,4 @@
-#define __SP_WINDOW_C__
-
-/*
+/**
* Generic window implementation
*
* Author:
@@ -9,61 +7,61 @@
* This code is in public domain
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
+#include <glibmm.h>
#include <gtkmm/window.h>
+#include "desktop.h"
#include "inkscape.h"
#include "shortcuts.h"
-#include "desktop.h"
#include "ui/tools/tool-base.h"
#include "window.h"
-#include <gtk/gtk.h>
static bool on_window_key_press(GdkEventKey* event)
{
- unsigned int shortcut;
- shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
+ unsigned shortcut = 0;
+ // FIXME why?
+ shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
SP_SHORTCUT_CONTROL_MASK : 0 ) |
( event->state & GDK_MOD1_MASK ?
SP_SHORTCUT_ALT_MASK : 0 );
- return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
+ return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
}
-Gtk::Window *
-Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
+Gtk::Window * Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
{
- Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
- window->set_title (title);
- window->set_resizable (resizeable);
- window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
+ Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
+ window->set_title (title);
+ window->set_resizable (resizeable);
+ window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
- return window;
+ return window;
}
-static gboolean
-sp_window_key_press(GtkWidget */*widget*/, GdkEventKey *event)
+static gboolean sp_window_key_press(GtkWidget *, GdkEventKey *event)
{
return on_window_key_press(event);
}
-GtkWidget *
-sp_window_new (const gchar *title, unsigned int resizeable)
+GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable)
{
- GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title ((GtkWindow *) window, title);
- gtk_window_set_resizable ((GtkWindow *) window, resizeable);
- g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL);
+ GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title ((GtkWindow *) window, title);
+ gtk_window_set_resizable ((GtkWindow *) window, resizeable);
+ g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL);
- return window;
+ return window;
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/helper/window.h b/src/helper/window.h
index c6807f9e5..a0efcd292 100644
--- a/src/helper/window.h
+++ b/src/helper/window.h
@@ -1,7 +1,7 @@
-#ifndef __SP_WINDOW_H__
-#define __SP_WINDOW_H__
+#ifndef SEEN_SP_WINDOW_H
+#define SEEN_SP_WINDOW_H
-/*
+/**
* Generic window implementation
*
* Author:
@@ -17,10 +17,11 @@ namespace Gtk {
class Window;
}
-/*
- * This function is deprecated. Use Inkscape::UI::window_new instead.
- */
-GtkWidget *sp_window_new (const gchar *title, unsigned int resizeable);
+// Can we just get rid of this altogether?
+#if defined(GCC_VERSION) || defined(__clang__)
+__attribute__((deprecated))
+#endif
+GtkWidget * sp_window_new (const gchar *title, unsigned int resizeable);
namespace Inkscape {
namespace UI {
@@ -30,7 +31,7 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable);
}
}
-#endif
+#endif // !SEEN_SP_WINDOW_H
/*
Local Variables:
@@ -41,4 +42,4 @@ Gtk::Window *window_new (const gchar *title, unsigned int resizeable);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :