summaryrefslogtreecommitdiffstats
path: root/src/widgets/mesh-toolbar.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-10 02:47:25 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-10 02:47:25 +0000
commit764f8e7612bbf000a5fab4eeed165432f4ff779b (patch)
treeee2a1c55b35548b5d585c80c99de4860c0fb448f /src/widgets/mesh-toolbar.cpp
parentUpdate to trunk r13504 (diff)
downloadinkscape-764f8e7612bbf000a5fab4eeed165432f4ff779b.tar.gz
inkscape-764f8e7612bbf000a5fab4eeed165432f4ff779b.zip
Further fixes related to bug #1327267, toolbars don't need to update when their context is not in use
(bzr r13341.1.126)
Diffstat (limited to 'src/widgets/mesh-toolbar.cpp')
-rw-r--r--src/widgets/mesh-toolbar.cpp88
1 files changed, 46 insertions, 42 deletions
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();
+ }
}
/*