index c2e80db784b3065c415ca4cbcbc26499db7032f1..4b0d84d90a0a5d0b0ef26811ecaea244f93bc089 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "../box3d-context.h"
#include "../box3d.h"
-#include "calligraphic-profile-rename.h"
#include "../conn-avoid-ref.h"
#include "../connection-pool.h"
#include "../connector-context.h"
#include "../ege-select-one-action.h"
#include "../flood-context.h"
#include "gradient-toolbar.h"
-#include "../graphlayout/graphlayout.h"
+#include "../graphlayout.h"
#include "../helper/unit-menu.h"
#include "../helper/units.h"
#include "../helper/unit-tracker.h"
#include "icon.h"
#include "../ink-action.h"
#include "../inkscape.h"
-#include "../inkscape-stock.h"
#include "../interface.h"
#include "../libnrtype/font-instance.h"
#include "../libnrtype/font-lister.h"
#include "../live_effects/lpe-line_segment.h"
#include "../lpe-tool-context.h"
#include "../mod360.h"
-#include "../node-context.h"
#include "../pen-context.h"
#include "../preferences.h"
#include "../selection-chemistry.h"
#include "../svg/css-ostringstream.h"
#include "../tools-switch.h"
#include "../tweak-context.h"
+#include "../spray-context.h"
+#include "../ui/dialog/calligraphic-profile-rename.h"
+#include "../ui/icon-names.h"
+#include "../ui/tool/control-point-selection.h"
+#include "../ui/tool/node-tool.h"
+#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/widget/style-swatch.h"
#include "../verbs.h"
#include "../widgets/button.h"
#include "../xml/attribute-record.h"
#include "../xml/node-event-vector.h"
#include "../xml/repr.h"
+#include "ui/uxmanager.h"
#include "toolbox.h"
+#define ENABLE_TASK_SUPPORT 1
+
using Inkscape::UnitTracker;
+using Inkscape::UI::UXManager;
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+enum BarId {
+ BAR_TOOL = 0,
+ BAR_AUX,
+ BAR_COMMANDS,
+ BAR_SNAP,
+};
+
+#define BAR_ID_KEY "BarIdValue"
+#define HANDLE_POS_MARK "x-inkscape-pos"
+
static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
+static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_zoom_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
namespace { GtkWidget *sp_text_toolbox_new (SPDesktop *desktop); }
-Inkscape::IconSize prefToSize( Glib::ustring const &path, int base ) {
+#if ENABLE_TASK_SUPPORT
+static void fireTaskChange( EgeSelectOneAction *act, SPDesktop *dt )
+{
+ gint selected = ege_select_one_action_get_active( act );
+ UXManager::getInstance()->setTask(dt, selected);
+}
+#endif // ENABLE_TASK_SUPPORT
+
+using Inkscape::UI::ToolboxFactory;
+
+
+Inkscape::IconSize ToolboxFactory::prefToSize( Glib::ustring const &path, int base ) {
static Inkscape::IconSize sizeChoices[] = {
Inkscape::ICON_SIZE_LARGE_TOOLBAR,
Inkscape::ICON_SIZE_SMALL_TOOLBAR,
sp_verb_t doubleclick_verb;
} const tools[] = {
{ "SPSelectContext", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS},
- { "SPNodeContext", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS },
+ { "InkNodeTool", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS },
{ "SPTweakContext", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS },
+ { "SPSprayContext", "spray_tool", SP_VERB_CONTEXT_SPRAY, SP_VERB_CONTEXT_SPRAY_PREFS },
{ "SPZoomContext", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS },
{ "SPRectContext", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS },
{ "Box3DContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS },
} const aux_toolboxes[] = {
{ "SPSelectContext", "select_toolbox", 0, sp_select_toolbox_prep, "SelectToolbar",
SP_VERB_INVALID, 0, 0},
- { "SPNodeContext", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
+ { "InkNodeTool", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")},
+ { "SPSprayContext", "spray_toolbox", 0, sp_spray_toolbox_prep, "SprayToolbar",
+ SP_VERB_CONTEXT_SPRAY_PREFS, "/tools/spray", N_("Color/opacity used for color spraying")},
{ "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
" </toolbar>"
" <toolbar name='NodeToolbar'>"
+ " <separator />"
" <toolitem action='NodeInsertAction' />"
" <toolitem action='NodeDeleteAction' />"
" <separator />"
" <toolitem action='ObjectEditMaskPathAction' />"
" <toolitem action='EditNextLPEParameterAction' />"
" <separator />"
+ " <toolitem action='NodesShowTransformHandlesAction' />"
" <toolitem action='NodesShowHandlesAction' />"
" <toolitem action='NodesShowHelperpath' />"
" </toolbar>"
" <toolitem action='TweakDoO' />"
" </toolbar>"
+ " <toolbar name='SprayToolbar'>"
+ " <toolitem action='SprayModeAction' />"
+ " <separator />"
+ " <separator />"
+ " <toolitem action='SprayWidthAction' />"
+ " <toolitem action='SprayPressureAction' />"
+ " <toolitem action='SprayPopulationAction' />"
+ " <separator />"
+ " <toolitem action='SprayRotationAction' />"
+ " <toolitem action='SprayScaleAction' />"
+ " <separator />"
+ " <toolitem action='SprayStandard_deviationAction' />"
+ " <toolitem action='SprayMeanAction' />"
+ " </toolbar>"
+
" <toolbar name='ZoomToolbar'>"
" <toolitem action='ZoomIn' />"
" <toolitem action='ZoomOut' />"
" </toolbar>"
" <toolbar name='ConnectorToolbar'>"
+// " <toolitem action='ConnectorEditModeAction' />"
" <toolitem action='ConnectorAvoidAction' />"
" <toolitem action='ConnectorIgnoreAction' />"
+ " <toolitem action='ConnectorOrthogonalAction' />"
+ " <toolitem action='ConnectorCurvatureAction' />"
" <toolitem action='ConnectorSpacingAction' />"
" <toolitem action='ConnectorGraphAction' />"
" <toolitem action='ConnectorLengthAction' />"
" <toolitem action='ConnectorDirectedAction' />"
" <toolitem action='ConnectorOverlapAction' />"
+// " <toolitem action='ConnectorNewConnPointAction' />"
+// " <toolitem action='ConnectorRemoveConnPointAction' />"
" </toolbar>"
"</ui>"
static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* desktop );
-static void toolbox_set_desktop (GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection*);
+void setup_snap_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
static void setup_tool_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
static void update_tool_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
@@ -475,7 +529,6 @@ static void update_aux_toolbox (SPDesktop *desktop, SPEventContext *eventcontext
static void setup_commands_toolbox (GtkWidget *toolbox, SPDesktop *desktop);
static void update_commands_toolbox (SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
-
GtkWidget * sp_toolbox_button_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
Inkscape::UI::View::View *view, GtkTooltips *tt);
Gtk::Widget* VerbAction::create_tool_item_vfunc()
{
// Gtk::Widget* widg = Gtk::Action::create_tool_item_vfunc();
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
+ Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small");
GtkWidget* toolbox = 0;
GtkWidget *button = sp_toolbox_button_new_from_verb_with_doubleclick( toolbox, toolboxSize,
SP_BUTTON_TYPE_TOGGLE,
SP_VERB_DIALOG_NAMEDVIEW,
SP_VERB_DIALOG_TEXT,
SP_VERB_DIALOG_XML_EDITOR,
+ SP_VERB_DIALOG_LAYERS,
SP_VERB_EDIT_CLONE,
SP_VERB_EDIT_COPY,
SP_VERB_EDIT_CUT,
SP_VERB_ZOOM_SELECTION,
};
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
+ Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
static std::map<SPDesktop*, Glib::RefPtr<Gtk::ActionGroup> > groups;
Glib::RefPtr<Gtk::ActionGroup> mainActions;
}
}
+#if ENABLE_TASK_SUPPORT
+ if ( !mainActions->get_action("TaskSetAction") ) {
+ GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
+
+ GtkTreeIter iter;
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Default"),
+ 1, _("Default interface setup"),
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Custom"),
+ 1, _("Set the custom task"),
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Wide"),
+ 1, _("Setup for widescreen work"),
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "TaskSetAction", _("Task"), (""), NULL, GTK_TREE_MODEL(model) );
+ g_object_set( act, "short_label", _("Task:"), NULL );
+ mainActions->add(Glib::wrap(GTK_ACTION(act)));
+ //g_object_set_data( holder, "mode_action", act );
+
+ ege_select_one_action_set_appearance( act, "minimal" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ //ege_select_one_action_set_icon_size( act, secondarySize );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+
+ //ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(fireTaskChange), desktop );
+ }
+#endif // ENABLE_TASK_SUPPORT
return mainActions;
}
@@ -808,25 +899,21 @@ void handlebox_attached(GtkHandleBox* /*handlebox*/, GtkWidget* widget, gpointer
gtk_widget_set_size_request( widget, -1, -1 );
}
-
-
-GtkWidget *
-sp_tool_toolbox_new()
+static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType handlePos )
{
- GtkTooltips *tt = gtk_tooltips_new();
- GtkWidget* tb = gtk_toolbar_new();
- gtk_toolbar_set_orientation(GTK_TOOLBAR(tb), GTK_ORIENTATION_VERTICAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(tb), TRUE);
-
g_object_set_data(G_OBJECT(tb), "desktop", NULL);
- g_object_set_data(G_OBJECT(tb), "tooltips", tt);
gtk_widget_set_sensitive(tb, FALSE);
- GtkWidget *hb = gtk_handle_box_new();
- gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), GTK_POS_TOP);
- gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
- gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
+ GtkWidget *hb = 0;
+ if ( UXManager::getInstance()->isFloatWindowProblem() ) {
+ hb = gtk_event_box_new(); // A simple, neutral container.
+ } else {
+ hb = gtk_handle_box_new();
+ gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), handlePos);
+ gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
+ gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
+ }
gtk_container_add(GTK_CONTAINER(hb), tb);
gtk_widget_show(GTK_WIDGET(tb));
sigc::connection* conn = new sigc::connection;
g_object_set_data(G_OBJECT(hb), "event_context_connection", conn);
- g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
- g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+ if ( GTK_IS_HANDLE_BOX(hb) ) {
+ g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
+ g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+ }
+
+ gpointer val = GINT_TO_POINTER(id);
+ g_object_set_data(G_OBJECT(hb), BAR_ID_KEY, val);
return hb;
}
-GtkWidget *
-sp_aux_toolbox_new()
+GtkWidget *ToolboxFactory::createToolToolbox()
{
GtkWidget *tb = gtk_vbox_new(FALSE, 0);
- gtk_box_set_spacing(GTK_BOX(tb), AUX_SPACING);
-
- g_object_set_data(G_OBJECT(tb), "desktop", NULL);
-
- gtk_widget_set_sensitive(tb, FALSE);
-
- GtkWidget *hb = gtk_handle_box_new();
- gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
- gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
- gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
-
- gtk_container_add(GTK_CONTAINER(hb), tb);
- gtk_widget_show(GTK_WIDGET(tb));
-
- sigc::connection* conn = new sigc::connection;
- g_object_set_data(G_OBJECT(hb), "event_context_connection", conn);
+ return toolboxNewCommon( tb, BAR_TOOL, GTK_POS_TOP );
+}
- g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
- g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+GtkWidget *ToolboxFactory::createAuxToolbox()
+{
+ GtkWidget *tb = gtk_vbox_new(FALSE, 0);
- return hb;
+ return toolboxNewCommon( tb, BAR_AUX, GTK_POS_LEFT );
}
//####################################
//# Commands Bar
//####################################
-GtkWidget *
-sp_commands_toolbox_new()
+GtkWidget *ToolboxFactory::createCommandsToolbox()
{
- GtkWidget *tb = gtk_toolbar_new();
-
- g_object_set_data(G_OBJECT(tb), "desktop", NULL);
- gtk_widget_set_sensitive(tb, FALSE);
-
- GtkWidget *hb = gtk_handle_box_new();
- gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
- gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
- gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
-
- gtk_container_add(GTK_CONTAINER(hb), tb);
- gtk_widget_show(GTK_WIDGET(tb));
+ GtkWidget *tb = gtk_vbox_new(FALSE, 0);
- sigc::connection* conn = new sigc::connection;
- g_object_set_data(G_OBJECT(hb), "event_context_connection", conn);
+ return toolboxNewCommon( tb, BAR_COMMANDS, GTK_POS_LEFT );
+}
- g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
- g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+GtkWidget *ToolboxFactory::createSnapToolbox()
+{
+ GtkWidget *tb = gtk_vbox_new(FALSE, 0);
- return hb;
+ return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT );
}
-
static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
gchar const *label, gchar const *shortLabel, gchar const *tooltip,
Glib::ustring const &path, gdouble def,
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( prefs->getDouble(path, def) * factor,
- lower, upper, step, page, page ) );
+ lower, upper, step, page, 0 ) );
if (us) {
sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us), adj );
}
//# node editing callbacks
//####################################
-/**
- * FIXME: Returns current shape_editor in context. // later eliminate this function at all!
- */
-static ShapeEditor *get_current_shape_editor()
+/** Temporary hack: Returns the node tool in the active desktop.
+ * Will go away during tool refactoring. */
+static InkNodeTool *get_node_tool()
{
- if (!SP_ACTIVE_DESKTOP) {
- return NULL;
- }
-
- SPEventContext *event_context = (SP_ACTIVE_DESKTOP)->event_context;
-
- if (!SP_IS_NODE_CONTEXT(event_context)) {
- return NULL;
- }
-
- return event_context->shape_editor;
+ if (!SP_ACTIVE_DESKTOP) return NULL;
+ SPEventContext *ec = SP_ACTIVE_DESKTOP->event_context;
+ if (!INK_IS_NODE_TOOL(ec)) return NULL;
+ return static_cast<InkNodeTool*>(ec);
}
-
void
sp_node_path_edit_add(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->add_node();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->insertNodes();
+ }
}
void
sp_node_path_edit_delete(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->delete_nodes_preserving_shape();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true));
+ }
}
void
sp_node_path_edit_delete_segment(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->delete_segment();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->deleteSegments();
+ }
}
void
sp_node_path_edit_break(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->break_at_nodes();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->breakNodes();
+ }
}
void
sp_node_path_edit_join(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->join_nodes();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->joinNodes();
+ }
}
void
sp_node_path_edit_join_segment(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->join_segments();
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->joinSegments();
+ }
}
void
sp_node_path_edit_toline(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_type_of_segments(NR_LINETO);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT);
+ }
}
void
sp_node_path_edit_tocurve(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_type_of_segments(NR_CURVETO);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER);
+ }
}
void
sp_node_path_edit_cusp(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_CUSP);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP);
+ }
}
void
sp_node_path_edit_smooth(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_SMOOTH);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH);
+ }
}
void
sp_node_path_edit_symmetrical(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_SYMM);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC);
+ }
}
void
sp_node_path_edit_auto(void)
{
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_AUTO);
+ InkNodeTool *nt = get_node_tool();
+ if (nt) {
+ nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO);
+ }
+}
+
+static void toggle_show_transform_handles (GtkToggleAction *act, gpointer /*data*/) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool show = gtk_toggle_action_get_active( act );
+ prefs->setBool("/tools/nodes/show_transform_handles", show);
}
static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
prefs->setBool("/tools/nodes/show_handles", show);
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->show_handles(show);
}
static void toggle_show_helperpath (GtkToggleAction *act, gpointer /*data*/) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
- prefs->setBool("/tools/nodes/show_helperpath", show);
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor) shape_editor->show_helperpath(show);
+ prefs->setBool("/tools/nodes/show_outline", show);
}
void sp_node_path_edit_nextLPEparam (GtkAction */*act*/, gpointer data) {
sp_selection_next_patheffect_param( reinterpret_cast<SPDesktop*>(data) );
}
-void sp_node_path_edit_clippath (GtkAction */*act*/, gpointer data) {
- sp_selection_edit_clip_or_mask( reinterpret_cast<SPDesktop*>(data), true);
+void toggle_edit_clip (GtkToggleAction *act, gpointer /*data*/) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool edit = gtk_toggle_action_get_active( act );
+ prefs->setBool("/tools/nodes/edit_clipping_paths", edit);
}
-void sp_node_path_edit_maskpath (GtkAction */*act*/, gpointer data) {
- sp_selection_edit_clip_or_mask( reinterpret_cast<SPDesktop*>(data), false);
+void toggle_edit_mask (GtkToggleAction *act, gpointer /*data*/) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool edit = gtk_toggle_action_get_active( act );
+ prefs->setBool("/tools/nodes/edit_masks", edit);
}
/* is called when the node selection is modified */
UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) );
SPUnit const *unit = tracker->getActiveUnit();
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor && shape_editor->has_nodepath()) {
- Inkscape::NodePath::Path *nodepath = shape_editor->get_nodepath();
- int n_selected = 0;
- if (nodepath) {
- n_selected = nodepath->numSelected();
- }
-
- if (n_selected == 0) {
- gtk_action_set_sensitive(xact, FALSE);
- gtk_action_set_sensitive(yact, FALSE);
- } else {
- gtk_action_set_sensitive(xact, TRUE);
- gtk_action_set_sensitive(yact, TRUE);
- Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
- Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
-
- if (n_selected == 1) {
- Geom::Point sel_node = nodepath->singleSelectedCoords();
- if (oldx != sel_node[Geom::X] || oldy != sel_node[Geom::Y]) {
- gtk_adjustment_set_value(xadj, sp_pixels_get_units(sel_node[Geom::X], *unit));
- gtk_adjustment_set_value(yadj, sp_pixels_get_units(sel_node[Geom::Y], *unit));
- }
- } else {
- boost::optional<Geom::Coord> x = sp_node_selected_common_coord(nodepath, Geom::X);
- boost::optional<Geom::Coord> y = sp_node_selected_common_coord(nodepath, Geom::Y);
- if ((x && ((*x) != oldx)) || (y && ((*y) != oldy))) {
- /* Note: Currently x and y will always have a value, even if the coordinates of the
- selected nodes don't coincide (in this case we use the coordinates of the center
- of the bounding box). So the entries are never set to zero. */
- // FIXME: Maybe we should clear the entry if several nodes are selected
- // instead of providing a kind of average value
- gtk_adjustment_set_value(xadj, sp_pixels_get_units(x ? (*x) : 0.0, *unit));
- gtk_adjustment_set_value(yadj, sp_pixels_get_units(y ? (*y) : 0.0, *unit));
- }
- }
- }
- } else {
- // no shape-editor or nodepath yet (when we just switched to the tool); coord entries must be inactive
+ InkNodeTool *nt = get_node_tool();
+ if (!nt || nt->_selected_nodes->empty()) {
+ // no path selected
gtk_action_set_sensitive(xact, FALSE);
gtk_action_set_sensitive(yact, FALSE);
+ } else {
+ gtk_action_set_sensitive(xact, TRUE);
+ gtk_action_set_sensitive(yact, TRUE);
+ Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
+ Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
+ Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint();
+
+ if (oldx != mid[Geom::X])
+ gtk_adjustment_set_value(xadj, sp_pixels_get_units(mid[Geom::X], *unit));
+ if (oldy != mid[Geom::Y])
+ gtk_adjustment_set_value(yadj, sp_pixels_get_units(mid[Geom::Y], *unit));
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
static void
-sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name)
+sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::Dim2 d)
{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1160,7 +1223,8 @@ sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_
SPUnit const *unit = tracker->getActiveUnit();
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- prefs->setDouble(Glib::ustring("/tools/nodes/") + value_name, sp_units_get_pixels(adj->value, *unit));
+ prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
+ sp_units_get_pixels(adj->value, *unit));
}
// quit if run by the attr_changed listener
@@ -1171,15 +1235,13 @@ sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
- ShapeEditor *shape_editor = get_current_shape_editor();
- if (shape_editor && shape_editor->has_nodepath()) {
+ InkNodeTool *nt = get_node_tool();
+ if (nt && !nt->_selected_nodes->empty()) {
double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit);
- if (!strcmp(value_name, "x")) {
- sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, Geom::X);
- }
- if (!strcmp(value_name, "y")) {
- sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, Geom::Y);
- }
+ double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d];
+ Geom::Point delta(0,0);
+ delta[d] = val - oldval;
+ nt->_multipath->move(delta);
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
@@ -1188,13 +1250,13 @@ sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_
static void
sp_node_path_x_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_node_path_value_changed(adj, tbl, "x");
+ sp_node_path_value_changed(adj, tbl, Geom::X);
}
static void
sp_node_path_y_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_node_path_value_changed(adj, tbl, "y");
+ sp_node_path_value_changed(adj, tbl, Geom::Y);
}
void
gtk_action_set_sensitive(w, FALSE);
}
}
-
- {
- GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "nodes_clippathedit" ) );
- SPItem *item = selection->singleItem();
- if (item && item->clip_ref && item->clip_ref->getObject()) {
- gtk_action_set_sensitive(w, TRUE);
- } else {
- gtk_action_set_sensitive(w, FALSE);
- }
- }
-
- {
- GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "nodes_maskedit" ) );
- SPItem *item = selection->singleItem();
- if (item && item->mask_ref && item->mask_ref->getObject()) {
- gtk_action_set_sensitive(w, TRUE);
- } else {
- gtk_action_set_sensitive(w, FALSE);
- }
- }
}
void
@@ -1254,13 +1296,13 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
g_object_set_data( holder, "tracker", tracker );
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
InkAction* inky = ink_action_new( "NodeInsertAction",
_("Insert node"),
_("Insert new nodes into selected segments"),
- "node_insert",
+ INKSCAPE_ICON_NODE_ADD,
secondarySize );
g_object_set( inky, "short_label", _("Insert"), NULL );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add), 0 );
@@ -1271,7 +1313,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeDeleteAction",
_("Delete node"),
_("Delete selected nodes"),
- "node_delete",
+ INKSCAPE_ICON_NODE_DELETE,
secondarySize );
g_object_set( inky, "short_label", _("Delete"), NULL );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete), 0 );
@@ -1280,9 +1322,9 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
InkAction* inky = ink_action_new( "NodeJoinAction",
- _("Join endnodes"),
- _("Join selected endnodes"),
- "node_join",
+ _("Join nodes"),
+ _("Join selected nodes"),
+ INKSCAPE_ICON_NODE_JOIN,
secondarySize );
g_object_set( inky, "short_label", _("Join"), NULL );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join), 0 );
@@ -1293,7 +1335,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeBreakAction",
_("Break nodes"),
_("Break path at selected nodes"),
- "node_break",
+ INKSCAPE_ICON_NODE_BREAK,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_break), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1304,7 +1346,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeJoinSegmentAction",
_("Join with segment"),
_("Join selected endnodes with a new segment"),
- "node_join_segment",
+ INKSCAPE_ICON_NODE_JOIN_SEGMENT,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join_segment), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1314,7 +1356,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeDeleteSegmentAction",
_("Delete segment"),
_("Delete segment between two non-endpoint nodes"),
- "node_delete_segment",
+ INKSCAPE_ICON_NODE_DELETE_SEGMENT,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete_segment), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1324,7 +1366,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeCuspAction",
_("Node Cusp"),
_("Make selected nodes corner"),
- "node_cusp",
+ INKSCAPE_ICON_NODE_TYPE_CUSP,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_cusp), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1334,7 +1376,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeSmoothAction",
_("Node Smooth"),
_("Make selected nodes smooth"),
- "node_smooth",
+ INKSCAPE_ICON_NODE_TYPE_SMOOTH,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_smooth), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1344,7 +1386,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeSymmetricAction",
_("Node Symmetric"),
_("Make selected nodes symmetric"),
- "node_symmetric",
+ INKSCAPE_ICON_NODE_TYPE_SYMMETRIC,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_symmetrical), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1354,7 +1396,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeAutoAction",
_("Node Auto"),
_("Make selected nodes auto-smooth"),
- "node_auto",
+ INKSCAPE_ICON_NODE_TYPE_AUTO_SMOOTH,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_auto), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1364,7 +1406,7 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeLineAction",
_("Node Line"),
_("Make selected segments lines"),
- "node_line",
+ INKSCAPE_ICON_NODE_SEGMENT_LINE,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_toline), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -1374,18 +1416,29 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "NodeCurveAction",
_("Node Curve"),
_("Make selected segments curves"),
- "node_curve",
+ INKSCAPE_ICON_NODE_SEGMENT_CURVE,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_tocurve), 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
}
+ {
+ InkToggleAction* act = ink_toggle_action_new( "NodesShowTransformHandlesAction",
+ _("Show Transform Handles"),
+ _("Show node transformation handles"),
+ "node-transform",
+ secondarySize );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_transform_handles), desktop );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_transform_handles", false) );
+ }
+
{
InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction",
_("Show Handles"),
_("Show the Bezier handles of selected nodes"),
- "nodes_show_handles",
- Inkscape::ICON_SIZE_DECORATION );
+ INKSCAPE_ICON_SHOW_NODE_HANDLES,
+ secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_handles), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_handles", true) );
@@ -1395,44 +1448,44 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath",
_("Show Outline"),
_("Show the outline of the path"),
- "nodes_show_helperpath",
- Inkscape::ICON_SIZE_DECORATION );
+ INKSCAPE_ICON_SHOW_PATH_OUTLINE,
+ secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_helperpath), desktop );
- gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_helperpath", false) );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_outline", false) );
}
{
InkAction* inky = ink_action_new( "EditNextLPEParameterAction",
_("Next path effect parameter"),
_("Show next path effect parameter for editing"),
- "edit_next_parameter",
- Inkscape::ICON_SIZE_DECORATION );
+ INKSCAPE_ICON_PATH_EFFECT_PARAMETER_NEXT,
+ secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
g_object_set_data( holder, "nodes_lpeedit", inky);
}
{
- InkAction* inky = ink_action_new( "ObjectEditClipPathAction",
- _("Edit clipping path"),
- _("Edit the clipping path of the object"),
- "nodeedit-clippath",
- Inkscape::ICON_SIZE_DECORATION );
- g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_clippath), desktop );
+ InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction",
+ _("Edit clipping paths"),
+ _("Show editing controls for clipping paths of selected objects"),
+ INKSCAPE_ICON_PATH_CLIP_EDIT,
+ secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
- g_object_set_data( holder, "nodes_clippathedit", inky);
+ g_signal_connect_after( G_OBJECT(inky), "toggled", G_CALLBACK(toggle_edit_clip), desktop );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(inky), prefs->getBool("/tools/nodes/edit_clipping_paths") );
}
{
- InkAction* inky = ink_action_new( "ObjectEditMaskPathAction",
- _("Edit mask path"),
- _("Edit the mask of the object"),
- "nodeedit-mask",
- Inkscape::ICON_SIZE_DECORATION );
- g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_maskpath), desktop );
+ InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction",
+ _("Edit masks"),
+ _("Show editing controls for masks of selected objects"),
+ INKSCAPE_ICON_PATH_MASK_EDIT,
+ secondarySize );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
- g_object_set_data( holder, "nodes_maskedit", inky);
+ g_signal_connect_after( G_OBJECT(inky), "toggled", G_CALLBACK(toggle_edit_mask), desktop );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(inky), prefs->getBool("/tools/nodes/edit_masks") );
}
/* X coord of selected node(s) */
@@ -1513,43 +1566,41 @@ static void sp_zoom_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* /*mainA
// no custom GtkAction setup needed
} // end of sp_zoom_toolbox_prep()
-void
-sp_tool_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop)
+void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop)
{
- toolbox_set_desktop(toolbox,
- desktop,
- setup_tool_toolbox,
- update_tool_toolbox,
- static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox),
- "event_context_connection")));
-}
+ sigc::connection *conn = static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox),
+ "event_context_connection"));
+ BarId id = static_cast<BarId>( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toolbox), BAR_ID_KEY)) );
-void
-sp_aux_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop)
-{
- toolbox_set_desktop(gtk_bin_get_child(GTK_BIN(toolbox)),
- desktop,
- setup_aux_toolbox,
- update_aux_toolbox,
- static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox),
- "event_context_connection")));
-}
+ SetupFunction setup_func = 0;
+ UpdateFunction update_func = 0;
-void
-sp_commands_toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop)
-{
- toolbox_set_desktop(toolbox,
- desktop,
- setup_commands_toolbox,
- update_commands_toolbox,
- static_cast<sigc::connection*>(g_object_get_data(G_OBJECT(toolbox),
- "event_context_connection")));
-}
+ switch (id) {
+ case BAR_TOOL:
+ setup_func = setup_tool_toolbox;
+ update_func = update_tool_toolbox;
+ break;
+
+ case BAR_AUX:
+ toolbox = gtk_bin_get_child(GTK_BIN(toolbox));
+ setup_func = setup_aux_toolbox;
+ update_func = update_aux_toolbox;
+ break;
+
+ case BAR_COMMANDS:
+ setup_func = setup_commands_toolbox;
+ update_func = update_commands_toolbox;
+ break;
+
+ case BAR_SNAP:
+ setup_func = setup_snap_toolbox;
+ update_func = updateSnapToolbox;
+ break;
+ default:
+ g_warning("Unexpected toolbox id encountered.");
+ }
-static void
-toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_func, UpdateFunction update_func, sigc::connection *conn)
-{
gpointer ptr = g_object_get_data(G_OBJECT(toolbox), "desktop");
SPDesktop *old_desktop = static_cast<SPDesktop*>(ptr);
@@ -1565,18 +1616,155 @@ toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_
g_object_set_data(G_OBJECT(toolbox), "desktop", (gpointer)desktop);
- if (desktop) {
+ if (desktop && setup_func && update_func) {
gtk_widget_set_sensitive(toolbox, TRUE);
setup_func(toolbox, desktop);
update_func(desktop, desktop->event_context, toolbox);
- *conn = desktop->connectEventContextChanged
- (sigc::bind (sigc::ptr_fun(update_func), toolbox));
+ *conn = desktop->connectEventContextChanged(sigc::bind (sigc::ptr_fun(update_func), toolbox));
} else {
gtk_widget_set_sensitive(toolbox, FALSE);
}
-} // end of toolbox_set_desktop()
+} // end of sp_toolbox_set_desktop()
+
+
+static void setupToolboxCommon( GtkWidget *toolbox,
+ SPDesktop *desktop,
+ gchar const *descr,
+ gchar const* toolbarName,
+ gchar const* sizePref )
+{
+ Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ GtkUIManager* mgr = gtk_ui_manager_new();
+ GError* errVal = 0;
+
+ GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
+
+ gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
+ gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
+
+ GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName );
+ if ( prefs->getBool("/toolbox/icononly", true) ) {
+ gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
+ }
+
+ Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize(sizePref);
+ gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
+
+ if (GTK_IS_HANDLE_BOX(toolbox)) {
+ // g_message("GRABBING ORIENTATION [%s]", toolbarName);
+ GtkPositionType pos = gtk_handle_box_get_handle_position(GTK_HANDLE_BOX(toolbox));
+ orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
+ } else {
+ GtkPositionType pos = static_cast<GtkPositionType>(GPOINTER_TO_INT(g_object_get_data( G_OBJECT(toolbox), HANDLE_POS_MARK )));
+ orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
+ }
+ gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), orientation);
+ gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
+
+ g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
+
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
+ if ( child ) {
+ gtk_container_remove( GTK_CONTAINER(toolbox), child );
+ }
+
+ gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
+}
+
+#define noDUMP_DETAILS 1
+
+void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientation)
+{
+#if DUMP_DETAILS
+ g_message("Set orientation for %p to be %d", toolbox, orientation);
+ GType type = GTK_WIDGET_TYPE(toolbox);
+ g_message(" [%s]", g_type_name(type));
+ g_message(" %p", g_object_get_data(G_OBJECT(toolbox), BAR_ID_KEY));
+#endif
+
+ GtkPositionType pos = (orientation == GTK_ORIENTATION_HORIZONTAL) ? GTK_POS_LEFT : GTK_POS_TOP;
+ GtkHandleBox* handleBox = 0;
+
+ if (GTK_IS_BIN(toolbox)) {
+#if DUMP_DETAILS
+ g_message(" is a BIN");
+#endif // DUMP_DETAILS
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
+ if (child) {
+#if DUMP_DETAILS
+ GType type2 = GTK_WIDGET_TYPE(child);
+ g_message(" child [%s]", g_type_name(type2));
+#endif // DUMP_DETAILS
+
+ if (GTK_IS_BOX(child)) {
+#if DUMP_DETAILS
+ g_message(" is a BOX");
+#endif // DUMP_DETAILS
+
+ GList* children = gtk_container_get_children(GTK_CONTAINER(child));
+ if (children) {
+ for (GList* curr = children; curr; curr = g_list_next(curr)) {
+ GtkWidget* child2 = GTK_WIDGET(curr->data);
+#if DUMP_DETAILS
+ GType type3 = GTK_WIDGET_TYPE(child2);
+ g_message(" child2 [%s]", g_type_name(type3));
+#endif // DUMP_DETAILS
+
+ if (GTK_IS_CONTAINER(child2)) {
+ GList* children2 = gtk_container_get_children(GTK_CONTAINER(child2));
+ if (children2) {
+ for (GList* curr2 = children2; curr2; curr2 = g_list_next(curr2)) {
+ GtkWidget* child3 = GTK_WIDGET(curr2->data);
+#if DUMP_DETAILS
+ GType type4 = GTK_WIDGET_TYPE(child3);
+ g_message(" child3 [%s]", g_type_name(type4));
+#endif // DUMP_DETAILS
+ if (GTK_IS_TOOLBAR(child3)) {
+ GtkToolbar* childBar = GTK_TOOLBAR(child3);
+ gtk_toolbar_set_orientation(childBar, orientation);
+ }
+ }
+ g_list_free(children2);
+ }
+ }
+
+
+ if (GTK_IS_TOOLBAR(child2)) {
+ GtkToolbar* childBar = GTK_TOOLBAR(child2);
+ gtk_toolbar_set_orientation(childBar, orientation);
+ if (GTK_IS_HANDLE_BOX(toolbox)) {
+ handleBox = GTK_HANDLE_BOX(toolbox);
+ }
+ } else {
+ g_message("need to add dynamic switch");
+ }
+ }
+ g_list_free(children);
+ } else {
+ // The call is being made before the toolbox proper has been setup.
+ if (GTK_IS_HANDLE_BOX(toolbox)) {
+ handleBox = GTK_HANDLE_BOX(toolbox);
+ } else {
+ g_object_set_data(G_OBJECT(toolbox), HANDLE_POS_MARK, GINT_TO_POINTER(pos));
+ }
+ }
+ } else if (GTK_IS_TOOLBAR(child)) {
+ GtkToolbar* toolbar = GTK_TOOLBAR(child);
+ gtk_toolbar_set_orientation( toolbar, orientation );
+ if (GTK_IS_HANDLE_BOX(toolbox)) {
+ handleBox = GTK_HANDLE_BOX(toolbox);
+ }
+ }
+ }
+ }
+ if (handleBox) {
+ gtk_handle_box_set_handle_position(handleBox, pos);
+ }
+}
static void
setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
" <toolitem action='ToolSelector' />"
" <toolitem action='ToolNode' />"
" <toolitem action='ToolTweak' />"
+ " <toolitem action='ToolSpray' />"
" <toolitem action='ToolZoom' />"
" <toolitem action='ToolRect' />"
" <toolitem action='Tool3DBox' />"
" <toolitem action='ToolDropper' />"
" </toolbar>"
"</ui>";
- Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
- GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
-
- GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/ToolToolbar" );
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
- }
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
-
- gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_VERTICAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
-
- g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
-
- GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
- if ( child ) {
- gtk_container_remove( GTK_CONTAINER(toolbox), child );
- }
- gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
-// Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/ToolToolbar",
+ "/toolbox/tools/small");
}
-
static void
update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget */*toolbox*/ )
{
} else {
GtkWidget *sub_toolbox = 0;
- if (aux_toolboxes[i].create_func == NULL)
+ if (aux_toolboxes[i].create_func == NULL) {
sub_toolbox = sp_empty_toolbox_new(desktop);
- else {
+ } else {
sub_toolbox = aux_toolboxes[i].create_func(desktop);
}
g_free( tmp );
tmp = 0;
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
if ( prefs->getBool( "/toolbox/icononly", true) ) {
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
+ Inkscape::IconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
+ gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
gtk_table_attach( GTK_TABLE(holder), toolBar, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0 );
" <separator />"
" <toolitem action='DialogFillStroke' />"
" <toolitem action='DialogText' />"
+ " <toolitem action='DialogLayers' />"
" <toolitem action='DialogXMLEditor' />"
" <toolitem action='DialogAlignDistribute' />"
" <separator />"
" <toolitem action='DialogPreferences' />"
" <toolitem action='DialogDocumentProperties' />"
+#if ENABLE_TASK_SUPPORT
+ " <separator />"
+ " <toolitem action='TaskSetAction' />"
+#endif // ENABLE_TASK_SUPPORT
" </toolbar>"
"</ui>";
- Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/CommandsToolbar",
+ "/toolbox/small" );
+}
- gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
+static void
+update_commands_toolbox(SPDesktop */*desktop*/, SPEventContext */*eventcontext*/, GtkWidget */*toolbox*/)
+{
+}
- GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/CommandsToolbar" );
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
+void toggle_snap_callback (GtkToggleAction *act, gpointer data) { //data points to the toolbox
+
+ if (g_object_get_data(G_OBJECT(data), "freeze" )) {
+ return;
}
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
+ gpointer ptr = g_object_get_data(G_OBJECT(data), "desktop");
+ g_assert(ptr != NULL);
- gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_HORIZONTAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
+ SPDesktop *dt = reinterpret_cast<SPDesktop*>(ptr);
+ SPNamedView *nv = sp_desktop_namedview(dt);
+ SPDocument *doc = SP_OBJECT_DOCUMENT(nv);
+ if (dt == NULL || nv == NULL) {
+ g_warning("No desktop or namedview specified (in toggle_snap_callback)!");
+ return;
+ }
- g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(nv);
- GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
- if ( child ) {
- gtk_container_remove( GTK_CONTAINER(toolbox), child );
+ if (repr == NULL) {
+ g_warning("This namedview doesn't have a xml representation attached!");
+ return;
}
- gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
-}
+ bool saved = sp_document_get_undo_sensitive(doc);
+ sp_document_set_undo_sensitive(doc, false);
-static void
-update_commands_toolbox(SPDesktop */*desktop*/, SPEventContext */*eventcontext*/, GtkWidget */*toolbox*/)
+ bool v = false;
+ SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE"));
+
+ switch (attr) {
+ case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
+ dt->toggleSnapGlobal();
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_BBOX:
+ v = nv->snap_manager.snapprefs.getSnapModeBBox();
+ sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v);
+ break;
+ case SP_ATTR_INKSCAPE_BBOX_PATHS:
+ v = nv->snap_manager.snapprefs.getSnapToBBoxPath();
+ sp_repr_set_boolean(repr, "inkscape:bbox-paths", !v);
+ break;
+ case SP_ATTR_INKSCAPE_BBOX_NODES:
+ v = nv->snap_manager.snapprefs.getSnapToBBoxNode();
+ sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_NODES:
+ v = nv->snap_manager.snapprefs.getSnapModeNode();
+ sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v);
+ break;
+ case SP_ATTR_INKSCAPE_OBJECT_PATHS:
+ v = nv->snap_manager.snapprefs.getSnapToItemPath();
+ sp_repr_set_boolean(repr, "inkscape:object-paths", !v);
+ break;
+ case SP_ATTR_INKSCAPE_OBJECT_NODES:
+ v = nv->snap_manager.snapprefs.getSnapToItemNode();
+ sp_repr_set_boolean(repr, "inkscape:object-nodes", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES:
+ v = nv->snap_manager.snapprefs.getSnapSmoothNodes();
+ sp_repr_set_boolean(repr, "inkscape:snap-smooth-nodes", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS:
+ v = nv->snap_manager.snapprefs.getSnapIntersectionCS();
+ sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_CENTER:
+ v = nv->snap_manager.snapprefs.getIncludeItemCenter();
+ sp_repr_set_boolean(repr, "inkscape:snap-center", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_GRIDS:
+ v = nv->snap_manager.snapprefs.getSnapToGrids();
+ sp_repr_set_boolean(repr, "inkscape:snap-grids", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES:
+ v = nv->snap_manager.snapprefs.getSnapToGuides();
+ sp_repr_set_boolean(repr, "inkscape:snap-to-guides", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_PAGE:
+ v = nv->snap_manager.snapprefs.getSnapToPageBorder();
+ sp_repr_set_boolean(repr, "inkscape:snap-page", !v);
+ break;
+ /*case SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE:
+ v = nv->snap_manager.snapprefs.getSnapIntersectionGG();
+ sp_repr_set_boolean(repr, "inkscape:snap-intersection-grid-guide", !v);
+ break;*/
+ case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS:
+ v = nv->snap_manager.snapprefs.getSnapLineMidpoints();
+ sp_repr_set_boolean(repr, "inkscape:snap-midpoints", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS:
+ v = nv->snap_manager.snapprefs.getSnapObjectMidpoints();
+ sp_repr_set_boolean(repr, "inkscape:snap-object-midpoints", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS:
+ v = nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints();
+ sp_repr_set_boolean(repr, "inkscape:snap-bbox-edge-midpoints", !v);
+ break;
+ case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS:
+ v = nv->snap_manager.snapprefs.getSnapBBoxMidpoints();
+ sp_repr_set_boolean(repr, "inkscape:snap-bbox-midpoints", !v);
+ break;
+ default:
+ g_warning("toggle_snap_callback has been called with an ID for which no action has been defined");
+ break;
+ }
+
+ // The snapping preferences are stored in the document, and therefore toggling makes the document dirty
+ doc->setModifiedSinceSave();
+
+ sp_document_set_undo_sensitive(doc, saved);
+}
+
+void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
+{
+ Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions(desktop);
+
+ gchar const * descr =
+ "<ui>"
+ " <toolbar name='SnapToolbar'>"
+ " <toolitem action='ToggleSnapGlobal' />"
+ " <separator />"
+ " <toolitem action='ToggleSnapFromBBoxCorner' />"
+ " <toolitem action='ToggleSnapToBBoxPath' />"
+ " <toolitem action='ToggleSnapToBBoxNode' />"
+ " <toolitem action='ToggleSnapToFromBBoxEdgeMidpoints' />"
+ " <toolitem action='ToggleSnapToFromBBoxCenters' />"
+ " <separator />"
+ " <toolitem action='ToggleSnapFromNode' />"
+ " <toolitem action='ToggleSnapToItemPath' />"
+ " <toolitem action='ToggleSnapToPathIntersections' />"
+ " <toolitem action='ToggleSnapToItemNode' />"
+ " <toolitem action='ToggleSnapToSmoothNodes' />"
+ " <toolitem action='ToggleSnapToFromLineMidpoints' />"
+ " <toolitem action='ToggleSnapToFromObjectCenters' />"
+ " <toolitem action='ToggleSnapToFromRotationCenter' />"
+ " <separator />"
+ " <toolitem action='ToggleSnapToPageBorder' />"
+ " <toolitem action='ToggleSnapToGrids' />"
+ " <toolitem action='ToggleSnapToGuides' />"
+ //" <toolitem action='ToggleSnapToGridGuideIntersections' />"
+ " </toolbar>"
+ "</ui>";
+
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapGlobal",
+ _("Snap"), _("Enable snapping"), INKSCAPE_ICON_SNAP, secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_GLOBAL);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromBBoxCorner",
+ _("Bounding box"), _("Snap bounding box corners"), INKSCAPE_ICON_SNAP_BOUNDING_BOX,
+ secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxPath",
+ _("Bounding box edges"), _("Snap to edges of a bounding box"),
+ INKSCAPE_ICON_SNAP_BOUNDING_BOX_EDGES, secondarySize, SP_ATTR_INKSCAPE_BBOX_PATHS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToBBoxNode",
+ _("Bounding box corners"), _("Snap to bounding box corners"),
+ INKSCAPE_ICON_SNAP_BOUNDING_BOX_CORNERS, secondarySize, SP_ATTR_INKSCAPE_BBOX_NODES);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxEdgeMidpoints",
+ _("BBox Edge Midpoints"), _("Snap from and to midpoints of bounding box edges"),
+ INKSCAPE_ICON_SNAP_BOUNDING_BOX_MIDPOINTS, secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromBBoxCenters",
+ _("BBox Centers"), _("Snapping from and to centers of bounding boxes"),
+ INKSCAPE_ICON_SNAP_BOUNDING_BOX_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapFromNode",
+ _("Nodes"), _("Snap nodes or handles"), INKSCAPE_ICON_SNAP_NODES, secondarySize, SP_ATTR_INKSCAPE_SNAP_NODES);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemPath",
+ _("Paths"), _("Snap to paths"), INKSCAPE_ICON_SNAP_NODES_PATH, secondarySize,
+ SP_ATTR_INKSCAPE_OBJECT_PATHS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPathIntersections",
+ _("Path intersections"), _("Snap to path intersections"),
+ INKSCAPE_ICON_SNAP_NODES_INTERSECTION, secondarySize, SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToItemNode",
+ _("To nodes"), _("Snap to cusp nodes"), INKSCAPE_ICON_SNAP_NODES_CUSP, secondarySize,
+ SP_ATTR_INKSCAPE_OBJECT_NODES);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToSmoothNodes",
+ _("Smooth nodes"), _("Snap to smooth nodes"), INKSCAPE_ICON_SNAP_NODES_SMOOTH,
+ secondarySize, SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromLineMidpoints",
+ _("Line Midpoints"), _("Snap from and to midpoints of line segments"),
+ INKSCAPE_ICON_SNAP_NODES_MIDPOINT, secondarySize, SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINTS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromObjectCenters",
+ _("Object Centers"), _("Snap from and to centers of objects"),
+ INKSCAPE_ICON_SNAP_NODES_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToFromRotationCenter",
+ _("Rotation Centers"), _("Snap from and to an item's rotation center"),
+ INKSCAPE_ICON_SNAP_NODES_ROTATION_CENTER, secondarySize, SP_ATTR_INKSCAPE_SNAP_CENTER);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToPageBorder",
+ _("Page border"), _("Snap to the page border"), INKSCAPE_ICON_SNAP_PAGE,
+ secondarySize, SP_ATTR_INKSCAPE_SNAP_PAGE);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGrids",
+ _("Grids"), _("Snap to grids"), INKSCAPE_ICON_GRID_RECTANGULAR, secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_GRIDS);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ {
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGuides",
+ _("Guides"), _("Snap to guides"), INKSCAPE_ICON_GUIDES, secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_TO_GUIDES);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }
+
+ /*{
+ InkToggleAction* act = ink_toggle_action_new("ToggleSnapToGridGuideIntersections",
+ _("Grid/guide intersections"), _("Snap to intersections of a grid with a guide"),
+ INKSCAPE_ICON_SNAP_GRID_GUIDE_INTERSECTIONS, secondarySize,
+ SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE);
+
+ gtk_action_group_add_action( mainActions->gobj(), GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
+ }*/
+
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/SnapToolbar",
+ "/toolbox/secondary" );
+}
+
+Glib::ustring ToolboxFactory::getToolboxName(GtkWidget* toolbox)
{
+ Glib::ustring name;
+ BarId id = static_cast<BarId>( GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toolbox), BAR_ID_KEY)) );
+ switch(id) {
+ case BAR_TOOL:
+ name = "ToolToolbar";
+ break;
+ case BAR_AUX:
+ name = "AuxToolbar";
+ break;
+ case BAR_COMMANDS:
+ name = "CommandsToolbar";
+ break;
+ case BAR_SNAP:
+ name = "SnapToolbar";
+ break;
+ }
+
+ return name;
}
-void show_aux_toolbox(GtkWidget *toolbox_toplevel)
+void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext */*eventcontext*/, GtkWidget *toolbox)
+{
+ g_assert(desktop != NULL);
+ g_assert(toolbox != NULL);
+
+ SPNamedView *nv = sp_desktop_namedview(desktop);
+ if (nv == NULL) {
+ g_warning("Namedview cannot be retrieved (in updateSnapToolbox)!");
+ return;
+ }
+
+ Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions(desktop);
+
+ Glib::RefPtr<Gtk::Action> act1 = mainActions->get_action("ToggleSnapGlobal");
+ Glib::RefPtr<Gtk::Action> act2 = mainActions->get_action("ToggleSnapFromBBoxCorner");
+ Glib::RefPtr<Gtk::Action> act3 = mainActions->get_action("ToggleSnapToBBoxPath");
+ Glib::RefPtr<Gtk::Action> act4 = mainActions->get_action("ToggleSnapToBBoxNode");
+ Glib::RefPtr<Gtk::Action> act4b = mainActions->get_action("ToggleSnapToFromBBoxEdgeMidpoints");
+ Glib::RefPtr<Gtk::Action> act4c = mainActions->get_action("ToggleSnapToFromBBoxCenters");
+ Glib::RefPtr<Gtk::Action> act5 = mainActions->get_action("ToggleSnapFromNode");
+ Glib::RefPtr<Gtk::Action> act6 = mainActions->get_action("ToggleSnapToItemPath");
+ Glib::RefPtr<Gtk::Action> act6b = mainActions->get_action("ToggleSnapToPathIntersections");
+ Glib::RefPtr<Gtk::Action> act7 = mainActions->get_action("ToggleSnapToItemNode");
+ Glib::RefPtr<Gtk::Action> act8 = mainActions->get_action("ToggleSnapToSmoothNodes");
+ Glib::RefPtr<Gtk::Action> act9 = mainActions->get_action("ToggleSnapToFromLineMidpoints");
+ Glib::RefPtr<Gtk::Action> act10 = mainActions->get_action("ToggleSnapToFromObjectCenters");
+ Glib::RefPtr<Gtk::Action> act11 = mainActions->get_action("ToggleSnapToFromRotationCenter");
+ Glib::RefPtr<Gtk::Action> act12 = mainActions->get_action("ToggleSnapToPageBorder");
+ //Glib::RefPtr<Gtk::Action> act13 = mainActions->get_action("ToggleSnapToGridGuideIntersections");
+ Glib::RefPtr<Gtk::Action> act14 = mainActions->get_action("ToggleSnapToGrids");
+ Glib::RefPtr<Gtk::Action> act15 = mainActions->get_action("ToggleSnapToGuides");
+
+
+ if (!act1) {
+ return; // The snap actions haven't been defined yet (might be the case during startup)
+ }
+
+ // The ..._set_active calls below will toggle the buttons, but this shouldn't lead to
+ // changes in our document because we're only updating the UI;
+ // Setting the "freeze" parameter to true will block the code in toggle_snap_callback()
+ g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(TRUE));
+
+ bool const c1 = nv->snap_manager.snapprefs.getSnapEnabledGlobally();
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act1->gobj()), c1);
+
+ bool const c2 = nv->snap_manager.snapprefs.getSnapModeBBox();
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2);
+ gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1);
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act3->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxPath());
+ gtk_action_set_sensitive(GTK_ACTION(act3->gobj()), c1 && c2);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4->gobj()), nv->snap_manager.snapprefs.getSnapToBBoxNode());
+ gtk_action_set_sensitive(GTK_ACTION(act4->gobj()), c1 && c2);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4b->gobj()), nv->snap_manager.snapprefs.getSnapBBoxEdgeMidpoints());
+ gtk_action_set_sensitive(GTK_ACTION(act4b->gobj()), c1 && c2);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.getSnapBBoxMidpoints());
+ gtk_action_set_sensitive(GTK_ACTION(act4c->gobj()), c1 && c2);
+
+ bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode();
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3);
+ gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1);
+
+ bool const c4 = nv->snap_manager.snapprefs.getSnapToItemPath();
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4);
+ gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionCS());
+ gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.getSnapToItemNode());
+ gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.getSnapSmoothNodes());
+ gtk_action_set_sensitive(GTK_ACTION(act8->gobj()), c1 && c3);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.getSnapLineMidpoints());
+ gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), nv->snap_manager.snapprefs.getSnapObjectMidpoints());
+ gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1 && c3);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act11->gobj()), nv->snap_manager.snapprefs.getIncludeItemCenter());
+ gtk_action_set_sensitive(GTK_ACTION(act11->gobj()), c1 && c3);
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act12->gobj()), nv->snap_manager.snapprefs.getSnapToPageBorder());
+ gtk_action_set_sensitive(GTK_ACTION(act12->gobj()), c1);
+ //gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act13->gobj()), nv->snap_manager.snapprefs.getSnapIntersectionGG());
+ //gtk_action_set_sensitive(GTK_ACTION(act13->gobj()), c1);
+
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act14->gobj()), nv->snap_manager.snapprefs.getSnapToGrids());
+ gtk_action_set_sensitive(GTK_ACTION(act14->gobj()), c1);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act15->gobj()), nv->snap_manager.snapprefs.getSnapToGuides());
+ gtk_action_set_sensitive(GTK_ACTION(act15->gobj()), c1);
+
+
+ g_object_set_data(G_OBJECT(toolbox), "freeze", GINT_TO_POINTER(FALSE)); // unfreeze (see above)
+}
+
+void ToolboxFactory::showAuxToolbox(GtkWidget *toolbox_toplevel)
{
gtk_widget_show(toolbox_toplevel);
GtkWidget *toolbox = gtk_bin_get_child(GTK_BIN(toolbox_toplevel));
gtk_widget_show_all(shown_toolbox);
}
-static GtkWidget *
-sp_empty_toolbox_new(SPDesktop *desktop)
+static GtkWidget *sp_empty_toolbox_new(SPDesktop *desktop)
{
GtkWidget *tbl = gtk_toolbar_new();
gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
@@ -1912,8 +2485,10 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" );
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("/tools/shapes/star/proportion", adj->value);
+ if (!IS_NAN(adj->value)) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/tools/shapes/star/proportion", adj->value);
+ }
}
// quit if run by the attr_changed listener
static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "StarStateAction", _("<b>New:</b>"), "", 0 );
@@ -2251,14 +2826,14 @@ static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
gtk_list_store_set( model, &iter,
0, _("Polygon"),
1, _("Regular polygon (with one handle) instead of a star"),
- 2, "star_flat",
+ 2, INKSCAPE_ICON_DRAW_POLYGON,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Star"),
1, _("Star instead of a regular polygon (with one handle)"),
- 2, "star_angled",
+ 2, INKSCAPE_ICON_DRAW_STAR,
-1 );
EgeSelectOneAction* act = ege_select_one_action_new( "FlatAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
@@ -2597,7 +3172,7 @@ sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "RectStateAction", _("<b>New:</b>"), "", 0 );
@@ -2688,7 +3263,7 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
InkAction* inky = ink_action_new( "RectResetAction",
_("Not rounded"),
_("Make corners sharp"),
- "squared_corner",
+ INKSCAPE_ICON_RECTANGLE_MAKE_CORNERS_SHARP,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_rtb_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
// TODO: Take all selected perspectives into account but don't touch the state button if not all of them
// have the same state (otherwise a call to box3d_vp_z_state_changed() is triggered and the states
// are reset).
- bool is_infinite = !persp3d_VP_is_finite(persp, axis);
+ bool is_infinite = !persp3d_VP_is_finite(persp->perspective_impl, axis);
if (is_infinite) {
gtk_toggle_action_set_active(tact, TRUE);
GtkAction *act = 0;
GtkToggleAction *tact = 0;
Persp3D *persp = persp3d_get_from_repr(persp_repr);
+ if (!persp) {
+ // Hmm, is it an error if this happens?
+ return;
+ }
{
adj = GTK_ADJUSTMENT(gtk_object_get_data(GTK_OBJECT(tbl), "box3d_angle_x"));
act = GTK_ACTION(g_object_get_data(G_OBJECT(tbl), "box3d_angle_x_action"));
sp_repr_synthesize_events(persp_repr, &box3d_persp_tb_repr_events, tbl);
}
- inkscape_active_document()->current_persp3d = persp3d_get_from_repr(persp_repr);
+ inkscape_active_document()->setCurrentPersp3D(persp3d_get_from_repr(persp_repr));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setString("/tools/shapes/3dbox/persp", persp_repr->attribute("id"));
@@ -2863,7 +3442,6 @@ box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis ax
// in turn, prevent listener from responding
g_object_set_data(dataKludge, "freeze", GINT_TO_POINTER(TRUE));
- //Persp3D *persp = document->current_persp3d;
std::list<Persp3D *> sel_persps = sp_desktop_selection(desktop)->perspList();
if (sel_persps.empty()) {
// this can happen when the document is created; we silently ignore it
@@ -2871,7 +3449,7 @@ box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis ax
}
Persp3D *persp = sel_persps.front();
- persp->tmat.set_infinite_direction (axis, adj->value);
+ persp->perspective_impl->tmat.set_infinite_direction (axis, adj->value);
SP_OBJECT(persp)->updateRepr();
// TODO: use the correct axis here, too
@@ -2934,7 +3512,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
SPDocument *document = sp_desktop_document (desktop);
- Persp3D *persp = document->current_persp3d;
+ Persp3DImpl *persp_impl = document->getCurrentPersp3DImpl();
EgeAdjustmentAction* box3d_angle_x = 0;
EgeAdjustmentAction* box3d_angle_y = 0;
@@ -2958,7 +3536,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
box3d_angle_x = eact;
}
- if (!persp3d_VP_is_finite(persp, Proj::X)) {
+ if (!persp_impl || !persp3d_VP_is_finite(persp_impl, Proj::X)) {
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
} else {
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -2971,7 +3549,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
// Translators: VP is short for 'vanishing point'
_("State of VP in X direction"),
_("Toggle VP in X direction between 'finite' and 'infinite' (=parallel)"),
- "toggle_vp_x",
+ INKSCAPE_ICON_PERSPECTIVE_PARALLEL,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_x_state_action", act );
@@ -2998,7 +3576,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
box3d_angle_y = eact;
}
- if (!persp3d_VP_is_finite(persp, Proj::Y)) {
+ if (!persp_impl || !persp3d_VP_is_finite(persp_impl, Proj::Y)) {
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
} else {
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -3010,7 +3588,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
// Translators: VP is short for 'vanishing point'
_("State of VP in Y direction"),
_("Toggle VP in Y direction between 'finite' and 'infinite' (=parallel)"),
- "toggle_vp_y",
+ INKSCAPE_ICON_PERSPECTIVE_PARALLEL,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_y_state_action", act );
@@ -3037,7 +3615,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
box3d_angle_z = eact;
}
- if (!persp3d_VP_is_finite(persp, Proj::Z)) {
+ if (!persp_impl || !persp3d_VP_is_finite(persp_impl, Proj::Z)) {
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
} else {
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -3049,7 +3627,7 @@ static void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
// Translators: VP is short for 'vanishing point'
_("State of VP in Z direction"),
_("Toggle VP in Z direction between 'finite' and 'infinite' (=parallel)"),
- "toggle_vp_z",
+ INKSCAPE_ICON_PERSPECTIVE_PARALLEL,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_object_set_data( holder, "box3d_vp_z_state_action", act );
@@ -3236,7 +3814,7 @@ sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl
static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
EgeOutputAction* act = ege_output_action_new( "SpiralStateAction", _("<b>New:</b>"), "", 0 );
@@ -3343,7 +3921,7 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint freehandMode = prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/freehand-mode" : "/tools/freehand/pen/freehand-mode" ), 0);
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
@@ -3353,14 +3931,14 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
gtk_list_store_set( model, &iter,
0, _("Bezier"),
1, _("Create regular Bezier path"),
- 2, "bezier_mode",
+ 2, INKSCAPE_ICON_PATH_MODE_BEZIER,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Spiro"),
1, _("Create Spiro path"),
- 2, "spiro_splines_mode",
+ 2, INKSCAPE_ICON_PATH_MODE_SPIRO,
-1 );
if (!tool_is_pencil) {
@@ -3368,21 +3946,21 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho
gtk_list_store_set( model, &iter,
0, _("Zigzag"),
1, _("Create a sequence of straight line segments"),
- 2, "polylines_mode",
+ 2, INKSCAPE_ICON_PATH_MODE_POLYLINE,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Paraxial"),
1, _("Create a sequence of paraxial line segments"),
- 2, "paraxial_lines_mode",
+ 2, INKSCAPE_ICON_PATH_MODE_POLYLINE_PARAXIAL,
-1 );
}
EgeSelectOneAction* act = ege_select_one_action_new(tool_is_pencil ?
"FreehandModeActionPencil" :
"FreehandModeActionPen",
- (_("Mode:")), ("Mode"), NULL, GTK_TREE_MODEL(model) );
+ (_("Mode:")), (_("Mode of new lines drawn by this tool")), NULL, GTK_TREE_MODEL(model) );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
ege_select_one_action_set_appearance( act, "full" );
@@ -3439,7 +4017,7 @@ freehand_add_advanced_shape_options(GtkActionGroup* mainActions, GObject* holder
items = 0;
EgeSelectOneAction* act1 = ege_select_one_action_new(
tool_is_pencil ? "SetPencilShapeAction" : "SetPenShapeAction",
- _("Shape:"), ("Shape"), NULL, GTK_TREE_MODEL(model));
+ _("Shape:"), (_("Shape of new paths drawn by this tool")), NULL, GTK_TREE_MODEL(model));
g_object_set( act1, "short_label", _("Shape:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
ege_select_one_action_set_active( act1, prefs->getInt(( tool_is_pencil ? "/tools/freehand/pencil/shape" : "/tools/freehand/pen/shape" ), 0) );
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
+/*
class PencilToleranceObserver : public Inkscape::Preferences::Observer {
public:
PencilToleranceObserver(Glib::ustring const &path, GObject *x) : Observer(path), _obj(x)
}
virtual ~PencilToleranceObserver() {
if (g_object_get_data(_obj, "prefobserver") == this) {
- g_object_set_data(_obj, "prefobserver", NULL);
+ g_object_set_data(_obj, "prefobserver", NULL);
}
}
virtual void notify(Inkscape::Preferences::Entry const &val) {
private:
GObject *_obj;
};
-
+*/
static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -3533,15 +4112,12 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
3.0,
GTK_WIDGET(desktop->canvas), NULL,
holder, TRUE, "altx-pencil",
- 1, 100.0, 0.5, 0,
+ 1, 100.0, 0.5, 1.0,
labels, values, G_N_ELEMENTS(labels),
sp_pencil_tb_tolerance_value_changed,
1, 2);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
-
- PencilToleranceObserver *obs =
- new PencilToleranceObserver("/tools/freehand/pencil/tolerance", G_OBJECT(holder));
}
/* advanced shape options */
static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
{
@@ -3650,7 +4226,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
_("Width"), _("Width:"), _("The width of the tweak area (relative to the visible canvas area)"),
"/tools/tweak/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-tweak",
- 1, 100, 1.0, 0.0,
+ 1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_tweak_width_value_changed, 0.01, 0, 100 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
@@ -3667,7 +4243,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
_("Force"), _("Force:"), _("The force of the tweak action"),
"/tools/tweak/force", 20,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-force",
- 1, 100, 1.0, 0.0,
+ 1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
sp_tweak_force_value_changed, 0.01, 0, 100 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
@@ -3684,91 +4260,91 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
gtk_list_store_set( model, &iter,
0, _("Move mode"),
1, _("Move objects in any direction"),
- 2, "tweak_move_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_PUSH,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Move in/out mode"),
1, _("Move objects towards cursor; with Shift from cursor"),
- 2, "tweak_move_mode_inout",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_ATTRACT,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Move jitter mode"),
1, _("Move objects in random directions"),
- 2, "tweak_move_mode_jitter",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_RANDOMIZE,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Scale mode"),
- 1, _("Scale objects, with Shift scale up"),
- 2, "tweak_scale_mode",
+ 1, _("Shrink objects, with Shift enlarge"),
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_SHRINK,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Rotate mode"),
1, _("Rotate objects, with Shift counterclockwise"),
- 2, "tweak_rotate_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_ROTATE,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Duplicate/delete mode"),
1, _("Duplicate objects, with Shift delete"),
- 2, "tweak_moreless_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_DUPLICATE,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Push mode"),
1, _("Push parts of paths in any direction"),
- 2, "tweak_push_mode",
+ 2, INKSCAPE_ICON_PATH_TWEAK_PUSH,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Shrink/grow mode"),
1, _("Shrink (inset) parts of paths; with Shift grow (outset)"),
- 2, "tweak_shrink_mode",
+ 2, INKSCAPE_ICON_PATH_TWEAK_SHRINK,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Attract/repel mode"),
1, _("Attract parts of paths towards cursor; with Shift from cursor"),
- 2, "tweak_attract_mode",
+ 2, INKSCAPE_ICON_PATH_TWEAK_ATTRACT,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Roughen mode"),
1, _("Roughen parts of paths"),
- 2, "tweak_roughen_mode",
+ 2, INKSCAPE_ICON_PATH_TWEAK_ROUGHEN,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Color paint mode"),
1, _("Paint the tool's color upon selected objects"),
- 2, "tweak_colorpaint_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_PAINT,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Color jitter mode"),
1, _("Jitter the colors of selected objects"),
- 2, "tweak_colorjitter_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_JITTER_COLOR,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Blur mode"),
1, _("Blur selected objects more; with Shift, blur less"),
- 2, "tweak_blur_mode",
+ 2, INKSCAPE_ICON_OBJECT_TWEAK_BLUR,
-1 );
@@ -3887,7 +4463,7 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
InkToggleAction* act = ink_toggle_action_new( "TweakPressureAction",
_("Pressure"),
_("Use the pressure of the input device to alter the force of tweak action"),
- "use_pressure",
+ INKSCAPE_ICON_DRAW_USE_PRESSURE,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL);
@@ -3898,164 +4474,386 @@ static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
//########################
-//## Calligraphy ##
+//## Spray ##
//########################
-static void update_presets_list (GObject *tbl)
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (g_object_get_data(tbl, "presets_blocked"))
- return;
-
- EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
- if (!sel) {
- // WTF!? This will cause a segfault if ever reached
- //ege_select_one_action_set_active(sel, 0);
- return;
- }
-
- std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
-
- int ege_index = 1;
- for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) {
- bool match = true;
-
- std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(*i);
- for (std::vector<Inkscape::Preferences::Entry>::iterator j = preset.begin(); j != preset.end(); ++j) {
- Glib::ustring entry_name = j->getEntryName();
- if (entry_name == "id" || entry_name == "name") continue;
-
- void *widget = g_object_get_data(tbl, entry_name.data());
- if (widget) {
- if (GTK_IS_ADJUSTMENT(widget)) {
- double v = j->getDouble();
- GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
- //std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n";
- if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) {
- match = false;
- break;
- }
- } else if (GTK_IS_TOGGLE_ACTION(widget)) {
- bool v = j->getBool();
- GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
- //std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n";
- if ( static_cast<bool>(gtk_toggle_action_get_active(toggle)) != v ) {
- match = false;
- break;
- }
- }
- }
- }
-
- if (match) {
- // newly added item is at the same index as the
- // save command, so we need to change twice for it to take effect
- ege_select_one_action_set_active(sel, 0);
- ege_select_one_action_set_active(sel, ege_index); // one-based index
- return;
- }
- }
-
- // no match found
- ege_select_one_action_set_active(sel, 0);
-}
-
-static void sp_ddc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/mass", adj->value * 0.01 );
- update_presets_list(tbl);
-}
-static void sp_ddc_wiggle_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_width_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/wiggle", adj->value * 0.01 );
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/width", adj->value );
}
-static void sp_ddc_angle_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_mean_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/angle", adj->value );
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/mean", adj->value );
}
-static void sp_ddc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
+static void sp_spray_standard_deviation_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/width", adj->value * 0.01 );
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/standard_deviation", adj->value );
}
-static void sp_ddc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_pressure_state_changed( GtkToggleAction *act, gpointer /*data*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("/tools/calligraphic/thinning", adj->value * 0.01 );
- update_presets_list(tbl);
+ prefs->setBool("/tools/spray/usepressure", gtk_toggle_action_get_active(act));
}
-static void sp_ddc_flatness_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject */*tbl*/ )
{
+ int mode = ege_select_one_action_get_active( act );
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/flatness", adj->value * 0.01);
- update_presets_list(tbl);
+ prefs->setInt("/tools/spray/mode", mode);
}
-static void sp_ddc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_population_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/tremor", adj->value * 0.01 );
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/population", adj->value );
}
-static void sp_ddc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl )
+static void sp_spray_rotation_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/calligraphic/cap_rounding", adj->value );
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/rotation_variation", adj->value );
}
-static void sp_ddc_pressure_state_changed( GtkToggleAction *act, GObject* tbl )
+static void sp_spray_scale_value_changed( GtkAdjustment *adj, GObject */*tbl*/ )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("/tools/calligraphic/usepressure", gtk_toggle_action_get_active( act ));
- update_presets_list(tbl);
+ prefs->setDouble( "/tools/spray/scale_variation", adj->value );
}
-static void sp_ddc_trace_background_changed( GtkToggleAction *act, GObject* tbl )
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setBool("/tools/calligraphic/tracebackground", gtk_toggle_action_get_active( act ));
- update_presets_list(tbl);
-}
-static void sp_ddc_tilt_state_changed( GtkToggleAction *act, GObject* tbl )
+static void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- GtkAction * calligraphy_angle = static_cast<GtkAction *> (g_object_get_data(tbl,"angle_action"));
- prefs->setBool("/tools/calligraphic/usetilt", gtk_toggle_action_get_active( act ));
- update_presets_list(tbl);
- if (calligraphy_angle )
- gtk_action_set_sensitive( calligraphy_angle, !gtk_toggle_action_get_active( act ) );
-}
-
-static gchar const *const widget_names[] = {
- "width",
- "mass",
- "wiggle",
- "angle",
- "thinning",
- "tremor",
- "flatness",
- "cap_rounding",
- "usepressure",
- "tracebackground",
- "usetilt"
-};
+ {
+ /* Width */
+ gchar const* labels[] = {_("(narrow spray)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad spray)")};
+ gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayWidthAction",
+ _("Width"), _("Width:"), _("The width of the spray area (relative to the visible canvas area)"),
+ "/tools/spray/width", 15,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-spray",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_width_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+ {
+ /* Mean */
+ gchar const* labels[] = {_("(minimum mean)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum mean)")};
+ gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayMeanAction",
+ _("Focus"), _("Focus:"), _("0 to spray a spot. Increase to enlarge the ring radius."),
+ "/tools/spray/mean", 0,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-mean",
+ 0, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_mean_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
-static void sp_dcc_build_presets_list(GObject *tbl)
+ {
+ /* Standard_deviation */
+ gchar const* labels[] = {_("(minimum scatter)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum scatter)")};
+ gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayStandard_deviationAction",
+ _("Scatter"), _("Scatter:"), _("Increase to scatter sprayed objects."),
+ "/tools/spray/standard_deviation", 70,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-standard_deviation",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_standard_deviation_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+
+ /* Mode */
+ {
+ GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
+
+ GtkTreeIter iter;
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Spray with copies"),
+ 1, _("Spray copies of the initial selection"),
+ 2, INKSCAPE_ICON_SPRAY_COPY_MODE,
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Spray with clones"),
+ 1, _("Spray clones of the initial selection"),
+ 2, INKSCAPE_ICON_SPRAY_CLONE_MODE,
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Spray single path"),
+ 1, _("Spray objects in a single path"),
+ 2, INKSCAPE_ICON_SPRAY_UNION_MODE,
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) );
+ g_object_set( act, "short_label", _("Mode:"), NULL );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "mode_action", act );
+
+ ege_select_one_action_set_appearance( act, "full" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
+ ege_select_one_action_set_icon_column( act, 2 );
+ ege_select_one_action_set_icon_size( act, secondarySize );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+
+ gint mode = prefs->getInt("/tools/spray/mode", 1);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_spray_mode_changed), holder );
+
+ g_object_set_data( G_OBJECT(holder), "spray_tool_mode", act);
+ }
+
+ { /* Population */
+ gchar const* labels[] = {_("(low population)"), 0, 0, _("(default)"), 0, 0, _("(high population)")};
+ gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayPopulationAction",
+ _("Amount"), _("Amount:"),
+ _("Adjusts the number of items sprayed per clic."),
+ "/tools/spray/population", 70,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-population",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_population_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "spray_population", eact );
+ }
+
+ /* Use Pressure button */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "SprayPressureAction",
+ _("Pressure"),
+ _("Use the pressure of the input device to alter the amount of sprayed objects."),
+ "use_pressure",
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_spray_pressure_state_changed), NULL);
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/spray/usepressure", true) );
+ }
+
+ { /* Rotation */
+ gchar const* labels[] = {_("(low rotation variation)"), 0, 0, _("(default)"), 0, 0, _("(high rotation variation)")};
+ gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayRotationAction",
+ _("Rotation"), _("Rotation:"),
+ // xgettext:no-c-format
+ _("Variation of the rotation of the sprayed objects. 0% for the same rotation than the original object."),
+ "/tools/spray/rotation_variation", 0,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-rotation",
+ 0, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_rotation_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "spray_rotation", eact );
+ }
+
+ { /* Scale */
+ gchar const* labels[] = {_("(low scale variation)"), 0, 0, _("(default)"), 0, 0, _("(high scale variation)")};
+ gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "SprayScaleAction",
+ _("Scale"), _("Scale:"),
+ // xgettext:no-c-format
+ _("Variation in the scale of the sprayed objects. 0% for the same scale than the original object."),
+ "/tools/spray/scale_variation", 0,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "spray-scale",
+ 0, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_spray_scale_value_changed, 1, 0 );
+ ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ g_object_set_data( holder, "spray_scale", eact );
+ }
+
+
+
+}
+
+
+//########################
+//## Calligraphy ##
+//########################
+static void update_presets_list (GObject *tbl)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (g_object_get_data(tbl, "presets_blocked"))
+ return;
+
+ EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
+ if (!sel) {
+ // WTF!? This will cause a segfault if ever reached
+ //ege_select_one_action_set_active(sel, 0);
+ return;
+ }
+
+ std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
+
+ int ege_index = 1;
+ for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) {
+ bool match = true;
+
+ std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(*i);
+ for (std::vector<Inkscape::Preferences::Entry>::iterator j = preset.begin(); j != preset.end(); ++j) {
+ Glib::ustring entry_name = j->getEntryName();
+ if (entry_name == "id" || entry_name == "name") continue;
+
+ void *widget = g_object_get_data(tbl, entry_name.data());
+ if (widget) {
+ if (GTK_IS_ADJUSTMENT(widget)) {
+ double v = j->getDouble();
+ GtkAdjustment* adj = static_cast<GtkAdjustment *>(widget);
+ //std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n";
+ if (fabs(gtk_adjustment_get_value(adj) - v) > 1e-6) {
+ match = false;
+ break;
+ }
+ } else if (GTK_IS_TOGGLE_ACTION(widget)) {
+ bool v = j->getBool();
+ GtkToggleAction* toggle = static_cast<GtkToggleAction *>(widget);
+ //std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n";
+ if ( static_cast<bool>(gtk_toggle_action_get_active(toggle)) != v ) {
+ match = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (match) {
+ // newly added item is at the same index as the
+ // save command, so we need to change twice for it to take effect
+ ege_select_one_action_set_active(sel, 0);
+ ege_select_one_action_set_active(sel, ege_index); // one-based index
+ return;
+ }
+ }
+
+ // no match found
+ ege_select_one_action_set_active(sel, 0);
+}
+
+static void sp_ddc_mass_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/mass", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_wiggle_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/wiggle", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_angle_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/angle", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/width", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/tools/calligraphic/thinning", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_flatness_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/flatness", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/tremor", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble( "/tools/calligraphic/cap_rounding", adj->value );
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_pressure_state_changed( GtkToggleAction *act, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/tools/calligraphic/usepressure", gtk_toggle_action_get_active( act ));
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_trace_background_changed( GtkToggleAction *act, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/tools/calligraphic/tracebackground", gtk_toggle_action_get_active( act ));
+ update_presets_list(tbl);
+}
+
+static void sp_ddc_tilt_state_changed( GtkToggleAction *act, GObject* tbl )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ GtkAction * calligraphy_angle = static_cast<GtkAction *> (g_object_get_data(tbl,"angle_action"));
+ prefs->setBool("/tools/calligraphic/usetilt", gtk_toggle_action_get_active( act ));
+ update_presets_list(tbl);
+ if (calligraphy_angle )
+ gtk_action_set_sensitive( calligraphy_angle, !gtk_toggle_action_get_active( act ) );
+}
+
+
+static gchar const *const widget_names[] = {
+ "width",
+ "mass",
+ "wiggle",
+ "angle",
+ "thinning",
+ "tremor",
+ "flatness",
+ "cap_rounding",
+ "usepressure",
+ "tracebackground",
+ "usetilt"
+};
+
+
+static void sp_dcc_build_presets_list(GObject *tbl)
{
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE));
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter, 0, _("No preset"), 1, 0, -1 );
}
-
+
// iterate over all presets to populate the list
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
int ii=1;
-
+
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i) {
- GtkTreeIter iter;
+ GtkTreeIter iter;
Glib::ustring preset_name = prefs->getString(*i + "/name");
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, preset_name.data(), 1, ii++, -1 );
+ gtk_list_store_set( model, &iter, 0, _(preset_name.data()), 1, ii++, -1 );
}
{
}
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE));
-
+
// If there's a preset with the given name, find it and set save_path appropriately
std::vector<Glib::ustring> presets = prefs->getAllDirs("/tools/calligraphic/preset");
int total_presets = presets.size();
int new_index = -1;
Glib::ustring save_path; // profile pref path without a trailing slash
-
+
int temp_index = 0;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) {
- Glib::ustring name = prefs->getString(*i + "/name");
- if (!name.empty() && profile_name == name) {
- new_index = temp_index;
+ Glib::ustring name = prefs->getString(*i + "/name");
+ if (!name.empty() && profile_name == name) {
+ new_index = temp_index;
save_path = *i;
break;
- }
+ }
}
if (new_index == -1) {
if (!preset_path.empty()) {
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it
-
+
std::vector<Inkscape::Preferences::Entry> preset = prefs->getAllEntries(preset_path);
// Shouldn't this be std::map?
@@ -4242,9 +5040,9 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("The width of the calligraphic pen (relative to the visible canvas area)"),
"/tools/calligraphic/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-calligraphy",
- 1, 100, 1.0, 0.0,
+ 1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_width_value_changed, 0.01, 0, 100 );
+ sp_ddc_width_value_changed, 1, 0 );
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -4259,9 +5057,9 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"),
"/tools/calligraphic/thinning", 10,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
- -100, 100, 1, 0.1,
+ -100, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_velthin_value_changed, 0.01, 0, 100);
+ sp_ddc_velthin_value_changed, 1, 0);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
@@ -4295,7 +5093,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
0.0, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_flatness_value_changed, 0.01, 0, 100 );
+ sp_ddc_flatness_value_changed, 1, 0);
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
}
@@ -4326,9 +5124,9 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("Increase to make strokes rugged and trembling"),
"/tools/calligraphic/tremor", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
- 0.0, 100, 1, 0.0,
+ 0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_tremor_value_changed, 0.01, 0, 100 );
+ sp_ddc_tremor_value_changed, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -4344,9 +5142,9 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("Increase to make the pen waver and wiggle"),
"/tools/calligraphic/wiggle", 0.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
- 0.0, 100, 1, 0.0,
+ 0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_wiggle_value_changed, 0.01, 0, 100 );
+ sp_ddc_wiggle_value_changed, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -4361,9 +5159,9 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("Increase to make the pen drag behind, as if slowed by inertia"),
"/tools/calligraphic/mass", 2.0,
GTK_WIDGET(desktop->canvas), NULL, holder, FALSE, NULL,
- 0.0, 100, 1, 0.0,
+ 0.0, 100, 1, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_ddc_mass_value_changed, 0.01, 0, 100 );
+ sp_ddc_mass_value_changed, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -4375,7 +5173,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
InkToggleAction* act = ink_toggle_action_new( "TraceAction",
_("Trace Background"),
_("Trace the lightness of the background by the width of the pen (white - minimum width, black - maximum width)"),
- "trace_background",
+ INKSCAPE_ICON_DRAW_TRACE_BACKGROUND,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_trace_background_changed), holder);
@@ -4388,7 +5186,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
InkToggleAction* act = ink_toggle_action_new( "PressureAction",
_("Pressure"),
_("Use the pressure of the input device to alter the width of the pen"),
- "use_pressure",
+ INKSCAPE_ICON_DRAW_USE_PRESSURE,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_pressure_state_changed), holder);
@@ -4401,7 +5199,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
InkToggleAction* act = ink_toggle_action_new( "TiltAction",
_("Tilt"),
_("Use the tilt of the input device to alter the angle of the pen's nib"),
- "use_tilt",
+ INKSCAPE_ICON_DRAW_USE_TILT,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_ddc_tilt_state_changed), holder );
@@ -4455,7 +5253,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v
if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble(Glib::ustring("/tools/shapes/arc") + value_name, (adj->value * M_PI)/ 180);
+ prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value);
}
// quit if run by the attr_changed listener
@@ -4678,7 +5476,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
EgeAdjustmentAction* eact = 0;
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
@@ -4723,14 +5521,14 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
gtk_list_store_set( model, &iter,
0, _("Closed arc"),
1, _("Switch to segment (closed shape with two radii)"),
- 2, "circle_closed_arc",
+ 2, INKSCAPE_ICON_DRAW_ELLIPSE_SEGMENT,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Open Arc"),
1, _("Switch to arc (unclosed shape)"),
- 2, "circle_open_arc",
+ 2, INKSCAPE_ICON_DRAW_ELLIPSE_ARC,
-1 );
EgeSelectOneAction* act = ege_select_one_action_new( "ArcOpenAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
@@ -4754,7 +5552,7 @@ static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions,
InkAction* inky = ink_action_new( "ArcResetAction",
_("Make whole"),
_("Make the shape a whole ellipse, not arc or segment"),
- "reset_circle",
+ INKSCAPE_ICON_DRAW_ELLIPSE_WHOLE,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_arctb_defaults), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
g_object_set_data(tbl, "freeze", GINT_TO_POINTER(TRUE));
gint mode = ege_select_one_action_get_active(act);
- EffectType type = lpesubtools[mode];
+ EffectType type = lpesubtools[mode].type;
SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
bool success = lpetool_try_construction(lc, type);
@@ -5099,17 +5897,17 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
gtk_list_store_set( model, &iter,
0, _("All inactive"),
1, _("No geometric tool is active"),
- 2, _("all_inactive"),
+ 2, "draw-geometry-inactive",
-1 );
Inkscape::LivePathEffect::EffectType type;
for (int i = 1; i < num_subtools; ++i) { // we start with i = 1 because INVALID_LPE was already added
- type = lpesubtools[i];
+ type = lpesubtools[i].type;
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
1, Inkscape::LivePathEffect::LPETypeConverter.get_label(type).c_str(),
- 2, Inkscape::LivePathEffect::LPETypeConverter.get_key(type).c_str(),
+ 2, lpesubtools[i].icon_name,
-1 );
}
@@ -5133,7 +5931,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
InkToggleAction* act = ink_toggle_action_new( "LPEShowBBoxAction",
_("Show limiting bounding box"),
_("Show bounding box (used to cut infinite lines)"),
- "lpetool_show_bbox",
+ "show-bounding-box",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_bbox), desktop );
@@ -5145,7 +5943,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
InkToggleAction* act = ink_toggle_action_new( "LPEBBoxFromSelectionAction",
_("Get limiting bounding box from selection"),
_("Set limiting bounding box (used to cut infinite lines) to the bounding box of current selection"),
- "lpetool_set_bbox",
+ "draw-geometry-set-bounding-box",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_set_bbox), desktop );
@@ -5174,7 +5972,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
InkToggleAction* act = ink_toggle_action_new( "LPEMeasuringAction",
_("Display measuring info"),
_("Display measuring info for selected items"),
- "lpetool_measuring_info",
+ "draw-geometry-show-measuring-info",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_toggle_show_measuring_info), holder );
@@ -5195,7 +5993,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
InkToggleAction* act = ink_toggle_action_new( "LPEOpenLPEDialogAction",
_("Open LPE dialog"),
_("Open LPE dialog (to adapt parameters numerically)"),
- "lpetool_open_lpe_dialog",
+ "dialog-geometry",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(lpetool_open_lpe_dialog), desktop );
@@ -5223,7 +6021,7 @@ static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActi
static void sp_erc_width_value_changed( GtkAdjustment *adj, GObject *tbl )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble( "/tools/eraser/width", adj->value * 0.01 );
+ prefs->setDouble( "/tools/eraser/width", adj->value );
update_presets_list(tbl);
}
@@ -5261,9 +6059,9 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
_("The width of the eraser pen (relative to the visible canvas area)"),
"/tools/eraser/width", 15,
GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-eraser",
- 1, 100, 1.0, 0.0,
+ 1, 100, 1.0, 10.0,
labels, values, G_N_ELEMENTS(labels),
- sp_erc_width_value_changed, 0.01, 0, 100 );
+ sp_erc_width_value_changed, 1, 0);
ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
@@ -5277,14 +6075,14 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
gtk_list_store_set( model, &iter,
0, _("Delete"),
1, _("Delete objects touched by the eraser"),
- 2, "delete_object",
+ 2, INKSCAPE_ICON_DRAW_ERASER_DELETE_OBJECTS,
-1 );
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Cut"),
1, _("Cut out from objects"),
- 2, "difference",
+ 2, INKSCAPE_ICON_PATH_DIFFERENCE,
-1 );
EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
namespace {
-bool popdown_visible = false;
-bool popdown_hasfocus = false;
-
void
sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *tbl)
{
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
SPStyle *query =
sp_style_new (SP_ACTIVE_DOCUMENT);
-// int result_fontspec = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
-
int result_family =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
@@ -5367,12 +6167,13 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_family == QUERY_STYLE_NOTHING || result_style == QUERY_STYLE_NOTHING || result_numbers == QUERY_STYLE_NOTHING) {
// there are no texts in selection, read from prefs
-
- sp_style_read_from_prefs(query, "/tools/text");
-
- if (g_object_get_data(tbl, "text_style_from_prefs")) {
+
+ sp_style_read_from_prefs(query, "/tools/text");
+
+ if (g_object_get_data(tbl, "text_style_from_prefs")) {
// do not reset the toolbar style from prefs if we already did it last time
sp_style_unref(query);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
return;
}
g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
@@ -5388,7 +6189,8 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
} else if (query->text->font_specification.value || query->text->font_family.value) {
- GtkWidget *entry = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "family-entry"));
+ Gtk::ComboBoxEntry *combo = (Gtk::ComboBoxEntry *) (g_object_get_data (G_OBJECT (tbl), "family-entry-combo"));
+ GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
// Get the font that corresponds
Glib::ustring familyName;
@@ -5402,33 +6204,26 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
gtk_entry_set_text (GTK_ENTRY (entry), familyName.c_str());
- Gtk::TreePath path;
+ Gtk::TreeIter iter;
try {
- path = Inkscape::FontLister::get_instance()->get_row_for_font (familyName);
+ Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (familyName);
+ Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
+ iter = model->get_iter(path);
} catch (...) {
g_warning("Family name %s does not have an entry in the font lister.", familyName.c_str());
sp_style_unref(query);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
return;
}
- GtkTreeSelection *tselection = GTK_TREE_SELECTION (g_object_get_data (G_OBJECT(tbl), "family-tree-selection"));
- GtkTreeView *treeview = GTK_TREE_VIEW (g_object_get_data (G_OBJECT(tbl), "family-tree-view"));
-
- g_object_set_data (G_OBJECT (tselection), "block", gpointer(1));
-
- gtk_tree_selection_select_path (tselection, path.gobj());
- gtk_tree_view_scroll_to_cell (treeview, path.gobj(), NULL, TRUE, 0.5, 0.0);
-
- g_object_set_data (G_OBJECT (tselection), "block", gpointer(0));
+ combo->set_active (iter);
}
//Size
{
GtkWidget *cbox = GTK_WIDGET(g_object_get_data(G_OBJECT(tbl), "combo-box-size"));
gchar *const str = g_strdup_printf("%.5g", query->font_size.computed);
- g_object_set_data(tbl, "size-block", gpointer(1));
gtk_entry_set_text(GTK_ENTRY(GTK_BIN(cbox)->child), str);
- g_object_set_data(tbl, "size-block", gpointer(0));
g_free(str);
}
@@ -5470,7 +6265,7 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
GtkToggleButton *button = GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (tbl), "style-bold"));
gboolean active = gtk_toggle_button_get_active (button);
- gboolean check = (query->font_weight.computed >= SP_CSS_FONT_WEIGHT_700);
+ gboolean check = ((query->font_weight.computed >= SP_CSS_FONT_WEIGHT_700) && (query->font_weight.computed != SP_CSS_FONT_WEIGHT_NORMAL) && (query->font_weight.computed != SP_CSS_FONT_WEIGHT_LIGHTER));
if (active != check)
{
@@ -5515,6 +6310,8 @@ sp_text_toolbox_selection_changed (Inkscape::Selection */*selection*/, GObject *
}
sp_style_unref(query);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
void
@@ -5524,37 +6321,27 @@ sp_text_toolbox_selection_modified (Inkscape::Selection *selection, guint /*flag
}
void
-sp_text_toolbox_subselection_changed (gpointer /*dragger*/, GObject *tbl)
+sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl)
{
sp_text_toolbox_selection_changed (NULL, tbl);
}
void
-sp_text_toolbox_family_changed (GtkTreeSelection *selection,
+sp_text_toolbox_family_changed (GtkComboBoxEntry *,
GObject *tbl)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- GtkTreeModel *model = 0;
- GtkWidget *entry = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
- GtkTreeIter iter;
- char *family = 0;
-
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
-
- if ( !gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
return;
}
- gtk_tree_model_get (model, &iter, 0, &family, -1);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- if (g_object_get_data (G_OBJECT (selection), "block"))
- {
- gtk_entry_set_text (GTK_ENTRY (entry), family);
- return;
- }
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ GtkWidget *entry = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
+ const gchar* family = gtk_entry_get_text (GTK_ENTRY (entry));
- gtk_entry_set_text (GTK_ENTRY (entry), family);
+ //g_print ("family changed to: %s\n", family);
SPStyle *query =
sp_style_new (SP_ACTIVE_DOCUMENT);
int result_fontspec =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
- //font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
-
SPCSSAttr *css = sp_repr_css_attr_new ();
-
// First try to get the font spec from the stored value
Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
}
if (!fontSpec.empty()) {
+
Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
- if (!newFontSpec.empty() && fontSpec != newFontSpec) {
- font_instance *font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str());
- if (font) {
- sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str());
- // Set all the these just in case they were altered when finding the best
- // match for the new family and old style...
+ if (!newFontSpec.empty()) {
- gchar c[256];
+ if (fontSpec != newFontSpec) {
- font->Family(c, 256);
- sp_repr_css_set_property (css, "font-family", c);
+ font_instance *font = font_factory::Default()->FaceFromFontSpecification(newFontSpec.c_str());
- font->Attribute( "weight", c, 256);
- sp_repr_css_set_property (css, "font-weight", c);
+ if (font) {
+ sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str());
- font->Attribute("style", c, 256);
- sp_repr_css_set_property (css, "font-style", c);
+ // Set all the these just in case they were altered when finding the best
+ // match for the new family and old style...
- font->Attribute("stretch", c, 256);
- sp_repr_css_set_property (css, "font-stretch", c);
+ gchar c[256];
- font->Attribute("variant", c, 256);
- sp_repr_css_set_property (css, "font-variant", c);
+ font->Family(c, 256);
- font->Unref();
+ sp_repr_css_set_property (css, "font-family", c);
+
+ font->Attribute( "weight", c, 256);
+ sp_repr_css_set_property (css, "font-weight", c);
+
+ font->Attribute("style", c, 256);
+ sp_repr_css_set_property (css, "font-style", c);
+
+ font->Attribute("stretch", c, 256);
+ sp_repr_css_set_property (css, "font-stretch", c);
+
+ font->Attribute("variant", c, 256);
+ sp_repr_css_set_property (css, "font-variant", c);
+
+ font->Unref();
+ }
}
+
+ } else {
+ // If the old font on selection (or default) was not existing on the system,
+ // ReplaceFontSpecificationFamily does not work. In that case we fall back to blindly
+ // setting the family reported by the family chooser.
+
+ //g_print ("fallback setting family: %s\n", family);
+ sp_repr_css_set_property (css, "-inkscape-font-specification", family);
+ sp_repr_css_set_property (css, "font-family", family);
}
}
// If querying returned nothing, set the default style of the tool (for new texts)
if (result_fontspec == QUERY_STYLE_NOTHING)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setStyle("/tools/text/style", css);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
sp_text_edit_dialog_default_set_insensitive (); //FIXME: Replace trough a verb
}
else
sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT,
_("Text: Change font family"));
sp_repr_css_attr_unref (css);
- g_free(family);
+
gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));
+ // unfreeze
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+
+ // focus to canvas
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
}
-/* This is where execution comes when the contents of the font family box have been completed
- by the press of the return key */
-void
-sp_text_toolbox_family_entry_activate (GtkEntry *entry,
- GObject *tbl)
-{
- const char *family = gtk_entry_get_text (entry); // Fetch the requested font family
-
-// Try to match that to a known font. If not, then leave current font alone and remain focused on text box
- try {
- Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
- GtkTreeSelection *selection = GTK_TREE_SELECTION (g_object_get_data (G_OBJECT(tbl), "family-tree-selection"));
- GtkTreeView *treeview = GTK_TREE_VIEW (g_object_get_data (G_OBJECT(tbl), "family-tree-view"));
- gtk_tree_selection_select_path (selection, path.gobj());
- gtk_tree_view_scroll_to_cell (treeview, path.gobj(), NULL, TRUE, 0.5, 0.0);
- gtk_widget_hide (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));
- } catch (...) {
- if (family && strlen (family))
- {
- gtk_widget_show_all (GTK_WIDGET (g_object_get_data (G_OBJECT(tbl), "warning-image")));
- }
- }
-}
void
sp_text_toolbox_anchoring_toggled (GtkRadioButton *button,
int prop = GPOINTER_TO_INT(data);
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- SPCSSAttr *css = sp_repr_css_attr_new ();
+ // move the x of all texts to preserve the same bbox
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
+ if (SP_IS_TEXT((SPItem *) items->data)) {
+ SPItem *item = SP_ITEM(items->data);
+
+ unsigned writing_mode = SP_OBJECT_STYLE(item)->writing_mode.value;
+ // below, variable names suggest horizontal move, but we check the writing direction
+ // and move in the corresponding axis
+ int axis;
+ if (writing_mode == SP_CSS_WRITING_MODE_LR_TB || writing_mode == SP_CSS_WRITING_MODE_RL_TB) {
+ axis = NR::X;
+ } else {
+ axis = NR::Y;
+ }
+
+ Geom::OptRect bbox
+ = item->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX);
+ if (!bbox)
+ continue;
+ double width = bbox->dimensions()[axis];
+ // If you want to align within some frame, other than the text's own bbox, calculate
+ // the left and right (or top and bottom for tb text) slacks of the text inside that
+ // frame (currently unused)
+ double left_slack = 0;
+ double right_slack = 0;
+ unsigned old_align = SP_OBJECT_STYLE(item)->text_align.value;
+ double move = 0;
+ if (old_align == SP_CSS_TEXT_ALIGN_START || old_align == SP_CSS_TEXT_ALIGN_LEFT) {
+ switch (prop) {
+ case 0:
+ move = -left_slack;
+ break;
+ case 1:
+ move = width/2 + (right_slack - left_slack)/2;
+ break;
+ case 2:
+ move = width + right_slack;
+ break;
+ }
+ } else if (old_align == SP_CSS_TEXT_ALIGN_CENTER) {
+ switch (prop) {
+ case 0:
+ move = -width/2 - left_slack;
+ break;
+ case 1:
+ move = (right_slack - left_slack)/2;
+ break;
+ case 2:
+ move = width/2 + right_slack;
+ break;
+ }
+ } else if (old_align == SP_CSS_TEXT_ALIGN_END || old_align == SP_CSS_TEXT_ALIGN_RIGHT) {
+ switch (prop) {
+ case 0:
+ move = -width - left_slack;
+ break;
+ case 1:
+ move = -width/2 + (right_slack - left_slack)/2;
+ break;
+ case 2:
+ move = right_slack;
+ break;
+ }
+ }
+ Geom::Point XY = SP_TEXT(item)->attributes.firstXY();
+ if (axis == NR::X) {
+ XY = XY + Geom::Point (move, 0);
+ } else {
+ XY = XY + Geom::Point (0, move);
+ }
+ SP_TEXT(item)->attributes.setFirstXY(XY);
+ SP_OBJECT(item)->updateRepr();
+ SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ }
+ }
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
switch (prop)
{
case 0:
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_numbers == QUERY_STYLE_NOTHING)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setStyle("/tools/text/style", css);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
}
sp_style_unref(query);
fontFromStyle->Unref();
}
+ bool nochange = true;
switch (prop)
{
case 0:
{
if (!fontSpec.empty()) {
newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active);
+ if (!newFontSpec.empty()) {
+ // Don't even set the bold if the font didn't exist on the system
+ sp_repr_css_set_property (css, "font-weight", active ? "bold" : "normal" );
+ nochange = false;
+ }
}
- if (fontSpec != newFontSpec) {
- // Don't even set the bold if the font didn't exist on the system
- sp_repr_css_set_property (css, "font-weight", active ? "bold" : "normal" );
+ // set or reset the button according
+ if(nochange) {
+ gboolean check = gtk_toggle_button_get_active (button);
+
+ if (active != check)
+ {
+ g_object_set_data (G_OBJECT (button), "block", gpointer(1));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
+ g_object_set_data (G_OBJECT (button), "block", gpointer(0));
+ }
}
+
break;
}
{
if (!fontSpec.empty()) {
newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active);
+ if (!newFontSpec.empty()) {
+ // Don't even set the italic if the font didn't exist on the system
+ sp_repr_css_set_property (css, "font-style", active ? "italic" : "normal");
+ nochange = false;
+ }
}
- if (fontSpec != newFontSpec) {
- // Don't even set the italic if the font didn't exist on the system
- sp_repr_css_set_property (css, "font-style", active ? "italic" : "normal");
+ if(nochange) {
+ gboolean check = gtk_toggle_button_get_active (button);
+
+ if (active != check)
+ {
+ g_object_set_data (G_OBJECT (button), "block", gpointer(1));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), active);
+ g_object_set_data (G_OBJECT (button), "block", gpointer(0));
+ }
}
break;
}
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
if (result_fontspec == QUERY_STYLE_NOTHING)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setStyle("/tools/text/style", css);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->mergeStyle("/tools/text/style", css);
}
sp_style_unref(query);
gpointer data)
{
if (g_object_get_data (G_OBJECT (button), "block")) {
- g_object_set_data (G_OBJECT (button), "block", gpointer(0));
return;
}
if (result_numbers == QUERY_STYLE_NOTHING)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setStyle("/tools/text/style", css);
+ prefs->mergeStyle("/tools/text/style", css);
}
sp_desktop_set_style (desktop, css, true, true);
@@ -5853,9 +6736,16 @@ sp_text_toolbox_family_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject *
if (!desktop) return FALSE;
switch (get_group0_keyval (event)) {
- case GDK_Escape: // defocus
+ case GDK_KP_Enter: // chosen
+ case GDK_Return:
+ // unfreeze and update, which will defocus
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ sp_text_toolbox_family_changed (NULL, tbl);
+ return TRUE; // I consumed the event
+ break;
+ case GDK_Escape:
+ // defocus
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- sp_text_toolbox_selection_changed (NULL, tbl); // update
return TRUE; // I consumed the event
break;
}
@@ -5863,7 +6753,7 @@ sp_text_toolbox_family_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject *
}
gboolean
-sp_text_toolbox_family_list_keypress (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/)
+sp_text_toolbox_family_list_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject */*tbl*/)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (!desktop) return FALSE;
@@ -5872,16 +6762,12 @@ sp_text_toolbox_family_list_keypress (GtkWidget *w, GdkEventKey *event, GObject
case GDK_KP_Enter:
case GDK_Return:
case GDK_Escape: // defocus
- gtk_widget_hide (w);
- popdown_visible = false;
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
return TRUE; // I consumed the event
break;
case GDK_w:
case GDK_W:
if (event->state & GDK_CONTROL_MASK) {
- gtk_widget_hide (w);
- popdown_visible = false;
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
return TRUE; // I consumed the event
}
sp_text_toolbox_size_changed (GtkComboBox *cbox,
GObject *tbl)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ // quit if run by the _changed callbacks
+ if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
+ return;
+ }
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- if (g_object_get_data (tbl, "size-block")) return;
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
// If this is not from selecting a size in the list (in which case get_active will give the
// index of the selected item, otherwise -1) and not from user pressing Enter/Return, do not
// process this event. This fixes GTK's stupid insistence on sending an activate change every
// time any character gets typed or deleted, which made this control nearly unusable in 0.45.
- if (gtk_combo_box_get_active (cbox) < 0 && !g_object_get_data (tbl, "enter-pressed"))
+ if (gtk_combo_box_get_active (cbox) < 0 && !g_object_get_data (tbl, "enter-pressed")) {
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
return;
+ }
gdouble value = -1;
{
}
}
if (value <= 0) {
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
return; // could not parse value
}
if (result_numbers == QUERY_STYLE_NOTHING)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setStyle("/tools/text/style", css);
+ prefs->mergeStyle("/tools/text/style", css);
}
sp_style_unref(query);
sp_repr_css_attr_unref (css);
gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
gboolean
@@ -5991,80 +6887,30 @@ sp_text_toolbox_size_keypress (GtkWidget */*w*/, GdkEventKey *event, GObject *tb
return FALSE;
}
-void
-sp_text_toolbox_text_popdown_clicked (GtkButton */*button*/,
- GObject *tbl)
-{
- GtkWidget *popdown = GTK_WIDGET (g_object_get_data (tbl, "family-popdown-window"));
- GtkWidget *widget = GTK_WIDGET (g_object_get_data (tbl, "family-entry"));
- int x, y;
-
- if (!popdown_visible)
- {
- gdk_window_get_origin (widget->window, &x, &y);
- gtk_window_move (GTK_WINDOW (popdown), x, y + widget->allocation.height + 2); //2px of grace space
- gtk_widget_show_all (popdown);
- //sp_transientize (popdown);
-
- gdk_pointer_grab (widget->window, TRUE,
- GdkEventMask (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK),
- NULL, NULL, GDK_CURRENT_TIME);
-
- gdk_keyboard_grab (widget->window, TRUE, GDK_CURRENT_TIME);
-
- popdown_visible = true;
- }
- else
- {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- gtk_widget_hide (popdown);
- popdown_visible = false;
- }
-}
-
+// While editing font name in the entry, disable family_changed by freezing, otherwise completion
+// does not work!
gboolean
sp_text_toolbox_entry_focus_in (GtkWidget *entry,
GdkEventFocus */*event*/,
- GObject */*tbl*/)
+ GObject *tbl)
{
- gtk_entry_select_region (GTK_ENTRY (entry), 0, -1);
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ gtk_entry_select_region (GTK_ENTRY (entry), 0, -1); // select all
return FALSE;
}
gboolean
-sp_text_toolbox_popdown_focus_out (GtkWidget *popdown,
- GdkEventFocus */*event*/,
- GObject */*tbl*/)
+sp_text_toolbox_entry_focus_out (GtkWidget *entry,
+ GdkEventFocus */*event*/,
+ GObject *tbl)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
- if (popdown_hasfocus) {
- gtk_widget_hide (popdown);
- popdown_hasfocus = false;
- popdown_visible = false;
- gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
- return TRUE;
- }
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ gtk_entry_select_region (GTK_ENTRY (entry), 0, 0); // deselect
return FALSE;
}
-gboolean
-sp_text_toolbox_popdown_focus_in (GtkWidget */*popdown*/,
- GdkEventFocus */*event*/,
- GObject */*tbl*/)
-{
- popdown_hasfocus = true;
- return TRUE;
-}
-
-
void
-cell_data_func (GtkTreeViewColumn */*column*/,
+cell_data_func (GtkCellLayout */*cell_layout*/,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gtk_tree_model_get(tree_model, iter, 0, &family, -1);
gchar *const family_escaped = g_markup_escape_text(family, -1);
- static char const *const sample = _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()");
- gchar *const sample_escaped = g_markup_escape_text(sample, -1);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1);
+ if (show_sample) {
+
+ Glib::ustring sample = prefs->getString("/tools/text/font_sample");
+ gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1);
std::stringstream markup;
markup << family_escaped << " <span foreground='darkgray' font_family='"
<< family_escaped << "'>" << sample_escaped << "</span>";
g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL);
+ g_free(sample_escaped);
+ } else {
+ g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL);
+ }
+
g_free(family);
g_free(family_escaped);
- g_free(sample_escaped);
}
-static void delete_completion(GObject */*obj*/, GtkWidget *entry) {
- GObject *completion = (GObject *) gtk_object_get_data(GTK_OBJECT(entry), "completion");
- if (completion) {
- gtk_entry_set_completion (GTK_ENTRY(entry), NULL);
- g_object_unref (completion);
- }
+gboolean text_toolbox_completion_match_selected(GtkEntryCompletion */*widget*/,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ GObject *tbl)
+{
+ // We intercept this signal so as to fire family_changed at once (without it, you'd have to
+ // press Enter again after choosing a completion)
+ gchar *family = 0;
+ gtk_tree_model_get(model, iter, 0, &family, -1);
+
+ GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
+ gtk_entry_set_text (GTK_ENTRY (entry), family);
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+ sp_text_toolbox_family_changed (NULL, tbl);
+ return TRUE;
}
-GtkWidget*
-sp_text_toolbox_new (SPDesktop *desktop)
+
+static void
+cbe_add_completion (GtkComboBoxEntry *cbe, GObject *tbl){
+ GtkEntry *entry;
+ GtkEntryCompletion *completion;
+ GtkTreeModel *model;
+
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(cbe)));
+ completion = gtk_entry_completion_new();
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
+ gtk_entry_completion_set_model(completion, model);
+ gtk_entry_completion_set_text_column(completion, 0);
+ gtk_entry_completion_set_inline_completion(completion, FALSE);
+ gtk_entry_completion_set_inline_selection(completion, FALSE);
+ gtk_entry_completion_set_popup_completion(completion, TRUE);
+ gtk_entry_set_completion(entry, completion);
+
+ g_signal_connect (G_OBJECT (completion), "match-selected", G_CALLBACK (text_toolbox_completion_match_selected), tbl);
+
+ g_object_unref(completion);
+}
+
+void sp_text_toolbox_family_popnotify(GtkComboBox *widget,
+ void */*property*/,
+ GObject *tbl)
+{
+ // while the drop-down is open, we disable font family changing, reenabling it only when it closes
+
+ gboolean shown;
+ g_object_get (G_OBJECT(widget), "popup-shown", &shown, NULL);
+ if (shown) {
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ //g_print("POP: notify: SHOWN\n");
+ } else {
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+
+ // stupid GTK doesn't let us attach to events in the drop-down window, so we peek here to
+ // find out if the drop down was closed by Enter and if so, manually update (only
+ // necessary on Windows, on Linux it updates itself - what a mess, but we'll manage)
+ GdkEvent *ev = gtk_get_current_event();
+ if (ev) {
+ //g_print ("ev type: %d\n", ev->type);
+ if (ev->type == GDK_KEY_PRESS) {
+ switch (get_group0_keyval ((GdkEventKey *) ev)) {
+ case GDK_KP_Enter: // chosen
+ case GDK_Return:
+ {
+ // make sure the chosen one is inserted into the entry
+ GtkComboBox *combo = GTK_COMBO_BOX (((Gtk::ComboBox *) (g_object_get_data (tbl, "family-entry-combo")))->gobj());
+ GtkTreeModel *model = gtk_combo_box_get_model(combo);
+ GtkTreeIter iter;
+ gboolean has_active = gtk_combo_box_get_active_iter (combo, &iter);
+ if (has_active) {
+ gchar *family;
+ gtk_tree_model_get(model, &iter, 0, &family, -1);
+ GtkEntry *entry = GTK_ENTRY (g_object_get_data (G_OBJECT (tbl), "family-entry"));
+ gtk_entry_set_text (GTK_ENTRY (entry), family);
+ }
+
+ // update
+ sp_text_toolbox_family_changed (NULL, tbl);
+ break;
+ }
+ }
+ }
+ }
+
+ // regardless of whether we updated, defocus the widget
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop)
+ gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
+ //g_print("POP: notify: HIDDEN\n");
+ }
+}
+
+GtkWidget *sp_text_toolbox_new (SPDesktop *desktop)
{
GtkToolbar *tbl = GTK_TOOLBAR(gtk_toolbar_new());
- GtkIconSize secondarySize = static_cast<GtkIconSize>(prefToSize("/toolbox/secondary", 1));
+ GtkIconSize secondarySize = static_cast<GtkIconSize>(ToolboxFactory::prefToSize("/toolbox/secondary", 1));
gtk_object_set_data(GTK_OBJECT(tbl), "dtw", desktop->canvas);
gtk_object_set_data(GTK_OBJECT(tbl), "desktop", desktop);
GtkTooltips *tt = gtk_tooltips_new();
- Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
////////////Family
- //Window
- GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
-
- //Entry
- GtkWidget *entry = gtk_entry_new ();
- gtk_object_set_data(GTK_OBJECT(entry), "altx-text", entry);
- GtkEntryCompletion *completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (Glib::unwrap(store)));
- gtk_entry_completion_set_text_column (completion, 0);
- gtk_entry_completion_set_minimum_key_length (completion, 1);
- g_object_set (G_OBJECT(completion), "inline-completion", TRUE, "popup-completion", TRUE, NULL);
- gtk_entry_set_completion (GTK_ENTRY(entry), completion);
- gtk_object_set_data(GTK_OBJECT(entry), "completion", completion);
- gtk_toolbar_append_widget( tbl, entry, "", "" );
- g_signal_connect(G_OBJECT(tbl), "destroy", G_CALLBACK(delete_completion), entry);
-
- //Button
- GtkWidget *button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE));
- gtk_toolbar_append_widget( tbl, button, "", "");
-
- //Popdown
- GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
- GtkWidget *treeview = gtk_tree_view_new ();
+ Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
+ Gtk::ComboBoxEntry *font_sel = Gtk::manage(new Gtk::ComboBoxEntry(store));
- GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
- GtkTreeViewColumn *column = gtk_tree_view_column_new ();
- gtk_tree_view_column_pack_start (column, cell, FALSE);
- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_cell_data_func (column, cell, GtkTreeCellDataFunc (cell_data_func), NULL, NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+ gtk_rc_parse_string (
+ "style \"dropdown-as-list-style\"\n"
+ "{\n"
+ " GtkComboBox::appears-as-list = 1\n"
+ "}\n"
+ "widget \"*.toolbox-fontfamily-list\" style \"dropdown-as-list-style\"");
+ gtk_widget_set_name(GTK_WIDGET (font_sel->gobj()), "toolbox-fontfamily-list");
+ gtk_tooltips_set_tip (tt, GTK_WIDGET (font_sel->gobj()), _("Select font family (Alt+X to access)"), "");
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (Glib::unwrap(store)));
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
- gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (treeview), TRUE);
+ g_signal_connect (G_OBJECT (font_sel->gobj()), "key-press-event", G_CALLBACK(sp_text_toolbox_family_list_keypress), tbl);
- //gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), TRUE);
+ cbe_add_completion(font_sel->gobj(), G_OBJECT(tbl));
+
+ gtk_toolbar_append_widget( tbl, (GtkWidget*) font_sel->gobj(), "", "");
+ g_object_set_data (G_OBJECT (tbl), "family-entry-combo", font_sel);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
- gtk_container_add (GTK_CONTAINER (sw), treeview);
+ // expand the field a bit so as to view more of the previews in the drop-down
+ GtkRequisition req;
+ gtk_widget_size_request (GTK_WIDGET (font_sel->gobj()), &req);
+ gtk_widget_set_size_request (GTK_WIDGET (font_sel->gobj()), MIN(req.width + 50, 500), -1);
- gtk_container_add (GTK_CONTAINER (window), sw);
- gtk_widget_set_size_request (window, 300, 450);
+ GtkWidget* entry = (GtkWidget*) font_sel->get_entry()->gobj();
+ g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
- g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (sp_text_toolbox_family_entry_activate), tbl);
- g_signal_connect (G_OBJECT (entry), "focus-in-event", G_CALLBACK (sp_text_toolbox_entry_focus_in), tbl);
+ g_signal_connect (G_OBJECT (font_sel->gobj()), "changed", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
+ g_signal_connect (G_OBJECT (font_sel->gobj()), "notify::popup-shown",
+ G_CALLBACK (sp_text_toolbox_family_popnotify), tbl);
g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK(sp_text_toolbox_family_keypress), tbl);
+ g_signal_connect (G_OBJECT (entry), "focus-in-event", G_CALLBACK (sp_text_toolbox_entry_focus_in), tbl);
+ g_signal_connect (G_OBJECT (entry), "focus-out-event", G_CALLBACK (sp_text_toolbox_entry_focus_out), tbl);
- g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (sp_text_toolbox_text_popdown_clicked), tbl);
-
- g_signal_connect (G_OBJECT (window), "focus-out-event", G_CALLBACK (sp_text_toolbox_popdown_focus_out), tbl);
- g_signal_connect (G_OBJECT (window), "focus-in-event", G_CALLBACK (sp_text_toolbox_popdown_focus_in), tbl);
- g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK(sp_text_toolbox_family_list_keypress), tbl);
-
- GtkTreeSelection *tselection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
- g_signal_connect (G_OBJECT (tselection), "changed", G_CALLBACK (sp_text_toolbox_family_changed), tbl);
-
+ gtk_object_set_data(GTK_OBJECT(entry), "altx-text", entry);
g_object_set_data (G_OBJECT (tbl), "family-entry", entry);
- g_object_set_data (G_OBJECT (tbl), "family-popdown-button", button);
- g_object_set_data (G_OBJECT (tbl), "family-popdown-window", window);
- g_object_set_data (G_OBJECT (tbl), "family-tree-selection", tselection);
- g_object_set_data (G_OBJECT (tbl), "family-tree-view", treeview);
+
+ GtkCellRenderer *cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_clear( GTK_CELL_LAYOUT(font_sel->gobj()) );
+ gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(font_sel->gobj()) , cell , TRUE );
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT(font_sel->gobj()), cell, GtkCellLayoutDataFunc (cell_data_func), NULL, NULL);
GtkWidget *image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, secondarySize);
GtkWidget *box = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (box), image);
gtk_toolbar_append_widget( tbl, box, "", "");
g_object_set_data (G_OBJECT (tbl), "warning-image", box);
- GtkTooltips *tooltips = gtk_tooltips_new ();
- gtk_tooltips_set_tip (tooltips, box, _("This font is currently not installed on your system. Inkscape will use the default font instead."), "");
+ gtk_tooltips_set_tip (tt, box, _("This font is currently not installed on your system. Inkscape will use the default font instead."), "");
gtk_widget_hide (GTK_WIDGET (box));
g_signal_connect_swapped (G_OBJECT (tbl), "show", G_CALLBACK (gtk_widget_hide), box);
//spacer
gtk_toolbar_append_widget( tbl, gtk_vseparator_new(), "", "" );
- ////////////Text orientation
+ // Text orientation
group = gtk_radio_button_new (NULL);
row = gtk_hbox_new (FALSE, 4);
g_object_set_data (G_OBJECT (tbl), "orientation-group", group);
rbutton = group;
gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (rbutton),
- sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_STOCK_WRITING_MODE_LR));
+ sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_HORIZONTAL));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
gtk_tooltips_set_tip(tt, rbutton, _("Horizontal text"), NULL);
rbutton = gtk_radio_button_new (gtk_radio_button_group (GTK_RADIO_BUTTON (group)));
gtk_button_set_relief (GTK_BUTTON (rbutton), GTK_RELIEF_NONE);
gtk_container_add (GTK_CONTAINER (rbutton),
- sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_STOCK_WRITING_MODE_TB));
+ sp_icon_new (static_cast<Inkscape::IconSize>(secondarySize), INKSCAPE_ICON_FORMAT_TEXT_DIRECTION_VERTICAL));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (rbutton), FALSE);
gtk_tooltips_set_tip(tt, rbutton, _("Vertical text"), NULL);
//## Connector ##
//#########################
+static void sp_connector_mode_toggled( GtkToggleAction* act, GtkObject */*tbl*/ )
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/tools/connector/mode",
+ gtk_toggle_action_get_active( act ));
+}
+
static void sp_connector_path_set_avoid(void)
{
cc_selection_set_avoid(true);
cc_selection_set_avoid(false);
}
+static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl )
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ Inkscape::Selection * selection = sp_desktop_selection(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
+
+ if (!sp_document_get_undo_sensitive(doc))
+ {
+ return;
+ }
-static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
-{
// quit if run by the _changed callbacks
if (g_object_get_data( tbl, "freeze" )) {
return;
}
+ // in turn, prevent callbacks from responding
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+
+ bool is_orthog = gtk_toggle_action_get_active( act );
+ gchar orthog_str[] = "orthogonal";
+ gchar polyline_str[] = "polyline";
+ gchar *value = is_orthog ? orthog_str : polyline_str ;
+
+ bool modmade = false;
+ GSList *l = (GSList *) selection->itemList();
+ while (l) {
+ SPItem *item = (SPItem *) l->data;
+
+ if (cc_item_is_connector(item)) {
+ sp_object_setAttribute(item, "inkscape:connector-type",
+ value, false);
+ item->avoidRef->handleSettingChange();
+ modmade = true;
+ }
+ l = l->next;
+ }
+
+ if (!modmade)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setBool("/tools/connector/orthogonal", is_orthog);
+ }
+
+ sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline"));
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
+{
SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ Inkscape::Selection * selection = sp_desktop_selection(desktop);
SPDocument *doc = sp_desktop_document(desktop);
if (!sp_document_get_undo_sensitive(doc))
return;
}
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
- if ( repr->attribute("inkscape:connector-spacing") ) {
- gdouble priorValue = gtk_adjustment_get_value(adj);
- sp_repr_get_double( repr, "inkscape:connector-spacing", &priorValue );
- if ( priorValue == gtk_adjustment_get_value(adj) ) {
- return;
- }
- } else if ( adj->value == defaultConnSpacing ) {
+ // quit if run by the _changed callbacks
+ if (g_object_get_data( tbl, "freeze" )) {
return;
}
// in turn, prevent callbacks from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ gdouble newValue = gtk_adjustment_get_value(adj);
+ gchar value[G_ASCII_DTOSTR_BUF_SIZE];
+ g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue);
+
+ bool modmade = false;
+ GSList *l = (GSList *) selection->itemList();
+ while (l) {
+ SPItem *item = (SPItem *) l->data;
+
+ if (cc_item_is_connector(item)) {
+ sp_object_setAttribute(item, "inkscape:connector-curvature",
+ value, false);
+ item->avoidRef->handleSettingChange();
+ modmade = true;
+ }
+ l = l->next;
+ }
+
+ if (!modmade)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue);
+ }
+
+ sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR,
+ _("Change connector curvature"));
+
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
+}
+
+
+static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPDocument *doc = sp_desktop_document(desktop);
+
+ if (!sp_document_get_undo_sensitive(doc))
+ {
+ return;
+ }
+
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
+
+ if ( !repr->attribute("inkscape:connector-spacing") &&
+ ( adj->value == defaultConnSpacing )) {
+ // Don't need to update the repr if the attribute doesn't
+ // exist and it is being set to the default value -- as will
+ // happen at startup.
+ return;
+ }
+
+ // quit if run by the attr_changed listener
+ if (g_object_get_data( tbl, "freeze" )) {
+ return;
+ }
+
+ // in turn, prevent listener from responding
+ g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
+
sp_repr_set_css_double(repr, "inkscape:connector-spacing", adj->value);
SP_OBJECT(desktop->namedview)->updateRepr();
_("Change connector spacing"));
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
-
- spinbutton_defocus(GTK_OBJECT(tbl));
}
static void sp_connector_graph_layout(void)
@@ -6444,11 +7461,10 @@ static void sp_nooverlaps_graph_layout_toggled( GtkToggleAction* act, GtkObject
}
-static void connector_length_changed(GtkAdjustment *adj, GObject* tbl)
+static void connector_length_changed(GtkAdjustment *adj, GObject* /*tbl*/)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/tools/connector/length", adj->value);
- spinbutton_defocus(GTK_OBJECT(tbl));
}
static void connector_tb_event_attr_changed(Inkscape::XML::Node *repr,
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
return;
}
- if (strcmp(name, "inkscape:connector-spacing") != 0) {
- return;
+ if (strcmp(name, "inkscape:connector-spacing") == 0)
+ {
+ GtkAdjustment *adj = (GtkAdjustment*)
+ gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
+ gdouble spacing = defaultConnSpacing;
+ sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);
+
+ gtk_adjustment_set_value(adj, spacing);
+ gtk_adjustment_value_changed(adj);
}
- GtkAdjustment *adj = (GtkAdjustment*)
- gtk_object_get_data(GTK_OBJECT(tbl), "spacing");
- gdouble spacing = defaultConnSpacing;
- sp_repr_get_double(repr, "inkscape:connector-spacing", &spacing);
+ spinbutton_defocus(GTK_OBJECT(tbl));
+}
- gtk_adjustment_set_value(adj, spacing);
+static void sp_connector_new_connection_point(GtkWidget *, GObject *tbl)
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context);
+
+ if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE)
+ cc_create_connection_point(cc);
}
+static void sp_connector_remove_connection_point(GtkWidget *, GObject *tbl)
+{
+ SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" );
+ SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context);
+
+ if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE)
+ cc_remove_connection_point(cc);
+}
static Inkscape::XML::NodeEventVector connector_tb_repr_events = {
NULL, /* child_added */
NULL /* order_changed */
};
+static void sp_connector_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
+{
+ GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "curvature" ) );
+ GtkToggleAction *act = GTK_TOGGLE_ACTION( g_object_get_data( tbl, "orthogonal" ) );
+ SPItem *item = selection->singleItem();
+ if (SP_IS_PATH(item))
+ {
+ gdouble curvature = SP_PATH(item)->connEndPair.getCurvature();
+ bool is_orthog = SP_PATH(item)->connEndPair.isOrthogonal();
+ gtk_toggle_action_set_active(act, is_orthog);
+ gtk_adjustment_set_value(adj, curvature);
+ }
+
+}
static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder )
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- Inkscape::IconSize secondarySize = prefToSize("/toolbox/secondary", 1);
+ Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
+
+ // Editing mode toggle button
+ {
+ InkToggleAction* act = ink_toggle_action_new( "ConnectorEditModeAction",
+ _("EditMode"),
+ _("Switch between connection point editing and connector drawing mode"),
+ INKSCAPE_ICON_CONNECTOR_EDIT,
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+
+ bool tbuttonstate = prefs->getBool("/tools/connector/mode");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
+ g_object_set_data( holder, "mode", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_connector_mode_toggled), holder );
+ }
+
{
InkAction* inky = ink_action_new( "ConnectorAvoidAction",
_("Avoid"),
_("Make connectors avoid selected objects"),
- "connector_avoid",
+ INKSCAPE_ICON_CONNECTOR_AVOID,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_path_set_avoid), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -6501,23 +7566,48 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
InkAction* inky = ink_action_new( "ConnectorIgnoreAction",
_("Ignore"),
_("Make connectors ignore selected objects"),
- "connector_ignore",
+ INKSCAPE_ICON_CONNECTOR_IGNORE,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_path_set_ignore), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
}
+ // Orthogonal connectors toggle button
+ {
+ InkToggleAction* act = ink_toggle_action_new( "ConnectorOrthogonalAction",
+ _("Orthogonal"),
+ _("Make connector orthogonal or polyline"),
+ INKSCAPE_ICON_CONNECTOR_ORTHOGONAL,
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+
+ bool tbuttonstate = prefs->getBool("/tools/connector/orthogonal");
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
+ g_object_set_data( holder, "orthogonal", act );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_connector_orthogonal_toggled), holder );
+ }
+
EgeAdjustmentAction* eact = 0;
+ // Curvature spinbox
+ eact = create_adjustment_action( "ConnectorCurvatureAction",
+ _("Connector Curvature"), _("Curvature:"),
+ _("The amount of connectors curvature"),
+ "/tools/connector/curvature", defaultConnCurvature,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-curvature",
+ 0, 100, 1.0, 10.0,
+ 0, 0, 0,
+ connector_curvature_changed, 1, 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
// Spacing spinbox
eact = create_adjustment_action( "ConnectorSpacingAction",
- _("Connector Spacing"), _("Spacing:"),
- _("The amount of space left around objects by auto-routing connectors"),
- "/tools/connector/spacing", defaultConnSpacing,
- GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-spacing",
- 0, 100, 1.0, 10.0,
- 0, 0, 0,
- connector_spacing_changed, 1, 0 );
+ _("Connector Spacing"), _("Spacing:"),
+ _("The amount of space left around objects by auto-routing connectors"),
+ "/tools/connector/spacing", defaultConnSpacing,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "inkscape:connector-spacing",
+ 0, 100, 1.0, 10.0,
+ 0, 0, 0,
+ connector_spacing_changed, 1, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
// Graph (connector network) layout
@@ -6525,7 +7615,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
InkAction* inky = ink_action_new( "ConnectorGraphAction",
_("Graph"),
_("Nicely arrange selected connector network"),
- "graph_layout",
+ INKSCAPE_ICON_DISTRIBUTE_GRAPH,
secondarySize );
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_graph_layout), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
@@ -6548,7 +7638,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
InkToggleAction* act = ink_toggle_action_new( "ConnectorDirectedAction",
_("Downwards"),
_("Make connectors with end-markers (arrows) point downwards"),
- "directed_graph",
+ INKSCAPE_ICON_DISTRIBUTE_GRAPH_DIRECTED,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -6556,6 +7646,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder );
+ sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), (GObject *)holder));
}
// Avoid overlaps toggle button
@@ -6563,7 +7654,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
InkToggleAction* act = ink_toggle_action_new( "ConnectorOverlapAction",
_("Remove overlaps"),
_("Do not allow overlapping shapes"),
- "remove_overlaps",
+ INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS,
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
@@ -6573,6 +7664,31 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_nooverlaps_graph_layout_toggled), holder );
}
+
+ // New connection point button
+ {
+ InkAction* inky = ink_action_new( "ConnectorNewConnPointAction",
+ _("New connection point"),
+ _("Add a new connection point to the currently selected item"),
+ INKSCAPE_ICON_CONNECTOR_NEW_CONNPOINT,
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_new_connection_point), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
+ }
+
+ // Remove selected connection point button
+
+ {
+ InkAction* inky = ink_action_new( "ConnectorRemoveConnPointAction",
+ _("Remove connection point"),
+ _("Remove the currently selected connection point"),
+ INKSCAPE_ICON_CONNECTOR_REMOVE_CONNPOINT,
+ secondarySize );
+ g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_remove_connection_point), holder );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
+ }
+
+
// Code to watch for changes to the connector-spacing attribute in
// the XML.
Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
@@ -6681,7 +7797,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
_("Fill Threshold"), _("Threshold:"),
_("The maximum allowed difference between the clicked pixel and the neighboring pixels to be counted in the fill"),
"/tools/paintbucket/threshold", 5, GTK_WIDGET(desktop->canvas), NULL, holder, TRUE,
- "inkscape:paintbucket-threshold", 0, 100.0, 1.0, 0.0,
+ "inkscape:paintbucket-threshold", 0, 100.0, 1.0, 10.0,
0, 0, 0,
paintbucket_threshold_changed, 1, 0 );