summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorSebastian Wüst <sebi@timewaster.de>2013-10-20 15:32:08 +0000
committerSebastian Wüst <sebi@timewaster.de>2013-10-20 15:32:08 +0000
commit82908f949129e1fcbf62002799ee7b1b77986eed (patch)
treec02098dd7720cdf424f2793ecd3ddac2ea86b969 /src/widgets
parentchanged text (diff)
parentFix build errors with clang 3.3 and c++11 enabled. (diff)
downloadinkscape-82908f949129e1fcbf62002799ee7b1b77986eed.tar.gz
inkscape-82908f949129e1fcbf62002799ee7b1b77986eed.zip
merge from trunk
(bzr r12417.1.24)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/CMakeLists.txt4
-rw-r--r--src/widgets/Makefile_insert4
-rw-r--r--src/widgets/arc-toolbar.cpp23
-rw-r--r--src/widgets/box3d-toolbar.cpp11
-rw-r--r--src/widgets/calligraphy-toolbar.cpp36
-rw-r--r--src/widgets/connector-toolbar.cpp16
-rw-r--r--src/widgets/dash-selector.cpp128
-rw-r--r--src/widgets/dash-selector.h5
-rw-r--r--src/widgets/desktop-widget.cpp37
-rw-r--r--src/widgets/desktop-widget.h1
-rw-r--r--src/widgets/dropper-toolbar.cpp4
-rw-r--r--src/widgets/eek-preview.cpp4
-rw-r--r--src/widgets/eraser-toolbar.cpp (renamed from src/widgets/erasor-toolbar.cpp)10
-rw-r--r--src/widgets/eraser-toolbar.h (renamed from src/widgets/erasor-toolbar.h)0
-rw-r--r--src/widgets/font-selector.cpp1
-rw-r--r--src/widgets/gradient-image.cpp185
-rw-r--r--src/widgets/gradient-toolbar.cpp30
-rw-r--r--src/widgets/gradient-vector.cpp10
-rw-r--r--src/widgets/gradient-vector.h2
-rw-r--r--src/widgets/icon.cpp3
-rw-r--r--src/widgets/lpe-toolbar.cpp21
-rw-r--r--src/widgets/measure-toolbar.cpp19
-rw-r--r--src/widgets/mesh-toolbar.cpp8
-rw-r--r--src/widgets/node-toolbar.cpp41
-rw-r--r--src/widgets/paint-selector.cpp8
-rw-r--r--src/widgets/paint-selector.h2
-rw-r--r--src/widgets/paintbucket-toolbar.cpp28
-rw-r--r--src/widgets/pencil-toolbar.cpp8
-rw-r--r--src/widgets/rect-toolbar.cpp68
-rw-r--r--src/widgets/ruler.cpp30
-rw-r--r--src/widgets/ruler.h11
-rw-r--r--src/widgets/select-toolbar.cpp61
-rw-r--r--src/widgets/sp-color-icc-selector.h2
-rw-r--r--src/widgets/sp-widget.cpp2
-rw-r--r--src/widgets/spiral-toolbar.cpp12
-rw-r--r--src/widgets/spray-toolbar.cpp28
-rw-r--r--src/widgets/spw-utilities.cpp48
-rw-r--r--src/widgets/spw-utilities.h7
-rw-r--r--src/widgets/star-toolbar.cpp16
-rw-r--r--src/widgets/stroke-marker-selector.cpp10
-rw-r--r--src/widgets/stroke-style.cpp131
-rw-r--r--src/widgets/stroke-style.h24
-rw-r--r--src/widgets/swatch-selector.cpp2
-rw-r--r--src/widgets/text-toolbar.cpp21
-rw-r--r--src/widgets/toolbox.cpp112
-rw-r--r--src/widgets/toolbox.h8
-rw-r--r--src/widgets/tweak-toolbar.cpp16
-rw-r--r--src/widgets/zoom-toolbar.cpp4
48 files changed, 594 insertions, 668 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 19410ee1d..fe4433153 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -6,7 +6,7 @@ set(widgets_SRC
calligraphy-toolbar.cpp
connector-toolbar.cpp
dropper-toolbar.cpp
- erasor-toolbar.cpp
+ eraser-toolbar.cpp
lpe-toolbar.cpp
measure-toolbar.cpp
mesh-toolbar.cpp
@@ -62,7 +62,7 @@ set(widgets_SRC
calligraphy-toolbar.h
connector-toolbar.h
dropper-toolbar.h
- erasor-toolbar.h
+ eraser-toolbar.h
lpe-toolbar.h
measure-toolbar.h
mesh-toolbar.h
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index 46f0bd645..97713cbee 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -21,8 +21,8 @@ ink_common_sources += \
widgets/eek-preview.h \
widgets/ege-paint-def.cpp \
widgets/ege-paint-def.h \
- widgets/erasor-toolbar.cpp \
- widgets/erasor-toolbar.h \
+ widgets/eraser-toolbar.cpp \
+ widgets/eraser-toolbar.h \
widgets/fill-style.cpp \
widgets/fill-style.h \
widgets/fill-n-stroke-factory.h \
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index 809050ad9..5569780e7 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -56,14 +56,10 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-ellipse.h"
#include "../mod360.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -116,10 +112,9 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
{
SPItem *item = SP_ITEM(items->data);
- if (SP_IS_ARC(item) && SP_IS_GENERICELLIPSE(item)) {
+ if (SP_IS_GENERICELLIPSE(item)) {
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
- SPArc *arc = SP_ARC(item);
if (!strcmp(value_name, "start")) {
ge->start = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
@@ -127,9 +122,9 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
ge->end = (gtk_adjustment_get_value(adj) * M_PI)/ 180;
}
- sp_genericellipse_normalize(ge);
- (SP_OBJECT(arc))->updateRepr();
- (SP_OBJECT(arc))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ ge->normalize();
+ (SP_OBJECT(ge))->updateRepr();
+ (SP_OBJECT(ge))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
modmade = true;
}
@@ -185,7 +180,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
items = items->next)
{
SPItem *item = reinterpret_cast<SPItem*>(items->data);
- if (SP_IS_ARC(item)) {
+ if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", "true");
item->updateRepr();
@@ -198,7 +193,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
items = items->next)
{
SPItem *item = reinterpret_cast<SPItem *>(items->data);
- if (SP_IS_ARC(item)) {
+ if (SP_IS_GENERICELLIPSE(item)) {
Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", NULL);
item->updateRepr();
@@ -290,7 +285,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb
items = items->next)
{
SPItem *item = reinterpret_cast<SPItem *>(items->data);
- if (SP_IS_ARC(item)) {
+ if (SP_IS_GENERICELLIPSE(item)) {
n_selected++;
repr = item->getRepr();
}
@@ -341,7 +336,7 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec
_("Start"), _("Start:"),
_("The angle (in degrees) from the horizontal to the arc's start point"),
"/tools/shapes/arc/start", 0.0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-arc",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-arc",
-360.0, 360.0, 1.0, 10.0,
0, 0, 0,
sp_arctb_start_value_changed);
@@ -354,7 +349,7 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec
_("End"), _("End:"),
_("The angle (in degrees) from the horizontal to the arc's end point"),
"/tools/shapes/arc/end", 0.0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
0, 0, 0,
sp_arctb_end_value_changed);
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index e8b330375..91d4ebdec 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -58,16 +58,11 @@
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
-
#include "../pen-context.h"
#include "../box3d-context.h"
#include "../box3d.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -321,7 +316,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
// Translators: PL is short for 'perspective line'
_("Angle of PLs in X direction"),
"/tools/shapes/3dbox/box3d_angle_x", 30,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-box3d",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-box3d",
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
box3d_angle_x_value_changed );
@@ -361,7 +356,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Y direction"),
"/tools/shapes/3dbox/box3d_angle_y", 30,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
box3d_angle_y_value_changed );
@@ -400,7 +395,7 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
// Translators: PL is short for 'perspective line'
_("Angle of PLs in Z direction"),
"/tools/shapes/3dbox/box3d_angle_z", 30,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-360.0, 360.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
box3d_angle_z_value_changed );
diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp
index 4cb4813b5..12228ce56 100644
--- a/src/widgets/calligraphy-toolbar.cpp
+++ b/src/widgets/calligraphy-toolbar.cpp
@@ -56,13 +56,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -451,10 +447,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Pen Width"), _("Width:"),
_("The width of the calligraphic pen (relative to the visible canvas area)"),
"/tools/calligraphic/width", 15,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-calligraphy",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-calligraphy",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_width_value_changed, 1, 0 );
+ sp_ddc_width_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -468,10 +464,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Stroke Thinning"), _("Thinning:"),
_("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"),
"/tools/calligraphic/thinning", 10,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-100, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_velthin_value_changed, 1, 0);
+ sp_ddc_velthin_value_changed, NULL /*unit tracker*/, 1, 0);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
@@ -484,10 +480,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Pen Angle"), _("Angle:"),
_("The angle of the pen's nib (in degrees; 0 = horizontal; has no effect if fixation = 0)"),
"/tools/calligraphic/angle", 30,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "calligraphy-angle",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "calligraphy-angle",
-90.0, 90.0, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_angle_value_changed, 1, 0 );
+ sp_ddc_angle_value_changed, NULL /*unit tracker*/, 1, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
g_object_set_data( holder, "angle_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -502,10 +498,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Fixation"), _("Fixation:"),
_("Angle behavior (0 = nib always perpendicular to stroke direction, 100 = fixed angle)"),
"/tools/calligraphic/flatness", 90,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_flatness_value_changed, 1, 0);
+ sp_ddc_flatness_value_changed, NULL /*unit tracker*/, 1, 0);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
@@ -519,10 +515,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Cap rounding"), _("Caps:"),
_("Increase to make caps at the ends of strokes protrude more (0 = no caps, 1 = round caps)"),
"/tools/calligraphic/cap_rounding", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 5.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_cap_rounding_value_changed, 0.01, 2 );
+ sp_ddc_cap_rounding_value_changed, NULL /*unit tracker*/, 0.01, 2 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
@@ -535,10 +531,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Stroke Tremor"), _("Tremor:"),
_("Increase to make strokes rugged and trembling"),
"/tools/calligraphic/tremor", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_tremor_value_changed, 1, 0);
+ sp_ddc_tremor_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -553,10 +549,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Pen Wiggle"), _("Wiggle:"),
_("Increase to make the pen waver and wiggle"),
"/tools/calligraphic/wiggle", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_wiggle_value_changed, 1, 0);
+ sp_ddc_wiggle_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -570,10 +566,10 @@ void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
_("Pen Mass"), _("Mass:"),
_("Increase to make the pen drag behind, as if slowed by inertia"),
"/tools/calligraphic/mass", 2.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_mass_value_changed, 1, 0);
+ sp_ddc_mass_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 7c72f8e0c..2e5c2ade1 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -55,9 +55,6 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../conn-avoid-ref.h"
@@ -66,7 +63,6 @@
#include "../sp-path.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -365,10 +361,10 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Connector Curvature"), _("Curvature:"),
_("The amount of connectors curvature"),
"/tools/connector/curvature", defaultConnCurvature,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-curvature",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "inkscape:connector-curvature",
0, 100, 1.0, 10.0,
0, 0, 0,
- connector_curvature_changed, 1, 0 );
+ connector_curvature_changed, NULL /*unit tracker*/, 1, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
// Spacing spinbox
@@ -376,10 +372,10 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Connector Spacing"), _("Spacing:"),
_("The amount of space left around objects by auto-routing connectors"),
"/tools/connector/spacing", defaultConnSpacing,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-spacing",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "inkscape:connector-spacing",
0, 100, 1.0, 10.0,
0, 0, 0,
- connector_spacing_changed, 1, 0 );
+ connector_spacing_changed, NULL /*unit tracker*/, 1, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
// Graph (connector network) layout
@@ -398,10 +394,10 @@ void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions,
_("Connector Length"), _("Length:"),
_("Ideal length for connectors when layout is applied"),
"/tools/connector/length", 100,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-length",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "inkscape:connector-length",
10, 1000, 10.0, 100.0,
0, 0, 0,
- connector_length_changed, 1, 0 );
+ connector_length_changed, NULL /*unit tracker*/, 1, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp
index 901d3b68c..afc81e574 100644
--- a/src/widgets/dash-selector.cpp
+++ b/src/widgets/dash-selector.cpp
@@ -39,6 +39,7 @@ static double dash_4_1[] = {4.0, 1.0, -1.0};
static double dash_1_2[] = {1.0, 2.0, -1.0};
static double dash_1_4[] = {1.0, 4.0, -1.0};
+#define bd_len 7 // must correspond to the number of entries in the next line
static double *builtin_dashes[] = {dash_0, dash_1_1, dash_2_1, dash_4_1, dash_1_2, dash_1_4, NULL};
static double **dashes = NULL;
@@ -79,12 +80,18 @@ SPDashSelector::SPDashSelector()
this->pack_start(*sb, false, false, 0);
- for (int i = 0; dashes[i]; i++) {
+ int np=0;
+ while (dashes[np]){ np++;}
+ for (int i = 0; i<np-1; i++) { // all but the custom one go this way
// Add the dashes to the combobox
Gtk::TreeModel::Row row = *(dash_store->append());
row[dash_columns.dash] = dashes[i];
row[dash_columns.pixbuf] = Glib::wrap(sp_dash_to_pixbuf(dashes[i]));
}
+ // add the custom one
+ Gtk::TreeModel::Row row = *(dash_store->append());
+ row[dash_columns.dash] = dashes[np-1];
+ row[dash_columns.pixbuf] = Glib::wrap(sp_text_to_pixbuf((char *)"Custom"));
this->set_data("pattern", dashes[0]);
}
@@ -109,10 +116,10 @@ void SPDashSelector::init_dashes() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
std::vector<Glib::ustring> dash_prefs = prefs->getAllDirs(_prefs_path);
+ int pos = 0;
if (!dash_prefs.empty()) {
- int pos = 0;
SPStyle *style = sp_style_new (NULL);
- dashes = g_new (double *, dash_prefs.size() + 1);
+ dashes = g_new (double *, dash_prefs.size() + 2); // +1 for custom slot, +1 for terminator slot
for (std::vector<Glib::ustring>::iterator i = dash_prefs.begin(); i != dash_prefs.end(); ++i) {
sp_style_read_from_prefs(style, *i);
@@ -130,23 +137,36 @@ void SPDashSelector::init_dashes() {
}
pos += 1;
}
- dashes[pos] = NULL;
- } else {
- dashes = builtin_dashes;
+ } else { // This code may never execute - a new preferences.xml is created for a new user. Maybe if the user deletes dashes from preferences.xml?
+ dashes = g_new (double *, bd_len + 2); // +1 for custom slot, +1 for terminator slot
+ int i;
+ for(i=0;i<bd_len;i++) {
+ dashes[i] = builtin_dashes[i];
+ }
+ pos = bd_len;
}
+ // make a place to hold the custom dashes, up to 15 positions long (+ terminator)
+ dashes[pos] = g_new (double, 16);
+ double *d = dashes[pos];
+ int i=0;
+ for(i=0;i<15;i++){ d[i]=i; } // have to put something in there, this is a pattern hopefully nobody would choose
+ d[15]=-1.0;
+ // final terminator
+ dashes[++pos] = NULL;
}
}
void SPDashSelector::set_dash (int ndash, double *dash, double o)
{
- int pos = 0;
+ int pos = -1; // Allows custom patterns to remain unscathed by this.
+ int count = 0; // will hold the NULL terminator at the end of the dashes list
if (ndash > 0) {
double delta = 0.0;
for (int i = 0; i < ndash; i++)
delta += dash[i];
delta /= 1000.0;
- for (int i = 0; dashes[i]; i++) {
+ for (int i = 0; dashes[i]; i++,count++) {
double *pattern = dashes[i];
int np = 0;
while (pattern[np] >= 0.0)
@@ -154,6 +174,7 @@ void SPDashSelector::set_dash (int ndash, double *dash, double o)
if (np == ndash) {
int j;
for (j = 0; j < ndash; j++) {
+
if (!Geom::are_near(dash[j], pattern[j], delta))
break;
}
@@ -164,10 +185,27 @@ void SPDashSelector::set_dash (int ndash, double *dash, double o)
}
}
}
+ else if(ndash==0) {
+ pos = 0;
+ }
- this->set_data("pattern", dashes[pos]);
- this->dash_combo.set_active(pos);
- this->offset->set_value(o);
+ if(pos>=0){
+ this->set_data("pattern", dashes[pos]);
+ this->dash_combo.set_active(pos);
+ this->offset->set_value(o);
+ }
+ else { // Hit a custom pattern in the SVG, write it into the combobox.
+ count--; // the one slot for custom patterns
+ double *d = dashes[count];
+ int i=0;
+ for(i=0;i< (ndash > 15 ? 15 : ndash) ;i++) {
+ d[i]=dash[i];
+ } // store the custom pattern
+ d[ndash]=-1.0; //terminate it
+ this->set_data("pattern", dashes[count]);
+ this->dash_combo.set_active(count);
+ this->offset->set_value(o); // what does this do????
+ }
}
void SPDashSelector::get_dash(int *ndash, double **dash, double *off)
@@ -200,33 +238,51 @@ void SPDashSelector::get_dash(int *ndash, double **dash, double *off)
/**
* Fill a pixbuf with the dash pattern using standard cairo drawing
*/
-GdkPixbuf* SPDashSelector::sp_dash_to_pixbuf(double *pattern) {
-
- int n_dashes;
- for (n_dashes = 0; pattern[n_dashes] >= 0.0; n_dashes ++) ;
-
- cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, preview_width, preview_height);
- cairo_t *ct = cairo_create(s);
-
- cairo_set_line_width (ct, preview_lineheight);
- cairo_scale (ct, preview_lineheight, 1);
- //cairo_set_source_rgb (ct, 0, 0, 0);
- cairo_move_to (ct, 0, preview_height/2);
- cairo_line_to (ct, preview_width, preview_height/2);
- cairo_set_dash(ct, pattern, n_dashes, 0);
- cairo_stroke (ct);
-
- cairo_destroy(ct);
- cairo_surface_flush(s);
-
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s),
- GDK_COLORSPACE_RGB, TRUE, 8,
- preview_width, preview_height, cairo_image_surface_get_stride(s),
- ink_cairo_pixbuf_cleanup, s);
- convert_pixbuf_argb32_to_normal(pixbuf);
- return pixbuf;
+GdkPixbuf* SPDashSelector::sp_dash_to_pixbuf(double *pattern)
+{
+ int n_dashes;
+ for (n_dashes = 0; pattern[n_dashes] >= 0.0; n_dashes ++) ;
+
+ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, preview_width, preview_height);
+ cairo_t *ct = cairo_create(s);
+
+ cairo_set_line_width (ct, preview_lineheight);
+ cairo_scale (ct, preview_lineheight, 1);
+ //cairo_set_source_rgb (ct, 0, 0, 0);
+ cairo_move_to (ct, 0, preview_height/2);
+ cairo_line_to (ct, preview_width, preview_height/2);
+ cairo_set_dash(ct, pattern, n_dashes, 0);
+ cairo_stroke (ct);
+
+ cairo_destroy(ct);
+ cairo_surface_flush(s);
+
+ GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s);
+ return pixbuf;
}
+/**
+ * Fill a pixbuf with a text label using standard cairo drawing
+ */
+GdkPixbuf* SPDashSelector::sp_text_to_pixbuf(char *text)
+{
+ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, preview_width, preview_height);
+ cairo_t *ct = cairo_create(s);
+
+ cairo_select_font_face (ct, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (ct, 12.0);
+ cairo_set_source_rgb (ct, 0.0, 0.0, 0.0);
+ cairo_move_to (ct, 16.0, 13.0);
+ cairo_show_text (ct, text);
+
+ cairo_stroke (ct);
+
+ cairo_destroy(ct);
+ cairo_surface_flush(s);
+
+ GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s);
+ return pixbuf;
+}
void SPDashSelector::on_selection ()
{
diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h
index faa667ac7..5b9ebfa2b 100644
--- a/src/widgets/dash-selector.h
+++ b/src/widgets/dash-selector.h
@@ -54,6 +54,11 @@ private:
GdkPixbuf* sp_dash_to_pixbuf(double *pattern);
/**
+ * Fill a pixbuf with text standard cairo drawing
+ */
+ GdkPixbuf* sp_text_to_pixbuf(char *text);
+
+ /**
* Callback for combobox image renderer
*/
void prepareImageRenderer( Gtk::TreeModel::const_iterator const &row );
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index c1214c1a4..3ca433586 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -43,8 +43,8 @@
#include "file.h"
#include "helper/action.h"
#include "helper/action-context.h"
-#include "helper/units.h"
-#include "helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "inkscape-private.h"
#include "interface.h"
#include "macros.h"
@@ -79,10 +79,11 @@
using Inkscape::round;
#endif
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::UI::ToolboxFactory;
using ege::AppearTimeTracker;
+using Inkscape::Util::unit_table;
enum {
ACTIVATE,
@@ -393,8 +394,9 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
GtkWidget *eventbox = gtk_event_box_new ();
dtw->hruler = sp_ruler_new(GTK_ORIENTATION_HORIZONTAL);
dtw->hruler_box = eventbox;
- sp_ruler_set_unit(SP_RULER(dtw->hruler), SP_PT);
- gtk_widget_set_tooltip_text (dtw->hruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))));
+ Inkscape::Util::Unit const *pt = unit_table.getUnit("pt");
+ sp_ruler_set_unit(SP_RULER(dtw->hruler), pt);
+ gtk_widget_set_tooltip_text (dtw->hruler_box, gettext(pt->name_plural.c_str()));
gtk_container_add (GTK_CONTAINER (eventbox), dtw->hruler);
g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (sp_dt_hruler_event), dtw);
g_signal_connect (G_OBJECT (eventbox), "button_release_event", G_CALLBACK (sp_dt_hruler_event), dtw);
@@ -422,8 +424,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
eventbox = gtk_event_box_new ();
dtw->vruler = sp_ruler_new(GTK_ORIENTATION_VERTICAL);
dtw->vruler_box = eventbox;
- sp_ruler_set_unit (SP_RULER (dtw->vruler), SP_PT);
- gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(sp_unit_get_plural (&sp_unit_get_by_id(SP_UNIT_PT))));
+ sp_ruler_set_unit (SP_RULER (dtw->vruler), pt);
+ gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(pt->name_plural.c_str()));
gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler));
#if GTK_CHECK_VERSION(3,0,0)
@@ -1674,7 +1676,7 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
{
SPDesktopWidget *dtw = static_cast<SPDesktopWidget*>(g_object_new(SP_TYPE_DESKTOP_WIDGET, NULL));
- dtw->dt2r = 1.0 / namedview->doc_units->unittobase;
+ dtw->dt2r = 1. / namedview->doc_units->factor;
dtw->ruler_origin = Geom::Point(0,0); //namedview->gridorigin; Why was the grid origin used here?
@@ -1746,11 +1748,11 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
SPNamedView *nv=SP_NAMEDVIEW(obj);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
- this->dt2r = 1.0 / nv->doc_units->unittobase;
+ this->dt2r = 1. / nv->doc_units->factor;
this->ruler_origin = Geom::Point(0,0); //nv->gridorigin; Why was the grid origin used here?
- sp_ruler_set_unit(SP_RULER (this->vruler), nv->getDefaultMetric());
- sp_ruler_set_unit(SP_RULER (this->hruler), nv->getDefaultMetric());
+ sp_ruler_set_unit(SP_RULER (this->vruler), nv->getDefaultUnit());
+ sp_ruler_set_unit(SP_RULER (this->hruler), nv->getDefaultUnit());
/* This loops through all the grandchildren of aux toolbox,
* and for each that it finds, it performs an sp_search_by_data_recursive(),
@@ -1786,8 +1788,8 @@ void SPDesktopWidget::namedviewModified(SPObject *obj, guint flags)
} // children
} // if aux_toolbox is a container
- gtk_widget_set_tooltip_text(this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units)));
- gtk_widget_set_tooltip_text(this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)));
+ gtk_widget_set_tooltip_text(this->hruler_box, gettext(nv->doc_units->name_plural.c_str()));
+ gtk_widget_set_tooltip_text(this->vruler_box, gettext(nv->doc_units->name_plural.c_str()));
sp_desktop_widget_update_rulers(this);
ToolboxFactory::updateSnapToolbox(this->desktop, 0, this->snap_toolbox);
@@ -1807,7 +1809,10 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWid
sp_desktop_widget_update_rulers (dtw);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
- sp_box3d_context_update_lines(dtw->desktop->event_context);
+ //sp_box3d_context_update_lines(dtw->desktop->event_context);
+ if (SP_IS_BOX3D_CONTEXT(dtw->desktop->event_context)) {
+ SP_BOX3D_CONTEXT(dtw->desktop->event_context)->_vpdrag->updateLines();
+ }
dtw->update = 0;
}
@@ -2130,8 +2135,8 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale)
/* The desktop region we always show unconditionally */
SPDocument *doc = dtw->desktop->doc();
- Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()),
- Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) );
+ Geom::Rect darea ( Geom::Point(-doc->getWidth().value("px"), -doc->getHeight().value("px")),
+ Geom::Point(2 * doc->getWidth().value("px"), 2 * doc->getHeight().value("px")) );
Geom::OptRect deskarea;
if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) {
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index 9031ac854..58739cf3b 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -129,7 +129,6 @@ struct SPDesktopWidget {
struct WidgetStub : public Inkscape::UI::View::EditWidgetInterface {
SPDesktopWidget *_dtw;
- SPDesktop *_dt;
WidgetStub (SPDesktopWidget* dtw) : _dtw(dtw) {}
virtual void setTitle (gchar const *uri)
diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp
index cf58aa507..054955d8f 100644
--- a/src/widgets/dropper-toolbar.cpp
+++ b/src/widgets/dropper-toolbar.cpp
@@ -54,13 +54,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../tools-switch.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp
index 988aa2453..19dbb04ab 100644
--- a/src/widgets/eek-preview.cpp
+++ b/src/widgets/eek-preview.cpp
@@ -245,12 +245,14 @@ gboolean eek_preview_draw(GtkWidget *widget,
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
-
+
+#if !GTK_CHECK_VERSION(3,0,0)
GdkColor fg = { 0,
static_cast<guint16>(priv->r),
static_cast<guint16>(priv->g),
static_cast<guint16>(priv->b)
};
+#endif
gint insetTop = 0, insetBottom = 0;
gint insetLeft = 0, insetRight = 0;
diff --git a/src/widgets/erasor-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index 2e074490d..1af574ed6 100644
--- a/src/widgets/erasor-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -31,7 +31,7 @@
#include "ui/widget/spinbutton.h"
#include <glibmm/i18n.h>
#include "toolbox.h"
-#include "erasor-toolbar.h"
+#include "eraser-toolbar.h"
#include "calligraphy-toolbar.h"
#include "../desktop.h"
@@ -55,13 +55,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -149,10 +145,10 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("Pen Width"), _("Width:"),
_("The width of the eraser pen (relative to the visible canvas area)"),
"/tools/eraser/width", 15,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-eraser",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_erc_width_value_changed, 1, 0);
+ sp_erc_width_value_changed, NULL /*unit tracker*/, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
diff --git a/src/widgets/erasor-toolbar.h b/src/widgets/eraser-toolbar.h
index b1bb3a3fa..b1bb3a3fa 100644
--- a/src/widgets/erasor-toolbar.h
+++ b/src/widgets/eraser-toolbar.h
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 7fa848f1e..5f9098d44 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -33,7 +33,6 @@
#include "desktop.h"
#include "widgets/font-selector.h"
#include "preferences.h"
-#include "unit-constants.h"
/* SPFontSelector */
diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp
index 2d58355db..64b058f62 100644
--- a/src/widgets/gradient-image.cpp
+++ b/src/widgets/gradient-image.cpp
@@ -16,7 +16,6 @@
#include "display/cairo-utils.h"
#include "gradient-image.h"
#include "sp-gradient.h"
-#include "sp-gradient-fns.h"
#include <sigc++/functors/ptr_fun.h>
#include <sigc++/adaptors/bind.h>
@@ -31,11 +30,11 @@ static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *r
static void sp_gradient_image_destroy(GtkWidget *object);
static void sp_gradient_image_get_preferred_width(GtkWidget *widget,
gint *minimal_width,
- gint *natural_width);
+ gint *natural_width);
static void sp_gradient_image_get_preferred_height(GtkWidget *widget,
gint *minimal_height,
- gint *natural_height);
+ gint *natural_height);
#else
static void sp_gradient_image_destroy(GtkObject *object);
static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event);
@@ -50,53 +49,53 @@ static GtkWidgetClass *parent_class;
GType sp_gradient_image_get_type(void)
{
- static GType type = 0;
- if (!type) {
- GTypeInfo info = {
- sizeof (SPGradientImageClass),
- NULL, NULL,
- (GClassInitFunc) sp_gradient_image_class_init,
- NULL, NULL,
- sizeof (SPGradientImage),
- 0,
- (GInstanceInitFunc) sp_gradient_image_init,
- NULL
- };
- type = g_type_register_static (GTK_TYPE_WIDGET, "SPGradientImage", &info, (GTypeFlags)0);
- }
- return type;
+ static GType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof (SPGradientImageClass),
+ NULL, NULL,
+ (GClassInitFunc) sp_gradient_image_class_init,
+ NULL, NULL,
+ sizeof (SPGradientImage),
+ 0,
+ (GInstanceInitFunc) sp_gradient_image_init,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_WIDGET, "SPGradientImage", &info, (GTypeFlags)0);
+ }
+ return type;
}
static void sp_gradient_image_class_init(SPGradientImageClass *klass)
{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
- parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent (klass));
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ parent_class = GTK_WIDGET_CLASS(g_type_class_peek_parent (klass));
#if GTK_CHECK_VERSION(3,0,0)
-// GObjectClass *object_class = G_OBJECT_CLASS(klass);
+// GObjectClass *object_class = G_OBJECT_CLASS(klass);
- widget_class->get_preferred_width = sp_gradient_image_get_preferred_width;
- widget_class->get_preferred_height = sp_gradient_image_get_preferred_height;
- widget_class->draw = sp_gradient_image_draw;
- widget_class->destroy = sp_gradient_image_destroy;
+ widget_class->get_preferred_width = sp_gradient_image_get_preferred_width;
+ widget_class->get_preferred_height = sp_gradient_image_get_preferred_height;
+ widget_class->draw = sp_gradient_image_draw;
+ widget_class->destroy = sp_gradient_image_destroy;
#else
- GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);
- object_class->destroy = sp_gradient_image_destroy;
- widget_class->size_request = sp_gradient_image_size_request;
- widget_class->expose_event = sp_gradient_image_expose;
+ object_class->destroy = sp_gradient_image_destroy;
+ widget_class->size_request = sp_gradient_image_size_request;
+ widget_class->expose_event = sp_gradient_image_expose;
#endif
}
static void
sp_gradient_image_init (SPGradientImage *image)
{
- gtk_widget_set_has_window (GTK_WIDGET(image), FALSE);
+ gtk_widget_set_has_window (GTK_WIDGET(image), FALSE);
- image->gradient = NULL;
+ image->gradient = NULL;
- new (&image->release_connection) sigc::connection();
- new (&image->modified_connection) sigc::connection();
+ new (&image->release_connection) sigc::connection();
+ new (&image->modified_connection) sigc::connection();
}
#if GTK_CHECK_VERSION(3,0,0)
@@ -105,23 +104,23 @@ static void sp_gradient_image_destroy(GtkWidget *object)
static void sp_gradient_image_destroy(GtkObject *object)
#endif
{
- SPGradientImage *image = SP_GRADIENT_IMAGE (object);
+ SPGradientImage *image = SP_GRADIENT_IMAGE (object);
- if (image->gradient) {
- image->release_connection.disconnect();
- image->modified_connection.disconnect();
- image->gradient = NULL;
- }
+ if (image->gradient) {
+ image->release_connection.disconnect();
+ image->modified_connection.disconnect();
+ image->gradient = NULL;
+ }
- image->release_connection.~connection();
- image->modified_connection.~connection();
+ image->release_connection.~connection();
+ image->modified_connection.~connection();
#if GTK_CHECK_VERSION(3,0,0)
- if (parent_class->destroy)
- (* (parent_class)->destroy) (object);
+ if (parent_class->destroy)
+ (* (parent_class)->destroy) (object);
#else
- if ((GTK_OBJECT_CLASS(parent_class))->destroy)
- (* (GTK_OBJECT_CLASS(parent_class))->destroy) (object);
+ if ((GTK_OBJECT_CLASS(parent_class))->destroy)
+ (* (GTK_OBJECT_CLASS(parent_class))->destroy) (object);
#endif
}
@@ -134,36 +133,36 @@ static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisitio
#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_image_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
{
- GtkRequisition requisition;
- sp_gradient_image_size_request(widget, &requisition);
- *minimal_width = *natural_width = requisition.width;
+ GtkRequisition requisition;
+ sp_gradient_image_size_request(widget, &requisition);
+ *minimal_width = *natural_width = requisition.width;
}
static void sp_gradient_image_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
{
- GtkRequisition requisition;
- sp_gradient_image_size_request(widget, &requisition);
- *minimal_height = *natural_height = requisition.height;
+ GtkRequisition requisition;
+ sp_gradient_image_size_request(widget, &requisition);
+ *minimal_height = *natural_height = requisition.height;
}
#endif
#if !GTK_CHECK_VERSION(3,0,0)
static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event)
{
- gboolean result = TRUE;
- if(gtk_widget_is_drawable(widget)) {
- cairo_t *ct = gdk_cairo_create(gtk_widget_get_window (widget));
- cairo_rectangle(ct, event->area.x, event->area.y,
- event->area.width, event->area.height);
- cairo_clip(ct);
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
- cairo_translate(ct, allocation.x, allocation.y);
- result = sp_gradient_image_draw(widget, ct);
- cairo_destroy(ct);
- }
-
- return result;
+ gboolean result = TRUE;
+ if(gtk_widget_is_drawable(widget)) {
+ cairo_t *ct = gdk_cairo_create(gtk_widget_get_window (widget));
+ cairo_rectangle(ct, event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_clip(ct);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ cairo_translate(ct, allocation.x, allocation.y);
+ result = sp_gradient_image_draw(widget, ct);
+ cairo_destroy(ct);
+ }
+
+ return result;
}
#endif
@@ -179,7 +178,7 @@ static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct)
cairo_paint(ct);
cairo_pattern_destroy(check);
- if (gr) {
+ if (gr) {
cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, allocation.width);
cairo_set_source(ct, p);
cairo_paint(ct);
@@ -192,11 +191,11 @@ static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct)
GtkWidget *
sp_gradient_image_new (SPGradient *gradient)
{
- SPGradientImage *image = SP_GRADIENT_IMAGE(g_object_new(SP_TYPE_GRADIENT_IMAGE, NULL));
+ SPGradientImage *image = SP_GRADIENT_IMAGE(g_object_new(SP_TYPE_GRADIENT_IMAGE, NULL));
- sp_gradient_image_set_gradient (image, gradient);
+ sp_gradient_image_set_gradient (image, gradient);
- return GTK_WIDGET(image);
+ return GTK_WIDGET(image);
}
GdkPixbuf*
@@ -220,12 +219,8 @@ sp_gradient_to_pixbuf (SPGradient *gr, int width, int height)
cairo_destroy(ct);
cairo_surface_flush(s);
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s),
- GDK_COLORSPACE_RGB, TRUE, 8,
- width, height, cairo_image_surface_get_stride(s),
- ink_cairo_pixbuf_cleanup, s);
- convert_pixbuf_argb32_to_normal(pixbuf);
-
+ // no need to free s - the call below takes ownership
+ GdkPixbuf *pixbuf = ink_pixbuf_create_from_cairo_surface(s);
return pixbuf;
}
@@ -233,44 +228,44 @@ sp_gradient_to_pixbuf (SPGradient *gr, int width, int height)
void
sp_gradient_image_set_gradient (SPGradientImage *image, SPGradient *gradient)
{
- if (image->gradient) {
- image->release_connection.disconnect();
- image->modified_connection.disconnect();
- }
+ if (image->gradient) {
+ image->release_connection.disconnect();
+ image->modified_connection.disconnect();
+ }
- image->gradient = gradient;
+ image->gradient = gradient;
- if (gradient) {
- image->release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_image_gradient_release), image));
- image->modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_image_gradient_modified), image));
- }
+ if (gradient) {
+ image->release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_image_gradient_release), image));
+ image->modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_image_gradient_modified), image));
+ }
- sp_gradient_image_update (image);
+ sp_gradient_image_update (image);
}
static void
sp_gradient_image_gradient_release (SPObject *, SPGradientImage *image)
{
- if (image->gradient) {
- image->release_connection.disconnect();
- image->modified_connection.disconnect();
- }
+ if (image->gradient) {
+ image->release_connection.disconnect();
+ image->modified_connection.disconnect();
+ }
- image->gradient = NULL;
+ image->gradient = NULL;
- sp_gradient_image_update (image);
+ sp_gradient_image_update (image);
}
static void
sp_gradient_image_gradient_modified (SPObject *, guint /*flags*/, SPGradientImage *image)
{
- sp_gradient_image_update (image);
+ sp_gradient_image_update (image);
}
static void
sp_gradient_image_update (SPGradientImage *image)
{
- if (gtk_widget_is_drawable (GTK_WIDGET(image))) {
- gtk_widget_queue_draw (GTK_WIDGET (image));
- }
+ if (gtk_widget_is_drawable (GTK_WIDGET(image))) {
+ gtk_widget_queue_draw (GTK_WIDGET (image));
+ }
}
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index ea125a380..f7d2b2bd5 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -91,7 +91,8 @@ void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType ini
bool isFill = (mode == Inkscape::FOR_FILL);
if (style
&& (isFill ? style->fill.isPaintserver() : style->stroke.isPaintserver())
- && SP_IS_GRADIENT(isFill ? style->getFillPaintServer() : style->getStrokePaintServer()) ) {
+ //&& SP_IS_GRADIENT(isFill ? style->getFillPaintServer() : style->getStrokePaintServer()) ) {
+ && (isFill ? SP_IS_GRADIENT(style->getFillPaintServer()) : SP_IS_GRADIENT(style->getStrokePaintServer())) ) {
SPPaintServer *server = isFill ? style->getFillPaintServer() : style->getStrokePaintServer();
if ( SP_IS_LINEARGRADIENT(server) ) {
sp_item_set_gradient(item, gr, SP_GRADIENT_TYPE_LINEAR, mode);
@@ -285,7 +286,7 @@ void gr_read_selection( Inkscape::Selection *selection,
}
}
if (spread != spr_selected) {
- if (spr_selected != INT_MAX) {
+ if (spr_selected != SP_GRADIENT_SPREAD_UNDEFINED) {
spr_multi = true;
} else {
spr_selected = spread;
@@ -318,7 +319,7 @@ void gr_read_selection( Inkscape::Selection *selection,
}
}
if (spread != spr_selected) {
- if (spr_selected != INT_MAX) {
+ if (spr_selected != SP_GRADIENT_SPREAD_UNDEFINED) {
spr_multi = true;
} else {
spr_selected = spread;
@@ -344,7 +345,7 @@ void gr_read_selection( Inkscape::Selection *selection,
}
}
if (spread != spr_selected) {
- if (spr_selected != INT_MAX) {
+ if (spr_selected != SP_GRADIENT_SPREAD_UNDEFINED) {
spr_multi = true;
} else {
spr_selected = spread;
@@ -372,14 +373,14 @@ static void gr_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe
Inkscape::Selection *selection = sp_desktop_selection(desktop); // take from desktop, not from args
if (selection) {
- SPEventContext *ev = sp_desktop_event_context(desktop);
+ SPEventContext *ev = desktop->getEventContext();
GrDrag *drag = NULL;
if (ev) {
drag = ev->get_drag();
}
SPGradient *gr_selected = 0;
- SPGradientSpread spr_selected = static_cast<SPGradientSpread>(INT_MAX); // meaning undefined
+ SPGradientSpread spr_selected = SP_GRADIENT_SPREAD_UNDEFINED;
bool gr_multi = false;
bool spr_multi = false;
@@ -584,7 +585,7 @@ static void gr_add_stop(GtkWidget * /*button*/, GtkWidget *vb)
return;
}
- SPEventContext *ev = sp_desktop_event_context(desktop);
+ SPEventContext *ev = desktop->getEventContext();
SPGradientContext *rc = SP_GRADIENT_CONTEXT(ev);
if (rc) {
@@ -606,7 +607,7 @@ static void gr_remove_stop(GtkWidget * /*button*/, GtkWidget *vb)
return;
}
- SPEventContext *ev = sp_desktop_event_context(desktop);
+ SPEventContext *ev = desktop->getEventContext();
GrDrag *drag = NULL;
if (ev) {
drag = ev->get_drag();
@@ -799,7 +800,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S
if (SP_IS_STOP(sl->data)){
SPStop *stop = SP_STOP(sl->data);
Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr();
- Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)));
+ Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
GdkPixbuf *pb = cpv->toPixbuf(32, 16);
Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25);
@@ -938,7 +939,7 @@ static void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
SPDesktop *desktop = static_cast<SPDesktop *>(data);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPEventContext *ev = sp_desktop_event_context(desktop);
+ SPEventContext *ev = desktop->getEventContext();
gr_apply_gradient(selection, ev? ev->get_drag() : NULL, gr);
@@ -980,7 +981,7 @@ static void gr_stop_combo_changed(GtkComboBox * /*widget*/, GtkWidget *data)
}
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(data), "desktop"));
- SPEventContext *ev = sp_desktop_event_context(desktop);
+ SPEventContext *ev = desktop->getEventContext();
SPGradient *gr = gr_get_selected_gradient(data);
select_drag_by_stop(data, gr, ev);
@@ -1171,11 +1172,12 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
eact = create_adjustment_action( "GradientEditOffsetAction",
_("Offset"), _("Offset:"), _("Offset of selected stop"),
"/tools/gradient/stopoffset", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 1.0, 0.01, 0.1,
0, 0, 0,
- gr_stop_offset_adjustment_changed
- , 0.01, 2, 1.0);
+ gr_stop_offset_adjustment_changed,
+ NULL /*unit tracker*/,
+ 0.01, 2, 1.0);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
g_object_set_data( holder, "offset_action", eact );
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 118d8a68a..e9fc426f6 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -369,7 +369,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
unsigned long sp_gradient_to_hhssll(SPGradient *gr)
{
SPStop *stop = gr->getFirstStop();
- unsigned long rgba = sp_stop_get_rgba32(stop);
+ unsigned long rgba = stop->get_rgba32();
float hsl[3];
sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba));
@@ -635,7 +635,7 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s
if (SP_IS_STOP(sl->data)){
SPStop *stop = SP_STOP(sl->data);
Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr();
- Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)));
+ Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
GdkPixbuf *pb = cpv->toPixbuf(64, 16);
gtk_list_store_append (store, &iter);
@@ -791,8 +791,8 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb)
newstop->offset = (stop->offset + next->offset) * 0.5 ;
- guint32 const c1 = sp_stop_get_rgba32(stop);
- guint32 const c2 = sp_stop_get_rgba32(next);
+ guint32 const c1 = stop->get_rgba32();
+ guint32 const c2 = next->get_rgba32();
guint32 cnew = sp_average_color(c1, c2);
Inkscape::CSSOStringStream os;
@@ -1315,7 +1315,7 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GObject *obj
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(combo_box), &iter)) {
GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)));
- Inkscape::UI::Widget::ColorPreview *cp = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)));
+ Inkscape::UI::Widget::ColorPreview *cp = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
GdkPixbuf *pb = cp->toPixbuf(64, 16);
gtk_list_store_set (store, &iter, 0, pb, /*1, repr->attribute("id"),*/ 2, stop, -1);
diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h
index 64e40a35b..b63120a6e 100644
--- a/src/widgets/gradient-vector.h
+++ b/src/widgets/gradient-vector.h
@@ -40,7 +40,7 @@
class SPDocument;
class SPObject;
class SPGradient;
-struct SPStop;
+class SPStop;
struct SPGradientVectorSelector {
GtkVBox vbox;
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index dda453bc4..feb69cc64 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -42,6 +42,7 @@
#include "display/drawing.h"
#include "io/sys.h"
#include "sp-root.h"
+#include "util/units.h"
#include "icon.h"
@@ -1137,7 +1138,7 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
if ( object->parent == NULL )
{
dbox = Geom::Rect(Geom::Point(0, 0),
- Geom::Point(doc->getWidth(), doc->getHeight()));
+ Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")));
}
/* This is in document coordinates, i.e. pixels */
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index c7659ab42..045d7aa78 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -57,9 +57,8 @@
#include "../ui/icon-names.h"
#include "../helper/action.h"
#include "../helper/action-context.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../tools-switch.h"
@@ -67,7 +66,9 @@
#include "../live_effects/lpe-angle_bisector.h"
#include "../lpe-tool-context.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -144,7 +145,7 @@ static void sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObje
SPItem *item = selection->singleItem();
if (item && SP_IS_LPE_ITEM(item) && lpetool_item_has_construction(lc, item)) {
SPLPEItem *lpeitem = SP_LPE_ITEM(item);
- Effect* lpe = sp_lpe_item_get_current_lpe(lpeitem);
+ Effect* lpe = lpeitem->getCurrentLPE();
if (lpe && lpe->effectType() == LINE_SEGMENT) {
LPELineSegment *lpels = static_cast<LPELineSegment*>(lpe);
g_object_set_data(tbl, "currentlpe", lpe);
@@ -197,9 +198,9 @@ static void lpetool_toggle_show_measuring_info(GtkToggleAction *act, GObject *tb
static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl)
{
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("/tools/lpetool/unitid", unit->unit_id);
+ prefs->setString("/tools/lpetool/unit", unit->abbr);
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) {
@@ -295,13 +296,13 @@ static void lpetool_open_lpe_dialog(GtkToggleAction *act, gpointer data)
void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- UnitTracker* tracker = new UnitTracker(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
tracker->setActiveUnit(sp_desktop_namedview(desktop)->doc_units);
g_object_set_data(holder, "tracker", tracker);
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("/tools/lpetool/unitid", unit->unit_id);
+ prefs->setString("/tools/lpetool/unit", unit->abbr);
/** Automatically create a list of LPEs that get added to the toolbar **/
{
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 21df4c6d9..58244566d 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -52,13 +52,12 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
+#include "ui/widget/unit-tracker.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -83,15 +82,17 @@ sp_measure_fontsize_value_changed(GtkAdjustment *adj, GObject *tbl)
static void measure_unit_changed(GtkAction* /*act*/, GObject* tbl)
{
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker"));
- SPUnit const *unit = tracker->getActiveUnit();
+ Glib::ustring const unit = tracker->getActiveUnit()->abbr;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setInt("/tools/measure/unitid", unit->unit_id);
+ prefs->setString("/tools/measure/unit", unit);
}
void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
{
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ tracker->setActiveUnitByAbbr(prefs->getString("/tools/measure/unit").c_str());
+
g_object_set_data( holder, "tracker", tracker );
EgeAdjustmentAction *eact = 0;
@@ -102,7 +103,7 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G
_("Font Size"), _("Font Size:"),
_("The font size to be used in the measurement labels"),
"/tools/measure/fontsize", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
10, 36, 1.0, 4.0,
0, 0, 0,
sp_measure_fontsize_value_changed);
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 99a34fbda..582243870 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -262,10 +262,10 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
eact = create_adjustment_action( "MeshRowAction",
_("Rows"), _("Rows:"), _("Number of rows in new mesh"),
"/tools/mesh/mesh_rows", 1,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
labels, values, G_N_ELEMENTS(labels),
- ms_row_changed,
+ ms_row_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -278,10 +278,10 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
eact = create_adjustment_action( "MeshColumnAction",
_("Columns"), _("Columns:"), _("Number of columns in new mesh"),
"/tools/mesh/mesh_cols", 1,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
labels, values, G_N_ELEMENTS(labels),
- ms_col_changed,
+ ms_col_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index 849de874d..0d4868642 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -58,17 +58,19 @@
#include "../ui/tool/node-tool.h"
#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "../lpe-tool-context.h"
#include "../sp-namedview.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::Util::unit_table;
//####################################
//# node editing callbacks
@@ -238,7 +240,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
if (!tracker) {
return;
}
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
InkNodeTool *nt = get_node_tool();
if (!nt || nt->_selected_nodes->empty()) {
@@ -248,15 +250,15 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
} else {
gtk_action_set_sensitive(xact, TRUE);
gtk_action_set_sensitive(yact, TRUE);
- Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
- Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
+ Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), unit, "px");
+ Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), unit, "px");
Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint();
if (oldx != mid[Geom::X]) {
- gtk_adjustment_set_value(xadj, sp_pixels_get_units(mid[Geom::X], *unit));
+ gtk_adjustment_set_value(xadj, Quantity::convert(mid[Geom::X], "px", unit));
}
if (oldy != mid[Geom::Y]) {
- gtk_adjustment_set_value(yadj, sp_pixels_get_units(mid[Geom::Y], *unit));
+ gtk_adjustment_set_value(yadj, Quantity::convert(mid[Geom::Y], "px", unit));
}
}
@@ -272,11 +274,11 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
if (!tracker) {
return;
}
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
- sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit));
+ Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
}
// quit if run by the attr_changed listener
@@ -289,7 +291,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
InkNodeTool *nt = get_node_tool();
if (nt && !nt->_selected_nodes->empty()) {
- double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit);
+ double val = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px");
double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d];
Geom::Point delta(0,0);
delta[d] = val - oldval;
@@ -315,7 +317,7 @@ static void sp_node_toolbox_sel_changed(Inkscape::Selection *selection, GObject
GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "nodes_lpeedit" ) );
SPItem *item = selection->singleItem();
if (item && SP_IS_LPE_ITEM(item)) {
- if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) {
+ if (SP_LPE_ITEM(item)->hasPathEffect()) {
gtk_action_set_sensitive(w, TRUE);
} else {
gtk_action_set_sensitive(w, FALSE);
@@ -339,8 +341,9 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint /
void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ Unit doc_units = *sp_desktop_namedview(desktop)->doc_units;
+ tracker->setActiveUnit(&doc_units);
g_object_set_data( holder, "tracker", tracker );
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
@@ -589,10 +592,10 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "NodeXAction",
_("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"),
"/tools/nodes/Xcoord", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-nodes",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-nodes",
-1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_node_path_x_value_changed );
+ sp_node_path_x_value_changed, tracker );
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "nodes_x_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -607,10 +610,10 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "NodeYAction",
_("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"),
"/tools/nodes/Ycoord", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_node_path_y_value_changed );
+ sp_node_path_y_value_changed, tracker );
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "nodes_y_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 40d2fb9f3..9466c875e 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -36,8 +36,8 @@
#include "xml/repr.h"
#include "sp-color-notebook.h"
-#include "sp-linear-gradient-fns.h"
-#include "sp-radial-gradient-fns.h"
+#include "sp-linear-gradient.h"
+#include "sp-radial-gradient.h"
/* fixme: Move it from dialogs to here */
#include "gradient-selector.h"
#include <inkscape.h>
@@ -1141,14 +1141,12 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele
gtk_widget_set_sensitive(psel->style, TRUE);
- SwatchSelector *swatchsel = NULL;
-
if (psel->mode == SPPaintSelector::MODE_SWATCH){
// swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
} else {
sp_paint_selector_clear_frame(psel);
// Create new gradient selector
- swatchsel = new SwatchSelector();
+ SwatchSelector *swatchsel = new SwatchSelector();
swatchsel->show();
swatchsel->connectGrabbedHandler( G_CALLBACK(sp_paint_selector_gradient_grabbed), psel );
diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h
index a66758434..d3b3f4116 100644
--- a/src/widgets/paint-selector.h
+++ b/src/widgets/paint-selector.h
@@ -22,7 +22,7 @@
class SPGradient;
class SPDesktop;
-struct SPPattern;
+class SPPattern;
struct SPStyle;
#define SP_TYPE_PAINT_SELECTOR (sp_paint_selector_get_type ())
diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp
index 73815b86d..363fadd3d 100644
--- a/src/widgets/paintbucket-toolbar.cpp
+++ b/src/widgets/paintbucket-toolbar.cpp
@@ -54,9 +54,8 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../flood-context.h"
@@ -64,11 +63,12 @@
#include <gtk/gtk.h>
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::Util::unit_table;
@@ -79,7 +79,8 @@ using Inkscape::UI::PrefPusher;
static void paintbucket_channels_changed(EgeSelectOneAction* act, GObject* /*tbl*/)
{
gint channels = ege_select_one_action_get_active( act );
- flood_channels_set_channels( channels );
+ //flood_channels_set_channels( channels );
+ SPFloodContext::set_channels(channels);
}
static void paintbucket_threshold_changed(GtkAdjustment *adj, GObject * /*tbl*/)
@@ -97,13 +98,13 @@ static void paintbucket_autogap_changed(EgeSelectOneAction* act, GObject * /*tbl
static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl)
{
UnitTracker* tracker = static_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Don't adjust the offset value because we're saving the
// unit and it'll be correctly handled on load.
prefs->setDouble("/tools/paintbucket/offset", (gdouble)gtk_adjustment_get_value(adj));
- prefs->setString("/tools/paintbucket/offsetunits", sp_unit_get_abbreviation(unit));
+ prefs->setString("/tools/paintbucket/offsetunits", unit->abbr);
}
static void paintbucket_defaults(GtkWidget *, GObject *tbl)
@@ -165,20 +166,21 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
"ThresholdAction",
_("Fill Threshold"), _("Threshold:"),
_("The maximum allowed difference between the clicked pixel and the neighboring pixels to be counted in the fill"),
- "/tools/paintbucket/threshold", 5, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE,
+ "/tools/paintbucket/threshold", 5, GTK_WIDGET(desktop->canvas), holder, TRUE,
"inkscape:paintbucket-threshold", 0, 100.0, 1.0, 10.0,
0, 0, 0,
- paintbucket_threshold_changed, 1, 0 );
+ paintbucket_threshold_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
// Create the units menu.
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
Glib::ustring stored_unit = prefs->getString("/tools/paintbucket/offsetunits");
if (!stored_unit.empty()) {
- tracker->setActiveUnit(sp_unit_get_by_abbreviation(stored_unit.data()));
+ Unit const *u = unit_table.getUnit(stored_unit);
+ tracker->setActiveUnit(u);
}
g_object_set_data( holder, "tracker", tracker );
{
@@ -192,10 +194,10 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
"OffsetAction",
_("Grow/shrink by"), _("Grow/shrink by:"),
_("The amount to grow (positive) or shrink (negative) the created fill path"),
- "/tools/paintbucket/offset", 0, GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE,
+ "/tools/paintbucket/offset", 0, GTK_WIDGET(desktop->canvas), holder, TRUE,
"inkscape:paintbucket-offset", -1e4, 1e4, 0.1, 0.5,
0, 0, 0,
- paintbucket_offset_changed, 1, 2);
+ paintbucket_offset_changed, tracker, 1, 2);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index e0cf67bd0..f112a35fa 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -67,15 +67,10 @@
//#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
-
#include "../pen-context.h"
//#include "../sp-namedview.h"
#include "../tools-switch.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -307,11 +302,12 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
_("How much smoothing (simplifying) is applied to the line"),
"/tools/freehand/pencil/tolerance",
3.0,
- GTK_WIDGET(desktop->canvas), NULL,
+ GTK_WIDGET(desktop->canvas),
holder, TRUE, "altx-pencil",
1, 100.0, 0.5, 1.0,
labels, values, G_N_ELEMENTS(labels),
sp_pencil_tb_tolerance_value_changed,
+ NULL /*unit tracker*/,
1, 2);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 8c1a735c5..0287a9aeb 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -53,18 +53,20 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../sp-rect.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
+using Inkscape::Util::unit_table;
//########################
@@ -86,17 +88,17 @@ static void sp_rtb_sensitivize( GObject *tbl )
static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
- void (*setter)(SPRect *, gdouble))
+ void (SPRect::*setter)(gdouble))
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name,
- sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit));
+ Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"));
}
// quit if run by the attr_changed listener
@@ -112,8 +114,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
if (SP_IS_RECT(items->data)) {
if (gtk_adjustment_get_value(adj) != 0) {
- setter(SP_RECT(items->data),
- sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit));
+ (SP_RECT(items->data)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, sp_desktop_namedview(desktop)->doc_units));
} else {
SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL);
}
@@ -133,22 +134,22 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
static void sp_rtb_rx_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "rx", sp_rect_set_visible_rx);
+ sp_rtb_value_changed(adj, tbl, "rx", &SPRect::setVisibleRx);
}
static void sp_rtb_ry_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "ry", sp_rect_set_visible_ry);
+ sp_rtb_value_changed(adj, tbl, "ry", &SPRect::setVisibleRy);
}
static void sp_rtb_width_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "width", sp_rect_set_visible_width);
+ sp_rtb_value_changed(adj, tbl, "width", &SPRect::setVisibleWidth);
}
static void sp_rtb_height_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "height", sp_rect_set_visible_height);
+ sp_rtb_value_changed(adj, tbl, "height", &SPRect::setVisibleHeight);
}
@@ -184,32 +185,37 @@ static void rect_tb_event_attr_changed(Inkscape::XML::Node * /*repr*/, gchar con
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) );
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
+ Unit const *doc_unit = sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units;
gpointer item = g_object_get_data( tbl, "item" );
if (item && SP_IS_RECT(item)) {
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "rx" ) );
- gdouble rx = sp_rect_get_visible_rx(SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(rx, *unit));
+
+ gdouble rx = SP_RECT(item)->getVisibleRx();
+ gtk_adjustment_set_value(adj, Quantity::convert(rx, doc_unit, unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "ry" ) );
- gdouble ry = sp_rect_get_visible_ry(SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(ry, *unit));
+
+ gdouble ry = SP_RECT(item)->getVisibleRy();
+ gtk_adjustment_set_value(adj, Quantity::convert(ry, doc_unit, unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "width" ) );
- gdouble width = sp_rect_get_visible_width (SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(width, *unit));
+
+ gdouble width = SP_RECT(item)->getVisibleWidth();
+ gtk_adjustment_set_value(adj, Quantity::convert(width, doc_unit, unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "height" ) );
- gdouble height = sp_rect_get_visible_height (SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(height, *unit));
+
+ gdouble height = SP_RECT(item)->getVisibleHeight();
+ gtk_adjustment_set_value(adj, Quantity::convert(height, doc_unit, unit));
}
}
@@ -301,7 +307,7 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
}
// rx/ry units menu: create
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
//tracker->addUnit( SP_UNIT_PERCENT, 0 );
// fixme: add % meaning per cent of the width/height
tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
@@ -314,10 +320,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RectWidthAction",
_("Width"), _("W:"), _("Width of rectangle"),
"/tools/shapes/rect/width", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-rect",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-rect",
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_width_value_changed );
+ sp_rtb_width_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "width_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -331,10 +337,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RectHeightAction",
_("Height"), _("H:"), _("Height of rectangle"),
"/tools/shapes/rect/height", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_height_value_changed );
+ sp_rtb_height_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "height_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -348,10 +354,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RadiusXAction",
_("Horizontal radius"), _("Rx:"), _("Horizontal radius of rounded corners"),
"/tools/shapes/rect/rx", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_rx_value_changed);
+ sp_rtb_rx_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
@@ -363,10 +369,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RadiusYAction",
_("Vertical radius"), _("Ry:"), _("Vertical radius of rounded corners"),
"/tools/shapes/rect/ry", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_ry_value_changed);
+ sp_rtb_ry_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index c1f9be2a5..2604ebf22 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -33,9 +33,9 @@
#include "widget-sizes.h"
#include "ruler.h"
-#include "unit-constants.h"
#include "round.h"
#include <glibmm/i18n.h>
+#include "util/units.h"
#define ROUND(x) ((int) ((x) + 0.5))
@@ -44,6 +44,7 @@
#define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_X_SMALL
#define MINIMUM_INCR 5
+using Inkscape::Util::unit_table;
enum {
PROP_0,
@@ -62,7 +63,7 @@ enum {
typedef struct
{
GtkOrientation orientation;
- SPMetric unit;
+ Inkscape::Util::Unit const *unit;
gdouble lower;
gdouble upper;
gdouble position;
@@ -196,11 +197,10 @@ sp_ruler_class_init (SPRulerClass *klass)
/* FIXME: Should probably use g_param_spec_enum */
g_object_class_install_property (object_class,
PROP_UNIT,
- g_param_spec_uint ("unit",
+ g_param_spec_string ("unit",
_("Unit"),
_("Unit of the ruler"),
- 0, 8,
- SP_PX,
+ "px",
static_cast<GParamFlags>(GTK_PARAM_READWRITE)));
g_object_class_install_property (object_class,
@@ -260,7 +260,7 @@ sp_ruler_init (SPRuler *ruler)
gtk_widget_set_has_window (GTK_WIDGET (ruler), FALSE);
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
- priv->unit = SP_PX;
+ priv->unit = unit_table.getUnit("px");
priv->lower = 0;
priv->upper = 0;
priv->position = 0;
@@ -387,7 +387,7 @@ sp_ruler_set_property (GObject *object,
break;
case PROP_UNIT:
- sp_ruler_set_unit (ruler, static_cast<SPMetric>(g_value_get_int (value)));
+ sp_ruler_set_unit (ruler, unit_table.getUnit(g_value_get_string (value)));
break;
case PROP_LOWER:
@@ -436,7 +436,7 @@ sp_ruler_get_property (GObject *object,
break;
case PROP_UNIT:
- g_value_set_int (value, priv->unit);
+ g_value_set_string (value, priv->unit->abbr.c_str());
break;
case PROP_LOWER:
g_value_set_double (value, priv->lower);
@@ -1071,13 +1071,13 @@ sp_ruler_remove_track_widget (SPRuler *ruler,
*/
void
sp_ruler_set_unit (SPRuler *ruler,
- SPMetric unit)
+ Inkscape::Util::Unit const *unit)
{
SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler);
g_return_if_fail (SP_IS_RULER (ruler));
- if (priv->unit != unit)
+ if (*priv->unit != *unit)
{
priv->unit = unit;
g_object_notify(G_OBJECT(ruler), "unit");
@@ -1092,11 +1092,9 @@ sp_ruler_set_unit (SPRuler *ruler,
*
* Return value: the unit currently used in the @ruler widget.
**/
-SPMetric
+Inkscape::Util::Unit const*
sp_ruler_get_unit (SPRuler *ruler)
{
- g_return_val_if_fail(SP_IS_RULER(ruler), static_cast<SPMetric>(0));
-
return SP_RULER_GET_PRIVATE (ruler)->unit;
}
@@ -1184,7 +1182,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
gint text_size;
gint pos;
gdouble max_size;
- SPMetric unit;
+ Inkscape::Util::Unit const *unit = NULL;
SPRulerMetric ruler_metric = ruler_metric_general; /* The metric to use for this unit system */
PangoLayout *layout;
PangoRectangle logical_rect, ink_rect;
@@ -1300,7 +1298,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
/* Inkscape change to ruler: Use a 1,2,4,8... scale for inches
* or a 1,2,5,10... scale for everything else */
- if (sp_ruler_get_unit (ruler) == SP_IN)
+ if (*sp_ruler_get_unit (ruler) == *unit_table.getUnit("in"))
ruler_metric = ruler_metric_inches;
for (scale = 0; scale < G_N_ELEMENTS (ruler_metric.ruler_scale); scale++)
@@ -1319,7 +1317,7 @@ sp_ruler_draw_ticks (SPRuler *ruler)
gdouble subd_incr;
/* hack to get proper subdivisions at full pixels */
- if (unit == SP_PX && scale == 1 && i == 1)
+ if (*unit == *unit_table.getUnit("px") && scale == 1 && i == 1)
subd_incr = 1.0;
else
subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
diff --git a/src/widgets/ruler.h b/src/widgets/ruler.h
index f0d866fff..ed529d082 100644
--- a/src/widgets/ruler.h
+++ b/src/widgets/ruler.h
@@ -14,10 +14,15 @@
*/
#include <gtk/gtk.h>
-#include "sp-metric.h"
#include <iostream>
#include <glib.h>
+namespace Inkscape {
+ namespace Util {
+ class Unit;
+ }
+}
+
G_BEGIN_DECLS
#define SP_TYPE_RULER (sp_ruler_get_type ())
@@ -51,8 +56,8 @@ void sp_ruler_remove_track_widget (SPRuler *ruler,
GtkWidget *widget);
void sp_ruler_set_unit (SPRuler *ruler,
- SPMetric unit);
-SPMetric sp_ruler_get_unit (SPRuler *ruler);
+ const Inkscape::Util::Unit *unit);
+Inkscape::Util::Unit const * sp_ruler_get_unit (SPRuler *ruler);
void sp_ruler_set_position (SPRuler *ruler,
gdouble set_position);
gdouble sp_ruler_get_position (SPRuler *ruler);
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 1bfc841e3..58d7134b3 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -39,8 +39,7 @@
#include <glibmm/i18n.h>
#include "helper/action.h"
#include "helper/action-context.h"
-#include "helper/unit-menu.h"
-#include "helper/units.h"
+#include "util/units.h"
#include "inkscape.h"
#include "verbs.h"
#include "selection.h"
@@ -48,7 +47,7 @@
#include "sp-item-transform.h"
#include "message-stack.h"
#include "display/sp-canvas.h"
-#include "helper/unit-tracker.h"
+#include "ui/widget/unit-tracker.h"
#include "ege-adjustment-action.h"
#include "ege-output-action.h"
#include "ink-action.h"
@@ -56,8 +55,11 @@
#include "ui/icon-names.h"
#include "select-toolbar.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
using Inkscape::DocumentUndo;
+using Inkscape::Util::unit_table;
static void
sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
@@ -78,7 +80,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
Geom::OptRect const bbox(sel->bounds(bbox_type));
if ( bbox ) {
UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
- SPUnit const &unit = *tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
struct { char const *key; double val; } const keyval[] = {
{ "X", bbox->min()[X] },
@@ -87,8 +89,8 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
{ "height", bbox->dimensions()[Y] }
};
- if (unit.base == SP_UNIT_DIMENSIONLESS) {
- double const val = 1. / unit.unittobase;
+ if (unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) {
+ double const val = unit->factor * 100;
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key));
gtk_adjustment_set_value(a, val);
@@ -97,7 +99,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
} else {
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key));
- gtk_adjustment_set_value(a, sp_pixels_get_units(keyval[i].val, unit));
+ gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit));
}
}
}
@@ -183,28 +185,28 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
gdouble y1 = 0;
gdouble xrel = 0;
gdouble yrel = 0;
- SPUnit const &unit = *tracker->getActiveUnit();
+ Unit const *unit = tracker->getActiveUnit();
GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) );
GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) );
GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) );
GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) );
- if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
- x0 = sp_units_get_pixels (gtk_adjustment_get_value (a_x), unit);
- y0 = sp_units_get_pixels (gtk_adjustment_get_value (a_y), unit);
- x1 = x0 + sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit);
- xrel = sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit) / bbox_user->dimensions()[Geom::X];
- y1 = y0 + sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit);
- yrel = sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit) / bbox_user->dimensions()[Geom::Y];
+ if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
+ x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px");
+ y0 = Quantity::convert(gtk_adjustment_get_value(a_y), unit, "px");
+ x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px");
+ xrel = Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px") / bbox_user->dimensions()[Geom::X];
+ y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px");;
+ yrel = Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px") / bbox_user->dimensions()[Geom::Y];
} else {
- double const x0_propn = gtk_adjustment_get_value (a_x) * unit.unittobase;
+ double const x0_propn = gtk_adjustment_get_value (a_x) / 100 / unit->factor;
x0 = bbox_user->min()[Geom::X] * x0_propn;
- double const y0_propn = gtk_adjustment_get_value (a_y) * unit.unittobase;
+ double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit->factor;
y0 = y0_propn * bbox_user->min()[Geom::Y];
- xrel = gtk_adjustment_get_value (a_w) * unit.unittobase;
+ xrel = gtk_adjustment_get_value (a_w) / (100 / unit->factor);
x1 = x0 + xrel * bbox_user->dimensions()[Geom::X];
- yrel = gtk_adjustment_get_value (a_h) * unit.unittobase;
+ yrel = gtk_adjustment_get_value (a_h) / (100 / unit->factor);
y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y];
}
@@ -225,11 +227,11 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
double sv = fabs(y1 - bbox_user->max()[Geom::Y]);
// unless the unit is %, convert the scales and moves to the unit
- if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
- mh = sp_pixels_get_units (mh, unit);
- sh = sp_pixels_get_units (sh, unit);
- mv = sp_pixels_get_units (mv, unit);
- sv = sp_pixels_get_units (sv, unit);
+ if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
+ mh = Quantity::convert(mh, "px", unit);
+ sh = Quantity::convert(sh, "px", unit);
+ mv = Quantity::convert(mv, "px", unit);
+ sv = Quantity::convert(sv, "px", unit);
}
// do the action only if one of the scales/moves is greater than half the last significant
@@ -271,7 +273,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
}
-static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits )
+static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker )
{
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true);
@@ -279,6 +281,7 @@ static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRa
#else
Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
#endif
+ inkSpinner->addUnitTracker(unit_tracker);
inkSpinner = Gtk::manage( inkSpinner );
GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() );
return widget;
@@ -311,7 +314,7 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
g_object_set_data( G_OBJECT(spw), data, adj );
}
- EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3 );
+ EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3, tracker );
if ( shortLabel ) {
g_object_set( act, "short_label", Q_(shortLabel), NULL );
}
@@ -488,8 +491,8 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
gtk_container_add(GTK_CONTAINER(spw), vb);
// Create the units menu.
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- tracker->addUnit( SP_UNIT_PERCENT, 0 );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ tracker->addUnit(unit_table.getUnit("%"));
tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
g_object_set_data( G_OBJECT(spw), "tracker", tracker );
diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h
index 404bc7265..3eb12222c 100644
--- a/src/widgets/sp-color-icc-selector.h
+++ b/src/widgets/sp-color-icc-selector.h
@@ -8,7 +8,7 @@
#include "sp-color-selector.h"
namespace Inkscape {
-struct ColorProfile;
+class ColorProfile;
}
struct SPColorICCSelector;
diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp
index 7876f0454..0e2295e36 100644
--- a/src/widgets/sp-widget.cpp
+++ b/src/widgets/sp-widget.cpp
@@ -183,7 +183,7 @@ void SPWidgetImpl::dispose(GObject *object)
if (spw->inkscape) {
// Disconnect signals
- // the checks are necessary because when destroy is caused by the the program shutting down,
+ // the checks are necessary because when destroy is caused by the program shutting down,
// the inkscape object may already be (partly?) invalid --bb
if (G_IS_OBJECT(spw->inkscape) && G_OBJECT_GET_CLASS(spw->inkscape)) {
sp_signal_disconnect_by_data(spw->inkscape, spw);
diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp
index 08d26f3d1..b4e8e68a7 100644
--- a/src/widgets/spiral-toolbar.cpp
+++ b/src/widgets/spiral-toolbar.cpp
@@ -53,13 +53,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-spiral.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -263,10 +259,10 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
eact = create_adjustment_action( "SpiralRevolutionAction",
_("Number of turns"), _("Turns:"), _("Number of revolutions"),
"/tools/shapes/spiral/revolution", 3.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-spiral",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-spiral",
0.01, 1024.0, 0.1, 1.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spl_tb_revolution_value_changed, 1, 2);
+ sp_spl_tb_revolution_value_changed, NULL /*unit tracker*/, 1, 2);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
@@ -277,7 +273,7 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
eact = create_adjustment_action( "SpiralExpansionAction",
_("Divergence"), _("Divergence:"), _("How much denser/sparser are outer revolutions; 1 = uniform"),
"/tools/shapes/spiral/expansion", 1.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 1000.0, 0.01, 1.0,
labels, values, G_N_ELEMENTS(labels),
sp_spl_tb_expansion_value_changed);
@@ -291,7 +287,7 @@ void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
eact = create_adjustment_action( "SpiralT0Action",
_("Inner radius"), _("Inner radius:"), _("Radius of the innermost revolution (relative to the spiral size)"),
"/tools/shapes/spiral/t0", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.0, 0.999, 0.01, 1.0,
labels, values, G_N_ELEMENTS(labels),
sp_spl_tb_t0_value_changed);
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 06850d261..247df53e2 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -52,13 +52,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../spray-context.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -131,10 +127,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayWidthAction",
_("Width"), _("Width:"), _("The width of the spray area (relative to the visible canvas area)"),
"/tools/spray/width", 15,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-spray",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-spray",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_width_value_changed, 1, 0 );
+ sp_spray_width_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -147,10 +143,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction",
_("Focus"), _("Focus:"), _("0 to spray a spot; increase to enlarge the ring radius"),
"/tools/spray/mean", 0,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-mean",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-mean",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_mean_value_changed, 1, 0 );
+ sp_spray_mean_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -163,10 +159,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction",
C_("Spray tool", "Scatter"), C_("Spray tool", "Scatter:"), _("Increase to scatter sprayed objects"),
"/tools/spray/standard_deviation", 70,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-standard_deviation",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_standard_deviation_value_changed, 1, 0 );
+ sp_spray_standard_deviation_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -224,10 +220,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Amount"), _("Amount:"),
_("Adjusts the number of items sprayed per click"),
"/tools/spray/population", 70,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-population",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_population_value_changed, 1, 0 );
+ sp_spray_population_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -255,10 +251,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
// xgettext:no-c-format
_("Variation of the rotation of the sprayed objects; 0% for the same rotation than the original object"),
"/tools/spray/rotation_variation", 0,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-rotation",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-rotation",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_rotation_value_changed, 1, 0 );
+ sp_spray_rotation_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -273,10 +269,10 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
// xgettext:no-c-format
_("Variation in the scale of the sprayed objects; 0% for the same scale than the original object"),
"/tools/spray/scale_variation", 0,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-scale",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "spray-scale",
0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_spray_scale_value_changed, 1, 0 );
+ sp_spray_scale_value_changed, NULL /*unit tracker*/, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 87ca80f2f..9c0c8d7c6 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -2,7 +2,7 @@
* Inkscape Widget Utilities
*
* Authors:
- * Bryce W. Harrington <brycehar@bryceharrington.com>
+ * Bryce W. Harrington <brycehar@bryceharrington.org>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2003 Bryce W. Harrington
@@ -32,7 +32,6 @@
#include "selection.h"
-#include "helper/unit-menu.h"
#include "spw-utilities.h"
#include <gtk/gtk.h>
@@ -231,51 +230,6 @@ spw_dropdown(GtkWidget * dialog, GtkWidget * table,
return selector;
}
-/**
- * Creates a unit selector widget, used for selecting whether one wishes
- * to measure screen elements in millimeters, points, etc. This is a
- * compound unit that includes a label as well as the dropdown selector.
- */
-GtkWidget *
-spw_unit_selector(GtkWidget * dialog, GtkWidget * table,
- const gchar * label_text, gchar * key, int row,
- GtkWidget * us, GCallback cb, bool can_be_negative)
-{
- g_assert(dialog != NULL);
- g_assert(table != NULL);
- g_assert(us != NULL);
-
- spw_label_old(table, label_text, 0, row);
-
-#if GTK_CHECK_VERSION(3,0,0)
- GtkAdjustment * a = gtk_adjustment_new(0.0, can_be_negative?-1e6:0, 1e6, 1.0, 10.0, 10.0);
-#else
- GtkObject * a = gtk_adjustment_new(0.0, can_be_negative?-1e6:0, 1e6, 1.0, 10.0, 10.0);
-#endif
-
- g_assert(a != NULL);
- g_object_set_data (G_OBJECT (a), "key", key);
- g_object_set_data (G_OBJECT (a), "unit_selector", us);
- g_object_set_data (G_OBJECT (dialog), key, a);
- sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (a));
- GtkWidget * sb = gtk_spin_button_new (GTK_ADJUSTMENT (a), 1.0, 4);
- g_assert(sb != NULL);
- gtk_widget_show (sb);
-
-#if GTK_CHECK_VERSION(3,0,0)
- gtk_widget_set_halign(sb, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(sb, TRUE);
- gtk_widget_set_valign(sb, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), sb, 1, row, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), sb, 1, 2, row, row+1,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 0, 0);
-#endif
-
- g_signal_connect (G_OBJECT (a), "value_changed", cb, dialog);
- return sb;
-}
-
static void
sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index fb8c04ebf..31f29e026 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -5,7 +5,7 @@
* Inkscape Widget Utilities
*
* Author:
- * Bryce W. Harrington <brycehar@bryceharrington.com>
+ * Bryce W. Harrington <brycehar@bryceharrington.org>
*
* Copyright (C) 2003 Bryce Harrington
*
@@ -56,11 +56,6 @@ spw_dropdown(GtkWidget *dialog, GtkWidget *table,
GtkWidget *selector
);
-GtkWidget *
-spw_unit_selector(GtkWidget *dialog, GtkWidget *table,
- gchar const *label, gchar *key, int row,
- GtkWidget *us, GCallback cb, bool can_be_negative = false);
-
void sp_set_font_size (GtkWidget *w, guint font);
void sp_set_font_size_smaller (GtkWidget *w);
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 8c07c6473..9e26988ff 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -53,14 +53,10 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-star.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -505,10 +501,10 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "MagnitudeAction",
_("Corners"), _("Corners:"), _("Number of corners of a polygon or star"),
"/tools/shapes/star/magnitude", 3,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
3, 1024, 1, 5,
labels, values, G_N_ELEMENTS(labels),
- sp_stb_magnitude_value_changed,
+ sp_stb_magnitude_value_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -524,7 +520,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
// Base radius is the same for the closest handle.
_("Base radius to tip radius ratio"),
"/tools/shapes/star/proportion", 0.5,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0.01, 1.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
sp_stb_proportion_value_changed );
@@ -545,7 +541,7 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RoundednessAction",
_("Rounded"), _("Rounded:"), _("How much rounded are the corners (0 for sharp)"),
"/tools/shapes/star/rounded", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-10.0, 10.0, 0.01, 0.1,
labels, values, G_N_ELEMENTS(labels),
sp_stb_rounded_value_changed );
@@ -560,10 +556,10 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RandomizationAction",
_("Randomized"), _("Randomized:"), _("Scatter randomly the corners and angles"),
"/tools/shapes/star/randomized", 0.0,
- GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
-10.0, 10.0, 0.001, 0.01,
labels, values, G_N_ELEMENTS(labels),
- sp_stb_randomized_value_changed, 0.1, 3 );
+ sp_stb_randomized_value_changed, NULL /*unit tracker*/, 0.1, 3 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp
index 2d1c932d3..00b6b5c91 100644
--- a/src/widgets/stroke-marker-selector.cpp
+++ b/src/widgets/stroke-marker-selector.cpp
@@ -544,16 +544,16 @@ MarkerComboBox::create_marker_image(unsigned psize, gchar const *mname,
gchar *cache_name = g_strconcat(combo_id, mname, NULL);
Glib::ustring key = svg_preview_cache.cache_key(source->getURI(), cache_name, psize);
g_free (cache_name);
- Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
+ GdkPixbuf *pixbuf = svg_preview_cache.get_preview_from_cache(key); // no ref created
if (!pixbuf) {
- pixbuf = Glib::wrap(render_pixbuf(drawing, 0.8, *dbox, psize));
- svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj());
+ pixbuf = render_pixbuf(drawing, 0.8, *dbox, psize);
+ svg_preview_cache.set_preview_in_cache(key, pixbuf);
+ g_object_unref(pixbuf); // reference is held by svg_preview_cache
}
// Create widget
- Gtk::Image *pb = new Gtk::Image(pixbuf);
-
+ Gtk::Image *pb = Glib::wrap(GTK_IMAGE(gtk_image_new_from_pixbuf(pixbuf)));
return pb;
}
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 0a5b3781b..d140cfb21 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -22,8 +22,11 @@
#include "sp-gradient.h"
#include "sp-stop.h"
#include "svg/svg-color.h"
+#include "util/units.h"
+#include "ui/widget/unit-menu.h"
using Inkscape::DocumentUndo;
+using Inkscape::Util::unit_table;
/**
* Creates a new widget for the line stroke paint.
@@ -82,6 +85,8 @@ SPObject* getMarkerObj(gchar const *n, SPDocument *doc)
// FIXME: get the document from the object and let the caller pass it in
SPObject *marker = doc->getObjectById(b);
+
+ g_free(b);
return marker;
}
@@ -142,7 +147,8 @@ StrokeStyle::StrokeStyle() :
selectModifiedConn(),
startMarkerConn(),
midMarkerConn(),
- endMarkerConn()
+ endMarkerConn(),
+ _old_unit(NULL)
{
Gtk::HBox *hb;
Gtk::HBox *f = new Gtk::HBox(false, 0);
@@ -189,22 +195,22 @@ StrokeStyle::StrokeStyle() :
sp_dialog_defocus_on_enter_cpp(widthSpin);
hb->pack_start(*widthSpin, false, false, 0);
- unitSelector = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
- Gtk::Widget *us = manage(Glib::wrap(unitSelector));
+ unitSelector = new Inkscape::UI::Widget::UnitMenu();
+ unitSelector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR);
+ Gtk::Widget *us = manage(unitSelector);
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop)
- sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unitSelector), sp_desktop_namedview(desktop)->doc_units);
- sp_unit_selector_add_unit(SP_UNIT_SELECTOR(unitSelector), &sp_unit_get_by_id(SP_UNIT_PERCENT), 0);
- g_signal_connect ( G_OBJECT (unitSelector), "set_unit", G_CALLBACK (StrokeStyle::setStrokeWidthUnit), this );
+ unitSelector->addUnit(*unit_table.getUnit("%"));
+ _old_unit = unitSelector->getUnit();
+ if (desktop) {
+ unitSelector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr);
+ _old_unit = sp_desktop_namedview(desktop)->doc_units;
+ }
+ widthSpin->setUnitMenu(unitSelector);
+ unitChangedConn = unitSelector->signal_changed().connect(sigc::mem_fun(*this, &StrokeStyle::unitChangedCB));
+
us->show();
-#if WITH_GTKMM_3_0
- sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(unitSelector), GTK_ADJUSTMENT((*widthAdj)->gobj()) );
-#else
- sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(unitSelector), GTK_ADJUSTMENT(widthAdj->gobj()) );
-#endif
-
hb->pack_start(*us, FALSE, FALSE, 0);
#if WITH_GTKMM_3_0
@@ -519,75 +525,17 @@ void StrokeStyle::updateMarkerHist(SPMarkerLoc const which)
}
/**
- * Sets the stroke width units for all selected items.
- * Also handles absolute and dimensionless units.
+ * Callback for when UnitMenu widget is modified.
+ * Triggers update action.
*/
-gboolean StrokeStyle::setStrokeWidthUnit(SPUnitSelector *,
- SPUnit const *old,
- SPUnit const *new_units,
- StrokeStyle *spw)
+void StrokeStyle::unitChangedCB()
{
- if (spw->update) {
- return FALSE;
- }
-
- if (!spw->desktop) {
- return FALSE;
+ Inkscape::Util::Unit const *new_unit = unitSelector->getUnit();
+ if (new_unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) {
+ widthSpin->set_value(100);
}
-
- Inkscape::Selection *selection = sp_desktop_selection (spw->desktop);
-
- if (selection->isEmpty())
- return FALSE;
-
- GSList const *objects = selection->itemList();
-
- if ((old->base == SP_UNIT_ABSOLUTE || old->base == SP_UNIT_DEVICE) &&
- (new_units->base == SP_UNIT_DIMENSIONLESS)) {
-
- /* Absolute to percentage */
- spw->update = true;
-
-#if WITH_GTKMM_3_0
- float w = sp_units_get_pixels( (*spw->widthAdj)->get_value(), *old);
-#else
- float w = sp_units_get_pixels(spw->widthAdj->get_value(), *old);
-#endif
-
- gdouble average = stroke_average_width (objects);
-
- if ((average == Geom::infinity()) || (average < 1e-8)){ //less than 1e-8: to campare against zero, while taking numeric accuracy into account
- return FALSE;
- }
-
-#if WITH_GTKMM_3_0
- (*spw->widthAdj)->set_value(100.0 * w / average);
-#else
- spw->widthAdj->set_value(100.0 * w / average);
-#endif
-
- spw->update = false;
- return TRUE;
-
- } else if ((old->base == SP_UNIT_DIMENSIONLESS) &&
- (new_units->base == SP_UNIT_ABSOLUTE || new_units->base == SP_UNIT_DEVICE)) {
-
- /* Percentage to absolute */
- spw->update = true;
-
- gdouble average = stroke_average_width (objects);
-
-#if WITH_GTKMM_3_0
- (*spw->widthAdj)->set_value (sp_pixels_get_units (0.01 * (*spw->widthAdj)->get_value() * average, *new_units));
-#else
- spw->widthAdj->set_value (sp_pixels_get_units (0.01 * spw->widthAdj->get_value() * average, *new_units));
-#endif
-
- spw->update = false;
- return TRUE;
- }
-
- return FALSE;
+ widthSpin->set_value(Inkscape::Util::Quantity::convert(widthSpin->get_value(), _old_unit, new_unit));
+ _old_unit = new_unit;
}
/**
@@ -762,7 +710,7 @@ StrokeStyle::getItemColorForMarker(SPItem *item, Inkscape::PaintTarget fill_or_s
stop = sp_last_stop(vector);
}
if (stop) {
- guint32 const c1 = sp_stop_get_rgba32(stop);
+ guint32 const c1 = stop->get_rgba32();
gchar c[64];
sp_svg_write_color(c, sizeof(c), c1);
color = g_strdup(c);
@@ -877,21 +825,20 @@ StrokeStyle::updateLine()
} else {
table->set_sensitive(true);
- SPUnit const *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unitSelector));
-
if (result_sw == QUERY_STYLE_MULTIPLE_AVERAGED) {
- sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unitSelector), &sp_unit_get_by_id(SP_UNIT_PERCENT));
+ unitSelector->setUnit("%");
} else {
// same width, or only one object; no sense to keep percent, switch to absolute
- if (unit->base != SP_UNIT_ABSOLUTE && unit->base != SP_UNIT_DEVICE) {
- sp_unit_selector_set_unit(SP_UNIT_SELECTOR(unitSelector), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
+ Inkscape::Util::Unit const *tempunit = unitSelector->getUnit();
+ if (tempunit->type != Inkscape::Util::UNIT_TYPE_LINEAR) {
+ unitSelector->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units->abbr);
}
}
- unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unitSelector));
+ Inkscape::Util::Unit const *unit = unitSelector->getUnit();
- if (unit->base == SP_UNIT_ABSOLUTE || unit->base == SP_UNIT_DEVICE) {
- double avgwidth = sp_pixels_get_units (query->stroke_width.computed, *unit);
+ if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
+ double avgwidth = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", unit);
#if WITH_GTKMM_3_0
(*widthAdj)->set_value(avgwidth);
#else
@@ -1017,7 +964,7 @@ StrokeStyle::scaleLine()
double const miterlimit = miterLimitAdj->get_value();
#endif
- SPUnit const *const unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unitSelector));
+ Inkscape::Util::Unit const *const unit = unitSelector->getUnit();
double *dash, offset;
int ndash;
@@ -1026,8 +973,8 @@ StrokeStyle::scaleLine()
for (GSList const *i = items; i != NULL; i = i->next) {
/* Set stroke width */
double width;
- if (unit->base == SP_UNIT_ABSOLUTE || unit->base == SP_UNIT_DEVICE) {
- width = sp_units_get_pixels (width_typed, *unit);
+ if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) {
+ width = Inkscape::Util::Quantity::convert(width_typed, unit, "px");
} else { // percentage
gdouble old_w = SP_OBJECT(i->data)->style->stroke_width.computed;
width = old_w * width_typed / 100;
@@ -1053,7 +1000,7 @@ StrokeStyle::scaleLine()
g_free(dash);
- if (unit->base != SP_UNIT_ABSOLUTE && unit->base != SP_UNIT_DEVICE) {
+ if (unit->type != Inkscape::Util::UNIT_TYPE_LINEAR) {
// reset to 100 percent
#if WITH_GTKMM_3_0
(*widthAdj)->set_value(100.0);
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index fd9940db1..6f0fe583b 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -40,8 +40,6 @@
#include "document-undo.h"
#include "gradient-chemistry.h"
#include "helper/stock-items.h"
-#include "helper/unit-menu.h"
-#include "helper/units.h"
#include "inkscape.h"
#include "io/sys.h"
#include "marker.h"
@@ -77,6 +75,17 @@ class Widget;
class Container;
}
+namespace Inkscape {
+ namespace Util {
+ class Unit;
+ }
+ namespace UI {
+ namespace Widget {
+ class UnitMenu;
+ }
+ }
+}
+
struct { gchar const *key; gint value; } const SPMarkerNames[] = {
{"marker-all", SP_MARKER_LOC},
{"marker-start", SP_MARKER_LOC_START},
@@ -162,17 +171,13 @@ private:
StrokeStyleButtonType button_type,
gchar const *stroke_style);
- static gboolean setStrokeWidthUnit(SPUnitSelector *,
- SPUnit const *old,
- SPUnit const *new_units,
- StrokeStyle *spw);
-
// Callback functions
void selectionModifiedCB(guint flags);
void selectionChangedCB();
void widthChangedCB();
void miterLimitChangedCB();
void lineDashChangedCB();
+ void unitChangedCB();
static void markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, SPMarkerLoc const which);
static void buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw);
@@ -191,7 +196,7 @@ private:
#endif
Inkscape::UI::Widget::SpinButton *miterLimitSpin;
Inkscape::UI::Widget::SpinButton *widthSpin;
- GtkWidget *unitSelector;
+ Inkscape::UI::Widget::UnitMenu *unitSelector;
StrokeStyleButton *joinMiter;
StrokeStyleButton *joinRound;
StrokeStyleButton *joinBevel;
@@ -207,6 +212,9 @@ private:
sigc::connection startMarkerConn;
sigc::connection midMarkerConn;
sigc::connection endMarkerConn;
+ sigc::connection unitChangedConn;
+
+ Inkscape::Util::Unit const *_old_unit;
};
} // namespace Inkscape
diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp
index ad59e0dc3..7178ad072 100644
--- a/src/widgets/swatch-selector.cpp
+++ b/src/widgets/swatch-selector.cpp
@@ -172,7 +172,7 @@ void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector)
if ( vector && vector->isSolid() ) {
SPStop* stop = vector->getFirstStop();
- guint32 const colorVal = sp_stop_get_rgba32(stop);
+ guint32 const colorVal = stop->get_rgba32();
_csel->base->setAlpha(SP_RGBA32_A_F(colorVal));
SPColor color( SP_RGBA32_R_F(colorVal), SP_RGBA32_G_F(colorVal), SP_RGBA32_B_F(colorVal) );
// set its color, from the stored array
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 87cb54d10..6b9fc900c 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -56,9 +56,6 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../sp-namedview.h"
#include "../svg/css-ostringstream.h"
@@ -72,7 +69,6 @@
#include "widgets/font-selector.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -1217,11 +1213,6 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
- // Is this used?
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
- g_object_set_data( holder, "tracker", tracker );
-
/* Font family */
{
// Font list
@@ -1462,13 +1453,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/lineheight", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
0.0, 10.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_lineheight_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
@@ -1493,13 +1484,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/wordspacing", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
-100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_wordspacing_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
@@ -1524,13 +1515,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/letterspacing", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
-100.0, 100.0, 0.01, 0.10, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_letterspacing_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
@@ -1555,13 +1546,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/dx", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
-100.0, 100.0, 0.01, 0.1, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_dx_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
@@ -1586,13 +1577,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/dy", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
-100.0, 100.0, 0.01, 0.1, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_dy_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
@@ -1617,13 +1608,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"/tools/text/rotation", /* preferences path */
0.0, /* default */
GTK_WIDGET(desktop->canvas), /* focusTarget */
- NULL, /* unit selector */
holder, /* dataKludge */
FALSE, /* set alt-x keyboard shortcut? */
NULL, /* altx_mark */
-180.0, 180.0, 0.1, 1.0, /* lower, upper, step (arrow up/down), page up/down */
labels, values, G_N_ELEMENTS(labels), /* drop down menu */
sp_text_rotation_value_changed, /* callback */
+ NULL, /* unit tracker */
0.1, /* step (used?) */
2, /* digits to show */
1.0 /* factor (multiplies default) */
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index ca593976f..ddbe77fbb 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -49,9 +49,6 @@
#include "../graphlayout.h"
#include "../helper/action.h"
#include "../helper/action-context.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "icon.h"
#include "../ink-action.h"
#include "../ink-comboboxentry-action.h"
@@ -79,7 +76,7 @@
#include "calligraphy-toolbar.h"
#include "connector-toolbar.h"
#include "dropper-toolbar.h"
-#include "erasor-toolbar.h"
+#include "eraser-toolbar.h"
#include "gradient-toolbar.h"
#include "lpe-toolbar.h"
#include "mesh-toolbar.h"
@@ -99,9 +96,10 @@
#include "toolbox.h"
#include <gtk/gtk.h>
+#include "event-context.h"
+
//#define DEBUG_TEXT
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::PrefPusher;
@@ -140,29 +138,29 @@ static struct {
sp_verb_t verb;
sp_verb_t doubleclick_verb;
} const tools[] = {
- { "SPSelectContext", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS},
- { "InkNodeTool", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS },
- { "SPTweakContext", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS },
- { "SPSprayContext", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS },
- { "SPZoomContext", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS },
- { "SPMeasureContext", "measure_tool", SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_MEASURE_PREFS },
- { "SPRectContext", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS },
- { "Box3DContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS },
- { "SPArcContext", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS },
- { "SPStarContext", "star_tool", SP_VERB_CONTEXT_STAR, SP_VERB_CONTEXT_STAR_PREFS },
- { "SPSpiralContext", "spiral_tool", SP_VERB_CONTEXT_SPIRAL, SP_VERB_CONTEXT_SPIRAL_PREFS },
- { "SPPencilContext", "pencil_tool", SP_VERB_CONTEXT_PENCIL, SP_VERB_CONTEXT_PENCIL_PREFS },
- { "SPPenContext", "pen_tool", SP_VERB_CONTEXT_PEN, SP_VERB_CONTEXT_PEN_PREFS },
- { "SPDynaDrawContext", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS },
- { "SPLPEToolContext", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS },
- { "SPEraserContext", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
- { "SPFloodContext", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
- { "SPTextContext", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
- { "SPConnectorContext","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
- { "SPGradientContext", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS },
- { "SPMeshContext", "mesh_tool", SP_VERB_CONTEXT_MESH, SP_VERB_CONTEXT_MESH_PREFS },
- { "SPDropperContext", "dropper_tool", SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_DROPPER_PREFS },
- { NULL, NULL, 0, 0 }
+ { "/tools/select", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS},
+ { "/tools/nodes", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS },
+ { "/tools/tweak", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS },
+ { "/tools/spray", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS },
+ { "/tools/zoom", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS },
+ { "/tools/measure", "measure_tool", SP_VERB_CONTEXT_MEASURE, SP_VERB_CONTEXT_MEASURE_PREFS },
+ { "/tools/shapes/rect", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS },
+ { "/tools/shapes/3dbox", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS },
+ { "/tools/shapes/arc", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS },
+ { "/tools/shapes/star", "star_tool", SP_VERB_CONTEXT_STAR, SP_VERB_CONTEXT_STAR_PREFS },
+ { "/tools/shapes/spiral", "spiral_tool", SP_VERB_CONTEXT_SPIRAL, SP_VERB_CONTEXT_SPIRAL_PREFS },
+ { "/tools/freehand/pencil", "pencil_tool", SP_VERB_CONTEXT_PENCIL, SP_VERB_CONTEXT_PENCIL_PREFS },
+ { "/tools/freehand/pen", "pen_tool", SP_VERB_CONTEXT_PEN, SP_VERB_CONTEXT_PEN_PREFS },
+ { "/tools/calligraphic", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS },
+ { "/tools/lpetool", "lpetool_tool", SP_VERB_CONTEXT_LPETOOL, SP_VERB_CONTEXT_LPETOOL_PREFS },
+ { "/tools/eraser", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
+ { "/tools/paintbucket", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
+ { "/tools/text", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
+ { "/tools/connector","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
+ { "/tools/gradient", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS },
+ { "/tools/mesh", "mesh_tool", SP_VERB_CONTEXT_MESH, SP_VERB_CONTEXT_MESH_PREFS },
+ { "/tools/dropper", "dropper_tool", SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_DROPPER_PREFS },
+ { NULL, NULL, 0, 0 }
};
static struct {
@@ -175,49 +173,49 @@ static struct {
gchar const *swatch_tool;
gchar const *swatch_tip;
} const aux_toolboxes[] = {
- { "SPSelectContext", "select_toolbox", 0, sp_select_toolbox_prep, "SelectToolbar",
+ { "/tools/select", "select_toolbox", 0, sp_select_toolbox_prep, "SelectToolbar",
SP_VERB_INVALID, 0, 0},
- { "InkNodeTool", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
+ { "/tools/nodes", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
+ { "/tools/tweak", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")},
- { "SPSprayContext", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar",
+ { "/tools/spray", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
+ { "/tools/zoom", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPMeasureContext", "measure_toolbox", 0, sp_measure_toolbox_prep, "MeasureToolbar",
+ { "/tools/measure", "measure_toolbox", 0, sp_measure_toolbox_prep, "MeasureToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
+ { "/tools/shapes/star", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
SP_VERB_CONTEXT_STAR_PREFS, "/tools/shapes/star", N_("Style of new stars")},
- { "SPRectContext", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar",
+ { "/tools/shapes/rect", "rect_toolbox", 0, sp_rect_toolbox_prep, "RectToolbar",
SP_VERB_CONTEXT_RECT_PREFS, "/tools/shapes/rect", N_("Style of new rectangles")},
- { "Box3DContext", "3dbox_toolbox", 0, box3d_toolbox_prep, "3DBoxToolbar",
+ { "/tools/shapes/3dbox", "3dbox_toolbox", 0, box3d_toolbox_prep, "3DBoxToolbar",
SP_VERB_CONTEXT_3DBOX_PREFS, "/tools/shapes/3dbox", N_("Style of new 3D boxes")},
- { "SPArcContext", "arc_toolbox", 0, sp_arc_toolbox_prep, "ArcToolbar",
+ { "/tools/shapes/arc", "arc_toolbox", 0, sp_arc_toolbox_prep, "ArcToolbar",
SP_VERB_CONTEXT_ARC_PREFS, "/tools/shapes/arc", N_("Style of new ellipses")},
- { "SPSpiralContext", "spiral_toolbox", 0, sp_spiral_toolbox_prep, "SpiralToolbar",
+ { "/tools/shapes/spiral", "spiral_toolbox", 0, sp_spiral_toolbox_prep, "SpiralToolbar",
SP_VERB_CONTEXT_SPIRAL_PREFS, "/tools/shapes/spiral", N_("Style of new spirals")},
- { "SPPencilContext", "pencil_toolbox", 0, sp_pencil_toolbox_prep, "PencilToolbar",
+ { "/tools/freehand/pencil", "pencil_toolbox", 0, sp_pencil_toolbox_prep, "PencilToolbar",
SP_VERB_CONTEXT_PENCIL_PREFS, "/tools/freehand/pencil", N_("Style of new paths created by Pencil")},
- { "SPPenContext", "pen_toolbox", 0, sp_pen_toolbox_prep, "PenToolbar",
+ { "/tools/freehand/pen", "pen_toolbox", 0, sp_pen_toolbox_prep, "PenToolbar",
SP_VERB_CONTEXT_PEN_PREFS, "/tools/freehand/pen", N_("Style of new paths created by Pen")},
- { "SPDynaDrawContext", "calligraphy_toolbox", 0, sp_calligraphy_toolbox_prep,"CalligraphyToolbar",
+ { "/tools/calligraphic", "calligraphy_toolbox", 0, sp_calligraphy_toolbox_prep,"CalligraphyToolbar",
SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS, "/tools/calligraphic", N_("Style of new calligraphic strokes")},
- { "SPEraserContext", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar",
+ { "/tools/eraser", "eraser_toolbox", 0, sp_eraser_toolbox_prep,"EraserToolbar",
SP_VERB_CONTEXT_ERASER_PREFS, "/tools/eraser", _("TBD")},
- { "SPLPEToolContext", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
+ { "/tools/lpetool", "lpetool_toolbox", 0, sp_lpetool_toolbox_prep, "LPEToolToolbar",
SP_VERB_CONTEXT_LPETOOL_PREFS, "/tools/lpetool", _("TBD")},
- { "SPTextContext", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar",
+ { "/tools/text", "text_toolbox", 0, sp_text_toolbox_prep, "TextToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPDropperContext", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
+ { "/tools/dropper", "dropper_toolbox", 0, sp_dropper_toolbox_prep, "DropperToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPConnectorContext", "connector_toolbox", 0, sp_connector_toolbox_prep, "ConnectorToolbar",
+ { "/tools/connector", "connector_toolbox", 0, sp_connector_toolbox_prep, "ConnectorToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPGradientContext", "gradient_toolbox", 0, sp_gradient_toolbox_prep, "GradientToolbar",
+ { "/tools/gradient", "gradient_toolbox", 0, sp_gradient_toolbox_prep, "GradientToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPMeshContext", "mesh_toolbox", 0, sp_mesh_toolbox_prep, "MeshToolbar",
+ { "/tools/mesh", "mesh_toolbox", 0, sp_mesh_toolbox_prep, "MeshToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPFloodContext", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar",
+ { "/tools/paintbucket", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar",
SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")},
{ NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL }
};
@@ -1014,7 +1012,7 @@ GtkWidget *ToolboxFactory::createSnapToolbox()
return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT );
}
-static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits )
+static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker)
{
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true);
@@ -1022,6 +1020,7 @@ static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRa
#else
Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
#endif
+ inkSpinner->addUnitTracker(unit_tracker);
inkSpinner = Gtk::manage( inkSpinner );
GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() );
return widget;
@@ -1031,12 +1030,12 @@ EgeAdjustmentAction * create_adjustment_action( gchar const *name,
gchar const *label, gchar const *shortLabel, gchar const *tooltip,
Glib::ustring const &path, gdouble def,
GtkWidget *focusTarget,
- GtkWidget *us,
GObject *dataKludge,
gboolean altx, gchar const *altx_mark,
gdouble lower, gdouble upper, gdouble step, gdouble page,
gchar const** descrLabels, gdouble const* descrValues, guint descrCount,
void (*callback)(GtkAdjustment *, GObject *),
+ Inkscape::UI::Widget::UnitTracker *unit_tracker,
gdouble climb/* = 0.1*/, guint digits/* = 3*/, double factor/* = 1.0*/ )
{
static bool init = false;
@@ -1048,13 +1047,10 @@ EgeAdjustmentAction * create_adjustment_action( gchar const *name,
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, def) * factor,
lower, upper, step, page, 0 ) );
- if (us) {
- sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us), adj );
- }
g_signal_connect( G_OBJECT(adj), "value-changed", G_CALLBACK(callback), dataKludge );
- EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, label, tooltip, 0, climb, digits );
+ EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, label, tooltip, 0, climb, digits, unit_tracker );
if ( shortLabel ) {
g_object_set( act, "short_label", shortLabel, NULL );
}
@@ -1317,7 +1313,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
void update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget * /*toolbox*/ )
{
gchar const *const tname = ( eventcontext
- ? g_type_name(G_OBJECT_TYPE(eventcontext))
+ ? eventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext))
: NULL );
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
@@ -1439,7 +1435,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
void update_aux_toolbox(SPDesktop * /*desktop*/, SPEventContext *eventcontext, GtkWidget *toolbox)
{
gchar const *tname = ( eventcontext
- ? g_type_name(G_OBJECT_TYPE(eventcontext))
+ ? eventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext))
: NULL );
for (int i = 0 ; aux_toolboxes[i].type_name ; i++ ) {
GtkWidget *sub_toolbox = GTK_WIDGET(g_object_get_data(G_OBJECT(toolbox), aux_toolboxes[i].data_name));
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index 9c839a8fe..e9ffcda4a 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -23,11 +23,15 @@
#define TOOLBAR_SLIDER_HINT "full"
class SPDesktop;
-struct SPEventContext;
+class SPEventContext;
namespace Inkscape {
namespace UI {
+namespace Widget {
+ class UnitTracker;
+}
+
/**
* Main toolbox source.
*/
@@ -118,12 +122,12 @@ void delete_connection(GObject * /*obj*/, sigc::connection *connection);
gchar const *label, gchar const *shortLabel, gchar const *tooltip,
Glib::ustring const &path, gdouble def,
GtkWidget *focusTarget,
- GtkWidget *us,
GObject *dataKludge,
gboolean altx, gchar const *altx_mark,
gdouble lower, gdouble upper, gdouble step, gdouble page,
gchar const** descrLabels, gdouble const* descrValues, guint descrCount,
void (*callback)(GtkAdjustment *, GObject *),
+ Inkscape::UI::Widget::UnitTracker *unit_tracker = NULL,
gdouble climb = 0.1, guint digits = 3, double factor = 1.0 );
#endif /* !SEEN_TOOLBOX_H */
diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp
index beb527a17..6da7608bd 100644
--- a/src/widgets/tweak-toolbar.cpp
+++ b/src/widgets/tweak-toolbar.cpp
@@ -52,13 +52,9 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../tweak-context.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -145,10 +141,10 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "TweakWidthAction",
_("Width"), _("Width:"), _("The width of the tweak area (relative to the visible canvas area)"),
"/tools/tweak/width", 15,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-tweak",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-tweak",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_tweak_width_value_changed, 0.01, 0, 100 );
+ sp_tweak_width_value_changed, NULL /*unit tracker*/, 0.01, 0, 100 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -162,10 +158,10 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeAdjustmentAction *eact = create_adjustment_action( "TweakForceAction",
_("Force"), _("Force:"), _("The force of the tweak action"),
"/tools/tweak/force", 20,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-force",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "tweak-force",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_tweak_force_value_changed, 0.01, 0, 100 );
+ sp_tweak_force_value_changed, NULL /*unit tracker*/, 0.01, 0, 100 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -371,10 +367,10 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
_("Fidelity"), _("Fidelity:"),
_("Low fidelity simplifies paths; high fidelity preserves path features but may generate a lot of new nodes"),
"/tools/tweak/fidelity", 50,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-fidelity",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "tweak-fidelity",
1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_tweak_fidelity_value_changed, 0.01, 0, 100 );
+ sp_tweak_fidelity_value_changed, NULL /*unit tracker*/, 0.01, 0, 100 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
if (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER) {
diff --git a/src/widgets/zoom-toolbar.cpp b/src/widgets/zoom-toolbar.cpp
index 7d7f2c774..9cdbc3d6a 100644
--- a/src/widgets/zoom-toolbar.cpp
+++ b/src/widgets/zoom-toolbar.cpp
@@ -51,14 +51,10 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
#include "../pen-context.h"
#include "../tweak-context.h"
-using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;