summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-20 18:00:42 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-20 18:00:42 +0000
commit567fbf4a2759ff93533a22a8688b4dcc01f19138 (patch)
treeb24af717efc26648371fd13f642a35980f36ebf1 /src
parentPorted "widgets/stroke-style.*". (diff)
downloadinkscape-567fbf4a2759ff93533a22a8688b4dcc01f19138.tar.gz
inkscape-567fbf4a2759ff93533a22a8688b4dcc01f19138.zip
Removed last traces of "SPUnit" and removed "helper/unit*".
(bzr r12380.1.45)
Diffstat (limited to 'src')
-rw-r--r--src/helper/Makefile_insert4
-rw-r--r--src/helper/unit-menu.cpp360
-rw-r--r--src/helper/unit-menu.h60
-rw-r--r--src/helper/units-test.h90
-rw-r--r--src/helper/units.cpp261
-rw-r--r--src/helper/units.h146
-rw-r--r--src/ui/widget/registered-widget.h1
7 files changed, 0 insertions, 922 deletions
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert
index 0008936dd..5d1703b5c 100644
--- a/src/helper/Makefile_insert
+++ b/src/helper/Makefile_insert
@@ -18,10 +18,6 @@ ink_common_sources += \
helper/png-write.h \
helper/sp-marshal.cpp \
helper/sp-marshal.h \
- helper/unit-menu.cpp \
- helper/unit-menu.h \
- helper/units.cpp \
- helper/units.h \
helper/window.cpp \
helper/window.h \
helper/stock-items.cpp \
diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp
deleted file mode 100644
index af07c03c1..000000000
--- a/src/helper/unit-menu.cpp
+++ /dev/null
@@ -1,360 +0,0 @@
-#define __SP_UNIT_MENU_C__
-
-/*
- * Unit selector with autupdate capability
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * bulia byak <buliabyak@users.sf.net>
- *
- * Copyright (C) 2000-2002 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#define noUNIT_SELECTOR_VERBOSE
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include <gtk/gtk.h>
-#include "helper/sp-marshal.h"
-#include "helper/units.h"
-#include "helper/unit-menu.h"
-#include "widgets/spw-utilities.h"
-
-struct SPUnitSelector {
- GtkHBox box;
-
- GtkWidget *combo_box;
- GtkListStore *store;
-
-
- guint bases;
- GSList *units;
- SPUnit const *unit;
- gdouble ctmscale;
- guint plural : 1;
- guint abbr : 1;
-
- guint update : 1;
-
- GSList *adjustments;
-};
-
-enum {COMBO_COL_LABEL=0, COMBO_COL_UNIT};
-
-struct SPUnitSelectorClass {
- GtkHBoxClass parent_class;
-
- gboolean (* set_unit)(SPUnitSelector *us, SPUnit const *old, SPUnit const *new_unit);
-};
-
-enum {SET_UNIT, LAST_SIGNAL};
-
-static void sp_unit_selector_finalize(GObject *object);
-
-static guint signals[LAST_SIGNAL] = {0};
-
-G_DEFINE_TYPE(SPUnitSelector, sp_unit_selector, GTK_TYPE_HBOX);
-
-static void
-sp_unit_selector_class_init(SPUnitSelectorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
- signals[SET_UNIT] = g_signal_new("set_unit",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(SPUnitSelectorClass, set_unit),
- NULL, NULL,
- sp_marshal_BOOLEAN__POINTER_POINTER,
- G_TYPE_BOOLEAN, 2,
- G_TYPE_POINTER, G_TYPE_POINTER);
-
- object_class->finalize = sp_unit_selector_finalize;
-}
-
-static void
-sp_unit_selector_init(SPUnitSelector *us)
-{
- us->ctmscale = 1.0;
- us->abbr = FALSE;
- us->plural = TRUE;
-
- /**
- * Create a combo_box and store with 2 columns,
- * a label and a pointer to a SPUnit
- */
- us->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
- us->combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (us->store));
-
- GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "scale", 0.8, "scale-set", TRUE, NULL);
- gtk_cell_renderer_set_padding (renderer, 2, 0);
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (us->combo_box), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (us->combo_box), renderer, "text", COMBO_COL_LABEL, NULL);
-
- gtk_widget_show (us->combo_box);
- gtk_box_pack_start (GTK_BOX(us), us->combo_box, TRUE, TRUE, 0);
-}
-
-static void
-sp_unit_selector_finalize(GObject *object)
-{
- SPUnitSelector *selector = SP_UNIT_SELECTOR(object);
-
- if (selector->combo_box) {
- selector->combo_box = NULL;
- }
-
- while (selector->adjustments) {
- g_object_unref(selector->adjustments->data);
- selector->adjustments = g_slist_remove(selector->adjustments, selector->adjustments->data);
- }
-
- if (selector->units) {
- sp_unit_free_list(selector->units);
- }
-
- selector->unit = NULL;
-
- G_OBJECT_CLASS(sp_unit_selector_parent_class)->finalize(object);
-}
-
-GtkWidget *
-sp_unit_selector_new(guint bases)
-{
- SPUnitSelector *us = SP_UNIT_SELECTOR(g_object_new(SP_TYPE_UNIT_SELECTOR, NULL));
-
- sp_unit_selector_set_bases(us, bases);
-
- return GTK_WIDGET(us);
-}
-
-void
-sp_unit_selector_setsize(GtkWidget *us, guint w, guint h)
-{
- gtk_widget_set_size_request((SP_UNIT_SELECTOR(us))->combo_box, w, h);
-}
-
-SPUnit const *
-sp_unit_selector_get_unit(SPUnitSelector const *us)
-{
- g_return_val_if_fail(us != NULL, NULL);
- g_return_val_if_fail(SP_IS_UNIT_SELECTOR(us), NULL);
-
- return us->unit;
-}
-
-
-static void
-on_combo_box_changed (GtkComboBox *widget, SPUnitSelector *us)
-{
- GtkTreeIter iter;
- if (!gtk_combo_box_get_active_iter (widget, &iter)) {
- return;
- }
-
- SPUnit const *unit = NULL;
- gtk_tree_model_get (GTK_TREE_MODEL(us->store), &iter, COMBO_COL_UNIT, &unit, -1);
-
- g_return_if_fail(unit != NULL);
-
-#ifdef UNIT_SELECTOR_VERBOSE
- g_print("Old unit %s new unit %s\n", us->unit->name, unit->name);
-#endif
-
- SPUnit const *old = us->unit;
- us->unit = unit;
-
- us->update = TRUE;
-
- gboolean consumed = FALSE;
- g_signal_emit(G_OBJECT(us), signals[SET_UNIT], 0, old, unit, &consumed);
-
- if ( !consumed
- && ( unit->base == old->base
- || ( unit->base == SP_UNIT_ABSOLUTE && old->base == SP_UNIT_DEVICE )
- || ( old->base == SP_UNIT_ABSOLUTE && unit->base == SP_UNIT_DEVICE ) ) ) {
- // Either the same base, or absolute<->device:
- /* Recalculate adjustments. */
- for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) {
- GtkAdjustment *adj = GTK_ADJUSTMENT(l->data);
- gdouble val = gtk_adjustment_get_value (adj);
-#ifdef UNIT_SELECTOR_VERBOSE
- g_print("Old val %g ... ", val);
-#endif
- val = sp_convert_distance_full(val, *old, *unit);
-#ifdef UNIT_SELECTOR_VERBOSE
- g_print("new val %g\n", val);
-#endif
- gtk_adjustment_set_value (adj, val);
- }
- /* need to separate the value changing from the notification
- * or else the unit changes can break the calculations */
- for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) {
- gtk_adjustment_value_changed(GTK_ADJUSTMENT(l->data));
- }
- } else if (!consumed && unit->base != old->base) {
- /* when the base changes, signal all the adjustments to get them
- * to recalculate */
- for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) {
- g_signal_emit_by_name(G_OBJECT(l->data), "value_changed");
- }
- }
-
- us->update = FALSE;
-
-}
-
-static void
-spus_rebuild_menu(SPUnitSelector *us)
-{
-
- gtk_list_store_clear(us->store);
-
- GtkTreeIter iter;
-
- gint pos = 0;
- gint p = 0;
- for (GSList *l = us->units; l != NULL; l = l->next) {
- SPUnit const *u = static_cast<SPUnit const*>(l->data);
-
- // use only abbreviations in the menu
- // i = gtk_menu_item_new_with_label((us->abbr) ? (us->plural) ? u->abbr_plural : u->abbr : (us->plural) ? u->plural : u->name);
- gtk_list_store_append (us->store, &iter);
- gtk_list_store_set (us->store, &iter, COMBO_COL_LABEL, u->abbr, COMBO_COL_UNIT, (gpointer) u, -1);
-
- if (u == us->unit) {
- pos = p;
- }
-
- p += 1;
- }
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos);
- g_signal_connect (G_OBJECT (us->combo_box), "changed", G_CALLBACK (on_combo_box_changed), us);
-}
-
-void
-sp_unit_selector_set_bases(SPUnitSelector *us, guint bases)
-{
- g_return_if_fail(us != NULL);
- g_return_if_fail(SP_IS_UNIT_SELECTOR(us));
-
- if (bases == us->bases) return;
-
- GSList *units = sp_unit_get_list(bases);
- g_return_if_fail(units != NULL);
- sp_unit_free_list(us->units);
- us->units = units;
- us->unit = static_cast<SPUnit *>(units->data);
-
- spus_rebuild_menu(us);
-}
-
-void
-sp_unit_selector_add_unit(SPUnitSelector *us, SPUnit const *unit, int position)
-{
- if (!g_slist_find(us->units, (gpointer) unit)) {
- us->units = g_slist_insert(us->units, (gpointer) unit, position);
-
- spus_rebuild_menu(us);
- }
-}
-
-void
-sp_unit_selector_set_unit(SPUnitSelector *us, SPUnit const *unit)
-{
- g_return_if_fail(us != NULL);
- g_return_if_fail(SP_IS_UNIT_SELECTOR(us));
-
- if (unit == NULL) {
- return; // silently return, by default a newly created selector uses pt
- }
- if (unit == us->unit) {
- return;
- }
-
- gint const pos = g_slist_index(us->units, (gpointer) unit);
- g_return_if_fail(pos >= 0);
-
- gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos);
-
- SPUnit const *old = us->unit;
- us->unit = unit;
-
- /* Recalculate adjustments */
- for (GSList *l = us->adjustments; l != NULL; l = l->next) {
- GtkAdjustment *adj = GTK_ADJUSTMENT(l->data);
- gdouble const val = sp_convert_distance_full(gtk_adjustment_get_value (adj), *old, *unit);
- gtk_adjustment_set_value(adj, val);
- }
-}
-
-void
-sp_unit_selector_add_adjustment(SPUnitSelector *us, GtkAdjustment *adj)
-{
- g_return_if_fail(us != NULL);
- g_return_if_fail(SP_IS_UNIT_SELECTOR(us));
- g_return_if_fail(adj != NULL);
- g_return_if_fail(GTK_IS_ADJUSTMENT(adj));
-
- g_return_if_fail(!g_slist_find(us->adjustments, adj));
-
- g_object_ref(adj);
- us->adjustments = g_slist_prepend(us->adjustments, adj);
-}
-
-void
-sp_unit_selector_remove_adjustment(SPUnitSelector *us, GtkAdjustment *adj)
-{
- g_return_if_fail(us != NULL);
- g_return_if_fail(SP_IS_UNIT_SELECTOR(us));
- g_return_if_fail(adj != NULL);
- g_return_if_fail(GTK_IS_ADJUSTMENT(adj));
-
- g_return_if_fail(g_slist_find(us->adjustments, adj));
-
- us->adjustments = g_slist_remove(us->adjustments, adj);
- g_object_unref(adj);
-}
-
-gboolean
-sp_unit_selector_update_test(SPUnitSelector const *selector)
-{
- g_return_val_if_fail(selector != NULL, FALSE);
- g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), FALSE);
-
- return selector->update;
-}
-
-double
-sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj)
-{
- g_return_val_if_fail(selector != NULL, gtk_adjustment_get_value (adj));
- g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), gtk_adjustment_get_value (adj));
-
- return sp_units_get_pixels(gtk_adjustment_get_value (adj), *(selector->unit));
-}
-
-void
-sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value)
-{
- g_return_if_fail(selector != NULL);
- g_return_if_fail(SP_IS_UNIT_SELECTOR(selector));
-
- gtk_adjustment_set_value(adj, sp_pixels_get_units(value, *(selector->unit)));
-}
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h
deleted file mode 100644
index b3ee6bcd1..000000000
--- a/src/helper/unit-menu.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef SP_UNIT_MENU_H
-#define SP_UNIT_MENU_H
-
-/*
- * SPUnitMenu
- *
- * Generic (and quite unintelligent) grid item for gnome canvas
- *
- * Copyright (C) Lauris Kaplinski 2000
- *
- */
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-struct SPUnit;
-struct SPUnitSelector;
-struct SPUnitSelectorClass;
-
-/* Unit selector Widget */
-
-#define SP_TYPE_UNIT_SELECTOR (sp_unit_selector_get_type())
-#define SP_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_UNIT_SELECTOR, SPUnitSelector))
-#define SP_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_UNIT_SELECTOR, SPUnitSelectorClass))
-#define SP_IS_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_UNIT_SELECTOR))
-#define SP_IS_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_UNIT_SELECTOR))
-
-GType sp_unit_selector_get_type(void);
-
-GtkWidget *sp_unit_selector_new(guint bases);
-void sp_unit_selector_setsize(GtkWidget *us, guint w, guint h);
-
-SPUnit const *sp_unit_selector_get_unit(SPUnitSelector const *selector);
-
-void sp_unit_selector_set_bases(SPUnitSelector *selector, guint bases);
-void sp_unit_selector_add_unit(SPUnitSelector *selector, SPUnit const *unit, int position);
-
-void sp_unit_selector_set_unit(SPUnitSelector *selector, SPUnit const *unit);
-void sp_unit_selector_add_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment);
-void sp_unit_selector_remove_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment);
-
-gboolean sp_unit_selector_update_test(SPUnitSelector const *selector);
-
-double sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj);
-void sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value);
-
-
-
-#endif // SP_UNIT_MENU_H
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/units-test.h b/src/helper/units-test.h
deleted file mode 100644
index 05bc75eff..000000000
--- a/src/helper/units-test.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <cxxtest/TestSuite.h>
-
-#include <helper/units.h>
-#include <glibmm/i18n.h>
-#include <math.h>
-
-class UnitsTest : public CxxTest::TestSuite {
-public:
-
- UnitsTest()
- {
- }
- virtual ~UnitsTest() {}
-
-// createSuite and destroySuite get us per-suite setup and teardown
-// without us having to worry about static initialization order, etc.
- static UnitsTest *createSuite() { return new UnitsTest(); }
- static void destroySuite( UnitsTest *suite ) { delete suite; }
-
- void testConversions()
- {
- struct Case { double x; char const *abbr; double pts; } const tests[] = {
- { 1.0, "pt", 1.0 },
- { 5.0, "pt", 5.0 },
- { 1.0, "in", 72.0 },
- { 2.0, "in", 144.0 },
- { 254., "mm", 720.0 },
- { 254., "cm", 7200. },
- { 254., "m", 720000. },
- { 1.5, "mm", (15 * 72. / 254) }
- };
- for (unsigned i = 0; i < G_N_ELEMENTS(tests); ++i) {
- Case const &c = tests[i];
- SPUnit const &unit = *sp_unit_get_by_abbreviation(N_(c.abbr));
-
- double const calc_pts = sp_units_get_points(c.x, unit);
- TS_ASSERT(approx_equal(calc_pts, c.pts));
-
- double const calc_x = sp_points_get_units(c.pts, unit);
- TS_ASSERT(approx_equal(calc_x, c.x));
-
- double tmp = c.x;
- bool const converted_to_pts = sp_convert_distance(&tmp, &unit, SP_PS_UNIT);
- TS_ASSERT(converted_to_pts);
- TS_ASSERT(approx_equal(tmp, c.pts));
-
- tmp = c.pts;
- bool const converted_from_pts = sp_convert_distance(&tmp, SP_PS_UNIT, &unit);
- TS_ASSERT(converted_from_pts);
- TS_ASSERT(approx_equal(tmp, c.x));
- }
- }
-
- void testUnitTable()
- {
- TS_ASSERT(sp_units_table_sane());
- }
-
-private:
- /* N.B. Wrongly returns false if both near 0. (Not a problem for current users.) */
- bool approx_equal(double const x, double const y)
- {
- return fabs(x / y - 1) < 1e-15;
- }
-
- double sp_units_get_points(double const x, SPUnit const &unit)
- {
- SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT);
- double const px = sp_units_get_pixels(x, unit);
- return sp_pixels_get_units(px, pt_unit);
- }
-
- double sp_points_get_units(double const pts, SPUnit const &unit)
- {
- SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT);
- double const px = sp_units_get_pixels(pts, pt_unit);
- return sp_pixels_get_units(px, unit);
- }
-};
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/units.cpp b/src/helper/units.cpp
deleted file mode 100644
index 1593fc131..000000000
--- a/src/helper/units.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-#define __SP_PAPER_C__
-
-/*
- * SPUnit
- *
- * Ported from libgnomeprint
- *
- * Authors:
- * Dirk Luetjens <dirk@luedi.oche.de>
- * Yves Arrouye <Yves.Arrouye@marin.fdn.fr>
- * Lauris Kaplinski <lauris@ximian.com>
- * bulia byak <buliabyak@users.sf.net>
- *
- * Copyright 1999-2001 Ximian, Inc. and authors
- *
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "helper/units.h"
-#include <glib.h> // g_assert()
-#include <glibmm/i18n.h>
-#include "unit-constants.h"
-#include "svg/svg-length.h"
-
-/* todo: use some fancy unit program */
-
-/* The order determines the order of the list returned by sp_unit_get_list.
- * (It can also affect string lookups if there are any duplicates in the
- * current locale... hopefully none.) If you re-order this list, then you must
- * also re-order the SPUnitId enum values accordingly. Run `make check' (which
- * calls sp_unit_table_sane) to ensure that the two are in sync.
- */
-SPUnit const sp_units[] = {
- {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, SP_NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""},
- {SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")},
- {SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")},
- {SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")},
- /* You can add new elements from this point forward */
- {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, SP_NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")},
- {SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")},
- {SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")},
- {SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit
- {SP_UNIT_IN, SP_UNIT_ABSOLUTE, PX_PER_IN, SP_IN, SVGLength::INCH, N_("Inch"), N_("in"), N_("Inches"), N_("in")},
- {SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")},
- /* Volatiles do not have default, so there are none here */
- // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
- {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")},
- // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
- {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")},
-};
-
-#define sp_num_units G_N_ELEMENTS(sp_units)
-
-SPUnit const *
-sp_unit_get_by_abbreviation(gchar const *abbreviation)
-{
- g_return_val_if_fail(abbreviation != NULL, NULL);
-
- for (unsigned i = 0 ; i < sp_num_units ; i++) {
- if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr)) return &sp_units[i];
- if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr_plural)) return &sp_units[i];
- }
-
- return NULL;
-}
-
-gchar const *
-sp_unit_get_abbreviation(SPUnit const *unit)
-{
- g_return_val_if_fail(unit != NULL, NULL);
-
- return unit->abbr;
-}
-
-gchar const *
-sp_unit_get_plural (SPUnit const *unit)
-{
- g_return_val_if_fail(unit != NULL, NULL);
-
- return unit->plural;
-}
-
-SPMetric sp_unit_get_metric(SPUnit const *unit)
-{
- g_return_val_if_fail(unit != NULL, SP_NONE);
-
- return unit->metric;
-}
-
-guint sp_unit_get_svg_unit(SPUnit const *unit)
-{
- g_return_val_if_fail(unit != NULL, SP_NONE);
-
- return unit->svg_unit;
-}
-
-GSList *
-sp_unit_get_list(guint bases)
-{
- g_return_val_if_fail((bases & ~SP_UNITS_ALL) == 0, NULL);
-
- GSList *units = NULL;
- for (unsigned i = sp_num_units ; i--; ) {
- if (bases & sp_units[i].base) {
- units = g_slist_prepend(units, (gpointer) &sp_units[i]);
- }
- }
-
- return units;
-}
-
-void
-sp_unit_free_list(GSList *units)
-{
- g_slist_free(units);
-}
-
-/* These are pure utility */
-/* Return TRUE if conversion is possible */
-gboolean
-sp_convert_distance(gdouble *distance, SPUnit const *from, SPUnit const *to)
-{
- g_return_val_if_fail(distance != NULL, FALSE);
- g_return_val_if_fail(from != NULL, FALSE);
- g_return_val_if_fail(to != NULL, FALSE);
-
- if (from == to) return TRUE;
- if ((from->base == SP_UNIT_DIMENSIONLESS) || (to->base == SP_UNIT_DIMENSIONLESS)) {
- *distance = *distance * from->unittobase / to->unittobase;
- return TRUE;
- }
- if ((from->base == SP_UNIT_VOLATILE) || (to->base == SP_UNIT_VOLATILE)) return FALSE;
-
- if ((from->base == to->base)
- || ((from->base == SP_UNIT_DEVICE) && (to->base == SP_UNIT_ABSOLUTE))
- || ((from->base == SP_UNIT_ABSOLUTE) && (to->base == SP_UNIT_DEVICE)))
- {
- *distance = *distance * from->unittobase / to->unittobase;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/** @param devicetransform for device units. */
-/* TODO: Remove the ctmscale parameter given that we no longer have SP_UNIT_USERSPACE. */
-gdouble
-sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to)
-{
- if (&from == &to) {
- return from_dist;
- }
- if (from.base == to.base) {
- gdouble ret = from_dist;
- bool const succ = sp_convert_distance(&ret, &from, &to);
- g_assert(succ);
- return ret;
- }
- if ((from.base == SP_UNIT_DIMENSIONLESS)
- || (to.base == SP_UNIT_DIMENSIONLESS))
- {
- return from_dist * from.unittobase / to.unittobase;
- }
- g_return_val_if_fail(((from.base != SP_UNIT_VOLATILE)
- && (to.base != SP_UNIT_VOLATILE)),
- from_dist);
-
- gdouble absolute;
- switch (from.base) {
- case SP_UNIT_ABSOLUTE:
- case SP_UNIT_DEVICE:
- absolute = from_dist * from.unittobase;
- break;
- default:
- g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, from.base);
- return from_dist;
- }
-
- gdouble ret;
- switch (to.base) {
- default:
- g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, to.base);
- /* FALL-THROUGH */
- case SP_UNIT_ABSOLUTE:
- case SP_UNIT_DEVICE:
- ret = absolute / to.unittobase;
- break;
- }
-
- return ret;
-}
-
-/* Some more convenience */
-
-gdouble
-sp_units_get_pixels(gdouble const units, SPUnit const &unit)
-{
- if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
- return units * unit.unittobase;
- } else {
- g_warning("Different unit bases: No exact unit conversion available");
- return units * unit.unittobase;
- }
-}
-
-gdouble
-sp_pixels_get_units(gdouble const pixels, SPUnit const &unit)
-{
- if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
- return pixels / unit.unittobase;
- } else {
- g_warning("Different unit bases: No exact unit conversion available");
- return pixels / unit.unittobase;
- }
-}
-
-bool
-sp_units_table_sane()
-{
- for (unsigned i = 0; i < G_N_ELEMENTS(sp_units); ++i) {
- if (unsigned(sp_units[i].unit_id) != i) {
- return false;
- }
- }
- return true;
-}
-
-/** Converts angle (in deg) to compass display */
-double
-angle_to_compass(double angle)
-{
- double ret = 90 - angle;
- if (ret < 0)
- ret = 360 + ret;
- return ret;
-}
-
-/** Converts angle (in deg) to compass display */
-double
-angle_from_compass(double angle)
-{
- double ret = 90 - angle;
- if (ret > 180)
- ret = ret - 180;
- return ret;
-}
-
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/units.h b/src/helper/units.h
deleted file mode 100644
index 93bd70615..000000000
--- a/src/helper/units.h
+++ /dev/null
@@ -1,146 +0,0 @@
-#ifndef __SP_UNIT_H__
-#define __SP_UNIT_H__
-
-/*
- * SPUnit
- *
- * Ported from libgnomeprint
- *
- * Authors:
- * Dirk Luetjens <dirk@luedi.oche.de>
- * Yves Arrouye <Yves.Arrouye@marin.fdn.fr>
- * Lauris Kaplinski <lauris@ximian.com>
- *
- * Copyright 1999-2001 Ximian, Inc. and authors
- *
- */
-
-#include <glib.h>
-#include "sp-metric.h"
-
-
-/*
- * Units and conversion methods used by libgnomeprint.
- *
- * You need those for certain config keys (like paper size), if you are
- * interested in using these (look at gnome-print-config.h for discussion,
- * why you may NOT be interested in paper size).
- *
- * Unit bases define set of mutually unrelated measuring systems (numbers,
- * paper, screen and dimesionless user coordinates). Still, you can convert
- * between those, specifying scaling factors explicitly.
- *
- * Paper (i.e. output) coordinates are taken as absolute real world units.
- * It has some justification, because screen unit (pixel) size changes,
- * if you change screen resolution, while you cannot change output on paper
- * as easily (unless you have thermally contracting paper, of course).
- *
- */
-
-struct SPUnit;
-struct SPDistance;
-
-/*
- * The base linear ("absolute") unit is 1/72th of an inch, i.e. the base unit of postscript.
- */
-
-/*
- * Unit bases
- */
-enum SPUnitBase {
- SP_UNIT_DIMENSIONLESS = (1 << 0), /* For percentages and like */
- SP_UNIT_ABSOLUTE = (1 << 1), /* Real world distances - i.e. mm, cm... */
- SP_UNIT_DEVICE = (1 << 2), /* Pixels in the SVG/CSS sense. */
- SP_UNIT_VOLATILE = (1 << 3) /* em and ex */
-};
-
-/*
- * Units: indexes into sp_units.
- */
-enum SPUnitId {
- SP_UNIT_SCALE, // 1.0 == 100%
- SP_UNIT_PT, // Postscript points: exactly 72 per inch
- SP_UNIT_PC, // Pica; there are 12 points per pica
- SP_UNIT_PX, // "Pixels" in the CSS sense; though Inkscape assumes a constant 90 per inch.
- SP_UNIT_PERCENT, /* Note: In Inkscape this often means "relative to current value" (for
- users to edit a value), rather than the SVG/CSS use of percentages. */
- SP_UNIT_MM, // millimetres
- SP_UNIT_CM, // centimetres
- SP_UNIT_M, // metres
- SP_UNIT_IN, // inches
- SP_UNIT_FT, // foot
- SP_UNIT_EM, // font-size of relevant font
- SP_UNIT_EX, // x-height of relevant font
- sp_max_unit_id = SP_UNIT_EX // For bounds-checking in sp_unit_get_by_id.
-};
-
-/*
- * Notice, that for correct menus etc. you have to use
- * ngettext method family yourself. For that reason we
- * do not provide translations in unit names.
- * I also do not know, whether to allow user-created units,
- * because this would certainly confuse textdomain.
- */
-
-struct SPUnit {
- SPUnitId unit_id; /* used as sanity check */
- SPUnitBase base;
- gdouble unittobase; /* how many base units in this unit */
- SPMetric metric; // the corresponding SPMetric from sp-metrics.h
- guint svg_unit; // the corresponding SVGLengthUnit
-
- /* When using, you must call "gettext" on them so they're translated */
- gchar const *name;
- gchar const *abbr;
- gchar const *plural;
- gchar const *abbr_plural;
-};
-
-const SPUnit *sp_unit_get_by_abbreviation (const gchar *abbreviation);
-/* When using, you must call "gettext" on them so they're translated */
-const gchar *sp_unit_get_abbreviation (const SPUnit *unit);
-gchar const *sp_unit_get_plural (SPUnit const *unit);
-
-SPMetric sp_unit_get_metric(SPUnit const *unit);
-guint sp_unit_get_svg_unit(SPUnit const *unit);
-
-extern SPUnit const sp_units[];
-
-inline SPUnit const &
-sp_unit_get_by_id(SPUnitId const id)
-{
- /* inline because the compiler should optimize away the g_return_val_if_fail test in the
- usual case that the argument value is known at compile-time, leaving just
- "return sp_units[constant]". */
- unsigned const ix = unsigned(id);
- g_return_val_if_fail(ix <= sp_max_unit_id, sp_units[SP_UNIT_PX]);
- return sp_units[ix];
-}
-
-#define SP_PS_UNIT (&sp_unit_get_by_id(SP_UNIT_PT))
-
-
-/** Used solely by units-test.cpp. */
-bool sp_units_table_sane();
-
-#define SP_UNITS_ALL (SP_UNIT_DIMENSIONLESS | SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE | SP_UNIT_VOLATILE)
-
-GSList *sp_unit_get_list (guint bases);
-void sp_unit_free_list (GSList *units);
-
-/* These are pure utility */
-/* Return TRUE if conversion is possible, FALSE if unit bases differ */
-gboolean sp_convert_distance (gdouble *distance, const SPUnit *from, const SPUnit *to);
-
-/* If either one is NULL, transconverting to/from that base fails */
-/* Generic conversion between volatile units would be useless anyways */
-gdouble sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to);
-
-/* Some more convenience */
-gdouble sp_units_get_pixels(gdouble const units, SPUnit const &unit);
-gdouble sp_pixels_get_units(gdouble const pixels, SPUnit const &unit);
-
-double angle_to_compass(double angle);
-double angle_from_compass(double angle);
-
-#endif
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index 491ca6050..53d53345a 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -32,7 +32,6 @@
#include <gtkmm/checkbutton.h>
-struct SPUnit;
class SPDocument;
namespace Gtk {