summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-12 21:37:42 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-12 21:37:42 +0000
commit78d439326a4dd26599853295e62b9f63136fc2f3 (patch)
treefc5159d3cbd5ae8e3564c961c8c3f2cc18e96e0f /src/widgets
parentUpdate to experimental r13465 (diff)
parentupdating pot files (diff)
downloadinkscape-78d439326a4dd26599853295e62b9f63136fc2f3.tar.gz
inkscape-78d439326a4dd26599853295e62b9f63136fc2f3.zip
Update to experimental r13479
(bzr r13090.1.103)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/arc-toolbar.cpp20
-rw-r--r--src/widgets/box3d-toolbar.cpp20
-rw-r--r--src/widgets/gradient-selector.cpp6
-rw-r--r--src/widgets/gradient-selector.h3
-rw-r--r--src/widgets/gradient-toolbar.cpp75
-rw-r--r--src/widgets/lpe-toolbar.cpp33
-rw-r--r--src/widgets/mesh-toolbar.cpp88
-rw-r--r--src/widgets/node-toolbar.cpp46
-rw-r--r--src/widgets/paint-selector.cpp55
-rw-r--r--src/widgets/paint-selector.h9
-rw-r--r--src/widgets/rect-toolbar.cpp20
-rw-r--r--src/widgets/star-toolbar.cpp23
-rw-r--r--src/widgets/text-toolbar.cpp2
13 files changed, 262 insertions, 138 deletions
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index ca6810c81..1005de70d 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -45,6 +45,7 @@
#include "toolbox.h"
#include "ui/icon-names.h"
#include "ui/uxmanager.h"
+#include "ui/tools/arc-tool.h"
#include "verbs.h"
#include "widgets/spinbutton-events.h"
#include "xml/node-event-vector.h"
@@ -304,6 +305,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb
}
}
+static void arc_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -402,14 +404,22 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec
sp_arctb_sensitivize( holder, gtk_adjustment_get_value(adj1), gtk_adjustment_get_value(adj2) );
}
-
- sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), G_OBJECT(holder)))
- );
- g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(arc_toolbox_check_ec), holder));
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
}
+static void arc_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection changed;
+
+ if (SP_IS_ARC_CONTEXT(ec)) {
+ changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_arc_toolbox_selection_changed), holder));
+ sp_arc_toolbox_selection_changed(sp_desktop_selection(desktop), holder);
+ } else {
+ if (changed)
+ changed.disconnect();
+ }
+}
/*
Local Variables:
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index 6d6b86c4d..7629e8c24 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -43,6 +43,7 @@
#include "selection.h"
#include "toolbox.h"
#include "ui/icon-names.h"
+#include "ui/tools/box3d-tool.h"
#include "ui/uxmanager.h"
#include "verbs.h"
#include "xml/node-event-vector.h"
@@ -280,6 +281,8 @@ static void box3d_vp_z_state_changed( GtkToggleAction *act, GtkAction *box3d_ang
box3d_vp_state_changed(act, box3d_angle, Proj::Z);
}
+static void box3d_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
+
void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -409,13 +412,22 @@ void box3d_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/shapes/3dbox/vp_z_state", true) );
}
- sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), G_OBJECT(holder)))
- );
- g_signal_connect(holder, "destroy", G_CALLBACK(delete_connection), connection);
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_check_ec), holder));
g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder);
}
+static void box3d_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection changed;
+ if (SP_IS_BOX3D_CONTEXT(ec)) {
+ changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(box3d_toolbox_selection_changed), holder));
+ box3d_toolbox_selection_changed(sp_desktop_selection(desktop), holder);
+ } else {
+ if (changed)
+ changed.disconnect();
+ }
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 871d1ee4c..511478111 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -20,9 +20,9 @@
#include <gtk/gtk.h>
#include "document.h"
-#include "../document-undo.h"
-#include "../document-private.h"
-#include "../gradient-chemistry.h"
+#include "document-undo.h"
+#include "document-private.h"
+#include "gradient-chemistry.h"
#include "inkscape.h"
#include "verbs.h"
#include "helper/action.h"
diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h
index 1f58de2e4..ee8980be9 100644
--- a/src/widgets/gradient-selector.h
+++ b/src/widgets/gradient-selector.h
@@ -54,6 +54,9 @@ struct SPGradientSelector {
enum SelectorMode {
MODE_LINEAR,
MODE_RADIAL,
+#ifdef WITH_MESH
+ MODE_MESH,
+#endif
MODE_SWATCH
};
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index 4fda44c8d..f5a99f3e7 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -448,11 +448,6 @@ static void gr_defs_modified(SPObject * /*defs*/, guint /*flags*/, GtkWidget *wi
gr_tb_selection_changed(NULL, (gpointer) widget);
}
-static void gr_disconnect_sigc(GObject * /*obj*/, sigc::connection *connection) {
- connection->disconnect();
- delete connection;
-}
-
static SPStop *get_selected_stop( GtkWidget *vb)
{
SPStop *stop = NULL;
@@ -1018,6 +1013,9 @@ void check_renderer(GtkWidget *combo)
g_object_set_data(G_OBJECT(combo), "renderers", renderer);
}
}
+
+static void gradient_toolbox_check_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
+
/**
* Gradient auxiliary toolbar construction and setup.
*
@@ -1229,34 +1227,51 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions,
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), !linkedmode );
}
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPDocument *document = sp_desktop_document(desktop);
-
g_object_set_data(holder, "desktop", desktop);
- // connect to selection modified and changed signals
- sigc::connection *conn1 = new sigc::connection(
- selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), (gpointer) holder)));
- sigc::connection *conn2 = new sigc::connection(
- selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), (gpointer) holder)));
- sigc::connection *conn3 = new sigc::connection(
- desktop->connectToolSubselectionChanged( sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), (gpointer) holder)));
-
- // when holder is destroyed, disconnect
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn1);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn2);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), conn3);
-
- // connect to release and modified signals of the defs (i.e. when someone changes gradient)
- sigc::connection *release_connection = new sigc::connection();
- *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder)));
- sigc::connection *modified_connection = new sigc::connection();
- *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder)));
-
- // when holder is destroyed, disconnect
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), release_connection);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(gr_disconnect_sigc), modified_connection);
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(&gradient_toolbox_check_ec), holder));
+}
+
+// lp:1327267
+/**
+ * Checks the current tool and connects gradient aux toolbox signals if it happens to be the gradient tool.
+ * Called every time the current tool changes by signal emission.
+ */
+static void gradient_toolbox_check_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection connChanged;
+ static sigc::connection connModified;
+ static sigc::connection connSubselectionChanged;
+ static sigc::connection connDefsRelease;
+ static sigc::connection connDefsModified;
+
+ if (SP_IS_GRADIENT_CONTEXT(ec)) {
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
+ SPDocument *document = sp_desktop_document(desktop);
+ // connect to selection modified and changed signals
+ connChanged = selection->connectChanged(sigc::bind(sigc::ptr_fun(&gr_tb_selection_changed), holder));
+ connModified = selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), holder));
+ connSubselectionChanged = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), holder));
+
+ // Is this necessary? Couldn't hurt.
+ gr_tb_selection_changed(selection, holder);
+
+ // connect to release and modified signals of the defs (i.e. when someone changes gradient)
+ connDefsRelease = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), GTK_WIDGET(holder)));
+ connDefsModified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder)));
+ } else {
+ if (connChanged)
+ connChanged.disconnect();
+ if (connModified)
+ connModified.disconnect();
+ if (connSubselectionChanged)
+ connSubselectionChanged.disconnect();
+ if (connDefsRelease)
+ connDefsRelease.disconnect();
+ if (connDefsModified)
+ connDefsModified.disconnect();
+ }
}
/*
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index 94d42b5eb..7ad88b856 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -30,7 +30,6 @@
#include "live_effects/lpe-line_segment.h"
#include "lpe-toolbar.h"
-#include "connection-pool.h"
#include "desktop-handles.h"
#include "desktop.h"
#include "document-undo.h"
@@ -276,6 +275,8 @@ static void lpetool_open_lpe_dialog(GtkToggleAction *act, gpointer data)
gtk_toggle_action_set_active(act, false);
}
+static void lpetool_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
+
void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
@@ -402,21 +403,27 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), FALSE );
}
- //watch selection
- Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox");
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(lpetool_toolbox_watch_ec), holder));
+}
- sigc::connection *c_selection_modified =
- new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_lpetool_toolbox_sel_modified), holder)));
- pool->add_connection ("selection-modified", c_selection_modified);
+static void lpetool_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection c_selection_modified;
+ static sigc::connection c_selection_changed;
- sigc::connection *c_selection_changed =
- new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder)));
- pool->add_connection ("selection-changed", c_selection_changed);
+ if (SP_IS_LPETOOL_CONTEXT(ec)) {
+ // Watch selection
+ c_selection_modified = sp_desktop_selection(desktop)->connectModified(sigc::bind(sigc::ptr_fun(sp_lpetool_toolbox_sel_modified), holder));
+ c_selection_changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_lpetool_toolbox_sel_changed), holder));
+ sp_lpetool_toolbox_sel_changed(sp_desktop_selection(desktop), holder);
+ } else {
+ if (c_selection_modified)
+ c_selection_modified.disconnect();
+ if (c_selection_changed)
+ c_selection_changed.disconnect();
+ }
}
-
/*
Local Variables:
mode:c++
@@ -426,4 +433,4 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 15dda94f0..73e450926 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -42,6 +42,7 @@
#include <glibmm/i18n.h>
#include "ui/tools/gradient-tool.h"
+#include "ui/tools/mesh-tool.h"
#include "gradient-drag.h"
#include "sp-mesh-gradient.h"
#include "gradient-chemistry.h"
@@ -49,17 +50,16 @@
#include "selection.h"
#include "ui/icon-names.h"
-#include "../ege-adjustment-action.h"
-#include "../ege-output-action.h"
-#include "../ege-select-one-action.h"
-#include "../ink-action.h"
-#include "../ink-comboboxentry-action.h"
+#include "ege-adjustment-action.h"
+#include "ege-output-action.h"
+#include "ege-select-one-action.h"
+#include "ink-action.h"
+#include "ink-comboboxentry-action.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
-#include "ui/tools/gradient-tool.h"
#include "toolbox.h"
@@ -67,7 +67,7 @@ using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
-static gboolean blocked = FALSE;
+static bool blocked = false;
//########################
//## Mesh ##
@@ -116,22 +116,16 @@ static void ms_drag_selection_changed(gpointer /*dragger*/, gpointer data)
}
-static void ms_defs_release(SPObject * /*defs*/, GtkWidget *widget)
+static void ms_defs_release(SPObject * /*defs*/, GObject *widget)
{
ms_tb_selection_changed(NULL, widget);
}
-static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GtkWidget *widget)
+static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GObject *widget)
{
- ms_tb_selection_changed(NULL, (gpointer) widget);
-}
-
-static void ms_disconnect_sigc(GObject * /*obj*/, sigc::connection *connection) {
- connection->disconnect();
- delete connection;
+ ms_tb_selection_changed(NULL, widget);
}
-
/*
* Callback functions for user actions
*/
@@ -184,6 +178,8 @@ static void ms_col_changed(GtkAdjustment *adj, GObject * /*tbl*/ )
blocked = FALSE;
}
+static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
+
/**
* Mesh auxiliary toolbar construction and setup.
*
@@ -323,35 +319,43 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher);
}
-
- Inkscape::Selection *selection = sp_desktop_selection (desktop);
- SPDocument *document = sp_desktop_document (desktop);
-
g_object_set_data(holder, "desktop", desktop);
- // connect to selection modified and changed signals
- sigc::connection *conn1 = new sigc::connection(
- selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), (gpointer) holder)));
- sigc::connection *conn2 = new sigc::connection(
- selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), (gpointer) holder)));
- sigc::connection *conn3 = new sigc::connection(
- desktop->connectToolSubselectionChanged( sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), (gpointer) holder)));
-
- // when holder is destroyed, disconnect
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn1);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn2);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), conn3);
-
- // connect to release and modified signals of the defs (i.e. when someone changes mesh)
- sigc::connection *release_connection = new sigc::connection();
- *release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), GTK_WIDGET(holder)));
- sigc::connection *modified_connection = new sigc::connection();
- *modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), GTK_WIDGET(holder)));
-
- // when holder is destroyed, disconnect
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), release_connection);
- g_signal_connect(G_OBJECT(holder), "destroy", G_CALLBACK(ms_disconnect_sigc), modified_connection);
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(mesh_toolbox_watch_ec), holder));
+}
+static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection c_selection_changed;
+ static sigc::connection c_selection_modified;
+ static sigc::connection c_subselection_changed;
+ static sigc::connection c_defs_release;
+ static sigc::connection c_defs_modified;
+
+ if (SP_IS_MESH_CONTEXT(ec)) {
+ // connect to selection modified and changed signals
+ Inkscape::Selection *selection = sp_desktop_selection (desktop);
+ SPDocument *document = sp_desktop_document (desktop);
+
+ c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder));
+ c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder));
+ c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder));
+
+ c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder));
+ c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder));
+ ms_tb_selection_changed(selection, holder);
+ } else {
+ if (c_selection_changed)
+ c_selection_changed.disconnect();
+ if (c_selection_modified)
+ c_selection_modified.disconnect();
+ if (c_subselection_changed)
+ c_subselection_changed.disconnect();
+ if (c_defs_release)
+ c_defs_release.disconnect();
+ if (c_defs_modified)
+ c_defs_modified.disconnect();
+ }
}
/*
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index 38e3f4fbd..ace78f8f5 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -31,7 +31,6 @@
#include "ui/tool/multi-path-manipulator.h"
#include <glibmm/i18n.h>
#include "node-toolbar.h"
-#include "connection-pool.h"
#include "desktop-handles.h"
#include "desktop.h"
#include "document-undo.h"
@@ -322,7 +321,7 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint /
sp_node_toolbox_sel_changed (selection, tbl);
}
-
+static void node_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
//################################
//## Node Editing Toolbox ##
@@ -615,32 +614,33 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
gtk_action_group_add_action( mainActions, act );
}
-
sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder);
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(node_toolbox_watch_ec), holder));
- //watch selection
- Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox");
-
- sigc::connection *c_selection_changed =
- new sigc::connection (sp_desktop_selection (desktop)->connectChanged
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder)));
- pool->add_connection ("selection-changed", c_selection_changed);
-
- sigc::connection *c_selection_modified =
- new sigc::connection (sp_desktop_selection (desktop)->connectModified
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder)));
- pool->add_connection ("selection-modified", c_selection_modified);
-
- sigc::connection *c_subselection_changed =
- new sigc::connection (desktop->connectToolSubselectionChanged
- (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder)));
- pool->add_connection ("tool-subselection-changed", c_subselection_changed);
+} // end of sp_node_toolbox_prep()
- Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool);
+static void node_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection c_selection_changed;
+ static sigc::connection c_selection_modified;
+ static sigc::connection c_subselection_changed;
- g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
-} // end of sp_node_toolbox_prep()
+ if (INK_IS_NODE_TOOL(ec)) {
+ // watch selection
+ c_selection_changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_node_toolbox_sel_changed), holder));
+ c_selection_modified = sp_desktop_selection(desktop)->connectModified(sigc::bind(sigc::ptr_fun(sp_node_toolbox_sel_modified), holder));
+ c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(sp_node_toolbox_coord_changed), holder));
+ sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder);
+ } else {
+ if (c_selection_changed)
+ c_selection_changed.disconnect();
+ if (c_selection_modified)
+ c_selection_modified.disconnect();
+ if (c_subselection_changed)
+ c_subselection_changed.disconnect();
+ }
+}
/*
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 9466c875e..f4ceee187 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -29,14 +29,15 @@
#endif
#include "widgets/swatch-selector.h"
-#include "../sp-pattern.h"
+#include "sp-pattern.h"
#include <glibmm/i18n.h>
-#include "../widgets/icon.h"
+#include "widgets/icon.h"
#include "widgets/widget-sizes.h"
#include "xml/repr.h"
#include "sp-color-notebook.h"
#include "sp-linear-gradient.h"
+#include "sp-mesh-gradient.h"
#include "sp-radial-gradient.h"
/* fixme: Move it from dialogs to here */
#include "gradient-selector.h"
@@ -113,10 +114,13 @@ static gchar const* modeStrings[] = {
#endif
-static bool isPaintModeGradient( SPPaintSelector::Mode mode )
+static bool isPaintModeGradient(SPPaintSelector::Mode mode)
{
bool isGrad = (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) ||
(mode == SPPaintSelector::MODE_GRADIENT_RADIAL) ||
+#ifdef WITH_MESH
+ (mode == SPPaintSelector::MODE_GRADIENT_MESH) ||
+#endif
(mode == SPPaintSelector::MODE_SWATCH);
return isGrad;
@@ -238,6 +242,10 @@ sp_paint_selector_init(SPPaintSelector *psel)
SPPaintSelector::MODE_GRADIENT_LINEAR, _("Linear gradient"));
psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-radial"),
SPPaintSelector::MODE_GRADIENT_RADIAL, _("Radial gradient"));
+#ifdef WITH_MESH
+ psel->mesh = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-gradient-mesh"),
+ SPPaintSelector::MODE_GRADIENT_MESH, _("Mesh gradient"));
+#endif
psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-pattern"),
SPPaintSelector::MODE_PATTERN, _("Pattern"));
psel->swatch = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON("paint-swatch"),
@@ -413,6 +421,9 @@ void SPPaintSelector::setMode(Mode mode)
break;
case MODE_GRADIENT_LINEAR:
case MODE_GRADIENT_RADIAL:
+#ifdef WITH_MESH
+ case MODE_GRADIENT_MESH:
+#endif
sp_paint_selector_set_mode_gradient(this, mode);
break;
case MODE_PATTERN:
@@ -511,6 +522,21 @@ void SPPaintSelector::setGradientRadial(SPGradient *vector)
gsel->setVector((vector) ? vector->document : 0, vector);
}
+#ifdef WITH_MESH
+void SPPaintSelector::setGradientMesh(SPGradient *vector)
+{
+#ifdef SP_PS_VERBOSE
+ g_print("PaintSelector set GRADIENT MESH\n");
+#endif
+ setMode(MODE_GRADIENT_RADIAL);
+
+ SPGradientSelector *gsel = getGradientFromData(this);
+
+ gsel->setMode(SPGradientSelector::MODE_MESH);
+ gsel->setVector((vector) ? vector->document : 0, vector);
+}
+#endif
+
void SPPaintSelector::setGradientProperties( SPGradientUnits units, SPGradientSpread spread )
{
g_return_if_fail(isPaintModeGradient(mode));
@@ -728,9 +754,14 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe
if (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) {
sp_paint_selector_set_style_buttons(psel, psel->gradient);
- } else {
+ } else if (mode == SPPaintSelector::MODE_GRADIENT_RADIAL) {
sp_paint_selector_set_style_buttons(psel, psel->radial);
}
+#ifdef WITH_MESH
+ else {
+ sp_paint_selector_set_style_buttons(psel, psel->mesh);
+ }
+#endif
gtk_widget_set_sensitive(psel->style, TRUE);
if ((psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (psel->mode == SPPaintSelector::MODE_GRADIENT_RADIAL)) {
@@ -756,10 +787,17 @@ static void sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSe
SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_LINEAR);
//sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_LINEAR);
gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Linear gradient</b>"));
- } else {
+ } else if (mode == SPPaintSelector::MODE_GRADIENT_LINEAR) {
SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL);
gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Radial gradient</b>"));
}
+#ifdef WITH_MESH
+ else {
+ SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL);
+ gtk_label_set_markup(GTK_LABEL(psel->label), _("<b>Mesh gradient</b>"));
+ }
+#endif
+
#ifdef SP_PS_VERBOSE
g_print("Gradient req\n");
#endif
@@ -772,6 +810,9 @@ sp_paint_selector_set_style_buttons(SPPaintSelector *psel, GtkWidget *active)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->solid), (active == psel->solid));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->gradient), (active == psel->gradient));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->radial), (active == psel->radial));
+#ifdef WITH_MESH
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->mesh), (active == psel->mesh));
+#endif
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->pattern), (active == psel->pattern));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->swatch), (active == psel->swatch));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->unset), (active == psel->unset));
@@ -1218,6 +1259,10 @@ SPPaintSelector::Mode SPPaintSelector::getModeForStyle(SPStyle const & style, Fi
mode = MODE_GRADIENT_LINEAR;
} else if (SP_IS_RADIALGRADIENT(server)) {
mode = MODE_GRADIENT_RADIAL;
+#ifdef WITH_MESH
+ } else if (SP_IS_MESHGRADIENT(server)) {
+ mode = MODE_GRADIENT_MESH;
+#endif
} else if (SP_IS_PATTERN(server)) {
mode = MODE_PATTERN;
} else {
diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h
index d6ad3f50c..a2a303a47 100644
--- a/src/widgets/paint-selector.h
+++ b/src/widgets/paint-selector.h
@@ -45,6 +45,9 @@ struct SPPaintSelector {
MODE_COLOR_CMYK,
MODE_GRADIENT_LINEAR,
MODE_GRADIENT_RADIAL,
+#ifdef WITH_MESH
+ MODE_GRADIENT_MESH,
+#endif
MODE_PATTERN,
MODE_SWATCH,
MODE_UNSET
@@ -64,6 +67,9 @@ struct SPPaintSelector {
GtkWidget *solid;
GtkWidget *gradient;
GtkWidget *radial;
+#ifdef WITH_MESH
+ GtkWidget *mesh;
+#endif
GtkWidget *pattern;
GtkWidget *swatch;
GtkWidget *unset;
@@ -88,6 +94,9 @@ struct SPPaintSelector {
void setGradientLinear( SPGradient *vector );
void setGradientRadial( SPGradient *vector );
+#ifdef WITH_MESH
+ void setGradientMesh(SPGradient *vector);
+#endif
void setSwatch( SPGradient *vector );
void setGradientProperties( SPGradientUnits units, SPGradientSpread spread );
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index c9a09e908..48808fe70 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -44,6 +44,7 @@
#include "sp-rect.h"
#include "toolbox.h"
#include "ui/icon-names.h"
+#include "ui/tools/rect-tool.h"
#include "ui/uxmanager.h"
#include "ui/widget/unit-tracker.h"
#include "util/units.h"
@@ -288,6 +289,7 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO
}
}
+static void rect_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -394,13 +396,21 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
g_object_set_data( holder, "single", GINT_TO_POINTER(TRUE) );
sp_rtb_sensitivize( holder );
- sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder))
- );
- g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(rect_toolbox_watch_ec), holder));
g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
}
+static void rect_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection changed;
+
+ if (SP_IS_RECT_CONTEXT(ec)) {
+ changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_rect_toolbox_selection_changed), holder));
+ } else {
+ if (changed)
+ changed.disconnect();
+ }
+}
/*
Local Variables:
@@ -411,4 +421,4 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 7a7d0dc71..0f8c31be8 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -42,6 +42,7 @@
#include "sp-star.h"
#include "toolbox.h"
#include "ui/icon-names.h"
+#include "ui/tools/star-tool.h"
#include "ui/uxmanager.h"
#include "verbs.h"
#include "widgets/../preferences.h"
@@ -435,6 +436,7 @@ static void sp_stb_defaults( GtkWidget * /*widget*/, GObject *dataKludge )
gtk_adjustment_value_changed(adj);
}
+static void star_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -571,15 +573,22 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
}
}
- sigc::connection *connection = new sigc::connection(
- sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder))
- );
- g_signal_connect( holder, "destroy", G_CALLBACK(delete_connection), connection );
- g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder );
+ desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(star_toolbox_watch_ec), holder));
+ g_signal_connect(holder, "destroy", G_CALLBACK(purge_repr_listener), holder);
}
+static void star_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
+{
+ static sigc::connection changed;
-
+ if (dynamic_cast<Inkscape::UI::Tools::StarTool const*>(ec) != NULL) {
+ changed = sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_star_toolbox_selection_changed), holder));
+ sp_star_toolbox_selection_changed(sp_desktop_selection(desktop), holder);
+ } else {
+ if (changed)
+ changed.disconnect();
+ }
+}
/*
Local Variables:
@@ -590,4 +599,4 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 36a151c52..408babf06 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -1661,4 +1661,4 @@ static void text_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolB
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :