From: Jon A. Cruz Date: Sat, 6 Mar 2010 08:29:16 +0000 (-0800) Subject: Block "special" solid gradients from gradient F&S dialog. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=438aa633b778c772e72fc75918155647ed50cde8;p=inkscape.git Block "special" solid gradients from gradient F&S dialog. --- diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 8ffacb9f5..0b3c13820 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -5,12 +5,14 @@ * Lauris Kaplinski * bulia byak * MenTaLguY + * Jon A. Cruz * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. * Copyright (C) 2004 Monash University * Copyright (C) 2004 David Turner * Copyright (C) 2006 MenTaLguY + * Copyright (C) 2010 Jon A. Cruz * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -46,16 +48,16 @@ enum { LAST_SIGNAL }; -static void sp_gradient_vector_selector_class_init (SPGradientVectorSelectorClass *klass); -static void sp_gradient_vector_selector_init (SPGradientVectorSelector *gvs); -static void sp_gradient_vector_selector_destroy (GtkObject *object); +static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass); +static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs); +static void sp_gradient_vector_selector_destroy(GtkObject *object); -static void sp_gvs_gradient_release (SPObject *obj, SPGradientVectorSelector *gvs); -static void sp_gvs_defs_release (SPObject *defs, SPGradientVectorSelector *gvs); -static void sp_gvs_defs_modified (SPObject *defs, guint flags, SPGradientVectorSelector *gvs); +static void sp_gvs_gradient_release(SPObject *obj, SPGradientVectorSelector *gvs); +static void sp_gvs_defs_release(SPObject *defs, SPGradientVectorSelector *gvs); +static void sp_gvs_defs_modified(SPObject *defs, guint flags, SPGradientVectorSelector *gvs); -static void sp_gvs_rebuild_gui_full (SPGradientVectorSelector *gvs); -static void sp_gvs_gradient_activate (GtkMenuItem *mi, SPGradientVectorSelector *gvs); +static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs); +static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *gvs); static GtkVBoxClass *parent_class; static guint signals[LAST_SIGNAL] = {0}; @@ -74,36 +76,35 @@ GType sp_gradient_vector_selector_get_type(void) sizeof(SPGradientVectorSelectorClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_gradient_vector_selector_class_init, + reinterpret_cast(sp_gradient_vector_selector_class_init), NULL, /* class_finalize */ NULL, /* class_data */ sizeof(SPGradientVectorSelector), 0, /* n_preallocs */ - (GInstanceInitFunc) sp_gradient_vector_selector_init, + reinterpret_cast(sp_gradient_vector_selector_init), 0, /* value_table */ }; type = g_type_register_static( GTK_TYPE_VBOX, "SPGradientVectorSelector", &info, - static_cast< GTypeFlags > (0) ); + static_cast< GTypeFlags >(0) ); } return type; } -static void -sp_gradient_vector_selector_class_init (SPGradientVectorSelectorClass *klass) +static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass) { GtkObjectClass *object_class; - object_class = GTK_OBJECT_CLASS (klass); + object_class = GTK_OBJECT_CLASS(klass); - parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); + parent_class = static_cast(gtk_type_class(GTK_TYPE_VBOX)); - signals[VECTOR_SET] = gtk_signal_new ("vector_set", + signals[VECTOR_SET] = gtk_signal_new( "vector_set", GTK_RUN_LAST, GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPGradientVectorSelectorClass, vector_set), + GTK_SIGNAL_OFFSET(SPGradientVectorSelectorClass, vector_set), gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); @@ -111,8 +112,7 @@ sp_gradient_vector_selector_class_init (SPGradientVectorSelectorClass *klass) object_class->destroy = sp_gradient_vector_selector_destroy; } -static void -sp_gradient_vector_selector_init (SPGradientVectorSelector *gvs) +static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs) { gvs->idlabel = TRUE; @@ -123,17 +123,14 @@ sp_gradient_vector_selector_init (SPGradientVectorSelector *gvs) new (&gvs->defs_release_connection) sigc::connection(); new (&gvs->defs_modified_connection) sigc::connection(); - gvs->menu = gtk_option_menu_new (); - gtk_widget_show (gvs->menu); - gtk_box_pack_start (GTK_BOX (gvs), gvs->menu, TRUE, TRUE, 0); + gvs->menu = gtk_option_menu_new(); + gtk_widget_show(gvs->menu); + gtk_box_pack_start(GTK_BOX(gvs), gvs->menu, TRUE, TRUE, 0); } -static void -sp_gradient_vector_selector_destroy (GtkObject *object) +static void sp_gradient_vector_selector_destroy(GtkObject *object) { - SPGradientVectorSelector *gvs; - - gvs = SP_GRADIENT_VECTOR_SELECTOR (object); + SPGradientVectorSelector *gvs = SP_GRADIENT_VECTOR_SELECTOR(object); if (gvs->gr) { gvs->gradient_release_connection.disconnect(); @@ -150,40 +147,39 @@ sp_gradient_vector_selector_destroy (GtkObject *object) gvs->defs_release_connection.~connection(); gvs->defs_modified_connection.~connection(); - if (((GtkObjectClass *) (parent_class))->destroy) - (* ((GtkObjectClass *) (parent_class))->destroy) (object); + if ((reinterpret_cast(parent_class))->destroy) { + (* (reinterpret_cast(parent_class))->destroy) (object); + } } -GtkWidget * -sp_gradient_vector_selector_new (SPDocument *doc, SPGradient *gr) +GtkWidget *sp_gradient_vector_selector_new(SPDocument *doc, SPGradient *gr) { GtkWidget *gvs; - g_return_val_if_fail (!gr || SP_IS_GRADIENT (gr), NULL); - g_return_val_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc), NULL); + g_return_val_if_fail(!gr || SP_IS_GRADIENT(gr), NULL); + g_return_val_if_fail(!gr || (SP_OBJECT_DOCUMENT(gr) == doc), NULL); - gvs = (GtkWidget*)gtk_type_new (SP_TYPE_GRADIENT_VECTOR_SELECTOR); + gvs = static_cast(gtk_type_new(SP_TYPE_GRADIENT_VECTOR_SELECTOR)); if (doc) { - sp_gradient_vector_selector_set_gradient (SP_GRADIENT_VECTOR_SELECTOR (gvs), doc, gr); + sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(gvs), doc, gr); } else { - sp_gvs_rebuild_gui_full (SP_GRADIENT_VECTOR_SELECTOR (gvs)); + sp_gvs_rebuild_gui_full(SP_GRADIENT_VECTOR_SELECTOR(gvs)); } return gvs; } -void -sp_gradient_vector_selector_set_gradient (SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr) +void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr) { static gboolean suppress = FALSE; - g_return_if_fail (gvs != NULL); - g_return_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs)); - g_return_if_fail (!gr || (doc != NULL)); - g_return_if_fail (!gr || SP_IS_GRADIENT (gr)); - g_return_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc)); - g_return_if_fail (!gr || SP_GRADIENT_HAS_STOPS (gr)); + g_return_if_fail(gvs != NULL); + g_return_if_fail(SP_IS_GRADIENT_VECTOR_SELECTOR(gvs)); + g_return_if_fail(!gr || (doc != NULL)); + g_return_if_fail(!gr || SP_IS_GRADIENT(gr)); + g_return_if_fail(!gr || (SP_OBJECT_DOCUMENT(gr) == doc)); + g_return_if_fail(!gr || SP_GRADIENT_HAS_STOPS(gr)); if (doc != gvs->doc) { /* Disconnect signals */ @@ -196,7 +192,8 @@ sp_gradient_vector_selector_set_gradient (SPGradientVectorSelector *gvs, SPDocum gvs->defs_modified_connection.disconnect(); gvs->doc = NULL; } - /* Connect signals */ + + // Connect signals if (doc) { gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs)); gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs)); @@ -206,145 +203,144 @@ sp_gradient_vector_selector_set_gradient (SPGradientVectorSelector *gvs, SPDocum } gvs->doc = doc; gvs->gr = gr; - sp_gvs_rebuild_gui_full (gvs); - if (!suppress) g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr); + sp_gvs_rebuild_gui_full(gvs); + if (!suppress) g_signal_emit(G_OBJECT(gvs), signals[VECTOR_SET], 0, gr); } else if (gr != gvs->gr) { - /* Harder case - keep document, rebuild menus and stuff */ - /* fixme: (Lauris) */ + // Harder case - keep document, rebuild menus and stuff + // fixme: (Lauris) suppress = TRUE; - sp_gradient_vector_selector_set_gradient (gvs, NULL, NULL); - sp_gradient_vector_selector_set_gradient (gvs, doc, gr); + sp_gradient_vector_selector_set_gradient(gvs, NULL, NULL); + sp_gradient_vector_selector_set_gradient(gvs, doc, gr); suppress = FALSE; - g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr); + g_signal_emit(G_OBJECT(gvs), signals[VECTOR_SET], 0, gr); } /* The case of setting NULL -> NULL is not very interesting */ } -SPDocument * -sp_gradient_vector_selector_get_document (SPGradientVectorSelector *gvs) +SPDocument *sp_gradient_vector_selector_get_document(SPGradientVectorSelector *gvs) { - g_return_val_if_fail (gvs != NULL, NULL); - g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL); + g_return_val_if_fail(gvs != NULL, NULL); + g_return_val_if_fail(SP_IS_GRADIENT_VECTOR_SELECTOR(gvs), NULL); return gvs->doc; } -SPGradient * -sp_gradient_vector_selector_get_gradient (SPGradientVectorSelector *gvs) +SPGradient *sp_gradient_vector_selector_get_gradient(SPGradientVectorSelector *gvs) { - g_return_val_if_fail (gvs != NULL, NULL); - g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL); + g_return_val_if_fail(gvs != NULL, NULL); + g_return_val_if_fail(SP_IS_GRADIENT_VECTOR_SELECTOR(gvs), NULL); return gvs->gr; } -static void -sp_gvs_rebuild_gui_full (SPGradientVectorSelector *gvs) +static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) { /* Clear old menu, if there is any */ - if (gtk_option_menu_get_menu (GTK_OPTION_MENU (gvs->menu))) { - gtk_option_menu_remove_menu (GTK_OPTION_MENU (gvs->menu)); + if (gtk_option_menu_get_menu(GTK_OPTION_MENU(gvs->menu))) { + gtk_option_menu_remove_menu(GTK_OPTION_MENU(gvs->menu)); } /* Create new menu widget */ - GtkWidget *m = gtk_menu_new (); - gtk_widget_show (m); + GtkWidget *m = gtk_menu_new(); + gtk_widget_show(m); /* 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"); - for (const GSList *l = gradients; l != NULL; l = l->next) { - if (SP_GRADIENT_HAS_STOPS (l->data)) { - gl = g_slist_prepend (gl, l->data); + const GSList *gradients = sp_document_get_resource_list(SP_OBJECT_DOCUMENT(gvs->gr), "gradient"); + for (const GSList *curr = gradients; curr; curr = curr->next) { + SPGradient* grad = SP_GRADIENT(curr->data); + if (SP_GRADIENT_HAS_STOPS(grad) && !grad->isSwatch()) { + gl = g_slist_prepend(gl, curr->data); } } } - gl = g_slist_reverse (gl); + gl = g_slist_reverse(gl); gint pos = 0; gint idx = 0; if (!gvs->doc) { GtkWidget *i; - i = gtk_menu_item_new_with_label (_("No document selected")); - gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); - gtk_widget_set_sensitive (gvs->menu, FALSE); + i = gtk_menu_item_new_with_label(_("No document selected")); + gtk_widget_show(i); + gtk_menu_append(GTK_MENU(m), i); + gtk_widget_set_sensitive(gvs->menu, FALSE); } else if (!gl) { GtkWidget *i; - i = gtk_menu_item_new_with_label (_("No gradients in document")); - gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); - gtk_widget_set_sensitive (gvs->menu, FALSE); + i = gtk_menu_item_new_with_label(_("No gradients in document")); + gtk_widget_show(i); + gtk_menu_append(GTK_MENU(m), i); + gtk_widget_set_sensitive(gvs->menu, FALSE); } else if (!gvs->gr) { GtkWidget *i; - i = gtk_menu_item_new_with_label (_("No gradient selected")); - gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); - gtk_widget_set_sensitive (gvs->menu, FALSE); + i = gtk_menu_item_new_with_label(_("No gradient selected")); + gtk_widget_show(i); + gtk_menu_append(GTK_MENU(m), i); + gtk_widget_set_sensitive(gvs->menu, FALSE); } else { while (gl) { SPGradient *gr; GtkWidget *i, *w; - gr = SP_GRADIENT (gl->data); - gl = g_slist_remove (gl, gr); + gr = SP_GRADIENT(gl->data); + gl = g_slist_remove(gl, gr); /* We have to know: */ /* Gradient destroy */ /* Gradient name change */ - i = gtk_menu_item_new (); - gtk_widget_show (i); - g_object_set_data (G_OBJECT (i), "gradient", gr); - g_signal_connect (G_OBJECT (i), "activate", G_CALLBACK (sp_gvs_gradient_activate), gvs); + i = gtk_menu_item_new(); + gtk_widget_show(i); + g_object_set_data(G_OBJECT(i), "gradient", gr); + g_signal_connect(G_OBJECT(i), "activate", G_CALLBACK(sp_gvs_gradient_activate), gvs); - w = sp_gradient_image_new (gr); - gtk_widget_show (w); + w = sp_gradient_image_new(gr); + gtk_widget_show(w); if (gvs->idlabel) { GtkWidget *hb, *l; - hb = gtk_hbox_new (FALSE, 4); - gtk_widget_show (hb); + hb = gtk_hbox_new(FALSE, 4); + gtk_widget_show(hb); l = gtk_label_new(gr->getId()); - gtk_widget_show (l); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hb), w, FALSE, FALSE, 0); + gtk_widget_show(l); + gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 0); w = hb; } - gtk_container_add (GTK_CONTAINER (i), w); + gtk_container_add(GTK_CONTAINER(i), w); - gtk_menu_append (GTK_MENU (m), i); + gtk_menu_append(GTK_MENU(m), i); - if (gr == gvs->gr) pos = idx; + if (gr == gvs->gr) { + pos = idx; + } idx += 1; } - gtk_widget_set_sensitive (gvs->menu, TRUE); + gtk_widget_set_sensitive(gvs->menu, TRUE); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (gvs->menu), m); + gtk_option_menu_set_menu(GTK_OPTION_MENU(gvs->menu), m); /* Set history */ - gtk_option_menu_set_history (GTK_OPTION_MENU (gvs->menu), pos); + gtk_option_menu_set_history(GTK_OPTION_MENU(gvs->menu), pos); } -static void -sp_gvs_gradient_activate (GtkMenuItem *mi, SPGradientVectorSelector *gvs) +static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *gvs) { SPGradient *gr, *norm; - gr = (SPGradient*)g_object_get_data (G_OBJECT (mi), "gradient"); + gr = (SPGradient*)g_object_get_data(G_OBJECT(mi), "gradient"); /* Hmmm... bad things may happen here, if actual gradient is something new */ /* 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", SP_OBJECT_ID(gr)); - norm = sp_gradient_ensure_vector_normalized (gr); + 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", SP_OBJECT_ID(norm)); /* But be careful that we do not have gradient saved anywhere else */ - g_object_set_data (G_OBJECT (mi), "gradient", norm); + g_object_set_data(G_OBJECT(mi), "gradient", norm); } /* fixme: Really we would want to use _set_vector */ @@ -359,19 +355,18 @@ sp_gvs_gradient_activate (GtkMenuItem *mi, SPGradientVectorSelector *gvs) gvs->gr = norm; } - g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, norm); + g_signal_emit(G_OBJECT(gvs), signals[VECTOR_SET], 0, norm); if (norm != gr) { /* 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, + sp_document_done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT, /* TODO: annotate */ "gradient-vector.cpp:350"); } } -static void -sp_gvs_gradient_release (SPObject */*obj*/, SPGradientVectorSelector *gvs) +static void sp_gvs_gradient_release(SPObject */*obj*/, SPGradientVectorSelector *gvs) { /* Disconnect gradient */ if (gvs->gr) { @@ -380,11 +375,10 @@ sp_gvs_gradient_release (SPObject */*obj*/, SPGradientVectorSelector *gvs) } /* Rebuild GUI */ - sp_gvs_rebuild_gui_full (gvs); + sp_gvs_rebuild_gui_full(gvs); } -static void -sp_gvs_defs_release (SPObject */*defs*/, SPGradientVectorSelector *gvs) +static void sp_gvs_defs_release(SPObject */*defs*/, SPGradientVectorSelector *gvs) { gvs->doc = NULL; @@ -398,15 +392,14 @@ sp_gvs_defs_release (SPObject */*defs*/, SPGradientVectorSelector *gvs) } /* Rebuild GUI */ - sp_gvs_rebuild_gui_full (gvs); + sp_gvs_rebuild_gui_full(gvs); } -static void -sp_gvs_defs_modified (SPObject */*defs*/, guint /*flags*/, SPGradientVectorSelector *gvs) +static void sp_gvs_defs_modified(SPObject */*defs*/, guint /*flags*/, SPGradientVectorSelector *gvs) { /* fixme: We probably have to check some flags here (Lauris) */ - sp_gvs_rebuild_gui_full (gvs); + sp_gvs_rebuild_gui_full(gvs); } /*################################################################## @@ -422,27 +415,27 @@ sp_gvs_defs_modified (SPObject */*defs*/, guint /*flags*/, SPGradientVectorSelec #define PAD 4 -static GtkWidget *sp_gradient_vector_widget_new (SPGradient *gradient, SPStop *stop); +static GtkWidget *sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *stop); -static void sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient); -static gint sp_gradient_vector_dialog_delete (GtkWidget *widget, GdkEvent *event, GtkWidget *dialog); -static void sp_gradient_vector_dialog_destroy (GtkObject *object, gpointer data); +static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient); +static gint sp_gradient_vector_dialog_delete(GtkWidget *widget, GdkEvent *event, GtkWidget *dialog); +static void sp_gradient_vector_dialog_destroy(GtkObject *object, gpointer data); -static void sp_gradient_vector_widget_destroy (GtkObject *object, gpointer data); -static void sp_gradient_vector_gradient_release (SPObject *obj, GtkWidget *widget); -static void sp_gradient_vector_gradient_modified (SPObject *obj, guint flags, GtkWidget *widget); -static void sp_gradient_vector_color_dragged (SPColorSelector *csel, GtkObject *object); -static void sp_gradient_vector_color_changed (SPColorSelector *csel, GtkObject *object); +static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer data); +static void sp_gradient_vector_gradient_release(SPObject *obj, GtkWidget *widget); +static void sp_gradient_vector_gradient_modified(SPObject *obj, guint flags, GtkWidget *widget); +static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *object); +static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *object); static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop); static gboolean blocked = FALSE; -static void grad_edit_dia_stop_added_or_removed (Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, gpointer data) +static void grad_edit_dia_stop_added_or_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, gpointer data) { GtkWidget *vb = GTK_WIDGET(data); - GtkWidget *mnu = (GtkWidget *)g_object_get_data (G_OBJECT(vb), "stopmenu"); - SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient"); - update_stop_list (mnu, gradient, NULL); + GtkWidget *mnu = (GtkWidget *)g_object_get_data(G_OBJECT(vb), "stopmenu"); + SPGradient *gradient = (SPGradient *)g_object_get_data(G_OBJECT(vb), "gradient"); + update_stop_list(mnu, gradient, NULL); } //FIXME!!! We must also listen to attr changes on all children (i.e. stops) too, @@ -457,14 +450,13 @@ static Inkscape::XML::NodeEventVector grad_edit_dia_repr_events = NULL /* order_changed */ }; -static void -verify_grad(SPGradient *gradient) +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) ) { - if (SP_IS_STOP (ochild)) { + if (SP_IS_STOP(ochild)) { i++; stop = SP_STOP(ochild); } @@ -475,7 +467,7 @@ verify_grad(SPGradient *gradient) if (i < 1) { gchar c[64]; - sp_svg_write_color (c, sizeof(c), 0x00000000); + sp_svg_write_color(c, sizeof(c), 0x00000000); Inkscape::CSSOStringStream os; os << "stop-color:" << c << ";stop-opacity:" << 1.0 << ";"; @@ -485,32 +477,31 @@ verify_grad(SPGradient *gradient) child = xml_doc->createElement("svg:stop"); sp_repr_set_css_double(child, "offset", 0.0); child->setAttribute("style", os.str().c_str()); - SP_OBJECT_REPR (gradient)->addChild(child, NULL); + SP_OBJECT_REPR(gradient)->addChild(child, NULL); Inkscape::GC::release(child); child = xml_doc->createElement("svg:stop"); sp_repr_set_css_double(child, "offset", 1.0); child->setAttribute("style", os.str().c_str()); - SP_OBJECT_REPR (gradient)->addChild(child, NULL); + SP_OBJECT_REPR(gradient)->addChild(child, NULL); Inkscape::GC::release(child); } if (i < 2) { sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", 0.0); Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document()); sp_repr_set_css_double(child, "offset", 1.0); - SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR (stop)); + SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR(stop)); Inkscape::GC::release(child); } } -static void -select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop) +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) ) { - if (SP_IS_STOP (ochild)) { - if (SP_OBJECT (ochild) == SP_OBJECT(new_stop)) { - gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), i); + if (SP_IS_STOP(ochild)) { + if (SP_OBJECT(ochild) == SP_OBJECT(new_stop)) { + gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), i); break; } i++; @@ -518,99 +509,100 @@ select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop) } } -static void -update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop) +static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop) { - if (!SP_IS_GRADIENT (gradient)) + if (!SP_IS_GRADIENT(gradient)) { return; + } blocked = TRUE; /* Clear old menu, if there is any */ - if (gtk_option_menu_get_menu (GTK_OPTION_MENU (mnu))) { - gtk_option_menu_remove_menu (GTK_OPTION_MENU (mnu)); + if (gtk_option_menu_get_menu(GTK_OPTION_MENU(mnu))) { + gtk_option_menu_remove_menu(GTK_OPTION_MENU(mnu)); } /* Create new menu widget */ - GtkWidget *m = gtk_menu_new (); - gtk_widget_show (m); + GtkWidget *m = gtk_menu_new(); + gtk_widget_show(m); GSList *sl = NULL; if (gradient->has_stops) { - for ( SPObject *ochild = sp_object_first_child (SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { - if (SP_IS_STOP (ochild)) { - sl = g_slist_append (sl, ochild); + for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { + if (SP_IS_STOP(ochild)) { + sl = g_slist_append(sl, ochild); } } } if (!sl) { - GtkWidget *i = gtk_menu_item_new_with_label (_("No stops in gradient")); - gtk_widget_show (i); - gtk_menu_append (GTK_MENU (m), i); - gtk_widget_set_sensitive (mnu, FALSE); + GtkWidget *i = gtk_menu_item_new_with_label(_("No stops in gradient")); + gtk_widget_show(i); + gtk_menu_append(GTK_MENU(m), i); + gtk_widget_set_sensitive(mnu, FALSE); } else { for (; sl != NULL; sl = sl->next){ SPStop *stop; GtkWidget *i; if (SP_IS_STOP(sl->data)){ - stop = SP_STOP (sl->data); - i = gtk_menu_item_new (); - gtk_widget_show (i); - g_object_set_data (G_OBJECT (i), "stop", stop); - GtkWidget *hb = gtk_hbox_new (FALSE, 4); + stop = SP_STOP(sl->data); + i = gtk_menu_item_new(); + gtk_widget_show(i); + g_object_set_data(G_OBJECT(i), "stop", stop); + GtkWidget *hb = gtk_hbox_new(FALSE, 4); GtkWidget *cpv = sp_color_preview_new(sp_stop_get_rgba32(stop)); - gtk_widget_show (cpv); - gtk_container_add ( GTK_CONTAINER (hb), cpv ); - g_object_set_data ( G_OBJECT (i), "preview", cpv ); + gtk_widget_show(cpv); + gtk_container_add( GTK_CONTAINER(hb), cpv ); + g_object_set_data( G_OBJECT(i), "preview", cpv ); Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) sl->data); - GtkWidget *l = gtk_label_new (repr->attribute("id")); - gtk_widget_show (l); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); - gtk_widget_show (hb); - gtk_container_add (GTK_CONTAINER (i), hb); - gtk_menu_append (GTK_MENU (m), i); + GtkWidget *l = gtk_label_new(repr->attribute("id")); + gtk_widget_show(l); + gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, 0); + gtk_widget_show(hb); + gtk_container_add(GTK_CONTAINER(i), hb); + gtk_menu_append(GTK_MENU(m), i); } } - gtk_widget_set_sensitive (mnu, TRUE); + gtk_widget_set_sensitive(mnu, TRUE); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (mnu), m); + gtk_option_menu_set_menu(GTK_OPTION_MENU(mnu), m); /* Set history */ if (new_stop == NULL) { - gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), 0); + gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), 0); } else { - select_stop_in_list (mnu, gradient, new_stop); + select_stop_in_list(mnu, gradient, new_stop); } blocked = FALSE; } -/*user selected existing stop from list*/ -static void -sp_grad_edit_select (GtkOptionMenu *mnu, GtkWidget *tbl) +// user selected existing stop from list +static void sp_grad_edit_select(GtkOptionMenu *mnu, GtkWidget *tbl) { - SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(tbl), "gradient"); + SPGradient *gradient = (SPGradient *)g_object_get_data(G_OBJECT(tbl), "gradient"); - GObject *item = G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))); - SPStop *stop = SP_STOP (g_object_get_data (item, "stop")); - if (!stop) return; + GObject *item = G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))); + SPStop *stop = SP_STOP(g_object_get_data(item, "stop")); + if (!stop) { + return; + } blocked = TRUE; - SPColorSelector *csel = (SPColorSelector*)g_object_get_data (G_OBJECT (tbl), "cselector"); + SPColorSelector *csel = (SPColorSelector*)g_object_get_data(G_OBJECT(tbl), "cselector"); guint32 const c = sp_stop_get_rgba32(stop); - csel->base->setAlpha(SP_RGBA32_A_F (c)); - SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) ); + csel->base->setAlpha(SP_RGBA32_A_F(c)); + SPColor color( SP_RGBA32_R_F(c), SP_RGBA32_G_F(c), SP_RGBA32_B_F(c) ); // set its color, from the stored array csel->base->setColor( color ); - GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offspn")); - GtkWidget *offslide =GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offslide")); + GtkWidget *offspin = GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offspn")); + GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "offslide")); - GtkAdjustment *adj = (GtkAdjustment*)gtk_object_get_data (GTK_OBJECT (tbl), "offset"); + GtkAdjustment *adj = static_cast(gtk_object_get_data(GTK_OBJECT(tbl), "offset")); bool isEndStop = false; @@ -634,16 +626,16 @@ sp_grad_edit_select (GtkOptionMenu *mnu, GtkWidget *tbl) //fixme: does this work on all possible input gradients? if (!isEndStop) { - gtk_widget_set_sensitive (offslide, TRUE); - gtk_widget_set_sensitive (GTK_WIDGET (offspin), TRUE); + gtk_widget_set_sensitive(offslide, TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(offspin), TRUE); } else { - gtk_widget_set_sensitive (offslide, FALSE); - gtk_widget_set_sensitive (GTK_WIDGET (offspin), FALSE); + gtk_widget_set_sensitive(offslide, FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(offspin), FALSE); } - gtk_adjustment_set_value (adj, stop->offset); + gtk_adjustment_set_value(adj, stop->offset); - gtk_adjustment_changed (adj); + gtk_adjustment_changed(adj); blocked = FALSE; } @@ -651,57 +643,58 @@ sp_grad_edit_select (GtkOptionMenu *mnu, GtkWidget *tbl) -static void -offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb) +static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb) { - if (blocked) + if (blocked) { return; + } blocked = TRUE; - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu"); - if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return; - SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(vb), "stopmenu")); + if (!g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")) { + return; + } + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); stop->offset = adjustment->value; sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); - sp_document_done (SP_OBJECT_DOCUMENT (stop), SP_VERB_CONTEXT_GRADIENT, + sp_document_done(SP_OBJECT_DOCUMENT(stop), SP_VERB_CONTEXT_GRADIENT, _("Change gradient stop offset")); blocked = FALSE; } -guint32 -sp_average_color (guint32 c1, guint32 c2, gdouble p = 0.5) +guint32 sp_average_color(guint32 c1, guint32 c2, gdouble p = 0.5) { - guint32 r = (guint32) (SP_RGBA32_R_U (c1) * p + SP_RGBA32_R_U (c2) * (1 - p)); - guint32 g = (guint32) (SP_RGBA32_G_U (c1) * p + SP_RGBA32_G_U (c2) * (1 - p)); - guint32 b = (guint32) (SP_RGBA32_B_U (c1) * p + SP_RGBA32_B_U (c2) * (1 - p)); - guint32 a = (guint32) (SP_RGBA32_A_U (c1) * p + SP_RGBA32_A_U (c2) * (1 - p)); + guint32 r = (guint32) (SP_RGBA32_R_U(c1) * p + SP_RGBA32_R_U(c2) * (1 - p)); + guint32 g = (guint32) (SP_RGBA32_G_U(c1) * p + SP_RGBA32_G_U(c2) * (1 - p)); + guint32 b = (guint32) (SP_RGBA32_B_U(c1) * p + SP_RGBA32_B_U(c2) * (1 - p)); + guint32 a = (guint32) (SP_RGBA32_A_U(c1) * p + SP_RGBA32_A_U(c2) * (1 - p)); - return SP_RGBA32_U_COMPOSE (r, g, b, a); + return SP_RGBA32_U_COMPOSE(r, g, b, a); } -static void -sp_grd_ed_add_stop (GtkWidget */*widget*/, GtkWidget *vb) +static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb) { - SPGradient *gradient = (SPGradient *) g_object_get_data (G_OBJECT(vb), "gradient"); - verify_grad (gradient); - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu"); + SPGradient *gradient = static_cast(g_object_get_data(G_OBJECT(vb), "gradient")); + verify_grad(gradient); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(vb), "stopmenu")); - SPStop *stop = (SPStop *) g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"); + SPStop *stop = static_cast(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); - if (stop == NULL) + if (stop == NULL) { return; + } Inkscape::XML::Node *new_stop_repr = NULL; - SPStop *next = sp_next_stop (stop); + SPStop *next = sp_next_stop(stop); if (next == NULL) { - SPStop *prev = sp_prev_stop (stop, gradient); + SPStop *prev = sp_prev_stop(stop, gradient); if (prev != NULL) { next = stop; stop = prev; @@ -723,186 +716,184 @@ sp_grd_ed_add_stop (GtkWidget */*widget*/, GtkWidget *vb) guint32 const c1 = sp_stop_get_rgba32(stop); guint32 const c2 = sp_stop_get_rgba32(next); - guint32 cnew = sp_average_color (c1, c2); + guint32 cnew = sp_average_color(c1, c2); Inkscape::CSSOStringStream os; gchar c[64]; - sp_svg_write_color (c, sizeof(c), cnew); - gdouble opacity = (gdouble) SP_RGBA32_A_F (cnew); + sp_svg_write_color(c, sizeof(c), cnew); + gdouble opacity = static_cast(SP_RGBA32_A_F(cnew)); os << "stop-color:" << c << ";stop-opacity:" << opacity <<";"; SP_OBJECT_REPR (newstop)->setAttribute("style", os.str().c_str()); sp_repr_set_css_double( SP_OBJECT_REPR(newstop), "offset", (double)newstop->offset); - sp_gradient_vector_widget_load_gradient (vb, gradient); + sp_gradient_vector_widget_load_gradient(vb, gradient); Inkscape::GC::release(new_stop_repr); update_stop_list(GTK_WIDGET(mnu), gradient, newstop); - GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (vb), "offspn")); - 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, + GtkWidget *offspin = GTK_WIDGET(g_object_get_data(G_OBJECT(vb), "offspn")); + 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")); } -static void -sp_grd_ed_del_stop (GtkWidget */*widget*/, GtkWidget *vb) +static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb) { - SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient"); + SPGradient *gradient = static_cast(g_object_get_data(G_OBJECT(vb), "gradient")); - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu"); - if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return; - SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(vb), "stopmenu")); + if (!g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")) return; + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); if (gradient->vector.stops.size() > 2) { // 2 is the minimum // if we delete first or last stop, move the next/previous to the edge if (stop->offset == 0) { - SPStop *next = sp_next_stop (stop); + SPStop *next = sp_next_stop(stop); if (next) { next->offset = 0; - sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0); + sp_repr_set_css_double(SP_OBJECT_REPR(next), "offset", 0); } } else if (stop->offset == 1) { - SPStop *prev = sp_prev_stop (stop, gradient); + SPStop *prev = sp_prev_stop(stop, gradient); if (prev) { prev->offset = 1; - sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1); + sp_repr_set_css_double(SP_OBJECT_REPR(prev), "offset", 1); } } SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop)); - sp_gradient_vector_widget_load_gradient (vb, gradient); + 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, + sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop")); } } -static GtkWidget * -sp_gradient_vector_widget_new (SPGradient *gradient, SPStop *select_stop) +static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *select_stop) { GtkWidget *vb, *w, *f, *csel; - g_return_val_if_fail (!gradient || SP_IS_GRADIENT (gradient), NULL); + g_return_val_if_fail(!gradient || SP_IS_GRADIENT(gradient), NULL); - vb = gtk_vbox_new (FALSE, PAD); - g_signal_connect (G_OBJECT (vb), "destroy", G_CALLBACK (sp_gradient_vector_widget_destroy), NULL); + vb = gtk_vbox_new(FALSE, PAD); + g_signal_connect(G_OBJECT(vb), "destroy", G_CALLBACK(sp_gradient_vector_widget_destroy), NULL); - w = sp_gradient_image_new (gradient); - g_object_set_data (G_OBJECT (vb), "preview", w); - gtk_widget_show (w); - gtk_box_pack_start (GTK_BOX (vb), w, TRUE, TRUE, PAD); + w = sp_gradient_image_new(gradient); + g_object_set_data(G_OBJECT(vb), "preview", w); + gtk_widget_show(w); + gtk_box_pack_start(GTK_BOX(vb), w, TRUE, TRUE, PAD); - sp_repr_add_listener (SP_OBJECT_REPR(gradient), &grad_edit_dia_repr_events, vb); - GtkTooltips *tt = gtk_tooltips_new (); + sp_repr_add_listener(SP_OBJECT_REPR(gradient), &grad_edit_dia_repr_events, vb); + GtkTooltips *tt = gtk_tooltips_new(); /* Stop list */ - GtkWidget *mnu = gtk_option_menu_new (); + GtkWidget *mnu = gtk_option_menu_new(); /* Create new menu widget */ - update_stop_list (GTK_WIDGET(mnu), gradient, NULL); - gtk_signal_connect (GTK_OBJECT (mnu), "changed", GTK_SIGNAL_FUNC (sp_grad_edit_select), vb); - gtk_widget_show (mnu); - gtk_object_set_data (GTK_OBJECT (vb), "stopmenu", mnu); - gtk_box_pack_start (GTK_BOX (vb), mnu, FALSE, FALSE, 0); + update_stop_list(GTK_WIDGET(mnu), gradient, NULL); + gtk_signal_connect(GTK_OBJECT(mnu), "changed", GTK_SIGNAL_FUNC(sp_grad_edit_select), vb); + gtk_widget_show(mnu); + gtk_object_set_data(GTK_OBJECT(vb), "stopmenu", mnu); + gtk_box_pack_start(GTK_BOX(vb), mnu, FALSE, FALSE, 0); /* Add and Remove buttons */ - GtkWidget *hb = gtk_hbox_new (FALSE, 1); + GtkWidget *hb = gtk_hbox_new(FALSE, 1); // TRANSLATORS: "Stop" means: a "phase" of a gradient - GtkWidget *b = gtk_button_new_with_label (_("Add stop")); - gtk_widget_show (b); - gtk_container_add (GTK_CONTAINER (hb), b); - gtk_tooltips_set_tip (tt, b, _("Add another control stop to gradient"), NULL); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_add_stop), vb); - b = gtk_button_new_with_label (_("Delete stop")); - gtk_widget_show (b); - gtk_container_add (GTK_CONTAINER (hb), b); - gtk_tooltips_set_tip (tt, b, _("Delete current control stop from gradient"), NULL); - gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_del_stop), vb); + GtkWidget *b = gtk_button_new_with_label(_("Add stop")); + gtk_widget_show(b); + gtk_container_add(GTK_CONTAINER(hb), b); + gtk_tooltips_set_tip(tt, b, _("Add another control stop to gradient"), NULL); + gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_add_stop), vb); + b = gtk_button_new_with_label(_("Delete stop")); + gtk_widget_show(b); + gtk_container_add(GTK_CONTAINER(hb), b); + gtk_tooltips_set_tip(tt, b, _("Delete current control stop from gradient"), NULL); + gtk_signal_connect(GTK_OBJECT(b), "clicked", GTK_SIGNAL_FUNC(sp_grd_ed_del_stop), vb); - gtk_widget_show (hb); - gtk_box_pack_start (GTK_BOX (vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); + gtk_widget_show(hb); + gtk_box_pack_start(GTK_BOX(vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); /* Offset Slider and stuff */ - hb = gtk_hbox_new (FALSE, 0); + hb = gtk_hbox_new(FALSE, 0); /* Label */ - GtkWidget *l = gtk_label_new (_("Offset:")); - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); - gtk_box_pack_start (GTK_BOX (hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); - gtk_widget_show (l); + GtkWidget *l = gtk_label_new(_("Offset:")); + gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); + gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); + gtk_widget_show(l); /* Adjustment */ GtkAdjustment *Offset_adj = NULL; - Offset_adj= (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.01, 0.0); - gtk_object_set_data (GTK_OBJECT (vb), "offset", Offset_adj); - GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu (GTK_OPTION_MENU(mnu))); - SPStop *stop = SP_STOP (g_object_get_data (G_OBJECT (gtk_menu_get_active (m)), "stop")); - gtk_adjustment_set_value (Offset_adj, stop->offset); + Offset_adj= (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 1.0, 0.01, 0.01, 0.0); + gtk_object_set_data(GTK_OBJECT(vb), "offset", Offset_adj); + GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(mnu))); + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "stop")); + gtk_adjustment_set_value(Offset_adj, stop->offset); /* Slider */ GtkWidget *slider = gtk_hscale_new(Offset_adj); gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE ); - gtk_widget_show (slider); - gtk_box_pack_start (GTK_BOX (hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); - gtk_object_set_data (GTK_OBJECT (vb), "offslide", slider); + gtk_widget_show(slider); + gtk_box_pack_start(GTK_BOX(hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); + gtk_object_set_data(GTK_OBJECT(vb), "offslide", slider); /* Spinbutton */ - GtkWidget *sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (Offset_adj), 0.01, 2); - sp_dialog_defocus_on_enter (sbtn); - gtk_widget_show (sbtn); - gtk_box_pack_start (GTK_BOX (hb),sbtn, FALSE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); - gtk_object_set_data (GTK_OBJECT (vb), "offspn", sbtn); + GtkWidget *sbtn = gtk_spin_button_new(GTK_ADJUSTMENT(Offset_adj), 0.01, 2); + sp_dialog_defocus_on_enter(sbtn); + gtk_widget_show(sbtn); + gtk_box_pack_start(GTK_BOX(hb),sbtn, FALSE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); + gtk_object_set_data(GTK_OBJECT(vb), "offspn", sbtn); if (stop->offset>0 && stop->offset<1) { - gtk_widget_set_sensitive (slider, TRUE); - gtk_widget_set_sensitive (GTK_WIDGET (sbtn), TRUE); + gtk_widget_set_sensitive(slider, TRUE); + gtk_widget_set_sensitive(GTK_WIDGET(sbtn), TRUE); } else { - gtk_widget_set_sensitive (slider, FALSE); - gtk_widget_set_sensitive (GTK_WIDGET (sbtn), FALSE); + gtk_widget_set_sensitive(slider, FALSE); + gtk_widget_set_sensitive(GTK_WIDGET(sbtn), FALSE); } /* Signals */ - gtk_signal_connect (GTK_OBJECT (Offset_adj), "value_changed", - GTK_SIGNAL_FUNC (offadjustmentChanged), vb); + gtk_signal_connect(GTK_OBJECT(Offset_adj), "value_changed", + GTK_SIGNAL_FUNC(offadjustmentChanged), vb); - // gtk_signal_connect (GTK_OBJECT (slider), "changed", GTK_SIGNAL_FUNC (offsliderChanged), vb); - gtk_widget_show (hb); - gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, PAD); + // gtk_signal_connect(GTK_OBJECT(slider), "changed", GTK_SIGNAL_FUNC(offsliderChanged), vb); + gtk_widget_show(hb); + gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, PAD); // TRANSLATORS: "Stop" means: a "phase" of a gradient - f = gtk_frame_new (_("Stop Color")); - gtk_widget_show (f); - gtk_box_pack_start (GTK_BOX (vb), f, TRUE, TRUE, PAD); - csel = (GtkWidget*)sp_color_selector_new (SP_TYPE_COLOR_NOTEBOOK); - g_object_set_data (G_OBJECT (vb), "cselector", csel); - gtk_widget_show (csel); - gtk_container_add (GTK_CONTAINER (f), csel); - g_signal_connect (G_OBJECT (csel), "dragged", G_CALLBACK (sp_gradient_vector_color_dragged), vb); - g_signal_connect (G_OBJECT (csel), "changed", G_CALLBACK (sp_gradient_vector_color_changed), vb); - - gtk_widget_show (vb); - - sp_gradient_vector_widget_load_gradient (vb, gradient); - - if (select_stop) - select_stop_in_list (GTK_WIDGET(mnu), gradient, select_stop); + f = gtk_frame_new(_("Stop Color")); + gtk_widget_show(f); + gtk_box_pack_start(GTK_BOX(vb), f, TRUE, TRUE, PAD); + csel = static_cast(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK)); + g_object_set_data(G_OBJECT(vb), "cselector", csel); + gtk_widget_show(csel); + gtk_container_add(GTK_CONTAINER(f), csel); + g_signal_connect(G_OBJECT(csel), "dragged", G_CALLBACK(sp_gradient_vector_color_dragged), vb); + g_signal_connect(G_OBJECT(csel), "changed", G_CALLBACK(sp_gradient_vector_color_changed), vb); + + gtk_widget_show(vb); + + sp_gradient_vector_widget_load_gradient(vb, gradient); + + if (select_stop) { + select_stop_in_list(GTK_WIDGET(mnu), gradient, select_stop); + } return vb; } -GtkWidget * -sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop) +GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop) { GtkWidget *wid; if (dlg == NULL) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - dlg = sp_window_new (_("Gradient editor"), TRUE); + dlg = sp_window_new(_("Gradient editor"), TRUE); if (x == -1000 || y == -1000) { x = prefs->getInt(prefs_path + "x", -1000); y = prefs->getInt(prefs_path + "y", -1000); @@ -912,32 +903,39 @@ sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop) h = prefs->getInt(prefs_path + "h", 0); } - if (x<0) x=0; - if (y<0) y=0; + if (x<0) { + x=0; + } + if (y<0) { + y=0; + } - if (x != 0 || y != 0) - gtk_window_move ((GtkWindow *) dlg, x, y); - else + if (x != 0 || y != 0) { + gtk_window_move(reinterpret_cast(dlg), x, y); + } else { gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); - if (w && h) gtk_window_resize ((GtkWindow *) dlg, w, h); - sp_transientize (dlg); + } + if (w && h) { + gtk_window_resize(reinterpret_cast(dlg), w, h); + } + sp_transientize(dlg); wd.win = dlg; wd.stop = 0; - g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd); - gtk_signal_connect (GTK_OBJECT (dlg), "event", GTK_SIGNAL_FUNC (sp_dialog_event_handler), dlg); - gtk_signal_connect (GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_gradient_vector_dialog_destroy), dlg); - gtk_signal_connect (GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg); - g_signal_connect (G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_hide", G_CALLBACK (sp_dialog_hide), dlg ); - g_signal_connect ( G_OBJECT (INKSCAPE), "dialogs_unhide", G_CALLBACK (sp_dialog_unhide), dlg ); - - gtk_container_set_border_width (GTK_CONTAINER (dlg), PAD); - - wid = (GtkWidget*)sp_gradient_vector_widget_new (gradient, stop); - g_object_set_data (G_OBJECT (dlg), "gradient-vector-widget", wid); + g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd); + gtk_signal_connect(GTK_OBJECT(dlg), "event", GTK_SIGNAL_FUNC(sp_dialog_event_handler), dlg); + gtk_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg); + gtk_signal_connect(GTK_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); + g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg); + g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg ); + g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(sp_dialog_unhide), dlg ); + + gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD); + + wid = static_cast(sp_gradient_vector_widget_new(gradient, stop)); + g_object_set_data(G_OBJECT(dlg), "gradient-vector-widget", wid); /* Connect signals */ - gtk_widget_show (wid); - gtk_container_add (GTK_CONTAINER (dlg), wid); + gtk_widget_show(wid); + gtk_container_add(GTK_CONTAINER(dlg), wid); } else { // FIXME: temp fix for 0.38 // Simply load_gradient into the editor does not work for multi-stop gradients, @@ -946,29 +944,28 @@ sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop) // and call sp_gradient_vector_editor_new again, so it creates the window anew. GdkEventAny event; - GtkWidget *widget = (GtkWidget *) dlg; + GtkWidget *widget = static_cast(dlg); event.type = GDK_DELETE; event.window = widget->window; event.send_event = TRUE; - g_object_ref (G_OBJECT (event.window)); - gtk_main_do_event ((GdkEvent*)&event); - g_object_unref (G_OBJECT (event.window)); + g_object_ref(G_OBJECT(event.window)); + gtk_main_do_event(reinterpret_cast(&event)); + g_object_unref(G_OBJECT(event.window)); - g_assert (dlg == NULL); - sp_gradient_vector_editor_new (gradient, stop); + g_assert(dlg == NULL); + sp_gradient_vector_editor_new(gradient, stop); } return dlg; } -static void -sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient) +static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient) { blocked = TRUE; SPGradient *old; - old = (SPGradient*)g_object_get_data (G_OBJECT (widget), "gradient"); + old = (SPGradient*)g_object_get_data(G_OBJECT(widget), "gradient"); if (old != gradient) { sigc::connection *release_connection; @@ -982,7 +979,7 @@ sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient g_assert( modified_connection != NULL ); release_connection->disconnect(); modified_connection->disconnect(); - sp_signal_disconnect_by_data (old, widget); + sp_signal_disconnect_by_data(old, widget); } if (gradient) { @@ -1009,62 +1006,64 @@ sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient g_object_set_data(G_OBJECT(widget), "gradient_modified_connection", modified_connection); } - g_object_set_data (G_OBJECT (widget), "gradient", gradient); + g_object_set_data(G_OBJECT(widget), "gradient", gradient); if (gradient) { - gtk_widget_set_sensitive (widget, TRUE); + gtk_widget_set_sensitive(widget, TRUE); - sp_gradient_ensure_vector (gradient); + sp_gradient_ensure_vector(gradient); - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(widget), "stopmenu"); - SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(widget), "stopmenu")); + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); guint32 const c = sp_stop_get_rgba32(stop); /// get the color selector - SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data (G_OBJECT (widget), "cselector")); + SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data(G_OBJECT(widget), "cselector")); // set alpha - csel->base->setAlpha(SP_RGBA32_A_F (c)); - SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) ); + csel->base->setAlpha(SP_RGBA32_A_F(c)); + SPColor color( SP_RGBA32_R_F(c), SP_RGBA32_G_F(c), SP_RGBA32_B_F(c) ); // set color csel->base->setColor( color ); /* Fill preview */ GtkWidget *w = static_cast(g_object_get_data(G_OBJECT(widget), "preview")); - sp_gradient_image_set_gradient (SP_GRADIENT_IMAGE (w), gradient); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(w), gradient); - update_stop_list (GTK_WIDGET(mnu), gradient, NULL); + update_stop_list(GTK_WIDGET(mnu), gradient, NULL); // 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); + SPDocument *document = SP_OBJECT_DOCUMENT(gradient); bool saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive (document, false); + sp_document_set_undo_sensitive(document, false); SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL); - sp_document_set_undo_sensitive (document, saved); + sp_document_set_undo_sensitive(document, saved); } } else { // no gradient, disable everything - gtk_widget_set_sensitive (widget, FALSE); + gtk_widget_set_sensitive(widget, FALSE); } blocked = FALSE; } -static void -sp_gradient_vector_dialog_destroy (GtkObject */*object*/, gpointer /*data*/) +static void sp_gradient_vector_dialog_destroy(GtkObject */*object*/, gpointer /*data*/) { - sp_signal_disconnect_by_data (INKSCAPE, dlg); + sp_signal_disconnect_by_data(INKSCAPE, dlg); wd.win = dlg = NULL; wd.stop = 0; } -static gboolean -sp_gradient_vector_dialog_delete (GtkWidget */*widget*/, GdkEvent */*event*/, GtkWidget */*dialog*/) +static gboolean sp_gradient_vector_dialog_delete(GtkWidget */*widget*/, GdkEvent */*event*/, GtkWidget */*dialog*/) { - gtk_window_get_position ((GtkWindow *) dlg, &x, &y); - gtk_window_get_size ((GtkWindow *) dlg, &w, &h); + gtk_window_get_position(GTK_WINDOW(dlg), &x, &y); + gtk_window_get_size(GTK_WINDOW(dlg), &w, &h); - if (x<0) x=0; - if (y<0) y=0; + if (x<0) { + x=0; + } + if (y<0) { + y=0; + } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "x", x); @@ -1077,12 +1076,11 @@ sp_gradient_vector_dialog_delete (GtkWidget */*widget*/, GdkEvent */*event*/, Gt /* Widget destroy handler */ -static void -sp_gradient_vector_widget_destroy (GtkObject *object, gpointer /*data*/) +static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data*/) { GObject *gradient; - gradient = (GObject*)g_object_get_data (G_OBJECT (object), "gradient"); + gradient = (GObject*)g_object_get_data(G_OBJECT(object), "gradient"); sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(object), "gradient_release_connection"); sigc::connection *modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(object), "gradient_modified_connection"); @@ -1092,27 +1090,25 @@ sp_gradient_vector_widget_destroy (GtkObject *object, gpointer /*data*/) g_assert( modified_connection != NULL ); release_connection->disconnect(); modified_connection->disconnect(); - sp_signal_disconnect_by_data (gradient, object); + sp_signal_disconnect_by_data(gradient, object); } if (gradient && SP_OBJECT_REPR(gradient)) { - sp_repr_remove_listener_by_data (SP_OBJECT_REPR(gradient), object); + sp_repr_remove_listener_by_data(SP_OBJECT_REPR(gradient), object); } } -static void -sp_gradient_vector_gradient_release (SPObject */*object*/, GtkWidget *widget) +static void sp_gradient_vector_gradient_release(SPObject */*object*/, GtkWidget *widget) { - sp_gradient_vector_widget_load_gradient (widget, NULL); + sp_gradient_vector_widget_load_gradient(widget, NULL); } -static void -sp_gradient_vector_gradient_modified (SPObject *object, guint /*flags*/, GtkWidget *widget) +static void sp_gradient_vector_gradient_modified(SPObject *object, guint /*flags*/, GtkWidget *widget) { SPGradient *gradient=SP_GRADIENT(object); if (!blocked) { blocked = TRUE; - sp_gradient_vector_widget_load_gradient (widget, gradient); + sp_gradient_vector_widget_load_gradient(widget, gradient); blocked = FALSE; } } @@ -1121,23 +1117,27 @@ static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *o { SPGradient *gradient, *ngr; - if (blocked) return; + if (blocked) { + return; + } - gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient"); - if (!gradient) return; + gradient = static_cast(g_object_get_data(G_OBJECT(object), "gradient")); + if (!gradient) { + return; + } blocked = TRUE; - ngr = sp_gradient_ensure_vector_normalized (gradient); + ngr = sp_gradient_ensure_vector_normalized(gradient); if (ngr != gradient) { /* Our master gradient has changed */ - sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr); + sp_gradient_vector_widget_load_gradient(GTK_WIDGET(object), ngr); } - sp_gradient_ensure_vector (ngr); + sp_gradient_ensure_vector(ngr); - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(object), "stopmenu"); - SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(object), "stopmenu")); + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); csel->base->getColorAlpha(stop->specified_color, &stop->opacity); @@ -1146,54 +1146,57 @@ static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *o blocked = FALSE; } -static void -sp_gradient_vector_color_changed (SPColorSelector *csel, GtkObject *object) +static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *object) { SPColor color; float alpha; guint32 rgb; - if (blocked) return; + if (blocked) { + return; + } - SPGradient *gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient"); - if (!gradient) return; + SPGradient *gradient = static_cast(g_object_get_data(G_OBJECT(object), "gradient")); + if (!gradient) { + return; + } blocked = TRUE; - SPGradient *ngr = sp_gradient_ensure_vector_normalized (gradient); + SPGradient *ngr = sp_gradient_ensure_vector_normalized(gradient); if (ngr != gradient) { /* Our master gradient has changed */ - sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr); + sp_gradient_vector_widget_load_gradient(GTK_WIDGET(object), ngr); } - sp_gradient_ensure_vector (ngr); + sp_gradient_ensure_vector(ngr); /* Set start parameters */ /* We rely on normalized vector, i.e. stops HAVE to exist */ g_return_if_fail(ngr->getFirstStop() != NULL); - GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(object), "stopmenu"); - SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast(g_object_get_data(G_OBJECT(object), "stopmenu")); + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); - csel = (SPColorSelector*)g_object_get_data (G_OBJECT (object), "cselector"); + csel = static_cast(g_object_get_data(G_OBJECT(object), "cselector")); csel->base->getColorAlpha( color, &alpha ); rgb = color.toRGBA32( 0x00 ); - sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset); + sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); Inkscape::CSSOStringStream os; gchar c[64]; - sp_svg_write_color (c, sizeof(c), rgb); - os << "stop-color:" << c << ";stop-opacity:" << (gdouble) alpha <<";"; - SP_OBJECT_REPR (stop)->setAttribute("style", os.str().c_str()); - // g_snprintf (c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, (gdouble) alpha); - //SP_OBJECT_REPR (stop)->setAttribute("style", c); + sp_svg_write_color(c, sizeof(c), rgb); + os << "stop-color:" << c << ";stop-opacity:" << static_cast(alpha) <<";"; + SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str()); + // g_snprintf(c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, static_cast(alpha)); + //SP_OBJECT_REPR(stop)->setAttribute("style", c); - sp_document_done (SP_OBJECT_DOCUMENT (ngr), SP_VERB_CONTEXT_GRADIENT, + sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, _("Change gradient stop color")); blocked = FALSE; - SPColorPreview *cpv = (SPColorPreview *)g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "preview"); + SPColorPreview *cpv = static_cast(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "preview")); sp_color_preview_set_rgba32(cpv, sp_stop_get_rgba32(stop)); }