summaryrefslogtreecommitdiffstats
path: root/src/widgets/gradient-vector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/gradient-vector.cpp')
-rw-r--r--src/widgets/gradient-vector.cpp108
1 files changed, 63 insertions, 45 deletions
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index e751f4872..31bd01719 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -23,6 +23,7 @@
# include "config.h"
#endif
+#include <glibmm.h>
#include "gradient-vector.h"
#include "ui/widget/color-preview.h"
#include "verbs.h"
@@ -39,7 +40,6 @@
#include "xml/repr.h"
-#include "../dialogs/dialog-events.h"
#include "../preferences.h"
#include "svg/css-ostringstream.h"
#include "sp-stop.h"
@@ -54,6 +54,7 @@
#include <sigc++/adaptors/bind.h>
#include "document-undo.h"
+#include "ui/dialog-events.h"
#include "ui/selected-color.h"
#include "ui/widget/color-notebook.h"
@@ -65,9 +66,6 @@ enum {
LAST_SIGNAL
};
-static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass);
-static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs);
-
#if GTK_CHECK_VERSION(3,0,0)
static void sp_gradient_vector_selector_destroy(GtkWidget *object);
#else
@@ -83,7 +81,6 @@ static SPStop *get_selected_stop( GtkWidget *vb);
void gr_get_usage_counts(SPDocument *doc, std::map<SPGradient *, gint> *mapUsageCount );
unsigned long sp_gradient_to_hhssll(SPGradient *gr);
-static GtkVBoxClass *parent_class;
static guint signals[LAST_SIGNAL] = {0};
// TODO FIXME kill these globals!!!
@@ -92,35 +89,15 @@ static win_data wd;
static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs
static Glib::ustring const prefs_path = "/dialogs/gradienteditor/";
-GType sp_gradient_vector_selector_get_type(void)
-{
- static GType type = 0;
- if (!type) {
- static const GTypeInfo info = {
- sizeof(SPGradientVectorSelectorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- reinterpret_cast<GClassInitFunc>(sp_gradient_vector_selector_class_init),
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(SPGradientVectorSelector),
- 0, /* n_preallocs */
- reinterpret_cast<GInstanceInitFunc>(sp_gradient_vector_selector_init),
- 0, /* value_table */
- };
-
- type = g_type_register_static( GTK_TYPE_VBOX,
- "SPGradientVectorSelector",
- &info,
- static_cast< GTypeFlags >(0) );
- }
- return type;
-}
+#if GTK_CHECK_VERSION(3,0,0)
+G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_BOX);
+#else
+G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_VBOX);
+#endif
static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
- parent_class = static_cast<GtkVBoxClass*>(g_type_class_peek_parent(klass));
signals[VECTOR_SET] = g_signal_new( "vector_set",
G_TYPE_FROM_CLASS(gobject_class),
@@ -142,6 +119,10 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass
static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_orientable_set_orientation(GTK_ORIENTABLE(gvs), GTK_ORIENTATION_VERTICAL);
+#endif
+
gvs->idlabel = TRUE;
gvs->swatched = false;
@@ -185,12 +166,12 @@ static void sp_gradient_vector_selector_destroy(GtkObject *object)
gvs->tree_select_connection.~connection();
#if GTK_CHECK_VERSION(3,0,0)
- if ((reinterpret_cast<GtkWidgetClass *>(parent_class))->destroy) {
- (* (reinterpret_cast<GtkWidgetClass *>(parent_class))->destroy) (object);
+ if ((GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy) {
+ (GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object);
}
#else
- if ((reinterpret_cast<GtkObjectClass *>(parent_class))->destroy) {
- (* (reinterpret_cast<GtkObjectClass *>(parent_class))->destroy) (object);
+ if ((GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy) {
+ (GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object);
}
#endif
}
@@ -492,9 +473,9 @@ void SPGradientVectorSelector::setSwatched()
### Vector Editing Widget
##################################################################*/
-#include "../widgets/widget-sizes.h"
-#include "../xml/node-event-vector.h"
-#include "../svg/svg-color.h"
+#include "widgets/widget-sizes.h"
+#include "xml/node-event-vector.h"
+#include "svg/svg-color.h"
#include "ui/widget/color-notebook.h"
#define PAD 4
@@ -1050,13 +1031,28 @@ GtkWidget * sp_gradient_vector_editor_new(SPGradient *gradient, SPStop *stop)
sp_transientize(dlg);
wd.win = dlg;
wd.stop = 0;
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK(sp_transientize_callback), &wd);
- g_signal_connect(G_OBJECT(dlg), "event", G_CALLBACK(sp_dialog_event_handler), dlg);
- g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg);
- g_signal_connect(G_OBJECT(dlg), "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect(G_OBJECT(INKSCAPE), "shut_down", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
- g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_hide", G_CALLBACK(sp_dialog_hide), dlg );
- g_signal_connect( G_OBJECT(INKSCAPE), "dialogs_unhide", G_CALLBACK(sp_dialog_unhide), dlg );
+
+ GObject *obj = G_OBJECT(dlg);
+ sigc::connection *conn = NULL;
+
+ conn = new sigc::connection(INKSCAPE.signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)));
+ g_object_set_data(obj, "desktop-activate-connection", conn);
+
+ g_signal_connect(obj, "event", G_CALLBACK(sp_dialog_event_handler), dlg);
+ g_signal_connect(obj, "destroy", G_CALLBACK(sp_gradient_vector_dialog_destroy), dlg);
+ g_signal_connect(obj, "delete_event", G_CALLBACK(sp_gradient_vector_dialog_delete), dlg);
+
+ conn = new sigc::connection(INKSCAPE.signal_shut_down.connect(
+ sigc::hide_return(
+ sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL)
+ )));
+ g_object_set_data(obj, "shutdown-connection", conn);
+
+ conn = new sigc::connection(INKSCAPE.signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(&gtk_widget_hide), dlg)));
+ g_object_set_data(obj, "dialog-hide-connection", conn);
+
+ conn = new sigc::connection(INKSCAPE.signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(&gtk_widget_show), dlg)));
+ g_object_set_data(obj, "dialog-unhide-connection", conn);
gtk_container_set_border_width(GTK_CONTAINER(dlg), PAD);
@@ -1181,7 +1177,29 @@ static void sp_gradient_vector_dialog_destroy(GtkWidget * /*object*/, gpointer /
static void sp_gradient_vector_dialog_destroy(GtkObject * /*object*/, gpointer /*data*/)
#endif
{
- sp_signal_disconnect_by_data(INKSCAPE, dlg);
+ GObject *obj = G_OBJECT(dlg);
+ assert(obj != NULL);
+
+ sigc::connection *conn = static_cast<sigc::connection *>(g_object_get_data(obj, "desktop-activate-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "shutdown-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "dialog-hide-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
+ conn = static_cast<sigc::connection *>(g_object_get_data(obj, "dialog-unhide-connection"));
+ assert(conn != NULL);
+ conn->disconnect();
+ delete conn;
+
wd.win = dlg = NULL;
wd.stop = 0;
}