2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith/**
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * @file
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Spiral aux toolbar
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith/* Authors:
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * MenTaLguY <mental@rydia.net>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Lauris Kaplinski <lauris@kaplinski.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * bulia byak <buliabyak@users.sf.net>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Frank Felfe <innerspace@iname.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * John Cliff <simarilius@yahoo.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * David Turner <novalis@gnu.org>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Josh Andler <scislac@scislac.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Jon A. Cruz <jon@joncruz.org>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Maximilian Albert <maximilian.albert@gmail.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Tavmjong Bah <tavmjong@free.fr>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Abhishek Sharma
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Kris De Gussem <Kris.DeGussem@gmail.com>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith *
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2004 David Turner
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2003 MenTaLguY
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 1999-2011 authors
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Copyright (C) 2001-2002 Ximian, Inc.
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith *
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith * Released under GNU GPL, read the file 'COPYING' for more information
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith#ifdef HAVE_CONFIG_H
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith# include "config.h"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith#endif
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
5c45bb188ab729e501e48732842cb9de6a9813beAlex Valavanis#include <glibmm/i18n.h>
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "spiral-toolbar.h"
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "desktop.h"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith#include "document-undo.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "widgets/ege-adjustment-action.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "widgets/ege-output-action.h"
9836787d16b657453784c30809d330f50d9bc6d8Liam P. White#include "widgets/ink-action.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "preferences.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "selection.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "sp-spiral.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "toolbox.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "ui/icon-names.h"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith#include "ui/uxmanager.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "verbs.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "widgets/spinbutton-events.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "xml/node-event-vector.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "xml/node.h"
a4142717644b885998f4de2b27be4e8648315decMarkus Engel#include "xml/repr.h"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithusing Inkscape::UI::UXManager;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithusing Inkscape::DocumentUndo;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithusing Inkscape::UI::ToolboxFactory;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithusing Inkscape::UI::PrefPusher;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//########################
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//## Spiral ##
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith//########################
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustring const &value_name)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
6b0fbf10b982696648debeede2b57f2b32a6a958Alex Valavanis SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::Preferences *prefs = Inkscape::Preferences::get();
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith prefs->setDouble("/tools/shapes/spiral/" + value_name,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_get_value(adj));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // quit if run by the attr_changed listener
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (g_object_get_data( tbl, "freeze" )) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith return;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // in turn, prevent listener from responding
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith bool modmade = false;
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin std::vector<SPItem*> itemlist=desktop->getSelection()->itemList();
41c4ddd6064c35b849f347c88f4e39bb31d4ce62Kris De Gussem for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
aa9235c966804d9b8f8daa083a2d123d9d47d2bbMarc Jeanmougin SPItem *item = *i;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (SP_IS_SPIRAL(item)) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::XML::Node *repr = item->getRepr();
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_set_svg_double( repr, namespaced_name,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_get_value(adj) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith item->updateRepr();
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith modmade = true;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_free(namespaced_name);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (modmade) {
9ba77856a8823f85b53c0a861d220cd0347f2754Liam P. White DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_SPIRAL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Change spiral"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_revolution_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_spl_tb_value_changed(adj, tbl, "revolution");
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_expansion_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_spl_tb_value_changed(adj, tbl, "expansion");
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_t0_value_changed(GtkAdjustment *adj, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_spl_tb_value_changed(adj, tbl, "t0");
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spl_tb_defaults(GtkWidget * /*widget*/, GObject *obj)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith GtkWidget *tbl = GTK_WIDGET(obj);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith GtkAdjustment *adj;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // fixme: make settable
8dc0b6629da67892f16b8b858244ae043f3c89bbJazzyNico gdouble rev = 3;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble exp = 1.0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble t0 = 0.0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "revolution"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, rev);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_value_changed(adj);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "expansion"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, exp);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_value_changed(adj);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(obj, "t0"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, t0);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_value_changed(adj);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith spinbutton_defocus(tbl);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void spiral_tb_event_attr_changed(Inkscape::XML::Node *repr,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const * /*name*/,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const * /*old_value*/,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const * /*new_value*/,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith bool /*is_interactive*/,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gpointer data)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith GtkWidget *tbl = GTK_WIDGET(data);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // quit if run by the _changed callbacks
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith return;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // in turn, prevent callbacks from responding
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith GtkAdjustment *adj;
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "revolution"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith double revolution = 3.0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_get_double(repr, "sodipodi:revolution", &revolution);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, revolution);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "expansion"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith double expansion = 1.0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_get_double(repr, "sodipodi:expansion", &expansion);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, expansion);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
253a831f0fda7107ad98c474e21b71e90592d0f2Alex Valavanis adj = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(tbl), "t0"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith double t0 = 0.0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_get_double(repr, "sodipodi:t0", &t0);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_adjustment_set_value(adj, t0);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(FALSE));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic Inkscape::XML::NodeEventVector spiral_tb_repr_events = {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith NULL, /* child_added */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith NULL, /* child_removed */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith spiral_tb_event_attr_changed,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith NULL, /* content_changed */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith NULL /* order_changed */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithstatic void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith int n_selected = 0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::XML::Node *repr = NULL;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith purge_repr_listener( tbl, tbl );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
acd93b79c034f4bcc8ff02de8aa877f70f081881Marc Jeanmougin std::vector<SPItem*> itemlist=selection->itemList();
41c4ddd6064c35b849f347c88f4e39bb31d4ce62Kris De Gussem for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
aa9235c966804d9b8f8daa083a2d123d9d47d2bbMarc Jeanmougin SPItem *item = *i;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (SP_IS_SPIRAL(item)) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith n_selected++;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith repr = item->getRepr();
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith EgeOutputAction* act = EGE_OUTPUT_ACTION( g_object_get_data( tbl, "mode_action" ) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (n_selected == 0) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>New:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith } else if (n_selected == 1) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>Change:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith if (repr) {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( tbl, "repr", repr );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::GC::anchor(repr);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_add_listener(repr, &spiral_tb_repr_events, tbl);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_repr_synthesize_events(repr, &spiral_tb_repr_events, tbl);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith } else {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith // FIXME: implement averaging of all parameters for multiple selected
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith //gtk_label_set_markup(GTK_LABEL(l), _("<b>Average:</b>"));
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set( G_OBJECT(act), "label", _("<b>Change:</b>"), NULL );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smithvoid sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith{
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith EgeAdjustmentAction* eact = 0;
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith EgeOutputAction* act = ege_output_action_new( "SpiralStateAction", _("<b>New:</b>"), "", 0 );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith ege_output_action_set_use_markup( act, TRUE );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_object_set_data( holder, "mode_action", act );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* Revolution */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("just a curve"), 0, _("one full revolution"), 0, 0, 0, 0, 0, 0};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble values[] = {0.01, 0.5, 1, 2, 3, 5, 10, 20, 50, 100};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralRevolutionAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Number of turns"), _("Turns:"), _("Number of revolutions"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith "/tools/shapes/spiral/revolution", 3.0,
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-spiral",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith 0.01, 1024.0, 0.1, 1.0,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith labels, values, G_N_ELEMENTS(labels),
add38d633bbf8ef881bdb908735ea27385c554b8Matthew Petroff sp_spl_tb_revolution_value_changed, NULL /*unit tracker*/, 1, 2);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* Expansion */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("circle"), _("edge is much denser"), _("edge is denser"), _("even"), _("center is denser"), _("center is much denser"), 0};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble values[] = {0, 0.1, 0.5, 1, 1.5, 5, 20};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralExpansionAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Divergence"), _("Divergence:"), _("How much denser/sparser are outer revolutions; 1 = uniform"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith "/tools/shapes/spiral/expansion", 1.0,
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith 0.0, 1000.0, 0.01, 1.0,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith labels, values, G_N_ELEMENTS(labels),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_spl_tb_expansion_value_changed);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* T0 */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gchar const* labels[] = {_("starts from center"), _("starts mid-way"), _("starts near edge")};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gdouble values[] = {0, 0.5, 0.9};
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith eact = create_adjustment_action( "SpiralT0Action",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Inner radius"), _("Inner radius:"), _("Radius of the innermost revolution (relative to the spiral size)"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith "/tools/shapes/spiral/t0", 0.0,
bf9ec3e969ba6b11cbbc613545aedc63cc886973Matthew Petroff GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith 0.0, 0.999, 0.01, 1.0,
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith labels, values, G_N_ELEMENTS(labels),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sp_spl_tb_t0_value_changed);
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith /* Reset */
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith {
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith InkAction* inky = ink_action_new( "SpiralResetAction",
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Defaults"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
02db7fad736ff0812658ef9c5f82ac2e64ffdefcAlex Valavanis INKSCAPE_ICON("edit-clear"),
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith secondarySize );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_spl_tb_defaults), holder );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith }
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith sigc::connection *connection = new sigc::connection(
769a6887551cf7ff7bce4b48d3ac303cbea69507Liam P. White desktop->getSelection()->connectChanged(sigc::bind(sigc::ptr_fun(sp_spiral_toolbox_selection_changed), holder))
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith}
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith/*
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith Local Variables:
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith mode:c++
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith c-file-style:"stroustrup"
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith indent-tabs-mode:nil
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith fill-column:99
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith End:
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith*/
2f5f997e354e7f4a02b6818bdc68fbece5cb237dJohn Smith// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :