index 6ea9f30b5fb8e503855bda7e4a50b9b05830c646..b4272a3a47227afdff671ac880d22641c0d759fb 100644 (file)
* Lauris Kaplinski <lauris@kaplinski.com>
* 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.
+ * Copyright (C) 2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#endif
#include <glibmm/i18n.h>
+#include <gtkmm/box.h>
#include <gtk/gtkvbox.h>
+#include "desktop.h"
+#include "selection.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "display/sp-canvas.h"
/* Fill */
-static void fillnstroke_fillrule_changed(SPPaintSelector *psel, SPPaintSelector::FillRule mode, GtkWidget *spw);
-static void fillnstroke_selection_modified(Inkscape::Application *inkscape, Inkscape::Selection *selection, guint flags, GtkWidget *spw);
-static void fillnstroke_selection_changed(Inkscape::Application *inkscape, Inkscape::Selection *selection, GtkWidget *spw);
-static void fillnstroke_subselection_changed(Inkscape::Application *inkscape, SPDesktop *desktop, GtkWidget *spw);
+Gtk::Widget *sp_fill_style_widget_new(void)
+{
+ return Inkscape::Widgets::createStyleWidget( FILL );
+}
-static void fillnstroke_paint_mode_changed(SPPaintSelector *psel, SPPaintSelector::Mode mode, GtkWidget *spw);
-static void fillnstroke_paint_dragged(SPPaintSelector *psel, GtkWidget *spw);
-static void fillnstroke_paint_changed(SPPaintSelector *psel, GtkWidget *spw);
-static void fillnstroke_performUpdate(GtkWidget *spw);
+namespace Inkscape {
-GtkWidget *sp_fill_style_widget_new(void)
+class FillNStroke : public Gtk::VBox
{
- return Inkscape::Widgets::createStyleWidget( FILL );
+public:
+ FillNStroke( FillOrStroke kind );
+ ~FillNStroke();
+
+ void setFillrule( SPPaintSelector::FillRule mode );
+
+ void setDesktop(SPDesktop *desktop);
+
+private:
+ static void paintModeChangeCB(SPPaintSelector *psel, SPPaintSelector::Mode mode, FillNStroke *self);
+ static void paintChangedCB(SPPaintSelector *psel, FillNStroke *self);
+ static void paintDraggedCB(SPPaintSelector *psel, FillNStroke *self);
+ static gboolean dragDelayCB(gpointer data);
+
+ static void fillruleChangedCB( SPPaintSelector *psel, SPPaintSelector::FillRule mode, FillNStroke *self );
+
+ void selectionModifiedCB(guint flags);
+
+ void dragFromPaint();
+ void updateFromPaint();
+
+ void performUpdate();
+
+ FillOrStroke kind;
+ SPDesktop *desktop;
+ SPPaintSelector *psel;
+ guint32 lastDrag;
+ guint dragId;
+ bool update;
+ sigc::connection selectChangedConn;
+ sigc::connection subselChangedConn;
+ sigc::connection selectModifiedConn;
+};
+
+} // namespace Inkscape
+
+void sp_fill_style_widget_set_desktop(Gtk::Widget *widget, SPDesktop *desktop)
+{
+ Inkscape::FillNStroke *fs = dynamic_cast<Inkscape::FillNStroke*>(widget);
+ if (fs) {
+ fs->setDesktop(desktop);
+ }
}
+namespace Inkscape {
+
/**
* Create the fill or stroke style widget, and hook up all the signals.
*/
-GtkWidget *Inkscape::Widgets::createStyleWidget( FillOrStroke kind )
+Gtk::Widget *Inkscape::Widgets::createStyleWidget( FillOrStroke kind )
{
- Inkscape::Application *appInstance = INKSCAPE;
- GtkWidget *spw = gtk_vbox_new(FALSE, 0);
-
- // with or without fillrule selector
- GtkWidget *psel = sp_paint_selector_new(kind == FILL);
- gtk_widget_show(psel);
- gtk_container_add(GTK_CONTAINER(spw), psel);
- g_object_set_data(G_OBJECT(spw), "paint-selector", psel);
- g_object_set_data(G_OBJECT(spw), "kind", GINT_TO_POINTER(kind));
-
- g_signal_connect( G_OBJECT(appInstance), "modify_selection",
- G_CALLBACK(fillnstroke_selection_modified),
- spw );
+ FillNStroke *filler = new FillNStroke(kind);
- g_signal_connect( G_OBJECT(appInstance), "change_selection",
- G_CALLBACK(fillnstroke_selection_changed),
- spw );
-
- g_signal_connect( G_OBJECT(appInstance), "change_subselection",
- G_CALLBACK(fillnstroke_subselection_changed),
- spw );
+ return filler;
+}
+FillNStroke::FillNStroke( FillOrStroke kind ) :
+ Gtk::VBox(),
+ kind(kind),
+ desktop(0),
+ psel(0),
+ lastDrag(0),
+ dragId(0),
+ update(false),
+ selectChangedConn(),
+ subselChangedConn(),
+ selectModifiedConn()
+{
+ // Add and connect up the paint selector widget:
+ psel = sp_paint_selector_new(kind);
+ gtk_widget_show(GTK_WIDGET(psel));
+ gtk_container_add(GTK_CONTAINER(gobj()), GTK_WIDGET(psel));
g_signal_connect( G_OBJECT(psel), "mode_changed",
- G_CALLBACK(fillnstroke_paint_mode_changed),
- spw );
+ G_CALLBACK(paintModeChangeCB),
+ this );
g_signal_connect( G_OBJECT(psel), "dragged",
- G_CALLBACK(fillnstroke_paint_dragged),
- spw );
+ G_CALLBACK(paintDraggedCB),
+ this );
g_signal_connect( G_OBJECT(psel), "changed",
- G_CALLBACK(fillnstroke_paint_changed),
- spw );
-
+ G_CALLBACK(paintChangedCB),
+ this );
if (kind == FILL) {
g_signal_connect( G_OBJECT(psel), "fillrule_changed",
- G_CALLBACK(fillnstroke_fillrule_changed),
- spw );
+ G_CALLBACK(fillruleChangedCB),
+ this );
}
- fillnstroke_performUpdate(spw);
+ performUpdate();
+}
- return spw;
+FillNStroke::~FillNStroke()
+{
+ if (dragId) {
+ g_source_remove(dragId);
+ dragId = 0;
+ }
+ psel = 0;
+ selectModifiedConn.disconnect();
+ subselChangedConn.disconnect();
+ selectChangedConn.disconnect();
}
/**
* On signal modified, invokes an update of the fill or stroke style paint object.
*/
-void fillnstroke_selection_modified( Inkscape::Application * /*inkscape*/,
- Inkscape::Selection * /*selection*/,
- guint flags,
- GtkWidget *spw )
+void FillNStroke::selectionModifiedCB( guint flags )
{
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
- SP_OBJECT_PARENT_MODIFIED_FLAG |
- SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
+ SP_OBJECT_PARENT_MODIFIED_FLAG |
+ SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
#ifdef SP_FS_VERBOSE
- g_message("fillnstroke_selection_modified()");
+ g_message("selectionModifiedCB(%d) on %p", flags, this);
#endif
- fillnstroke_performUpdate(spw);
+ performUpdate();
}
}
-/**
- * On signal selection changed, invokes an update of the fill or stroke style paint object.
- */
-void fillnstroke_selection_changed( Inkscape::Application * /*inkscape*/,
- Inkscape::Selection */*selection*/,
- GtkWidget *spw )
+void FillNStroke::setDesktop(SPDesktop *desktop)
{
- fillnstroke_performUpdate(spw);
-}
+ if (this->desktop != desktop) {
+ if (dragId) {
+ g_source_remove(dragId);
+ dragId = 0;
+ }
+ if (this->desktop) {
+ selectModifiedConn.disconnect();
+ subselChangedConn.disconnect();
+ selectChangedConn.disconnect();
+ }
+ this->desktop = desktop;
+ if (desktop && desktop->selection) {
+ selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &FillNStroke::performUpdate)));
+ subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &FillNStroke::performUpdate)));
-/**
- * On signal change subselection, invoke an update of the fill or stroke style widget.
- */
-void fillnstroke_subselection_changed( Inkscape::Application * /*inkscape*/,
- SPDesktop * /*desktop*/,
- GtkWidget *spw )
-{
- fillnstroke_performUpdate(spw);
+ // Must check flags, so can't call performUpdate() directly.
+ selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &FillNStroke::selectionModifiedCB)));
+ }
+ performUpdate();
+ }
}
/**
*
* @param sel Selection to use, or NULL.
*/
-void fillnstroke_performUpdate( GtkWidget *spw )
+void FillNStroke::performUpdate()
{
- if ( g_object_get_data(G_OBJECT(spw), "update") ) {
+ if ( update || !desktop ) {
return;
}
- FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
-
- if (kind == FILL) {
- if ( g_object_get_data(G_OBJECT(spw), "local") ) {
- g_object_set_data(G_OBJECT(spw), "local", GINT_TO_POINTER(FALSE)); // local change; do nothing, but reset the flag
- return;
- }
+ if ( dragId ) {
+ // local change; do nothing, but reset the flag
+ g_source_remove(dragId);
+ dragId = 0;
+ return;
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
-
- SPPaintSelector *psel = SP_PAINT_SELECTOR(g_object_get_data(G_OBJECT(spw), "paint-selector"));
+ update = true;
// create temporary style
- SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT);
+ SPStyle *query = sp_style_new(desktop->doc());
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
- int result = sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, (kind == FILL) ? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
+ int result = sp_desktop_query_style(desktop, query, (kind == FILL) ? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
SPIScale24 &targOpacity = (kind == FILL) ? query->fill_opacity : query->stroke_opacity;
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently, e.g. display "averaged" somewhere in paint selector
case QUERY_STYLE_MULTIPLE_SAME:
{
- SPPaintSelector::Mode pselmode = SPPaintSelector::getModeForStyle(*query, kind == FILL);
+ SPPaintSelector::Mode pselmode = SPPaintSelector::getModeForStyle(*query, kind);
psel->setMode(pselmode);
if (kind == FILL) {
psel->setGradientLinear( vector );
SPLinearGradient *lg = SP_LINEARGRADIENT(server);
- psel->setGradientProperties( SP_GRADIENT_UNITS(lg),
- SP_GRADIENT_SPREAD(lg) );
+ psel->setGradientProperties( lg->getUnits(),
+ lg->getSpread() );
} else if (SP_IS_RADIALGRADIENT(server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
psel->setGradientRadial( vector );
SPRadialGradient *rg = SP_RADIALGRADIENT(server);
- psel->setGradientProperties( SP_GRADIENT_UNITS(rg),
- SP_GRADIENT_SPREAD(rg) );
+ psel->setGradientProperties( rg->getUnits(),
+ rg->getSpread() );
} else if (SP_IS_PATTERN(server)) {
SPPattern *pat = pattern_getroot(SP_PATTERN(server));
psel->updatePatternList( pat );
sp_style_unref(query);
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
+ update = false;
}
/**
* When the mode is changed, invoke a regular changed handler.
*/
-void fillnstroke_paint_mode_changed( SPPaintSelector *psel,
+void FillNStroke::paintModeChangeCB( SPPaintSelector * /*psel*/,
SPPaintSelector::Mode /*mode*/,
- GtkWidget *spw )
+ FillNStroke *self )
{
- if (g_object_get_data(G_OBJECT(spw), "update")) {
- return;
- }
-
#ifdef SP_FS_VERBOSE
- g_message("fillnstroke_paint_mode_changed(psel:%p, mode, spw:%p)", psel, spw);
+ g_message("paintModeChangeCB(psel, mode, self:%p)", self);
#endif
-
- /* TODO: Does this work?
- * Not really, here we have to get old color back from object
- * Instead of relying on paint widget having meaningful colors set
- */
- fillnstroke_paint_changed(psel, spw);
+ if (self && !self->update) {
+ self->updateFromPaint();
+ }
}
-void fillnstroke_fillrule_changed( SPPaintSelector * /*psel*/,
- SPPaintSelector::FillRule mode,
- GtkWidget *spw )
+void FillNStroke::fillruleChangedCB( SPPaintSelector * /*psel*/,
+ SPPaintSelector::FillRule mode,
+ FillNStroke *self )
{
- if (g_object_get_data(G_OBJECT(spw), "update")) {
- return;
+ if (self) {
+ self->setFillrule(mode);
}
+}
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
- SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property(css, "fill-rule", mode == SPPaintSelector::FILLRULE_EVENODD? "evenodd":"nonzero");
+void FillNStroke::setFillrule( SPPaintSelector::FillRule mode )
+{
+ if (!update && desktop) {
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property(css, "fill-rule", (mode == SPPaintSelector::FILLRULE_EVENODD) ? "evenodd":"nonzero");
- sp_desktop_set_style(desktop, css);
+ sp_desktop_set_style(desktop, css);
- sp_repr_css_attr_unref(css);
- css = 0;
+ sp_repr_css_attr_unref(css);
+ css = 0;
- sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_FILL_STROKE,
- _("Change fill rule"));
+ DocumentUndo::done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE,
+ _("Change fill rule"));
+ }
}
static gchar const *undo_F_label_1 = "fill:flatcolor:1";
static gchar const *undo_F_label = undo_F_label_1;
static gchar const *undo_S_label = undo_S_label_1;
+
+void FillNStroke::paintDraggedCB(SPPaintSelector * /*psel*/, FillNStroke *self)
+{
+#ifdef SP_FS_VERBOSE
+ g_message("paintDraggedCB(psel, spw:%p)", self);
+#endif
+ if (self && !self->update) {
+ self->dragFromPaint();
+ }
+}
+
+
+gboolean FillNStroke::dragDelayCB(gpointer data)
+{
+ gboolean keepGoing = TRUE;
+ if (data) {
+ FillNStroke *self = reinterpret_cast<FillNStroke*>(data);
+ if (!self->update) {
+ if (self->dragId) {
+ g_source_remove(self->dragId);
+ self->dragId = 0;
+
+ self->dragFromPaint();
+ self->performUpdate();
+ }
+ keepGoing = FALSE;
+ }
+ } else {
+ keepGoing = FALSE;
+ }
+ return keepGoing;
+}
+
/**
* This is called repeatedly while you are dragging a color slider, only for flat color
* modes. Previously it set the color in style but did not update the repr for efficiency, however
* this was flakey and didn't buy us almost anything. So now it does the same as _changed, except
* lumps all its changes for undo.
*/
-void fillnstroke_paint_dragged(SPPaintSelector *psel, GtkWidget *spw)
+void FillNStroke::dragFromPaint()
{
- if (!INKSCAPE) {
+ if (!desktop || update) {
return;
}
- if (g_object_get_data(G_OBJECT(spw), "update")) {
- return;
- }
+ guint32 when = gtk_get_current_event_time();
- FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
+ // Don't attempt too many updates per second.
+ // Assume a base 15.625ms resolution on the timer.
+ if (!dragId && lastDrag && when && ((when - lastDrag) < 32)) {
+ // local change, do not update from selection
+ dragId = g_timeout_add_full(G_PRIORITY_DEFAULT, 33, dragDelayCB, this, 0);
+ }
- if (kind == FILL) {
- if (g_object_get_data(G_OBJECT(spw), "local")) {
- // previous local flag not cleared yet;
- // this means dragged events come too fast, so we better skip this one to speed up display
- // (it's safe to do this in any case)
- return;
- }
+ if (dragId) {
+ // previous local flag not cleared yet;
+ // this means dragged events come too fast, so we better skip this one to speed up display
+ // (it's safe to do this in any case)
+ return;
}
+ lastDrag = when;
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
+ update = true;
switch (psel->mode) {
case SPPaintSelector::MODE_COLOR_RGB:
case SPPaintSelector::MODE_COLOR_CMYK:
{
- psel->setFlatColor( SP_ACTIVE_DESKTOP, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" );
- sp_document_maybe_done(sp_desktop_document(SP_ACTIVE_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) {
- g_object_set_data(G_OBJECT(spw), "local", GINT_TO_POINTER(TRUE)); // local change, do not update from selection
- }
+ // 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" );
+ 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;
}
__FILE__, __LINE__, psel->mode );
break;
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
+ update = false;
}
/**
3 you changed a gradient selector parameter (e.g. spread)
Must update repr.
*/
-void fillnstroke_paint_changed( SPPaintSelector *psel, GtkWidget *spw )
+void FillNStroke::paintChangedCB( SPPaintSelector * /*psel*/, FillNStroke *self )
{
#ifdef SP_FS_VERBOSE
- g_message("fillnstroke_paint_changed(psel:%p, spw:%p)", psel, spw);
+ g_message("paintChangedCB(psel, spw:%p)", self);
#endif
- if (g_object_get_data(G_OBJECT(spw), "update")) {
- return;
+ if (self && !self->update) {
+ self->updateFromPaint();
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
-
- FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
+}
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+void FillNStroke::updateFromPaint()
+{
if (!desktop) {
return;
}
+ update = true;
+
SPDocument *document = sp_desktop_document(desktop);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
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;
}
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
SPGradientType const gradient_type = ( psel->mode != SPPaintSelector::MODE_GRADIENT_RADIAL
? SP_GRADIENT_TYPE_LINEAR
: SP_GRADIENT_TYPE_RADIAL );
+ bool createSwatch = (psel->mode == SPPaintSelector::MODE_SWATCH);
SPCSSAttr *css = 0;
if (kind == FILL) {
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
- SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT);
+ SPStyle *query = sp_style_new(desktop->doc());
int result = objects_query_fillstroke(const_cast<GSList *>(items), query, kind == FILL);
- SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
- guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
+ SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
+ SPColor common;
if (!targPaint.isColor()) {
- common_rgb = sp_desktop_get_color(desktop, kind == FILL);
+ common = sp_desktop_get_color(desktop, kind == FILL);
} else {
- common_rgb = targPaint.value.color.toRGBA32( 0xff );
+ common = targPaint.value.color;
+ }
+ vector = sp_document_default_gradient_vector( document, common, createSwatch );
+ if ( vector && createSwatch ) {
+ vector->setSwatch();
}
- vector = sp_document_default_gradient_vector(document, common_rgb);
}
sp_style_unref(query);
for (GSList const *i = items; i != NULL; i = i->next) {
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style");
+ sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style");
}
if (!vector) {
+ SPGradient *gr = sp_gradient_vector_for_object( document, desktop, reinterpret_cast<SPObject*>(i->data), kind == FILL, createSwatch );
+ if ( gr && createSwatch ) {
+ gr->setSwatch();
+ }
sp_item_set_gradient(SP_ITEM(i->data),
- sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), kind == FILL),
+ gr,
gradient_type, kind == FILL);
} else {
sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
for (GSList const *i = items; i != NULL; i = i->next) {
//FIXME: see above
if (kind == FILL) {
- sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), 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);
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;
*/
} else {
- Inkscape::XML::Node *patrepr = SP_OBJECT_REPR(pattern);
+ 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);
// 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 = SP_OBJECT_REPR(i->data);
+ Inkscape::XML::Node *selrepr = reinterpret_cast<SPObject*>(i->data)->getRepr();
if ( (kind == STROKE) && !selrepr) {
continue;
}
- SPObject *selobj = SP_OBJECT(i->data);
+ SPObject *selobj = reinterpret_cast<SPObject*>(i->data);
- SPStyle *style = SP_OBJECT_STYLE(selobj);
+ SPStyle *style = selobj->style;
if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) {
- SPObject *server = (kind == FILL) ?
- SP_OBJECT_STYLE_FILL_SERVER(selobj) :
- SP_OBJECT_STYLE_STROKE_SERVER(selobj);
+ SPPaintServer *server = (kind == FILL) ?
+ selobj->style->getFillPaintServer() :
+ selobj->style->getStrokePaintServer();
if (SP_IS_PATTERN(server) && pattern_getroot(SP_PATTERN(server)) == pattern)
// only if this object's pattern is not rooted in our selected pattern, apply
continue;
} // 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;
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;
break;
}
- g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
+ update = false;
}
+} // namespace Inkscape
/*
Local Variables:
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :