summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-12-15 16:19:28 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-12-15 16:19:28 +0000
commit70201e92aa1e700d49279871f2b84082750b8ed8 (patch)
tree1886fcdf8ad20d73b92bf4f4bfd3ab1406ba4c66 /src/widgets
parentFix mask luminance calculation, so the coeffs add up to 1 (diff)
parentWin32 post-GSoC fixups. (diff)
downloadinkscape-70201e92aa1e700d49279871f2b84082750b8ed8.tar.gz
inkscape-70201e92aa1e700d49279871f2b84082750b8ed8.zip
Merge from trunk (again)
(bzr r9508.1.72)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/CMakeLists.txt1
-rw-r--r--src/widgets/Makefile_insert2
-rw-r--r--src/widgets/desktop-widget.cpp36
-rw-r--r--src/widgets/desktop-widget.h2
-rw-r--r--src/widgets/ege-paint-def.cpp25
-rw-r--r--src/widgets/fill-style.cpp39
-rw-r--r--src/widgets/gradient-selector.cpp2
-rw-r--r--src/widgets/gradient-toolbar.cpp8
-rw-r--r--src/widgets/gradient-vector.cpp41
-rw-r--r--src/widgets/icon.cpp25
-rw-r--r--src/widgets/paint-selector.cpp7
-rw-r--r--src/widgets/select-toolbar.cpp6
-rw-r--r--src/widgets/sp-attribute-widget.cpp11
-rw-r--r--src/widgets/sp-color-icc-selector.cpp2
-rw-r--r--src/widgets/sp-color-wheel-selector.cpp88
-rw-r--r--src/widgets/sp-color-wheel-selector.h5
-rw-r--r--src/widgets/sp-color-wheel.cpp1161
-rw-r--r--src/widgets/sp-color-wheel.h80
-rw-r--r--src/widgets/sp-xmlview-content.cpp9
-rw-r--r--src/widgets/stroke-style.cpp44
-rw-r--r--src/widgets/swatch-selector.cpp4
-rw-r--r--src/widgets/toolbox.cpp162
22 files changed, 294 insertions, 1466 deletions
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index 9af325926..f3c0e70fa 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -21,7 +21,6 @@ sp-color-preview.cpp
sp-color-scales.cpp
sp-color-selector.cpp
sp-color-slider.cpp
-sp-color-wheel.cpp
sp-color-wheel-selector.cpp
spinbutton-events.cpp
sp-widget.cpp
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index 968bbf073..86046b918 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -48,8 +48,6 @@ ink_common_sources += \
widgets/sp-color-selector.h \
widgets/sp-color-slider.cpp \
widgets/sp-color-slider.h \
- widgets/sp-color-wheel.cpp \
- widgets/sp-color-wheel.h \
widgets/sp-color-wheel-selector.cpp \
widgets/sp-color-wheel-selector.h \
widgets/spinbutton-events.cpp \
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index d447abf2e..7a3e337de 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1,5 +1,3 @@
-#define __SP_DESKTOP_WIDGET_C__
-
/** \file
* Desktop widget implementation
*/
@@ -10,6 +8,8 @@
* Ralf Stephan <ralf@ark.in-berlin.de>
* John Bintz <jcoswell@coswellproductions.org>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 2006 John Bintz
@@ -709,8 +709,8 @@ sp_desktop_widget_realize (GtkWidget *widget)
NRRect d;
d.x0 = 0.0;
d.y0 = 0.0;
- d.x1 = sp_document_width (dtw->desktop->doc());
- d.y1 = sp_document_height (dtw->desktop->doc());
+ d.x1 = (dtw->desktop->doc())->getWidth ();
+ d.y1 = (dtw->desktop->doc())->getHeight ();
if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return;
@@ -731,7 +731,7 @@ void SPDesktopWidget::updateNamedview()
modified_connection = desktop->namedview->connectModified(sigc::mem_fun(*this, &SPDesktopWidget::namedviewModified));
namedviewModified(desktop->namedview, SP_OBJECT_MODIFIED_FLAG);
- updateTitle(SP_DOCUMENT_NAME (desktop->doc()));
+ updateTitle( desktop->doc()->getName() );
}
/**
@@ -858,7 +858,7 @@ SPDesktopWidget::shutdown()
GTK_BUTTONS_NONE,
_("<span weight=\"bold\" size=\"larger\">Save changes to document \"%s\" before closing?</span>\n\n"
"If you close without saving, your changes will be discarded."),
- SP_DOCUMENT_NAME(doc));
+ doc->getName());
// fix for bug 1767940:
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS);
@@ -880,12 +880,12 @@ SPDesktopWidget::shutdown()
{
Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
- sp_document_ref(doc);
+ doc->doRef();
sp_namedview_document_from_window(desktop);
if (sp_file_save_document(*window, doc)) {
- sp_document_unref(doc);
+ doc->doUnref();
} else { // save dialog cancelled or save failed
- sp_document_unref(doc);
+ doc->doUnref();
return TRUE;
}
@@ -900,7 +900,7 @@ SPDesktopWidget::shutdown()
}
/* Code to check data loss */
bool allow_data_loss = FALSE;
- while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
+ while (doc->getReprRoot()->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
GtkWidget *dialog;
/** \todo
@@ -914,7 +914,7 @@ SPDesktopWidget::shutdown()
GTK_BUTTONS_NONE,
_("<span weight=\"bold\" size=\"larger\">The file \"%s\" was saved with a format (%s) that may cause data loss!</span>\n\n"
"Do you want to save this file as Inkscape SVG?"),
- SP_DOCUMENT_NAME(doc)? SP_DOCUMENT_NAME(doc) : "Unnamed",
+ doc->getName() ? doc->getName() : "Unnamed",
SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE);
// fix for bug 1767940:
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS);
@@ -938,14 +938,14 @@ SPDesktopWidget::shutdown()
switch (response) {
case GTK_RESPONSE_YES:
{
- sp_document_ref(doc);
+ doc->doRef();
Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
if (sp_file_save_dialog(*window, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG)) {
- sp_document_unref(doc);
+ doc->doUnref();
} else { // save dialog cancelled or save failed
- sp_document_unref(doc);
+ doc->doUnref();
return TRUE;
}
@@ -1575,7 +1575,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/bitmapautoreload/value", true)) {
- GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image");
+ GSList const *imageList = (desktop->doc())->getResourceList("image");
for (GSList const *p = imageList; p; p = p->next) {
SPImage* image = SP_IMAGE(p->data);
sp_image_refresh_if_outdated( image );
@@ -1837,11 +1837,11 @@ 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(-sp_document_width(doc), -sp_document_height(doc)),
- Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) );
+ Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()),
+ Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) );
SPObject* root = doc->root;
SPItem* item = SP_ITEM(root);
- Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
+ Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop());
/* Canvas region we always show unconditionally */
Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index 33f2a6ae7..4edd434af 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -8,6 +8,7 @@
* Jon A. Cruz <jon@joncruz.org> (c) 2010
* John Bintz <jcoswell@coswellproductions.org> (c) 2006
* Ralf Stephan <ralf@ark.in-berlin.de> (c) 2005, distrib. under GPL2
+ * Abhishek Sharma
* ? -2004
*/
@@ -17,6 +18,7 @@
#include "display/display-forward.h"
#include "libnr/nr-point.h"
#include "forward.h"
+#include "sp-object.h"
#include "message.h"
#include "ui/view/view-widget.h"
#include "ui/view/edit-widget-interface.h"
diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp
index cab675b29..2fc6927df 100644
--- a/src/widgets/ege-paint-def.cpp
+++ b/src/widgets/ege-paint-def.cpp
@@ -50,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <glibmm/stringutils.h>
#if !defined(_)
#define _(s) gettext(s)
@@ -64,8 +65,6 @@ static std::string mimeTEXT("text/plain");
static std::string mimeX_COLOR("application/x-color");
static std::string mimeOSWB_COLOR("application/x-oswb-color");
-static std::string doubleToStr(double d);
-
PaintDef::PaintDef() :
descr(_("none")),
type(NONE),
@@ -183,11 +182,11 @@ void PaintDef::getMIMEData(std::string const & type, char*& dest, int& len, int&
{
tmp += std::string("<color name=\"") + descr + "\">";
tmp += "<sRGB r=\"";
- tmp += doubleToStr(getR()/255.0);
+ tmp += Glib::Ascii::dtostr(getR()/255.0);
tmp += "\" g=\"";
- tmp += doubleToStr(getG()/255.0);
+ tmp += Glib::Ascii::dtostr(getG()/255.0);
tmp += "\" b=\"";
- tmp += doubleToStr(getB()/255.0);
+ tmp += Glib::Ascii::dtostr(getB()/255.0);
tmp += "\"/>";
tmp += "</color>";
}
@@ -233,20 +232,17 @@ bool PaintDef::fromMIMEData(std::string const & type, char const * data, int len
this->type = ege::PaintDef::RGB;
size_t numPos = srgb.find("r=");
if (numPos != std::string::npos) {
- char* endPtr = 0;
- double dbl = strtod(srgb.c_str() + numPos + 3, &endPtr);
+ double dbl = Glib::Ascii::strtod(srgb.substr(numPos + 3));
this->r = static_cast<int>(255 * dbl);
}
numPos = srgb.find("g=");
if (numPos != std::string::npos) {
- char* endPtr = 0;
- double dbl = strtod(srgb.c_str() + numPos + 3, &endPtr);
+ double dbl = Glib::Ascii::strtod(srgb.substr(numPos + 3));
this->g = static_cast<int>(255 * dbl);
}
numPos = srgb.find("b=");
if (numPos != std::string::npos) {
- char* endPtr = 0;
- double dbl = strtod(srgb.c_str() + numPos + 3, &endPtr);
+ double dbl = Glib::Ascii::strtod(srgb.substr(numPos + 3));
this->b = static_cast<int>(255 * dbl);
}
@@ -307,13 +303,6 @@ void PaintDef::removeCallback( ColorCallback /*cb*/, void* /*data*/ )
{
}
-static std::string doubleToStr(double d)
-{
- // TODO ensure "." is used for decimal separator.
- std::stringstream out;
- out << d;
- return out.str();
-}
} // namespace ege
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp
index b70c8f47d..b4272a3a4 100644
--- a/src/widgets/fill-style.cpp
+++ b/src/widgets/fill-style.cpp
@@ -6,6 +6,7 @@
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
@@ -332,8 +333,8 @@ void FillNStroke::setFillrule( SPPaintSelector::FillRule mode )
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE,
- _("Change fill rule"));
+ DocumentUndo::done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE,
+ _("Change fill rule"));
}
}
@@ -417,8 +418,8 @@ void FillNStroke::dragFromPaint()
// local change, do not update from selection
dragId = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, dragDelayCB, this, 0);
psel->setFlatColor( desktop, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" );
- sp_document_maybe_done(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
+ DocumentUndo::maybeDone(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
break;
}
@@ -480,8 +481,8 @@ void FillNStroke::updateFromPaint()
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Remove fill") : _("Remove stroke"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Remove fill") : _("Remove stroke"));
break;
}
@@ -496,8 +497,8 @@ void FillNStroke::updateFromPaint()
psel->setFlatColor( desktop,
(kind == FILL) ? "fill" : "stroke",
(kind == FILL) ? "fill-opacity" : "stroke-opacity" );
- sp_document_maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
+ DocumentUndo::maybeDone(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Set fill color") : _("Set stroke color"));
if (kind == FILL) {
// resume interruptibility
@@ -556,7 +557,7 @@ void FillNStroke::updateFromPaint()
for (GSList const *i = items; i != NULL; i = i->next) {
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->repr, css, "style");
+ sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style");
}
if (!vector) {
@@ -578,7 +579,7 @@ void FillNStroke::updateFromPaint()
for (GSList const *i = items; i != NULL; i = i->next) {
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->repr, css, "style");
+ sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style");
}
SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
@@ -591,8 +592,8 @@ void FillNStroke::updateFromPaint()
css = 0;
}
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke"));
}
break;
@@ -608,7 +609,7 @@ void FillNStroke::updateFromPaint()
*/
} else {
- Inkscape::XML::Node *patrepr = pattern->repr;
+ Inkscape::XML::Node *patrepr = pattern->getRepr();
SPCSSAttr *css = sp_repr_css_attr_new();
gchar *urltext = g_strdup_printf("url(#%s)", patrepr->attribute("id"));
sp_repr_css_set_property(css, (kind == FILL) ? "fill" : "stroke", urltext);
@@ -622,7 +623,7 @@ void FillNStroke::updateFromPaint()
// objects who already have the same root pattern but through a different href
// chain. FIXME: move this to a sp_item_set_pattern
for (GSList const *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *selrepr = reinterpret_cast<SPObject*>(i->data)->repr;
+ Inkscape::XML::Node *selrepr = reinterpret_cast<SPObject*>(i->data)->getRepr();
if ( (kind == STROKE) && !selrepr) {
continue;
}
@@ -651,9 +652,9 @@ void FillNStroke::updateFromPaint()
} // end if
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Set pattern on fill") :
- _("Set pattern on stroke"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Set pattern on fill") :
+ _("Set pattern on stroke"));
} // end if
break;
@@ -678,8 +679,8 @@ void FillNStroke::updateFromPaint()
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- (kind == FILL) ? _("Unset fill") : _("Unset stroke"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ (kind == FILL) ? _("Unset fill") : _("Unset stroke"));
}
break;
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 5b663c493..49549de1c 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -340,7 +340,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
SPGradient *gr = sp_gradient_vector_selector_get_gradient(
SP_GRADIENT_VECTOR_SELECTOR (sel->vectors));
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *repr = NULL;
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index ce5f5fb8f..e7596ead4 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -4,6 +4,7 @@
* Authors:
* bulia byak <bulia@dr.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Abhishek Sharma
*
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 2005 authors
@@ -42,6 +43,7 @@
#include "toolbox.h"
+using Inkscape::DocumentUndo;
//########################
//## Gradient ##
@@ -150,8 +152,8 @@ gr_item_activate (GtkMenuItem *menuitem, gpointer data)
gr_apply_gradient (selection, ev? ev->get_drag() : NULL, gr);
- sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
- _("Assign gradient to object"));
+ DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT,
+ _("Assign gradient to object"));
}
gchar *
@@ -171,7 +173,7 @@ GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient *
GtkWidget *m = gtk_menu_new ();
GSList *gl = NULL;
- const GSList *gradients = sp_document_get_resource_list (document, "gradient");
+ const GSList *gradients = document->getResourceList("gradient");
for (const GSList *i = gradients; i != NULL; i = i->next) {
SPGradient *grad = SP_GRADIENT(i->data);
if ( grad->hasStops() && !grad->isSolid() ) {
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 06ba7b908..dbb934fb1 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -6,6 +6,7 @@
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
@@ -43,6 +44,8 @@
#include <sigc++/functors/ptr_fun.h>
#include <sigc++/adaptors/bind.h>
+using Inkscape::DocumentUndo;
+
enum {
VECTOR_SET,
LAST_SIGNAL
@@ -253,7 +256,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
/* Pick up all gradients with vectors */
GSList *gl = NULL;
if (gvs->gr) {
- const GSList *gradients = sp_document_get_resource_list(SP_OBJECT_DOCUMENT(gvs->gr), "gradient");
+ const GSList *gradients = SP_OBJECT_DOCUMENT(gvs->gr)->getResourceList("gradient");
for (const GSList *curr = gradients; curr; curr = curr->next) {
SPGradient* grad = SP_GRADIENT(curr->data);
if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) {
@@ -340,12 +343,12 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
/* Namely - menuitems etc. will be fucked up */
/* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
- //g_print("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID(gr));
+ //g_print("SPGradientVectorSelector: gradient %s activated\n", gr->getId());
//g_message("Setting to gradient %p swatch:%d solid:%d", gr, gr->isSwatch(), gr->isSolid());
norm = sp_gradient_ensure_vector_normalized(gr);
if (norm != gr) {
- //g_print("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID(norm));
+ //g_print("SPGradientVectorSelector: become %s after normalization\n", norm->getId());
/* But be careful that we do not have gradient saved anywhere else */
g_object_set_data(G_OBJECT(mi), "gradient", norm);
}
@@ -368,8 +371,8 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
/* We do extra undo push here */
/* If handler has already done it, it is just NOP */
// FIXME: looks like this is never a valid undo step, consider removing this
- sp_document_done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT,
- /* TODO: annotate */ "gradient-vector.cpp:350");
+ DocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT,
+ /* TODO: annotate */ "gradient-vector.cpp:350");
}
}
@@ -468,7 +471,7 @@ static void verify_grad(SPGradient *gradient)
int i = 0;
SPStop *stop = NULL;
/* count stops */
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
i++;
stop = SP_STOP(ochild);
@@ -508,7 +511,7 @@ static void verify_grad(SPGradient *gradient)
static void select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop)
{
int i = 0;
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
if (SP_OBJECT(ochild) == SP_OBJECT(new_stop)) {
gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), i);
@@ -538,7 +541,7 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_
gtk_widget_show(m);
GSList *sl = NULL;
if ( gradient->hasStops() ) {
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
sl = g_slist_append(sl, ochild);
}
@@ -659,8 +662,8 @@ static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb)
stop->offset = adjustment->value;
sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
- sp_document_maybe_done(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT,
- _("Change gradient stop offset"));
+ DocumentUndo::maybeDone(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT,
+ _("Change gradient stop offset"));
blocked = FALSE;
}
@@ -734,8 +737,8 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb)
GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(vb), "offslide"));
gtk_widget_set_sensitive(offslide, TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(offspin), TRUE);
- sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
- _("Add gradient stop"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+ _("Add gradient stop"));
}
static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb)
@@ -765,8 +768,8 @@ static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb)
SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
sp_gradient_vector_widget_load_gradient(vb, gradient);
update_stop_list(GTK_WIDGET(mnu), gradient, NULL);
- sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
- _("Delete gradient stop"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+ _("Delete gradient stop"));
}
}
@@ -1031,10 +1034,10 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien
// Once the user edits a gradient, it stops being auto-collectable
if (SP_OBJECT_REPR(gradient)->attribute("inkscape:collect")) {
SPDocument *document = SP_OBJECT_DOCUMENT(gradient);
- bool saved = sp_document_get_undo_sensitive(document);
- sp_document_set_undo_sensitive(document, false);
+ bool saved = DocumentUndo::getUndoSensitive(document);
+ DocumentUndo::setUndoSensitive(document, false);
SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL);
- sp_document_set_undo_sensitive(document, saved);
+ DocumentUndo::setUndoSensitive(document, saved);
}
} else { // no gradient, disable everything
gtk_widget_set_sensitive(widget, FALSE);
@@ -1183,8 +1186,8 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o
// g_snprintf(c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, static_cast<gdouble>(alpha));
//SP_OBJECT_REPR(stop)->setAttribute("style", c);
- sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
- _("Change gradient stop color"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+ _("Change gradient stop color"));
blocked = FALSE;
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index d039dd2de..1b6878c32 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -5,6 +5,7 @@
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2002 Lauris Kaplinski
*
@@ -220,7 +221,7 @@ void sp_icon_fetch_pixbuf( SPIcon *icon )
}
}
-static GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
+GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
GtkIconTheme *theme = gtk_icon_theme_get_default();
GdkPixbuf *pb = 0;
@@ -920,13 +921,13 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
SPObject *object = doc->getObjectById(name);
if (object && SP_IS_ITEM(object)) {
/* Find bbox in document */
- Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
+ Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine());
Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc);
if ( SP_OBJECT_PARENT(object) == NULL )
{
dbox = Geom::Rect(Geom::Point(0, 0),
- Geom::Point(sp_document_width(doc), sp_document_height(doc)));
+ Geom::Point(doc->getWidth(), doc->getHeight()));
}
/* This is in document coordinates, i.e. pixels */
@@ -1113,15 +1114,15 @@ static guchar *load_svg_pixels(gchar const *name, unsigned psize, unsigned &stri
/* Try to load from document. */
if (!info &&
Inkscape::IO::file_test( doc_filename, G_FILE_TEST_IS_REGULAR ) &&
- (doc = sp_document_new( doc_filename, FALSE )) ) {
+ (doc = SPDocument::createNewDoc( doc_filename, FALSE )) ) {
//g_message("Loaded icon file %s", doc_filename);
// prep the document
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
/* Create new arena */
NRArena *arena = NRArena::create();
/* Create ArenaItem and set transform */
- unsigned visionkey = sp_item_display_key_new(1);
+ unsigned visionkey = SPItem::display_key_new(1);
/* fixme: Memory manage root if needed (Lauris) */
// This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days
// because shapes are being rendered which are not being freed
@@ -1143,8 +1144,7 @@ static guchar *load_svg_pixels(gchar const *name, unsigned psize, unsigned &stri
==7014== by 0x5E9DDE: nr_arena_group_render(_cairo*, NRArenaItem*, NRRectL*, NRPixBlock*, unsigned int) (nr-arena-group.cpp:228)
==7014== by 0x5E72FB: nr_arena_item_invoke_render(_cairo*, NRArenaItem*, NRRectL const*, NRPixBlock*, unsigned int) (nr-arena-item.cpp:578)
*/
- root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT(doc)),
- arena, visionkey, SP_ITEM_SHOW_DISPLAY );
+ root = SP_ITEM(doc->getRoot())->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY );
// store into the cache
info = new svg_doc_cache_t;
@@ -1192,7 +1192,8 @@ void Inkscape::queueIconPrerender( Glib::ustring const &name, Inkscape::IconSize
{
GtkStockItem stock;
gboolean stockFound = gtk_stock_lookup( name.c_str(), &stock );
- if (!stockFound && !gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str()) ) {
+ gboolean themedFound = gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name.c_str());
+ if (!stockFound && !themedFound ) {
gint trySize = CLAMP( static_cast<gint>(lsize), 0, static_cast<gint>(G_N_ELEMENTS(iconSizeLookup) - 1) );
if ( !sizeMapDone ) {
injectCustomSize();
@@ -1359,7 +1360,9 @@ static void addPreRender( GtkIconSize lsize, gchar const *name )
}
gboolean icon_prerender_task(gpointer /*data*/) {
- if (!pendingRenders.empty()) {
+ if ( inkscapeIsCrashing() ) {
+ // stop
+ } else if (!pendingRenders.empty()) {
bool workDone = false;
do {
preRenderItem single = pendingRenders.front();
@@ -1369,7 +1372,7 @@ gboolean icon_prerender_task(gpointer /*data*/) {
} while (!pendingRenders.empty() && !workDone);
}
- if (!pendingRenders.empty()) {
+ if (!inkscapeIsCrashing() && !pendingRenders.empty()) {
return TRUE;
} else {
callbackHooked = false;
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index a7bed9e94..1d8acb40a 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -8,6 +8,7 @@
* bulia byak <buliabyak@users.sf.net>
* John Cliff <simarilius@yahoo.com>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) Lauris Kaplinski 2002
* Copyright (C) 2010 Authors
@@ -784,7 +785,7 @@ ink_pattern_list_get (SPDocument *source)
return NULL;
GSList *pl = NULL;
- GSList const *patterns = sp_document_get_resource_list(source, "pattern");
+ GSList const *patterns = source->getResourceList("pattern");
for (GSList *l = (GSList *) patterns; l != NULL; l = l->next) {
if (SP_PATTERN(l->data) == pattern_getroot(SP_PATTERN(l->data))) { // only if this is a root pattern
pl = g_slist_prepend(pl, l->data);
@@ -875,7 +876,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
if (patterns_doc == NULL) {
char *patterns_source = g_build_filename(INKSCAPE_PATTERNSDIR, "patterns.svg", NULL);
if (Inkscape::IO::file_test(patterns_source, G_FILE_TEST_IS_REGULAR)) {
- patterns_doc = sp_document_new(patterns_source, FALSE);
+ patterns_doc = SPDocument::createNewDoc(patterns_source, FALSE);
}
g_free(patterns_source);
}
@@ -894,7 +895,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
// suck in from patterns.svg
if (patterns_doc) {
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
sp_pattern_list_from_doc ( m, doc, patterns_doc, NULL );
}
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index ed54857f8..a0ec248ca 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -5,6 +5,7 @@
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2003-2005 authors
*
@@ -52,6 +53,7 @@
#include "ui/icon-names.h"
using Inkscape::UnitTracker;
+using Inkscape::DocumentUndo;
static void
sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel)
@@ -155,7 +157,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPDocument *document = sp_desktop_document(desktop);
- sp_document_ensure_up_to_date (document);
+ document->ensureUpToDate ();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getInt("/tools/bounding_box");
SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
@@ -243,7 +245,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
Geom::Matrix scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1);
sp_selection_apply_affine(selection, scaler);
- sp_document_maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT,
+ DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT,
_("Transform by toolbar"));
// resume interruptibility
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp
index 3473d8f31..0c31c2f74 100644
--- a/src/widgets/sp-attribute-widget.cpp
+++ b/src/widgets/sp-attribute-widget.cpp
@@ -3,6 +3,7 @@
*/
/* Authors:
* Lauris Kaplinski <lauris@ximian.com>
+ * Abhishek Sharma
*
* Copyright (C) 2001 Ximian, Inc.
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -21,6 +22,8 @@
#include "sp-attribute-widget.h"
+using Inkscape::DocumentUndo;
+
static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass);
static void sp_attribute_widget_init (SPAttributeWidget *widget);
static void sp_attribute_widget_destroy (GtkObject *object);
@@ -154,8 +157,8 @@ sp_attribute_widget_changed (GtkEditable *editable)
if (spaw->hasobj && spaw->src.object) {
SP_OBJECT_REPR (spaw->src.object)->setAttribute(spaw->attribute, text, false);
- sp_document_done (SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE,
- _("Set attribute"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE,
+ _("Set attribute"));
} else if (spaw->src.repr) {
@@ -761,8 +764,8 @@ sp_attribute_table_entry_changed ( GtkEditable *editable,
if (spat->hasobj && spat->src.object) {
SP_OBJECT_REPR (spat->src.object)->setAttribute(spat->attributes[i], text, false);
- sp_document_done (SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE,
- _("Set attribute"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE,
+ _("Set attribute"));
} else if (spat->src.repr) {
diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp
index 4b565d1a3..12467041c 100644
--- a/src/widgets/sp-color-icc-selector.cpp
+++ b/src/widgets/sp-color-icc-selector.cpp
@@ -581,7 +581,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name )
gtk_combo_box_set_active( combo, 0 );
int index = 1;
- const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" );
+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" );
while ( current ) {
SPObject* obj = SP_OBJECT(current->data);
Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp
index 5ba2c347b..2e36a024e 100644
--- a/src/widgets/sp-color-wheel-selector.cpp
+++ b/src/widgets/sp-color-wheel-selector.cpp
@@ -108,6 +108,47 @@ void sp_color_wheel_selector_init (SPColorWheelSelector *cs)
}
}
+static void resizeHSVWheel( GtkHSV *hsv, GtkAllocation *allocation )
+{
+ gint diam = std::min(allocation->width, allocation->height);
+
+ // drop a little for resizing
+ diam -= 4;
+
+ GtkStyle *style = gtk_widget_get_style( GTK_WIDGET(hsv) );
+ if ( style ) {
+ gint thick = std::max(style->xthickness, style->ythickness);
+ if (thick > 0) {
+ diam -= thick * 2;
+ }
+ }
+ gint padding = -1;
+ gtk_widget_style_get( GTK_WIDGET(hsv),
+ "focus-padding", &padding,
+ NULL );
+ if (padding > 0) {
+ diam -= padding * 2;
+ }
+
+ diam = std::max(20, diam);
+ gint ring = static_cast<gint>( static_cast<gdouble>(diam) / (4.0 * 1.618) );
+ gtk_hsv_set_metrics( hsv, diam, ring );
+}
+
+#if GTK_CHECK_VERSION(2,18,0)
+static void handleWheelStyleSet(GtkHSV *hsv, GtkStyle* /*previous*/, gpointer /*userData*/)
+{
+ GtkAllocation allocation = {0, 0, 0, 0};
+ gtk_widget_get_allocation( GTK_WIDGET(hsv), &allocation );
+ resizeHSVWheel( hsv, &allocation );
+}
+#endif // GTK_CHECK_VERSION(2,18,0)
+
+static void handleWheelAllocation(GtkHSV *hsv, GtkAllocation *allocation, gpointer /*userData*/)
+{
+ resizeHSVWheel( hsv, allocation );
+}
+
void ColorWheelSelector::init()
{
GtkWidget *t;
@@ -125,9 +166,10 @@ void ColorWheelSelector::init()
/* Create components */
row = 0;
- _wheel = sp_color_wheel_new ();
- gtk_widget_show (_wheel);
- gtk_table_attach (GTK_TABLE (t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), XPAD, YPAD);
+ _wheel = gtk_hsv_new();
+ gtk_hsv_set_metrics( GTK_HSV(_wheel), 48, 8 );
+ gtk_widget_show( _wheel );
+ gtk_table_attach( GTK_TABLE(t), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), XPAD, YPAD);
row++;
@@ -171,8 +213,17 @@ void ColorWheelSelector::init()
gtk_signal_connect (GTK_OBJECT (_slider), "changed",
GTK_SIGNAL_FUNC (_sliderChanged), _csel);
- gtk_signal_connect (GTK_OBJECT(_wheel), "changed",
- GTK_SIGNAL_FUNC (_wheelChanged), _csel);
+ gtk_signal_connect( GTK_OBJECT(_wheel), "changed",
+ GTK_SIGNAL_FUNC(_wheelChanged), _csel );
+
+
+ // GTK does not automatically scale the color wheel, so we have to add that in:
+ gtk_signal_connect( GTK_OBJECT(_wheel), "size-allocate",
+ GTK_SIGNAL_FUNC(handleWheelAllocation), _csel );
+#if GTK_CHECK_VERSION(2,18,0)
+ gtk_signal_connect( GTK_OBJECT(_wheel), "style-set",
+ GTK_SIGNAL_FUNC(handleWheelStyleSet), _csel );
+#endif // GTK_CHECK_VERSION(2,18,0)
}
static void
@@ -217,7 +268,13 @@ void ColorWheelSelector::_colorChanged()
g_message("ColorWheelSelector::_colorChanged( this=%p, %f, %f, %f, %f)", this, color.v.c[0], color.v.c[1], color.v.c[2], alpha );
#endif
_updating = TRUE;
- sp_color_wheel_set_color( SP_COLOR_WHEEL( _wheel ), &_color );
+ {
+ gdouble h = 0;
+ gdouble s = 0;
+ gdouble v = 0;
+ gtk_rgb_to_hsv( _color.v.c[0], _color.v.c[1], _color.v.c[2], &h, &s, &v );
+ gtk_hsv_set_color( GTK_HSV(_wheel), h, s, v );
+ }
guint32 start = _color.toRGBA32( 0x00 );
guint32 mid = _color.toRGBA32( 0x7f );
@@ -284,12 +341,21 @@ void ColorWheelSelector::_sliderChanged( SPColorSlider *slider, SPColorWheelSele
wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging );
}
-void ColorWheelSelector::_wheelChanged( SPColorWheel *wheel, SPColorWheelSelector *cs )
+void ColorWheelSelector::_wheelChanged( GtkHSV *hsv, SPColorWheelSelector *cs )
{
- ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base);
- SPColor color;
+ ColorWheelSelector* wheelSelector = static_cast<ColorWheelSelector*>(SP_COLOR_SELECTOR(cs)->base);
+
+ gdouble h = 0;
+ gdouble s = 0;
+ gdouble v = 0;
+ gtk_hsv_get_color( hsv, &h, &s, &v );
+
+ gdouble r = 0;
+ gdouble g = 0;
+ gdouble b = 0;
+ gtk_hsv_to_rgb(h, s, v, &r, &g, &b);
- sp_color_wheel_get_color( wheel, &color );
+ SPColor color(r, g, b);
guint32 start = color.toRGBA32( 0x00 );
guint32 mid = color.toRGBA32( 0x7f );
@@ -298,7 +364,7 @@ void ColorWheelSelector::_wheelChanged( SPColorWheel *wheel, SPColorWheelSelecto
sp_color_slider_set_colors (SP_COLOR_SLIDER(wheelSelector->_slider), start, mid, end);
preserve_icc(&color, cs);
- wheelSelector->_updateInternals( color, wheelSelector->_alpha, sp_color_wheel_is_adjusting( wheel ) );
+ wheelSelector->_updateInternals( color, wheelSelector->_alpha, gtk_hsv_is_adjusting( hsv ) );
}
diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h
index 1adbb65a7..34a5f4cd0 100644
--- a/src/widgets/sp-color-wheel-selector.h
+++ b/src/widgets/sp-color-wheel-selector.h
@@ -6,16 +6,15 @@
#include <gtk/gtkvbox.h>
#include "../color.h"
-#include "sp-color-wheel.h"
#include "sp-color-slider.h"
#include "sp-color-selector.h"
+typedef struct _GtkHSV GtkHSV;
struct SPColorWheelSelector;
struct SPColorWheelSelectorClass;
-
class ColorWheelSelector: public ColorSelector
{
public:
@@ -32,7 +31,7 @@ protected:
static void _sliderGrabbed( SPColorSlider *slider, SPColorWheelSelector *cs );
static void _sliderReleased( SPColorSlider *slider, SPColorWheelSelector *cs );
static void _sliderChanged( SPColorSlider *slider, SPColorWheelSelector *cs );
- static void _wheelChanged( SPColorWheel* wheel, SPColorWheelSelector *cs );
+ static void _wheelChanged( GtkHSV *hsv, SPColorWheelSelector *cs );
static void _fooChanged( GtkWidget foo, SPColorWheelSelector *cs );
diff --git a/src/widgets/sp-color-wheel.cpp b/src/widgets/sp-color-wheel.cpp
deleted file mode 100644
index ade226c0f..000000000
--- a/src/widgets/sp-color-wheel.cpp
+++ /dev/null
@@ -1,1161 +0,0 @@
-#define __SP_COLOR_WHEEL_C__
-
-/*
- * A wheel color widget
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Jon A. Cruz <jon@joncruz.org>
- * John Bintz <jcoswell@coswellproductions.org>
- *
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2003-2004 Authors
- *
- * This code is in public domain
- */
-
-#include <cstring>
-#include <string>
-
-#include <gtk/gtksignal.h>
-#include "sp-color-wheel.h"
-
-#include <2geom/transforms.h>
-
-#define WHEEL_SIZE 96
-
-enum {
- CHANGED,
- LAST_SIGNAL
-};
-
-#define noDUMP_CHANGE_INFO
-#define FOO_NAME(x) g_type_name( G_TYPE_FROM_INSTANCE(x) )
-
-static void sp_color_wheel_class_init (SPColorWheelClass *klass);
-static void sp_color_wheel_init (SPColorWheel *wheel);
-static void sp_color_wheel_destroy (GtkObject *object);
-
-static void sp_color_wheel_realize (GtkWidget *widget);
-static void sp_color_wheel_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void sp_color_wheel_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-
-static gint sp_color_wheel_expose (GtkWidget *widget, GdkEventExpose *event);
-static gint sp_color_wheel_button_press (GtkWidget *widget, GdkEventButton *event);
-static gint sp_color_wheel_button_release (GtkWidget *widget, GdkEventButton *event);
-static gint sp_color_wheel_motion_notify (GtkWidget *widget, GdkEventMotion *event);
-
-static void sp_color_wheel_set_hue(SPColorWheel *wheel, gdouble hue);
-static void sp_color_wheel_set_sv( SPColorWheel *wheel, gdouble sat, gdouble value );
-static void sp_color_wheel_recalc_triangle(SPColorWheel *wheel);
-
-static void sp_color_wheel_paint (SPColorWheel *wheel, GdkRectangle *area);
-static void sp_color_wheel_render_hue_wheel (SPColorWheel *wheel);
-static void sp_color_wheel_render_triangle (SPColorWheel *wheel);
-
-
-static gboolean sp_color_wheel_focus(GtkWidget *widget,
- GtkDirectionType direction);
-
-static void sp_color_wheel_process_in_triangle( SPColorWheel *wheel, gdouble x, gdouble y );
-
-static GtkWidgetClass *parent_class;
-static guint wheel_signals[LAST_SIGNAL] = {0};
-
-/*
-static double
-get_time (void)
-{
- GTimeVal tv;
- g_get_current_time (&tv);
- return tv.tv_sec + 1e-6 * tv.tv_usec;
-}
-*/
-
-GType sp_color_wheel_get_type(void)
-{
- static GType type = 0;
- if (!type) {
- GTypeInfo info = {
- sizeof(SPColorWheelClass),
- 0, // base_init
- 0, // base_finalize
- (GClassInitFunc)sp_color_wheel_class_init,
- 0, // class_finalize
- 0, // class_data
- sizeof(SPColorWheel),
- 0, // n_preallocs
- (GInstanceInitFunc)sp_color_wheel_init,
- 0 // value_table
- };
- type = g_type_register_static(GTK_TYPE_WIDGET, "SPColorWheel", &info, static_cast<GTypeFlags>(0));
- }
- return type;
-}
-
-static void
-sp_color_wheel_class_init (SPColorWheelClass *klass)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET);
-
- wheel_signals[CHANGED] = gtk_signal_new ("changed",
- (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE),
- GTK_CLASS_TYPE(object_class),
- GTK_SIGNAL_OFFSET (SPColorWheelClass, changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- object_class->destroy = sp_color_wheel_destroy;
-
- widget_class->realize = sp_color_wheel_realize;
- widget_class->size_request = sp_color_wheel_size_request;
- widget_class->size_allocate = sp_color_wheel_size_allocate;
-
- widget_class->focus = sp_color_wheel_focus;
-
- widget_class->expose_event = sp_color_wheel_expose;
- widget_class->button_press_event = sp_color_wheel_button_press;
- widget_class->button_release_event = sp_color_wheel_button_release;
- widget_class->motion_notify_event = sp_color_wheel_motion_notify;
-}
-
-static void
-sp_color_wheel_init (SPColorWheel *wheel)
-{
- /* We are widget with window */
- GTK_WIDGET_UNSET_FLAGS (wheel, GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (wheel, GTK_CAN_FOCUS );
-
- wheel->dragging = FALSE;
-
- wheel->_inTriangle = FALSE;
- wheel->_triDirty = TRUE;
- wheel->_triangle = NULL;
- for ( guint i = 0; i < G_N_ELEMENTS(wheel->_triPoints); i++ )
- {
- wheel->_triPoints[i].x = 0;
- wheel->_triPoints[i].y = 0;
- }
- wheel->_triImage = NULL;
- wheel->_triBs = 0;
-
- wheel->_image = NULL;
- wheel->_bs = 0;
- wheel->_hue = 0.0;
- wheel->_sat = 0.9;
- wheel->_value = 0.25;
- wheel->_inner = 0;
- wheel->_center = 0;
- wheel->_spotValue = 1.0;
-}
-
-static void
-sp_color_wheel_destroy (GtkObject *object)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (object);
-
- if ( wheel->_image )
- {
- g_free( wheel->_image );
- wheel->_image = NULL;
- wheel->_bs = 0;
- }
-
- if ( wheel->_triImage )
- {
- g_free( wheel->_triImage );
- wheel->_triImage = NULL;
- wheel->_triBs = 0;
- }
-
- if (((GtkObjectClass *) (parent_class))->destroy)
- (* ((GtkObjectClass *) (parent_class))->destroy) (object);
-}
-
-
-void sp_color_wheel_get_color( SPColorWheel *wheel, SPColor* color )
-{
- float rgb[3];
- gint i;
- g_return_if_fail (SP_IS_COLOR_WHEEL (wheel));
- g_return_if_fail (wheel != NULL);
- g_return_if_fail (color != NULL);
-
- sp_color_hsv_to_rgb_floatv (rgb, wheel->_hue, 1.0, 1.0);
- for ( i = 0; i < 3; i++ )
- {
- rgb[i] = (rgb[i] * wheel->_sat) + (wheel->_value * (1.0 - wheel->_sat));
- }
-
- color->set( rgb[0], rgb[1], rgb[2] );
-}
-
-void sp_color_wheel_set_color( SPColorWheel *wheel, const SPColor* color )
-{
-#ifdef DUMP_CHANGE_INFO
- g_message("sp_color_wheel_set_color( wheel=%p, %f, %f, %f)", wheel, color->v.c[0], color->v.c[1], color->v.c[2] );
-#endif
- g_return_if_fail (SP_IS_COLOR_WHEEL (wheel));
- g_return_if_fail (wheel != NULL);
- g_return_if_fail (color != NULL);
-
- float hue;
- float scratch[3];
- float rgb[3];
-
- sp_color_get_rgb_floatv (color, rgb);
- sp_color_rgb_to_hsv_floatv (scratch, rgb[0], rgb[1], rgb[2]);
- hue = scratch[0];
-
- sp_color_hsv_to_rgb_floatv (scratch, hue, 1.0, 1.0);
-
- gint lowInd = 0;
- gint hiInd = 0;
- for ( int i = 1; i < 3; i++ )
- {
- if ( scratch[i] < scratch[lowInd] )
- {
- lowInd = i;
- }
- if ( scratch[i] > scratch[hiInd] )
- {
- hiInd = i;
- }
- }
- // scratch[lowInd] should always be 0
- gdouble sat = (rgb[hiInd] - rgb[lowInd])/(scratch[hiInd]-scratch[lowInd]);
- gdouble val = sat < 1.0 ? (rgb[hiInd] - sat * scratch[hiInd])/(1.0-sat) : 0.0;
-
-
- sp_color_wheel_set_hue(wheel, hue);
- sp_color_wheel_set_sv(wheel, sat, val);
-}
-
-gboolean sp_color_wheel_is_adjusting( SPColorWheel *wheel )
-{
- g_return_val_if_fail( SP_IS_COLOR_WHEEL(wheel), FALSE );
- return wheel->dragging;
-}
-
-static void
-sp_color_wheel_realize (GtkWidget *widget)
-{
- SPColorWheel *wheel;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gdk_rgb_get_visual ();
- attributes.colormap = gdk_rgb_get_cmap ();
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_FOCUS_CHANGE_MASK );
- attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-}
-
-static void
-sp_color_wheel_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- requisition->width = WHEEL_SIZE + widget->style->xthickness * 2;
- requisition->height = WHEEL_SIZE + widget->style->ythickness * 2;
-}
-
-static void
-sp_color_wheel_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- widget->allocation = *allocation;
-
- wheel->_center = MIN(allocation->width, allocation->height)/2;
- wheel->_inner = (3 * wheel->_center)/4;
- if ( wheel->_image )
- {
- g_free( wheel->_image );
- wheel->_image = NULL;
- wheel->_bs = 0;
- }
-
- // Need to render the gradient before we do the triangle over
- sp_color_wheel_render_hue_wheel(wheel);
- sp_color_wheel_recalc_triangle(wheel);
- sp_color_wheel_render_triangle(wheel);
-
- if (GTK_WIDGET_REALIZED (widget)) {
- /* Resize GdkWindow */
- gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height);
- }
-}
-
-static gint
-sp_color_wheel_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- if (GTK_WIDGET_DRAWABLE (widget)) {
- gint width, height;
- width = widget->allocation.width;
- height = widget->allocation.height;
- sp_color_wheel_paint (wheel, &event->area);
- }
-
- return TRUE;
-}
-
-static gint
-sp_color_wheel_button_press (GtkWidget *widget, GdkEventButton *event)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- if (event->button == 1) {
- gint cx, cw;
- cx = widget->style->xthickness;
- cw = widget->allocation.width - 2 * cx;
- gboolean grabbed = FALSE;
-
- {
- double dx = event->x - wheel->_center;
- double dy = event->y - wheel->_center;
- gint hyp = static_cast<gint>(ABS(dx*dx) + ABS(dy*dy));
- if ( hyp <= (wheel->_center*wheel->_center) )
- {
- if ( hyp >= (wheel->_inner*wheel->_inner) )
- {
- gdouble rot = atan2( dy, -dx );
- sp_color_wheel_set_hue (wheel, (rot + M_PI) / (2.0 * M_PI));
-
- wheel->_inTriangle = FALSE;
- grabbed = TRUE;
- }
- else if ( wheel->_triangle && gdk_region_point_in( wheel->_triangle, (gint)event->x, (gint)event->y ) )
- {
- wheel->_inTriangle = TRUE;
- sp_color_wheel_process_in_triangle( wheel, event->x, event->y );
- grabbed = TRUE;
- }
- }
- }
-
- if ( grabbed )
- {
- gtk_widget_queue_draw( widget );
- gtk_widget_grab_focus( widget );
-
- wheel->dragging = TRUE;
-#ifdef DUMP_CHANGE_INFO
- {
- SPColor color;
- sp_color_wheel_get_color( wheel, &color );
- g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__,
- "CHANGED",
- color.toRGBA32( 0 ), FOO_NAME(wheel));
- }
-#endif
- gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]);
- gdk_pointer_grab (widget->window, FALSE,
- (GdkEventMask)(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK),
- NULL, NULL, event->time);
- }
- }
-
- return TRUE;
-}
-
-static gint
-sp_color_wheel_button_release (GtkWidget *widget, GdkEventButton *event)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- if (event->button == 1) {
- gdk_pointer_ungrab (event->time);
- wheel->dragging = FALSE;
-
-#ifdef DUMP_CHANGE_INFO
- {
- SPColor color;
- sp_color_wheel_get_color( wheel, &color );
- g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__,
- "CHANGED",
- color.toRGBA32( 0 ), FOO_NAME(wheel));
- }
-#endif
- gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]);
- }
-
- return TRUE;
-}
-
-static gint
-sp_color_wheel_motion_notify (GtkWidget *widget, GdkEventMotion *event)
-{
- SPColorWheel *wheel;
-
- wheel = SP_COLOR_WHEEL (widget);
-
- if (wheel->dragging) {
- double dx = event->x - wheel->_center;
- double dy = event->y - wheel->_center;
- if ( !wheel->_inTriangle )
- {
- gdouble rot = atan2( dy, -dx );
- sp_color_wheel_set_hue (wheel, (rot + M_PI) / (2.0 * M_PI));
- }
- else
- {
- sp_color_wheel_process_in_triangle( wheel, event->x, event->y );
- }
-
-#ifdef DUMP_CHANGE_INFO
- {
- SPColor color;
- sp_color_wheel_get_color( wheel, &color );
- g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__,
- "CHANGED",
- color.toRGBA32( 0 ), FOO_NAME(wheel));
- }
-#endif
- gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]);
- }
-
- return TRUE;
-}
-
-GtkWidget *
-sp_color_wheel_new ()
-{
- SPColorWheel *wheel;
-
- wheel = (SPColorWheel*)gtk_type_new (SP_TYPE_COLOR_WHEEL);
-
- return GTK_WIDGET (wheel);
-}
-
-static void sp_color_wheel_set_hue(SPColorWheel *wheel, gdouble hue)
-{
- g_return_if_fail (SP_IS_COLOR_WHEEL (wheel));
-
- if ( wheel->_hue != hue )
- {
- wheel->_hue = hue;
-
- sp_color_wheel_recalc_triangle(wheel);
-
- SPColor color;
- gfloat rgb[3];
- sp_color_wheel_get_color( wheel, &color );
- sp_color_get_rgb_floatv (&color, rgb);
-
- wheel->_spotValue = ( (0.299 * rgb[0]) + (0.587 * rgb[1]) + (0.114 * rgb[2]) );
-
- gtk_widget_queue_draw (GTK_WIDGET (wheel));
- }
-}
-
-
-static void sp_color_wheel_set_sv( SPColorWheel *wheel, gdouble sat, gdouble value )
-{
- static gdouble epsilon = 1e-6;
- gboolean changed = FALSE;
-
- if ( ABS( wheel->_sat - sat ) > epsilon )
- {
- wheel->_sat = sat;
- changed = TRUE;
- }
- if ( ABS( wheel->_value - value ) > epsilon )
- {
- wheel->_value = value;
- changed = TRUE;
- }
-
- if ( changed )
- {
- SPColor color;
- gfloat rgb[3];
- sp_color_wheel_get_color( wheel, &color );
- sp_color_get_rgb_floatv (&color, rgb);
-
- wheel->_spotValue = ( (0.299 * rgb[0]) + (0.587 * rgb[1]) + (0.114 * rgb[2]) );
-
-#ifdef DUMP_CHANGE_INFO
- {
- SPColor color;
- sp_color_wheel_get_color( wheel, &color );
- g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__,
- "CHANGED",
- color.toRGBA32( 0 ), FOO_NAME(wheel));
- }
-#endif
- gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]);
- }
- gtk_widget_queue_draw (GTK_WIDGET (wheel));
-}
-
-static void sp_color_wheel_recalc_triangle(SPColorWheel *wheel)
-{
- if ( wheel->_triangle )
- {
- gdk_region_destroy( wheel->_triangle );
- wheel->_triangle = NULL;
- }
- wheel->_triDirty = TRUE;
-
- if ( wheel->_center > 0 && wheel->_inner > 0 )
- {
- gdouble dx = cos( M_PI * 2 * wheel->_hue );
- gdouble dy = -sin( M_PI * 2 * wheel->_hue );
-
- wheel->_triPoints[0].x = wheel->_center + static_cast<gint>(dx * wheel->_inner);
- wheel->_triPoints[0].y = wheel->_center + static_cast<gint>(dy * wheel->_inner);
-
- dx = cos( M_PI * 2 * wheel->_hue + ((M_PI * 2)/ 3) );
- dy = -sin( M_PI * 2 * wheel->_hue + ((M_PI * 2) / 3) );
- wheel->_triPoints[1].x = wheel->_center + static_cast<gint>(dx * wheel->_inner);
- wheel->_triPoints[1].y = wheel->_center + static_cast<gint>(dy * wheel->_inner);
-
- dx = cos( M_PI * 2 * wheel->_hue - ((M_PI*2) / 3) );
- dy = -sin( M_PI * 2 * wheel->_hue - ((M_PI*2) / 3) );
- wheel->_triPoints[2].x = wheel->_center + static_cast<gint>(dx * wheel->_inner);
- wheel->_triPoints[2].y = wheel->_center + static_cast<gint>(dy * wheel->_inner);
-
-
- wheel->_triangle = gdk_region_polygon( wheel->_triPoints,
- 3,
- GDK_EVEN_ODD_RULE );
- }
-}
-
-#define VERT_SWAP( X, Y ) { \
- gfloat tmpF; \
- \
- tmpF = point##X.x; \
- point##X.x = point##Y.x; \
- point##Y.x = tmpF; \
- \
- tmpF = point##X.y; \
- point##X.y = point##Y.y; \
- point##Y.y = tmpF; \
- \
- tmpF = rgb##X[0]; \
- rgb##X[0] = rgb##Y[0]; \
- rgb##Y[0] = tmpF; \
- \
- tmpF = rgb##X[1]; \
- rgb##X[1] = rgb##Y[1]; \
- rgb##Y[1] = tmpF; \
- \
- tmpF = rgb##X[2]; \
- rgb##X[2] = rgb##Y[2]; \
- rgb##Y[2] = tmpF; \
-}
-
-#define VERT_COPY( dst, src ) { \
- point##dst.x = point##src.x; \
- \
- point##dst.y = point##src.y; \
- \
- rgb##dst[0] = rgb##src[0]; \
- rgb##dst[1] = rgb##src[1]; \
- rgb##dst[2] = rgb##src[2]; \
-}
-
-typedef struct {
- gfloat x;
- gfloat y;
-} PointF;
-
-/**
- * Render the provided color wheel information as a triangle.
- */
-static void sp_color_wheel_render_triangle (SPColorWheel *wheel)
-{
- if ( wheel->_image )
- {
- if ( wheel->_triBs < wheel->_bs )
- {
- g_free( wheel->_triImage );
- wheel->_triImage = NULL;
- }
-
- if (wheel->_triDirty || !wheel->_triImage)
- {
- if ( !wheel->_triImage )
- {
- wheel->_triBs = wheel->_bs;
- wheel->_triImage = g_new (guchar, wheel->_triBs * 3);
- //g_message( "just allocated %fKB for tri", ((wheel->_triBs * 3.0)/1024.0) );
- }
-
- memcpy( wheel->_triImage, wheel->_image, wheel->_bs * 3 );
-
- PointF pointA, pointB, pointC;
- pointA.x = wheel->_triPoints[0].x;
- pointA.y = wheel->_triPoints[0].y;
- pointB.x = wheel->_triPoints[1].x;
- pointB.y = wheel->_triPoints[1].y;
- pointC.x = wheel->_triPoints[2].x;
- pointC.y = wheel->_triPoints[2].y;
-
- gfloat rgbA[3];
- gfloat rgbB[3] = {0.0, 0.0, 0.0};
- gfloat rgbC[3] = {1.0, 1.0, 1.0};
-
- sp_color_hsv_to_rgb_floatv (rgbA, wheel->_hue, 1.0, 1.0);
-
-// Start of Gouraud fill ============================================================
- gint rowStride = wheel->_center * 2 * 3;
- guchar* dst = wheel->_triImage;
-
- if ( pointC.y < pointB.y )
- VERT_SWAP( C, B );
-
- if ( pointC.y < pointA.y )
- VERT_SWAP( C, A );
-
- if ( pointB.y < pointA.y )
- VERT_SWAP( B, A );
-
- if ( pointA.y == pointB.y && pointB.x < pointA.x )
- VERT_SWAP( A, B );
-
- gfloat dr, dg, db;
-
- gfloat dx1,dx2,dx3;
- gfloat dr1,dr2,dr3;
- gfloat dg1,dg2,dg3;
- gfloat db1,db2,db3;
-
-
- PointF pointS;
- PointF pointE;
- PointF pointP;
- gfloat rgbS[3];
- gfloat rgbE[3];
- gfloat rgbP[3];
-
-
- if (pointB.y-pointA.y > 0)
- {
- dx1=(pointB.x-pointA.x)/(pointB.y-pointA.y);
- dr1=(rgbB[0]-rgbA[0])/(pointB.y-pointA.y);
- dg1=(rgbB[1]-rgbA[1])/(pointB.y-pointA.y);
- db1=(rgbB[2]-rgbA[2])/(pointB.y-pointA.y);
- }
- else
- {
- dx1=dr1=dg1=db1=0;
- }
-
- if (pointC.y-pointA.y > 0)
- {
- dx2=(pointC.x-pointA.x)/(pointC.y-pointA.y);
- dr2=(rgbC[0]-rgbA[0])/(pointC.y-pointA.y);
- dg2=(rgbC[1]-rgbA[1])/(pointC.y-pointA.y);
- db2=(rgbC[2]-rgbA[2])/(pointC.y-pointA.y);
- }
- else
- {
- dx2=dr2=dg2=db2=0;
- }
-
- if (pointC.y-pointB.y > 0)
- {
- dx3=(pointC.x-pointB.x)/(pointC.y-pointB.y);
- dr3=(rgbC[0]-rgbB[0])/(pointC.y-pointB.y);
- dg3=(rgbC[1]-rgbB[1])/(pointC.y-pointB.y);
- db3=(rgbC[2]-rgbB[2])/(pointC.y-pointB.y);
- }
- else
- {
- dx3=dr3=dg3=db3=0;
- }
-
- VERT_COPY(S, A);
- VERT_COPY(E, A);
-
- int runs = 1; int fill_mode = 0;
-
- if ( dx1 == 0 )
- {
- fill_mode = 0;
- }
- else if ( dx1 > dx2 )
- {
- fill_mode = 1; runs = 2;
- }
- else if ( dx1 )
- {
- fill_mode = 2; runs = 2;
- }
-
- gfloat targetY = 0;
- int fill_direction_mode = 0;
-
- for (int current_run = 0; current_run < runs; current_run++)
- {
- targetY = pointC.y;
- switch (fill_mode)
- {
- case 0:
- VERT_COPY(E,B);
- fill_direction_mode = 0;
- break;
- case 1:
- if (current_run == 0) {
- targetY = pointB.y;
- fill_direction_mode = 1;
- } else {
- VERT_COPY(E,B);
- fill_direction_mode = 0;
- }
- break;
- case 2:
- if (current_run == 0) {
- targetY = pointB.y;
- fill_direction_mode = 2;
- } else {
- VERT_COPY(S,B);
- fill_direction_mode = 3;
- }
- break;
- }
-
- for(;pointS.y <= targetY; pointS.y++,pointE.y++)
- {
- if (pointE.x-pointS.x > 0)
- {
- dr=(rgbE[0]-rgbS[0])/(pointE.x-pointS.x);
- dg=(rgbE[1]-rgbS[1])/(pointE.x-pointS.x);
- db=(rgbE[2]-rgbS[2])/(pointE.x-pointS.x);
- }
- else
- {
- dr=dg=db=0;
- }
- VERT_COPY(P,S);
- dst = wheel->_triImage + (static_cast<gint>(pointP.y) * rowStride);
- dst += static_cast<gint>(pointP.x) * 3;
- for(;pointP.x < pointE.x;pointP.x++)
- {
- //putpixel(P);
- dst[0] = SP_COLOR_F_TO_U(rgbP[0]);
- dst[1] = SP_COLOR_F_TO_U(rgbP[1]);
- dst[2] = SP_COLOR_F_TO_U(rgbP[2]);
- dst += 3;
- rgbP[0]+=dr; rgbP[1]+=dg; rgbP[2]+=db;
- }
-
- switch (fill_direction_mode) {
- case 0:
- pointS.x+=dx2; rgbS[0]+=dr2; rgbS[1]+=dg2; rgbS[2]+=db2;
- pointE.x+=dx3; rgbE[0]+=dr3; rgbE[1]+=dg3; rgbE[2]+=db3;
- break;
- case 1:
- pointS.x+=dx2; rgbS[0]+=dr2; rgbS[1]+=dg2; rgbS[2]+=db2;
- pointE.x+=dx1; rgbE[0]+=dr1; rgbE[1]+=dg1; rgbE[2]+=db1;
- break;
- case 2:
- pointS.x+=dx1; rgbS[0]+=dr1; rgbS[1]+=dg1; rgbS[2]+=db1;
- pointE.x+=dx2; rgbE[0]+=dr2; rgbE[1]+=dg2; rgbE[2]+=db2;
- break;
- case 3:
- pointS.x+=dx3; rgbS[0]+=dr3; rgbS[1]+=dg3; rgbS[2]+=db3;
- pointE.x+=dx2; rgbE[0]+=dr2; rgbE[1]+=dg2; rgbE[2]+=db2;
- break;
- }
- }
- }
-
-
-// End of Gouraud fill ============================================================
-
- wheel->_triDirty = FALSE;
- //g_message( "Just updated triangle" );
- }
- }
-}
-
-static void
-sp_color_wheel_paint (SPColorWheel *wheel, GdkRectangle *area)
-{
- GtkWidget *widget;
- GdkRectangle warea, carea;
- GdkRectangle wpaint, cpaint;
-
- widget = GTK_WIDGET (wheel);
-
- /* Widget area */
- warea.x = 0;
- warea.y = 0;
- warea.width = widget->allocation.width;
- warea.height = widget->allocation.height;
-
- /* Color gradient area */
- carea.x = widget->style->xthickness;
- carea.y = widget->style->ythickness;
- carea.width = widget->allocation.width - 2 * carea.x;
- carea.height = widget->allocation.height - 2 * carea.y;
-
- /* Actual paintable area */
- if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return;
-
- //g_message( "Painted as state %d", widget->state );
-
- /* Paintable part of color gradient area */
- if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
- sp_color_wheel_render_hue_wheel (wheel);
- sp_color_wheel_render_triangle (wheel);
- }
-
-/*
- gtk_draw_box (widget->style,
- widget->window,
- (GtkStateType)widget->state,
- GTK_SHADOW_NONE,
- warea.x,
- warea.y,
- warea.width,
- warea.height);
-*/
-
- gtk_style_apply_default_background( widget->style,
- widget->window,
- TRUE,
- (GtkStateType)widget->state,
- NULL,
- 0,
- 0,
- warea.width,
- warea.height);
-
-
- /* Draw shadow */
-/*
- gtk_paint_shadow (widget->style, widget->window,
- (GtkStateType)widget->state, GTK_SHADOW_IN,
- NULL, widget, "colorwheel",
- 0, 0,
- warea.width, warea.height);
-*/
-
-
- /* Draw pixelstore */
- if (wheel->_triImage != NULL) {
- //gdouble start, end;
- //start = get_time();
- gdk_draw_rgb_image (widget->window, widget->style->black_gc,
- 0, 0,//cpaint.x, cpaint.y,
- //cpaint.width, cpaint.height,
- wheel->_center * 2, wheel->_center * 2,
- GDK_RGB_DITHER_MAX,
- wheel->_triImage, wheel->_center * 6);
-
- //end = get_time();
- //g_message( "blits took %f", (end-start) );
- }
-
- {
- gdouble dx = cos( M_PI * 2 * wheel->_hue );
- gdouble dy = -sin( M_PI * 2 * wheel->_hue );
-
- gfloat rgb[3];
- sp_color_hsv_to_rgb_floatv (rgb, wheel->_hue, 1.0, 1.0);
-
- GdkGC *line_gc = (( (0.299 * rgb[0]) + (0.587 * rgb[1]) + (0.114 * rgb[2]) ) < 0.5) ? widget->style->white_gc : widget->style->black_gc;
-
- gint inx = wheel->_center + static_cast<gint>(dx * wheel->_inner);
- gint iny = wheel->_center + static_cast<gint>(dy * wheel->_inner);
-
-
- gdk_draw_line (widget->window, line_gc,
- inx, iny,
- wheel->_center + static_cast<gint>(dx * wheel->_center), wheel->_center + static_cast<gint>(dy * wheel->_center) );
-
-
- GdkGCValues values;
-
- if ( GTK_WIDGET_HAS_FOCUS(wheel) )
- {
- line_gc = widget->style->black_gc;
-
- gdk_gc_get_values ( line_gc, &values );
-
- gdk_gc_set_line_attributes ( line_gc,
- 3, // Line width
- values.line_style, //GDK_LINE_SOLID,
- values.cap_style, //GDK_CAP_BUTT,
- values.join_style ); //GDK_JOIN_MITER );
-
- if ( wheel->_inTriangle )
- {
- gdk_draw_line (widget->window, line_gc,
- wheel->_triPoints[0].x, wheel->_triPoints[0].y,
- wheel->_triPoints[1].x, wheel->_triPoints[1].y );
-
- gdk_draw_line (widget->window, line_gc,
- wheel->_triPoints[1].x, wheel->_triPoints[1].y,
- wheel->_triPoints[2].x, wheel->_triPoints[2].y );
-
- gdk_draw_line (widget->window, line_gc,
- wheel->_triPoints[2].x, wheel->_triPoints[2].y,
- wheel->_triPoints[0].x, wheel->_triPoints[0].y );
- }
- else
- {
- gdk_draw_arc (widget->window, line_gc,
- FALSE, // filled
- 0, 0,
- wheel->_center * 2, wheel->_center * 2,
- 0, 64 * 360 );
-
- gint diff = wheel->_center - wheel->_inner;
-
- gdk_draw_arc (widget->window, line_gc,
- FALSE, // filled
- diff, diff,
- wheel->_inner * 2, wheel->_inner * 2,
- 0, 64 * 360 );
-
- }
- gdk_gc_set_line_attributes ( line_gc,
- values.line_width, // Line width
- values.line_style, //GDK_LINE_SOLID,
- values.cap_style, //GDK_CAP_BUTT,
- values.join_style ); //GDK_JOIN_MITER );
- }
-// ==========
-
-// line_gc = (p[3] < 0x80) ? widget->style->white_gc : widget->style->black_gc;
- line_gc = (wheel->_spotValue < 0.5) ? widget->style->white_gc : widget->style->black_gc;
-
- gdk_gc_get_values ( line_gc, &values );
-
- gdk_gc_set_line_attributes ( line_gc,
- 2, // Line width
- values.line_style, //GDK_LINE_SOLID,
- values.cap_style, //GDK_CAP_BUTT,
- values.join_style ); //GDK_JOIN_MITER );
-
- gint pointX = (gint)( (1.0 - wheel->_sat) * ((1.0-wheel->_value)*(gdouble)wheel->_triPoints[1].x + wheel->_value*(gdouble)wheel->_triPoints[2].x)
- + (wheel->_sat * wheel->_triPoints[0].x) );
-
- gint pointY = (gint)( (1.0 - wheel->_sat) * ((1.0-wheel->_value)*(gdouble)wheel->_triPoints[1].y + wheel->_value*(gdouble)wheel->_triPoints[2].y)
- + (wheel->_sat * wheel->_triPoints[0].y) );
-
-
- gdk_gc_set_line_attributes ( line_gc,
- values.line_width, // Line width
- values.line_style, //GDK_LINE_SOLID,
- values.cap_style, //GDK_CAP_BUTT,
- values.join_style ); //GDK_JOIN_MITER );
-
- gdk_draw_arc (widget->window, line_gc,
- FALSE, // filled
- pointX - 4, pointY - 4,
- 8, 8,
- 0, 64 * 360 );
-
- gdk_draw_arc (widget->window, line_gc,
- FALSE, // filled
- pointX - 3, pointY - 3,
- 6, 6,
- 0, 64 * 360 );
-
-
-
- }
-}
-
-/* Colors are << 16 */
-
-static void
-sp_color_wheel_render_hue_wheel (SPColorWheel *wheel)
-{
- guchar *dp;
- gint x, y;
- guint r, g, b;
- gint size = wheel->_center * 2;
- gboolean dirty = FALSE;
-
- if (wheel->_image && (wheel->_bs < (size * size) )) {
- g_free (wheel->_image);
- wheel->_image = NULL;
- wheel->_bs = 0;
-
- if ( wheel->_triImage )
- {
- g_free( wheel->_triImage );
- wheel->_triImage = NULL;
- wheel->_triBs = 0;
- wheel->_triDirty = TRUE;
- }
- }
-
- if (!wheel->_image) {
- wheel->_image = g_new (guchar, size * size * 3);
- wheel->_bs = size * size;
- dirty = TRUE;
- //g_message( "just allocated %fKB for hue", ((wheel->_bs * 3.0)/1024.0) );
- }
-
- if ( dirty )
- {
- GtkWidget* widget = GTK_WIDGET (wheel);
- dp = wheel->_image;
- r = widget->style->bg[widget->state].red >> 8;
- g = widget->style->bg[widget->state].green >> 8;
- b = widget->style->bg[widget->state].blue >> 8;
- //g_message( "Rendered as state %d", widget->state );
-
- gint offset = wheel->_center;
- gint inner = wheel->_inner * wheel->_inner;
- gint rad = wheel->_center * wheel->_center;
-
- for (x = 0; x < size; x++) {
- guchar *d = dp;
- for (y = 0; y < size; y++) {
- gint dx = x - offset;
- gint dy = y - offset;
- gint hyp = (ABS(dx*dx) + ABS(dy*dy));
- if ( hyp >= inner && hyp <= rad)
- {
- gdouble rot = atan2( static_cast<gdouble>(dy), static_cast<gdouble>(-dx) );
-
- gfloat rgb[3];
- sp_color_hsv_to_rgb_floatv (rgb, (rot + M_PI) / (2.0 * M_PI), 1.0, 1.0);
-
- d[0] = SP_COLOR_F_TO_U (rgb[0]);
- d[1] = SP_COLOR_F_TO_U (rgb[1]);
- d[2] = SP_COLOR_F_TO_U (rgb[2]);
- }
- else
- {
- /* Background value */
- d[0] = r;
- d[1] = g;
- d[2] = b;
- }
-
- d += 3 * size;
- }
- dp += 3;
- }
- }
-}
-
-static gboolean sp_color_wheel_focus(GtkWidget *widget,
- GtkDirectionType direction)
-{
- gboolean focusKept = FALSE;
- gboolean wasFocused = GTK_WIDGET_HAS_FOCUS(widget);
- SPColorWheel* wheel = SP_COLOR_WHEEL(widget);
- gboolean goingUp = FALSE;
-
- switch ( direction )
- {
- case GTK_DIR_TAB_FORWARD:
- case GTK_DIR_UP:
- case GTK_DIR_LEFT:
- goingUp = TRUE;
- break;
-
- case GTK_DIR_TAB_BACKWARD:
- case GTK_DIR_DOWN:
- case GTK_DIR_RIGHT:
- goingUp = FALSE;
- break;
- default:
- ;
- }
-
- if ( !wasFocused )
- {
- wheel->_inTriangle = !goingUp;
- gtk_widget_grab_focus (widget);
- focusKept = TRUE;
- }
- else if ( (!wheel->_inTriangle) == (!goingUp) )
- {
- focusKept = FALSE;
- }
- else
- {
- wheel->_inTriangle = !wheel->_inTriangle;
- gtk_widget_queue_draw( widget );
- focusKept = TRUE;
- }
-
- return focusKept;
-}
-
-static void sp_color_wheel_process_in_triangle( SPColorWheel *wheel, gdouble x, gdouble y )
-{
-// njh: dot(rot90(B-C), x) = saturation
-// njh: dot(B-C, x) = value
- Geom::Point delta( x - (((gdouble)(wheel->_triPoints[1].x + wheel->_triPoints[2].x)) / 2.0),
- y - (((gdouble)(wheel->_triPoints[1].y + wheel->_triPoints[2].y)) / 2.0) );
-
- gdouble rot = (M_PI * 2 * wheel->_hue );
-
- Geom::Point result = delta * Geom::Rotate(rot);
-
- gdouble sat = CLAMP( result[Geom::X] / (wheel->_inner * 1.5), 0.0, 1.0 );
-
- gdouble halfHeight = (wheel->_inner * sin(M_PI/3.0)) * (1.0 - sat);
- gdouble value = CLAMP( ((result[Geom::Y]+ halfHeight) / (2.0*halfHeight)), 0.0, 1.0 );
-
- wheel->_triDirty = TRUE;
-
- sp_color_wheel_set_sv( wheel, sat, value );
-}
-
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/sp-color-wheel.h b/src/widgets/sp-color-wheel.h
deleted file mode 100644
index d62c26782..000000000
--- a/src/widgets/sp-color-wheel.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef __SP_COLOR_WHEEL_H__
-#define __SP_COLOR_WHEEL_H__
-
-/*
- * A wheel color widget
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Jon A. Cruz <jon@joncruz.org>
- *
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2001-2004 Authors
- *
- * This code is in public domain
- */
-
-#include <gtk/gtkwidget.h>
-
-#include <glib.h>
-#include "color.h"
-
-
-#define SP_TYPE_COLOR_WHEEL (sp_color_wheel_get_type ())
-#define SP_COLOR_WHEEL(o) (GTK_CHECK_CAST ((o), SP_TYPE_COLOR_WHEEL, SPColorWheel))
-#define SP_COLOR_WHEEL_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_WHEEL, SPColorWheelClass))
-#define SP_IS_COLOR_WHEEL(o) (GTK_CHECK_TYPE ((o), SP_TYPE_COLOR_WHEEL))
-#define SP_IS_COLOR_WHEEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_WHEEL))
-
-struct SPColorWheel {
- GtkWidget widget;
-
- gboolean dragging : 1;
-
- gboolean _inTriangle;
- gboolean _triDirty;
- GdkRegion* _triangle;
- GdkPoint _triPoints[3];
- guchar *_triImage;
- gint _triBs;
-
- guchar *_image;
- gint _bs;
-
- gdouble _spotValue;
-
- gdouble _hue;
- gdouble _sat;
- gdouble _value;
-
- gint _inner;
- gint _center;
-};
-
-struct SPColorWheelClass {
- GtkWidgetClass parent_class;
-
- void (* changed) (SPColorWheel *wheel);
-};
-
-GType sp_color_wheel_get_type(void);
-
-GtkWidget *sp_color_wheel_new ();
-
-void sp_color_wheel_get_color( SPColorWheel *wheel, SPColor* color );
-void sp_color_wheel_set_color( SPColorWheel *wheel, const SPColor* color );
-
-gboolean sp_color_wheel_is_adjusting( SPColorWheel *wheel );
-
-#endif
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp
index 7150b07fd..75d68d25c 100644
--- a/src/widgets/sp-xmlview-content.cpp
+++ b/src/widgets/sp-xmlview-content.cpp
@@ -1,5 +1,3 @@
-#define __SP_XMLVIEW_CONTENT_C__
-
/*
* Specialization of GtkTextView for the XML tree view
*
@@ -7,6 +5,7 @@
* MenTaLguY <mental@rydia.net>
*
* Copyright (C) 2002 MenTaLguY
+ * Abhishek Sharma
*
* Released under the GNU GPL; see COPYING for details
*/
@@ -20,6 +19,8 @@
#include "document-private.h"
#include "inkscape.h"
+using Inkscape::DocumentUndo;
+
static void sp_xmlview_content_class_init (SPXMLViewContentClass * klass);
static void sp_xmlview_content_init (SPXMLViewContent * text);
static void sp_xmlview_content_destroy (GtkObject * object);
@@ -165,7 +166,7 @@ sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text)
text->repr->setContent(data);
g_free (data);
text->blocked = FALSE;
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR,
- _("Type text in a text node"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR,
+ _("Type text in a text node"));
}
}
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 43bc5fc07..7226b970e 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -7,6 +7,8 @@
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <maximilian.albert@gmail.com>
* Josh Andler <scislac@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2001-2005 authors
* Copyright (C) 2001 Ximian, Inc.
@@ -59,6 +61,8 @@
#include "fill-style.h" // to get sp_fill_style_widget_set_desktop
#include "fill-n-stroke-factory.h"
+using Inkscape::DocumentUndo;
+
/** Marker selection option menus */
static Gtk::OptionMenu * marker_start_menu = NULL;
static Gtk::OptionMenu * marker_mid_menu = NULL;
@@ -156,7 +160,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
return NULL;
// Create a copy repr of the marker with id="sample"
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox);
+ Inkscape::XML::Document *xml_doc = sandbox->getReprDoc();
Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc);
mrepr->setAttribute("id", "sample");
@@ -170,19 +174,19 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
// Uncomment this to get the sandbox documents saved (useful for debugging)
//FILE *fp = fopen (g_strconcat(menu_id, mname, ".svg", NULL), "w");
- //sp_repr_save_stream (sp_document_repr_doc (sandbox), fp);
+ //sp_repr_save_stream(sandbox->getReprDoc(), fp);
//fclose (fp);
// object to render; note that the id is the same as that of the menu we're building
SPObject *object = sandbox->getObjectById(menu_id);
- sp_document_root (sandbox)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- sp_document_ensure_up_to_date(sandbox);
+ sandbox->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ sandbox->ensureUpToDate();
if (object == NULL || !SP_IS_ITEM(object))
return NULL; // sandbox broken?
// Find object's bbox in document
- Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
+ Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine());
Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc);
if (!dbox) {
@@ -193,7 +197,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
double sf = 0.8;
gchar *cache_name = g_strconcat(menu_id, mname, NULL);
- Glib::ustring key = svg_preview_cache.cache_key(source->uri, cache_name, psize);
+ Glib::ustring key = svg_preview_cache.cache_key(source->getURI(), cache_name, psize);
g_free (cache_name);
// TODO: is this correct?
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
@@ -221,9 +225,7 @@ ink_marker_list_get (SPDocument *source)
GSList *ml = NULL;
SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source);
- for ( SPObject *child = sp_object_first_child(SP_OBJECT(defs));
- child != NULL;
- child = SP_OBJECT_NEXT (child) )
+ for ( SPObject *child = SP_OBJECT(defs)->firstChild(); child; child = child->getNext() )
{
if (SP_IS_MARKER(child)) {
ml = g_slist_prepend (ml, child);
@@ -242,8 +244,8 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
{
// Do this here, outside of loop, to speed up preview generation:
NRArena const *arena = NRArena::create();
- unsigned const visionkey = sp_item_display_key_new(1);
- NRArenaItem *root = sp_item_invoke_show(SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
+ unsigned const visionkey = SPItem::display_key_new(1);
+ NRArenaItem *root = SP_ITEM(sandbox->getRoot())->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
for (; marker_list != NULL; marker_list = marker_list->next) {
Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data);
@@ -280,7 +282,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
m->append(*i);
}
- sp_item_invoke_hide(SP_ITEM(sp_document_root(sandbox)), visionkey);
+ SP_ITEM(sandbox->getRoot())->invoke_hide(visionkey);
nr_object_unref((NRObject *) arena);
}
@@ -342,7 +344,7 @@ gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:sodipodi=
"</svg>";
- return sp_document_new_from_mem (buffer, strlen(buffer), FALSE);
+ return SPDocument::createNewDocFromMem (buffer, strlen(buffer), FALSE);
}
static void
@@ -373,7 +375,7 @@ ink_marker_menu_create_menu(Gtk::Menu *m, gchar const *menu_id, SPDocument *doc,
if (markers_doc == NULL) {
char *markers_source = g_build_filename(INKSCAPE_MARKERSDIR, "markers.svg", NULL);
if (Inkscape::IO::file_test(markers_source, G_FILE_TEST_IS_REGULAR)) {
- markers_doc = sp_document_new(markers_source, FALSE);
+ markers_doc = SPDocument::createNewDoc(markers_source, FALSE);
}
g_free(markers_source);
}
@@ -391,7 +393,7 @@ ink_marker_menu_create_menu(Gtk::Menu *m, gchar const *menu_id, SPDocument *doc,
// suck in from markers.svg
if (markers_doc) {
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
sp_marker_list_from_doc(m, doc, markers_doc, NULL, sandbox, menu_id);
}
@@ -498,8 +500,8 @@ sp_marker_select(Gtk::OptionMenu *mnu, Gtk::Container *spw, SPMarkerLoc const wh
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- _("Set markers"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ _("Set markers"));
};
@@ -1200,8 +1202,8 @@ sp_stroke_style_scale_line(Gtk::Container *spw)
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
- _("Set stroke style"));
+ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE,
+ _("Set stroke style"));
spw->set_data("update", GINT_TO_POINTER(FALSE));
}
@@ -1297,8 +1299,8 @@ sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw)
sp_repr_css_attr_unref(css);
css = 0;
- sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE,
- _("Set stroke style"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE,
+ _("Set stroke style"));
}
}
diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp
index 3c209a45d..935282a3a 100644
--- a/src/widgets/swatch-selector.cpp
+++ b/src/widgets/swatch-selector.cpp
@@ -135,8 +135,8 @@ void SwatchSelector::_changedCb(SPColorSelector */*csel*/, void *data)
os << "stop-color:" << c << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";";
SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str());
- sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
- _("Change swatch color"));
+ DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+ _("Change swatch color"));
}
}
}
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 0c94f5d68..28b4c9fb2 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -13,6 +13,7 @@
* Jon A. Cruz <jon@joncruz.org>
* Maximilian Albert <maximilian.albert@gmail.com>
* Tavmjong Bah <tavmjong@free.fr>
+ * Abhishek Sharma
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
@@ -112,6 +113,7 @@
using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
+using Inkscape::DocumentUndo;
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
@@ -1271,7 +1273,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
sp_units_get_pixels(adj->value, *unit));
}
@@ -2053,8 +2055,8 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
return;
}
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
bool v = false;
SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE"));
@@ -2139,7 +2141,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
// The snapping preferences are stored in the document, and therefore toggling makes the document dirty
doc->setModifiedSinceSave();
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
}
void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
@@ -2498,7 +2500,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
// do not remember prefs if this call is initiated by an undo change, because undoing object
// creation sets bogus values to its attributes before it is deleted
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -2529,8 +2531,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change number of corners"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change number of corners"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2540,7 +2542,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
if (!IS_NAN(adj->value)) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/proportion", adj->value);
@@ -2576,8 +2578,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change spoke ratio"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change spoke ratio"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2588,7 +2590,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
bool flat = ege_select_one_action_get_active( act ) == 0;
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/shapes/star/isflatsided", flat);
}
@@ -2620,8 +2622,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- flat ? _("Make polygon") : _("Make star"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ flat ? _("Make polygon") : _("Make star"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2631,7 +2633,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value);
}
@@ -2657,8 +2659,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change rounding"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change rounding"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -2668,7 +2670,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value);
}
@@ -2694,8 +2696,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
}
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
- _("Star: Change randomization"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Star: Change randomization"));
}
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
@@ -3033,7 +3035,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
SPUnit const *unit = tracker->getActiveUnit();
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ 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(adj->value, *unit));
}
@@ -3062,8 +3064,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
sp_rtb_sensitivize( tbl );
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
- _("Change rectangle"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
+ _("Change rectangle"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -3430,7 +3432,7 @@ static void box3d_persp_tb_event_attr_changed(Inkscape::XML::Node *repr,
}
// set freeze so that it can be caught in box3d_angle_z_value_changed() (to avoid calling
- // sp_document_maybe_done() when the document is undo insensitive)
+ // SPDocumentUndo::maybeDone() when the document is undo insensitive)
g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
// TODO: Only update the appropriate part of the toolbar
@@ -3514,7 +3516,7 @@ static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, P
SP_OBJECT(persp)->updateRepr();
// TODO: use the correct axis here, too
- sp_document_maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
+ DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -3709,7 +3711,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value);
}
@@ -3740,8 +3742,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
g_free(namespaced_name);
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
- _("Change spiral"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
+ _("Change spiral"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -5303,7 +5305,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value);
}
@@ -5351,8 +5353,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
sp_arctb_sensitivize( tbl, adj->value, other->value );
if (modmade) {
- sp_document_maybe_done(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC,
- _("Arc: Change start/end"));
+ DocumentUndo::maybeDone(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC,
+ _("Arc: Change start/end"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -5373,7 +5375,7 @@ static void sp_arctb_end_value_changed(GtkAdjustment *adj, GObject *tbl)
static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0);
}
@@ -5415,8 +5417,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
}
if (modmade) {
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
- _("Arc: Change open/closed"));
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC,
+ _("Arc: Change open/closed"));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -5746,7 +5748,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type;
}
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt( "/tools/lpetool/mode", mode );
}
@@ -6083,7 +6085,7 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
bool eraserMode = ege_select_one_action_get_active( act ) != 0;
- if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
+ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool( "/tools/eraser/mode", eraserMode );
}
@@ -6383,8 +6385,8 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb
g_free (family);
// Save for undo
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change font family"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change font family"));
sp_repr_css_attr_unref (css);
// unfreeze
@@ -6430,8 +6432,8 @@ static void sp_text_fontsize_value_changed( Ink_ComboBoxEntry_Action *act, GObje
sp_desktop_set_style (desktop, css, true, true);
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE,
- _("Text: Change font size"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE,
+ _("Text: Change font size"));
// If no selected objects, set default.
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6576,8 +6578,8 @@ static void sp_text_style_changed( InkToggleAction* act, GObject *tbl )
// Do we need to update other CSS values?
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
sp_desktop_set_style (desktop, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change font style"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change font style"));
sp_repr_css_attr_unref (css);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -6653,8 +6655,8 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl )
sp_desktop_set_style (desktop, css, true, false);
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE,
- _("Text: Change superscript or subscript"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE,
+ _("Text: Change superscript or subscript"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -6797,8 +6799,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
sp_style_unref(query);
sp_desktop_set_style (desktop, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change alignment"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change alignment"));
sp_repr_css_attr_unref (css);
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
@@ -6836,8 +6838,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
}
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE,
- _("Text: Change line-height"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE,
+ _("Text: Change line-height"));
// If no selected objects, set default.
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6875,8 +6877,8 @@ static void sp_text_wordspacing_value_changed( GtkAdjustment *adj, GObject *tbl
sp_desktop_set_style (desktop, css, true, false);
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE,
- _("Text: Change word-spacing"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE,
+ _("Text: Change word-spacing"));
// If no selected objects, set default.
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6914,8 +6916,8 @@ static void sp_text_letterspacing_value_changed( GtkAdjustment *adj, GObject *tb
sp_desktop_set_style (desktop, css, true, false);
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE,
- _("Text: Change letter-spacing"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE,
+ _("Text: Change letter-spacing"));
// If no selected objects, set default.
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
@@ -6959,8 +6961,8 @@ static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl )
}
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE,
- _("Text: Change dx (kern)"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE,
+ _("Text: Change dx (kern)"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -6990,8 +6992,8 @@ static void sp_text_dy_value_changed( GtkAdjustment *adj, GObject *tbl )
}
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE,
- _("Text: Change dy"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE,
+ _("Text: Change dy"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -7021,8 +7023,8 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl )
}
// Save for undo
- sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE,
- _("Text: Change rotate"));
+ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE,
+ _("Text: Change rotate"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -7066,8 +7068,8 @@ static void sp_text_orientation_mode_changed( EgeSelectOneAction *act, GObject *
}
sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true);
- sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
- _("Text: Change orientation"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
+ _("Text: Change orientation"));
sp_repr_css_attr_unref (css);
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -7093,7 +7095,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
items != NULL;
items = items->next)
{
- const gchar* id = SP_OBJECT_ID((SPItem *) items->data);
+ const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
std::cout << " " << id << std::endl;
}
Glib::ustring selected_text = sp_text_get_selected_text((SP_ACTIVE_DESKTOP)->event_context);
@@ -7118,7 +7120,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
for (GSList const *items = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList();
items != NULL;
items = items->next) {
- // const gchar* id = SP_OBJECT_ID((SPItem *) items->data);
+ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId();
// std::cout << " " << id << std::endl;
if( SP_IS_FLOWTEXT(( SPItem *) items->data )) {
isFlow = true;
@@ -7876,7 +7878,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
@@ -7900,7 +7902,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
SPItem *item = (SPItem *) l->data;
if (cc_item_is_connector(item)) {
- sp_object_setAttribute(item, "inkscape:connector-type",
+ item->setAttribute( "inkscape:connector-type",
value, false);
item->avoidRef->handleSettingChange();
modmade = true;
@@ -7913,8 +7915,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
prefs->setBool("/tools/connector/orthogonal", is_orthog);
}
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline"));
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -7925,7 +7927,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
@@ -7948,7 +7950,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
SPItem *item = (SPItem *) l->data;
if (cc_item_is_connector(item)) {
- sp_object_setAttribute(item, "inkscape:connector-curvature",
+ item->setAttribute( "inkscape:connector-curvature",
value, false);
item->avoidRef->handleSettingChange();
modmade = true;
@@ -7961,8 +7963,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue);
}
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- _("Change connector curvature"));
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ _("Change connector curvature"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -7973,7 +7975,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
SPDocument *doc = sp_desktop_document(desktop);
- if (!sp_document_get_undo_sensitive(doc)) {
+ if (!DocumentUndo::getUndoSensitive(doc)) {
return;
}
@@ -8009,8 +8011,8 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
g_slist_free(items);
}
- sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
- _("Change connector spacing"));
+ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ _("Change connector spacing"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
@@ -8030,7 +8032,7 @@ static void sp_connector_graph_layout(void)
prefs->setInt("/options/clonecompensation/value", saved_compensation);
- sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
+ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network"));
}
static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ )
@@ -8060,21 +8062,17 @@ static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
{
GtkWidget *tbl = GTK_WIDGET(data);
- if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
- return;
- }
- if (strcmp(name, "inkscape:connector-spacing") == 0)
- {
- GtkAdjustment *adj = (GtkAdjustment*)
- gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
+ if ( !g_object_get_data(G_OBJECT(tbl), "freeze")
+ && (strcmp(name, "inkscape:connector-spacing") == 0) ) {
+ GtkAdjustment *adj = static_cast<GtkAdjustment*>(gtk_object_get_data(GTK_OBJECT(tbl), "spacing"));
gdouble spacing = defaultConnSpacing;
sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);
gtk_adjustment_set_value(adj, spacing);
gtk_adjustment_value_changed(adj);
- }
- spinbutton_defocus(GTK_OBJECT(tbl));
+ spinbutton_defocus(GTK_OBJECT(tbl));
+ }
}
static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)