summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9e0770)
raw | patch | inline | side by side (parent: c9e0770)
author | joncruz <joncruz@users.sourceforge.net> | |
Thu, 4 Dec 2008 08:55:14 +0000 (08:55 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Thu, 4 Dec 2008 08:55:14 +0000 (08:55 +0000) |
src/widgets/gradient-vector.cpp | patch | blob | history | |
src/widgets/gradient-vector.h | patch | blob | history |
index 5f4d06172da612a705ceeb9d0ac307e37638db4c..b1ff7868997798a80a8420a2008fe9307f48c156 100644 (file)
-#define __SP_GRADIENT_VECTOR_C__
-
/*
* Gradient vector selection widget
*
#include <sigc++/adaptors/bind.h>
enum {
- VECTOR_SET,
- LAST_SIGNAL
+ VECTOR_SET,
+ LAST_SIGNAL
};
static void sp_gradient_vector_selector_class_init (SPGradientVectorSelectorClass *klass);
GtkType
sp_gradient_vector_selector_get_type (void)
{
- static GtkType type = 0;
- if (!type) {
- GtkTypeInfo info = {
- "SPGradientVectorSelector",
- sizeof (SPGradientVectorSelector),
- sizeof (SPGradientVectorSelectorClass),
- (GtkClassInitFunc) sp_gradient_vector_selector_class_init,
- (GtkObjectInitFunc) sp_gradient_vector_selector_init,
- NULL, NULL, NULL
- };
- type = gtk_type_unique (GTK_TYPE_VBOX, &info);
- }
- return type;
+ static GtkType type = 0;
+ if (!type) {
+ GtkTypeInfo info = {
+ "SPGradientVectorSelector",
+ sizeof (SPGradientVectorSelector),
+ sizeof (SPGradientVectorSelectorClass),
+ (GtkClassInitFunc) sp_gradient_vector_selector_class_init,
+ (GtkObjectInitFunc) sp_gradient_vector_selector_init,
+ NULL, NULL, NULL
+ };
+ type = gtk_type_unique (GTK_TYPE_VBOX, &info);
+ }
+ return type;
}
static void
sp_gradient_vector_selector_class_init (SPGradientVectorSelectorClass *klass)
{
- GtkObjectClass *object_class;
+ GtkObjectClass *object_class;
- object_class = GTK_OBJECT_CLASS (klass);
+ object_class = GTK_OBJECT_CLASS (klass);
- parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX);
+ parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX);
- signals[VECTOR_SET] = gtk_signal_new ("vector_set",
- GTK_RUN_LAST,
- GTK_CLASS_TYPE(object_class),
- GTK_SIGNAL_OFFSET (SPGradientVectorSelectorClass, vector_set),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
+ signals[VECTOR_SET] = gtk_signal_new ("vector_set",
+ GTK_RUN_LAST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET (SPGradientVectorSelectorClass, vector_set),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_POINTER);
- object_class->destroy = sp_gradient_vector_selector_destroy;
+ object_class->destroy = sp_gradient_vector_selector_destroy;
}
static void
sp_gradient_vector_selector_init (SPGradientVectorSelector *gvs)
{
- gvs->idlabel = TRUE;
+ gvs->idlabel = TRUE;
- gvs->doc = NULL;
- gvs->gr = NULL;
+ gvs->doc = NULL;
+ gvs->gr = NULL;
- new (&gvs->gradient_release_connection) sigc::connection();
- new (&gvs->defs_release_connection) sigc::connection();
- new (&gvs->defs_modified_connection) sigc::connection();
+ new (&gvs->gradient_release_connection) sigc::connection();
+ new (&gvs->defs_release_connection) sigc::connection();
+ new (&gvs->defs_modified_connection) sigc::connection();
- gvs->menu = gtk_option_menu_new ();
- gtk_widget_show (gvs->menu);
- gtk_box_pack_start (GTK_BOX (gvs), gvs->menu, TRUE, TRUE, 0);
+ gvs->menu = gtk_option_menu_new ();
+ gtk_widget_show (gvs->menu);
+ gtk_box_pack_start (GTK_BOX (gvs), gvs->menu, TRUE, TRUE, 0);
}
static void
sp_gradient_vector_selector_destroy (GtkObject *object)
{
- SPGradientVectorSelector *gvs;
+ SPGradientVectorSelector *gvs;
- gvs = SP_GRADIENT_VECTOR_SELECTOR (object);
+ gvs = SP_GRADIENT_VECTOR_SELECTOR (object);
- if (gvs->gr) {
- gvs->gradient_release_connection.disconnect();
- gvs->gr = NULL;
- }
+ if (gvs->gr) {
+ gvs->gradient_release_connection.disconnect();
+ gvs->gr = NULL;
+ }
- if (gvs->doc) {
- gvs->defs_release_connection.disconnect();
- gvs->defs_modified_connection.disconnect();
- gvs->doc = NULL;
- }
+ if (gvs->doc) {
+ gvs->defs_release_connection.disconnect();
+ gvs->defs_modified_connection.disconnect();
+ gvs->doc = NULL;
+ }
- gvs->gradient_release_connection.~connection();
- gvs->defs_release_connection.~connection();
- gvs->defs_modified_connection.~connection();
+ gvs->gradient_release_connection.~connection();
+ gvs->defs_release_connection.~connection();
+ gvs->defs_modified_connection.~connection();
- if (((GtkObjectClass *) (parent_class))->destroy)
- (* ((GtkObjectClass *) (parent_class))->destroy) (object);
+ if (((GtkObjectClass *) (parent_class))->destroy)
+ (* ((GtkObjectClass *) (parent_class))->destroy) (object);
}
GtkWidget *
sp_gradient_vector_selector_new (SPDocument *doc, SPGradient *gr)
{
- GtkWidget *gvs;
+ GtkWidget *gvs;
- g_return_val_if_fail (!gr || SP_IS_GRADIENT (gr), NULL);
- g_return_val_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc), NULL);
+ g_return_val_if_fail (!gr || SP_IS_GRADIENT (gr), NULL);
+ g_return_val_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc), NULL);
- gvs = (GtkWidget*)gtk_type_new (SP_TYPE_GRADIENT_VECTOR_SELECTOR);
+ gvs = (GtkWidget*)gtk_type_new (SP_TYPE_GRADIENT_VECTOR_SELECTOR);
- if (doc) {
- sp_gradient_vector_selector_set_gradient (SP_GRADIENT_VECTOR_SELECTOR (gvs), doc, gr);
- } else {
- sp_gvs_rebuild_gui_full (SP_GRADIENT_VECTOR_SELECTOR (gvs));
- }
+ if (doc) {
+ sp_gradient_vector_selector_set_gradient (SP_GRADIENT_VECTOR_SELECTOR (gvs), doc, gr);
+ } else {
+ sp_gvs_rebuild_gui_full (SP_GRADIENT_VECTOR_SELECTOR (gvs));
+ }
- return gvs;
+ return gvs;
}
void
sp_gradient_vector_selector_set_gradient (SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr)
{
- static gboolean suppress = FALSE;
-
- g_return_if_fail (gvs != NULL);
- g_return_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs));
- g_return_if_fail (!gr || (doc != NULL));
- g_return_if_fail (!gr || SP_IS_GRADIENT (gr));
- g_return_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc));
- g_return_if_fail (!gr || SP_GRADIENT_HAS_STOPS (gr));
-
- if (doc != gvs->doc) {
- /* Disconnect signals */
- if (gvs->gr) {
- gvs->gradient_release_connection.disconnect();
- gvs->gr = NULL;
- }
- if (gvs->doc) {
- gvs->defs_release_connection.disconnect();
- gvs->defs_modified_connection.disconnect();
- gvs->doc = NULL;
- }
- /* Connect signals */
- if (doc) {
- gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs));
- gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs));
- }
- if (gr) {
- gvs->gradient_release_connection = gr->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
- }
- gvs->doc = doc;
- gvs->gr = gr;
- sp_gvs_rebuild_gui_full (gvs);
- if (!suppress) g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr);
- } else if (gr != gvs->gr) {
- /* Harder case - keep document, rebuild menus and stuff */
- /* fixme: (Lauris) */
- suppress = TRUE;
- sp_gradient_vector_selector_set_gradient (gvs, NULL, NULL);
- sp_gradient_vector_selector_set_gradient (gvs, doc, gr);
- suppress = FALSE;
- g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr);
- }
- /* The case of setting NULL -> NULL is not very interesting */
+ static gboolean suppress = FALSE;
+
+ g_return_if_fail (gvs != NULL);
+ g_return_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs));
+ g_return_if_fail (!gr || (doc != NULL));
+ g_return_if_fail (!gr || SP_IS_GRADIENT (gr));
+ g_return_if_fail (!gr || (SP_OBJECT_DOCUMENT (gr) == doc));
+ g_return_if_fail (!gr || SP_GRADIENT_HAS_STOPS (gr));
+
+ if (doc != gvs->doc) {
+ /* Disconnect signals */
+ if (gvs->gr) {
+ gvs->gradient_release_connection.disconnect();
+ gvs->gr = NULL;
+ }
+ if (gvs->doc) {
+ gvs->defs_release_connection.disconnect();
+ gvs->defs_modified_connection.disconnect();
+ gvs->doc = NULL;
+ }
+ /* Connect signals */
+ if (doc) {
+ gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs));
+ gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs));
+ }
+ if (gr) {
+ gvs->gradient_release_connection = gr->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
+ }
+ gvs->doc = doc;
+ gvs->gr = gr;
+ sp_gvs_rebuild_gui_full (gvs);
+ if (!suppress) g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr);
+ } else if (gr != gvs->gr) {
+ /* Harder case - keep document, rebuild menus and stuff */
+ /* fixme: (Lauris) */
+ suppress = TRUE;
+ sp_gradient_vector_selector_set_gradient (gvs, NULL, NULL);
+ sp_gradient_vector_selector_set_gradient (gvs, doc, gr);
+ suppress = FALSE;
+ g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, gr);
+ }
+ /* The case of setting NULL -> NULL is not very interesting */
}
SPDocument *
sp_gradient_vector_selector_get_document (SPGradientVectorSelector *gvs)
{
- g_return_val_if_fail (gvs != NULL, NULL);
- g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL);
+ g_return_val_if_fail (gvs != NULL, NULL);
+ g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL);
- return gvs->doc;
+ return gvs->doc;
}
SPGradient *
sp_gradient_vector_selector_get_gradient (SPGradientVectorSelector *gvs)
{
- g_return_val_if_fail (gvs != NULL, NULL);
- g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL);
+ g_return_val_if_fail (gvs != NULL, NULL);
+ g_return_val_if_fail (SP_IS_GRADIENT_VECTOR_SELECTOR (gvs), NULL);
- return gvs->gr;
+ return gvs->gr;
}
static void
sp_gvs_rebuild_gui_full (SPGradientVectorSelector *gvs)
{
- /* Clear old menu, if there is any */
- if (gtk_option_menu_get_menu (GTK_OPTION_MENU (gvs->menu))) {
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (gvs->menu));
- }
-
- /* Create new menu widget */
- GtkWidget *m = gtk_menu_new ();
- gtk_widget_show (m);
-
- /* Pick up all gradients with vectors */
- GSList *gl = NULL;
- if (gvs->gr) {
- const GSList *gradients = sp_document_get_resource_list (SP_OBJECT_DOCUMENT (gvs->gr), "gradient");
- for (const GSList *l = gradients; l != NULL; l = l->next) {
- if (SP_GRADIENT_HAS_STOPS (l->data)) {
- gl = g_slist_prepend (gl, l->data);
- }
- }
- }
- gl = g_slist_reverse (gl);
-
- gint pos = 0;
- gint idx = 0;
-
- if (!gvs->doc) {
- GtkWidget *i;
- i = gtk_menu_item_new_with_label (_("No document selected"));
- gtk_widget_show (i);
- gtk_menu_append (GTK_MENU (m), i);
- gtk_widget_set_sensitive (gvs->menu, FALSE);
- } else if (!gl) {
- GtkWidget *i;
- i = gtk_menu_item_new_with_label (_("No gradients in document"));
- gtk_widget_show (i);
- gtk_menu_append (GTK_MENU (m), i);
- gtk_widget_set_sensitive (gvs->menu, FALSE);
- } else if (!gvs->gr) {
- GtkWidget *i;
- i = gtk_menu_item_new_with_label (_("No gradient selected"));
- gtk_widget_show (i);
- gtk_menu_append (GTK_MENU (m), i);
- gtk_widget_set_sensitive (gvs->menu, FALSE);
- } else {
- while (gl) {
- SPGradient *gr;
- GtkWidget *i, *w;
- gr = SP_GRADIENT (gl->data);
- gl = g_slist_remove (gl, gr);
-
- /* We have to know: */
- /* Gradient destroy */
- /* Gradient name change */
- i = gtk_menu_item_new ();
- gtk_widget_show (i);
- g_object_set_data (G_OBJECT (i), "gradient", gr);
- g_signal_connect (G_OBJECT (i), "activate", G_CALLBACK (sp_gvs_gradient_activate), gvs);
-
- w = sp_gradient_image_new (gr);
- gtk_widget_show (w);
-
- if (gvs->idlabel) {
- GtkWidget *hb, *l;
- hb = gtk_hbox_new (FALSE, 4);
- gtk_widget_show (hb);
- l = gtk_label_new (SP_OBJECT_ID (gr));
- gtk_widget_show (l);
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hb), w, FALSE, FALSE, 0);
- w = hb;
- }
-
- gtk_container_add (GTK_CONTAINER (i), w);
-
- gtk_menu_append (GTK_MENU (m), i);
-
- if (gr == gvs->gr) pos = idx;
- idx += 1;
- }
- gtk_widget_set_sensitive (gvs->menu, TRUE);
- }
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (gvs->menu), m);
- /* Set history */
- gtk_option_menu_set_history (GTK_OPTION_MENU (gvs->menu), pos);
+ /* Clear old menu, if there is any */
+ if (gtk_option_menu_get_menu (GTK_OPTION_MENU (gvs->menu))) {
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (gvs->menu));
+ }
+
+ /* Create new menu widget */
+ GtkWidget *m = gtk_menu_new ();
+ gtk_widget_show (m);
+
+ /* Pick up all gradients with vectors */
+ GSList *gl = NULL;
+ if (gvs->gr) {
+ const GSList *gradients = sp_document_get_resource_list (SP_OBJECT_DOCUMENT (gvs->gr), "gradient");
+ for (const GSList *l = gradients; l != NULL; l = l->next) {
+ if (SP_GRADIENT_HAS_STOPS (l->data)) {
+ gl = g_slist_prepend (gl, l->data);
+ }
+ }
+ }
+ gl = g_slist_reverse (gl);
+
+ gint pos = 0;
+ gint idx = 0;
+
+ if (!gvs->doc) {
+ GtkWidget *i;
+ i = gtk_menu_item_new_with_label (_("No document selected"));
+ gtk_widget_show (i);
+ gtk_menu_append (GTK_MENU (m), i);
+ gtk_widget_set_sensitive (gvs->menu, FALSE);
+ } else if (!gl) {
+ GtkWidget *i;
+ i = gtk_menu_item_new_with_label (_("No gradients in document"));
+ gtk_widget_show (i);
+ gtk_menu_append (GTK_MENU (m), i);
+ gtk_widget_set_sensitive (gvs->menu, FALSE);
+ } else if (!gvs->gr) {
+ GtkWidget *i;
+ i = gtk_menu_item_new_with_label (_("No gradient selected"));
+ gtk_widget_show (i);
+ gtk_menu_append (GTK_MENU (m), i);
+ gtk_widget_set_sensitive (gvs->menu, FALSE);
+ } else {
+ while (gl) {
+ SPGradient *gr;
+ GtkWidget *i, *w;
+ gr = SP_GRADIENT (gl->data);
+ gl = g_slist_remove (gl, gr);
+
+ /* We have to know: */
+ /* Gradient destroy */
+ /* Gradient name change */
+ i = gtk_menu_item_new ();
+ gtk_widget_show (i);
+ g_object_set_data (G_OBJECT (i), "gradient", gr);
+ g_signal_connect (G_OBJECT (i), "activate", G_CALLBACK (sp_gvs_gradient_activate), gvs);
+
+ w = sp_gradient_image_new (gr);
+ gtk_widget_show (w);
+
+ if (gvs->idlabel) {
+ GtkWidget *hb, *l;
+ hb = gtk_hbox_new (FALSE, 4);
+ gtk_widget_show (hb);
+ l = gtk_label_new (SP_OBJECT_ID (gr));
+ gtk_widget_show (l);
+ gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hb), w, FALSE, FALSE, 0);
+ w = hb;
+ }
+
+ gtk_container_add (GTK_CONTAINER (i), w);
+
+ gtk_menu_append (GTK_MENU (m), i);
+
+ if (gr == gvs->gr) pos = idx;
+ idx += 1;
+ }
+ gtk_widget_set_sensitive (gvs->menu, TRUE);
+ }
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (gvs->menu), m);
+ /* Set history */
+ gtk_option_menu_set_history (GTK_OPTION_MENU (gvs->menu), pos);
}
static void
sp_gvs_gradient_activate (GtkMenuItem *mi, SPGradientVectorSelector *gvs)
{
- SPGradient *gr, *norm;
-
- gr = (SPGradient*)g_object_get_data (G_OBJECT (mi), "gradient");
- /* Hmmm... bad things may happen here, if actual gradient is something new */
- /* Namely - menuitems etc. will be fucked up */
- /* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
-
- //g_print ("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID (gr));
-
- norm = sp_gradient_ensure_vector_normalized (gr);
- if (norm != gr) {
- //g_print ("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID (norm));
- /* But be careful that we do not have gradient saved anywhere else */
- g_object_set_data (G_OBJECT (mi), "gradient", norm);
- }
-
- /* fixme: Really we would want to use _set_vector */
- /* Detach old */
- if (gvs->gr) {
- gvs->gradient_release_connection.disconnect();
- gvs->gr = NULL;
- }
- /* Attach new */
- if (norm) {
- gvs->gradient_release_connection = norm->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
- gvs->gr = norm;
- }
-
- g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, norm);
-
- if (norm != gr) {
- /* We do extra undo push here */
- /* If handler has already done it, it is just NOP */
- // FIXME: looks like this is never a valid undo step, consider removing this
- sp_document_done (SP_OBJECT_DOCUMENT (norm), SP_VERB_CONTEXT_GRADIENT,
- /* TODO: annotate */ "gradient-vector.cpp:350");
- }
+ SPGradient *gr, *norm;
+
+ gr = (SPGradient*)g_object_get_data (G_OBJECT (mi), "gradient");
+ /* Hmmm... bad things may happen here, if actual gradient is something new */
+ /* Namely - menuitems etc. will be fucked up */
+ /* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
+
+ //g_print ("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID (gr));
+
+ norm = sp_gradient_ensure_vector_normalized (gr);
+ if (norm != gr) {
+ //g_print ("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID (norm));
+ /* But be careful that we do not have gradient saved anywhere else */
+ g_object_set_data (G_OBJECT (mi), "gradient", norm);
+ }
+
+ /* fixme: Really we would want to use _set_vector */
+ /* Detach old */
+ if (gvs->gr) {
+ gvs->gradient_release_connection.disconnect();
+ gvs->gr = NULL;
+ }
+ /* Attach new */
+ if (norm) {
+ gvs->gradient_release_connection = norm->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
+ gvs->gr = norm;
+ }
+
+ g_signal_emit (G_OBJECT (gvs), signals[VECTOR_SET], 0, norm);
+
+ if (norm != gr) {
+ /* We do extra undo push here */
+ /* If handler has already done it, it is just NOP */
+ // FIXME: looks like this is never a valid undo step, consider removing this
+ sp_document_done (SP_OBJECT_DOCUMENT (norm), SP_VERB_CONTEXT_GRADIENT,
+ /* TODO: annotate */ "gradient-vector.cpp:350");
+ }
}
static void
sp_gvs_gradient_release (SPObject *obj, SPGradientVectorSelector *gvs)
{
- /* Disconnect gradient */
- if (gvs->gr) {
- gvs->gradient_release_connection.disconnect();
- gvs->gr = NULL;
- }
-
- /* Rebuild GUI */
- sp_gvs_rebuild_gui_full (gvs);
+ /* Disconnect gradient */
+ if (gvs->gr) {
+ gvs->gradient_release_connection.disconnect();
+ gvs->gr = NULL;
+ }
+
+ /* Rebuild GUI */
+ sp_gvs_rebuild_gui_full (gvs);
}
static void
sp_gvs_defs_release (SPObject *defs, SPGradientVectorSelector *gvs)
{
- gvs->doc = NULL;
+ gvs->doc = NULL;
- gvs->defs_release_connection.disconnect();
- gvs->defs_modified_connection.disconnect();
+ gvs->defs_release_connection.disconnect();
+ gvs->defs_modified_connection.disconnect();
- /* Disconnect gradient as well */
- if (gvs->gr) {
- gvs->gradient_release_connection.disconnect();
- gvs->gr = NULL;
- }
+ /* Disconnect gradient as well */
+ if (gvs->gr) {
+ gvs->gradient_release_connection.disconnect();
+ gvs->gr = NULL;
+ }
- /* Rebuild GUI */
- sp_gvs_rebuild_gui_full (gvs);
+ /* Rebuild GUI */
+ sp_gvs_rebuild_gui_full (gvs);
}
static void
sp_gvs_defs_modified (SPObject *defs, guint flags, SPGradientVectorSelector *gvs)
{
- /* fixme: We probably have to check some flags here (Lauris) */
+ /* fixme: We probably have to check some flags here (Lauris) */
- sp_gvs_rebuild_gui_full (gvs);
+ sp_gvs_rebuild_gui_full (gvs);
}
/*##################################################################
-### Vector Editing Widget
-##################################################################*/
+ ### Vector Editing Widget
+ ##################################################################*/
#include "../widgets/sp-color-notebook.h"
#include "../widgets/sp-color-preview.h"
static void grad_edit_dia_stop_added_or_removed (Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data)
{
- GtkWidget *vb = GTK_WIDGET(data);
- GtkWidget *mnu = (GtkWidget *)g_object_get_data (G_OBJECT(vb), "stopmenu");
- SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient");
- update_stop_list (mnu, gradient, NULL);
+ GtkWidget *vb = GTK_WIDGET(data);
+ GtkWidget *mnu = (GtkWidget *)g_object_get_data (G_OBJECT(vb), "stopmenu");
+ SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient");
+ update_stop_list (mnu, gradient, NULL);
}
//FIXME!!! We must also listen to attr changes on all children (i.e. stops) too,
static void
verify_grad(SPGradient *gradient)
{
- int i = 0;
- SPStop *stop = NULL;
- /* count stops */
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
- if (SP_IS_STOP (ochild)) {
- i++;
- stop = SP_STOP(ochild);
- }
- }
-
- Inkscape::XML::Document *xml_doc;
- xml_doc = SP_OBJECT_REPR(gradient)->document();
-
- if (i < 1) {
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), 0x00000000);
-
- Inkscape::CSSOStringStream os;
- os << "stop-color:" << c << ";stop-opacity:" << 1.0 << ";";
-
- Inkscape::XML::Node *child;
-
- child = xml_doc->createElement("svg:stop");
- sp_repr_set_css_double(child, "offset", 0.0);
- child->setAttribute("style", os.str().c_str());
- SP_OBJECT_REPR (gradient)->addChild(child, NULL);
- Inkscape::GC::release(child);
-
- child = xml_doc->createElement("svg:stop");
- sp_repr_set_css_double(child, "offset", 1.0);
- child->setAttribute("style", os.str().c_str());
- SP_OBJECT_REPR (gradient)->addChild(child, NULL);
- Inkscape::GC::release(child);
- }
- if (i < 2) {
- sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", 0.0);
- Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
- sp_repr_set_css_double(child, "offset", 1.0);
- SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR (stop));
- Inkscape::GC::release(child);
- }
+ int i = 0;
+ SPStop *stop = NULL;
+ /* count stops */
+ for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ if (SP_IS_STOP (ochild)) {
+ i++;
+ stop = SP_STOP(ochild);
+ }
+ }
+
+ Inkscape::XML::Document *xml_doc;
+ xml_doc = SP_OBJECT_REPR(gradient)->document();
+
+ if (i < 1) {
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), 0x00000000);
+
+ Inkscape::CSSOStringStream os;
+ os << "stop-color:" << c << ";stop-opacity:" << 1.0 << ";";
+
+ Inkscape::XML::Node *child;
+
+ child = xml_doc->createElement("svg:stop");
+ sp_repr_set_css_double(child, "offset", 0.0);
+ child->setAttribute("style", os.str().c_str());
+ SP_OBJECT_REPR (gradient)->addChild(child, NULL);
+ Inkscape::GC::release(child);
+
+ child = xml_doc->createElement("svg:stop");
+ sp_repr_set_css_double(child, "offset", 1.0);
+ child->setAttribute("style", os.str().c_str());
+ SP_OBJECT_REPR (gradient)->addChild(child, NULL);
+ Inkscape::GC::release(child);
+ }
+ if (i < 2) {
+ sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", 0.0);
+ Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
+ sp_repr_set_css_double(child, "offset", 1.0);
+ SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR (stop));
+ Inkscape::GC::release(child);
+ }
}
static void
select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop)
{
- int i = 0;
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
- if (SP_IS_STOP (ochild)) {
- if (SP_OBJECT (ochild) == SP_OBJECT(new_stop)) {
- gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), i);
- break;
- }
- i++;
- }
- }
+ int i = 0;
+ for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ if (SP_IS_STOP (ochild)) {
+ if (SP_OBJECT (ochild) == SP_OBJECT(new_stop)) {
+ gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), i);
+ break;
+ }
+ i++;
+ }
+ }
}
static void
update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop)
{
- if (!SP_IS_GRADIENT (gradient))
- return;
-
- blocked = TRUE;
-
- /* Clear old menu, if there is any */
- if (gtk_option_menu_get_menu (GTK_OPTION_MENU (mnu))) {
- gtk_option_menu_remove_menu (GTK_OPTION_MENU (mnu));
- }
-
- /* Create new menu widget */
- GtkWidget *m = gtk_menu_new ();
- gtk_widget_show (m);
- GSList *sl = NULL;
- if (gradient->has_stops) {
- for ( SPObject *ochild = sp_object_first_child (SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
- if (SP_IS_STOP (ochild)) {
- sl = g_slist_append (sl, ochild);
- }
- }
- }
- if (!sl) {
- GtkWidget *i = gtk_menu_item_new_with_label (_("No stops in gradient"));
- gtk_widget_show (i);
- gtk_menu_append (GTK_MENU (m), i);
- gtk_widget_set_sensitive (mnu, FALSE);
- } else {
-
- for (; sl != NULL; sl = sl->next){
- SPStop *stop;
- GtkWidget *i;
- if (SP_IS_STOP(sl->data)){
- stop = SP_STOP (sl->data);
- i = gtk_menu_item_new ();
- gtk_widget_show (i);
- g_object_set_data (G_OBJECT (i), "stop", stop);
- GtkWidget *hb = gtk_hbox_new (FALSE, 4);
- GtkWidget *cpv = sp_color_preview_new(sp_stop_get_rgba32(stop));
- gtk_widget_show (cpv);
- gtk_container_add ( GTK_CONTAINER (hb), cpv );
- g_object_set_data ( G_OBJECT (i), "preview", cpv );
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) sl->data);
- GtkWidget *l = gtk_label_new (repr->attribute("id"));
- gtk_widget_show (l);
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
- gtk_widget_show (hb);
- gtk_container_add (GTK_CONTAINER (i), hb);
- gtk_menu_append (GTK_MENU (m), i);
- }
- }
-
- gtk_widget_set_sensitive (mnu, TRUE);
- }
- gtk_option_menu_set_menu (GTK_OPTION_MENU (mnu), m);
-
- /* Set history */
- if (new_stop == NULL) {
- gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), 0);
- } else {
- select_stop_in_list (mnu, gradient, new_stop);
- }
-
- blocked = FALSE;
+ if (!SP_IS_GRADIENT (gradient))
+ return;
+
+ blocked = TRUE;
+
+ /* Clear old menu, if there is any */
+ if (gtk_option_menu_get_menu (GTK_OPTION_MENU (mnu))) {
+ gtk_option_menu_remove_menu (GTK_OPTION_MENU (mnu));
+ }
+
+ /* Create new menu widget */
+ GtkWidget *m = gtk_menu_new ();
+ gtk_widget_show (m);
+ GSList *sl = NULL;
+ if (gradient->has_stops) {
+ for ( SPObject *ochild = sp_object_first_child (SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
+ if (SP_IS_STOP (ochild)) {
+ sl = g_slist_append (sl, ochild);
+ }
+ }
+ }
+ if (!sl) {
+ GtkWidget *i = gtk_menu_item_new_with_label (_("No stops in gradient"));
+ gtk_widget_show (i);
+ gtk_menu_append (GTK_MENU (m), i);
+ gtk_widget_set_sensitive (mnu, FALSE);
+ } else {
+
+ for (; sl != NULL; sl = sl->next){
+ SPStop *stop;
+ GtkWidget *i;
+ if (SP_IS_STOP(sl->data)){
+ stop = SP_STOP (sl->data);
+ i = gtk_menu_item_new ();
+ gtk_widget_show (i);
+ g_object_set_data (G_OBJECT (i), "stop", stop);
+ GtkWidget *hb = gtk_hbox_new (FALSE, 4);
+ GtkWidget *cpv = sp_color_preview_new(sp_stop_get_rgba32(stop));
+ gtk_widget_show (cpv);
+ gtk_container_add ( GTK_CONTAINER (hb), cpv );
+ g_object_set_data ( G_OBJECT (i), "preview", cpv );
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) sl->data);
+ GtkWidget *l = gtk_label_new (repr->attribute("id"));
+ gtk_widget_show (l);
+ gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);
+ gtk_widget_show (hb);
+ gtk_container_add (GTK_CONTAINER (i), hb);
+ gtk_menu_append (GTK_MENU (m), i);
+ }
+ }
+
+ gtk_widget_set_sensitive (mnu, TRUE);
+ }
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (mnu), m);
+
+ /* Set history */
+ if (new_stop == NULL) {
+ gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), 0);
+ } else {
+ select_stop_in_list (mnu, gradient, new_stop);
+ }
+
+ blocked = FALSE;
}
static void
sp_grad_edit_select (GtkOptionMenu *mnu, GtkWidget *tbl)
{
- SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(tbl), "gradient");
-
- GObject *item = G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu))));
- SPStop *stop = SP_STOP (g_object_get_data (item, "stop"));
- if (!stop) return;
-
- blocked = TRUE;
-
- SPColorSelector *csel = (SPColorSelector*)g_object_get_data (G_OBJECT (tbl), "cselector");
- guint32 const c = sp_stop_get_rgba32(stop);
- csel->base->setAlpha(SP_RGBA32_A_F (c));
- SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) );
- // set its color, from the stored array
- csel->base->setColor( color );
- GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offspn"));
- GtkWidget *offslide =GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offslide"));
-
- GtkAdjustment *adj = (GtkAdjustment*)gtk_object_get_data (GTK_OBJECT (tbl), "offset");
-
- bool isEndStop = false;
-
- SPStop *prev = NULL;
- prev = sp_prev_stop(stop, gradient);
- if (prev != NULL ) {
- adj->lower = prev->offset;
- } else {
- isEndStop = true;
- adj->lower = 0;
- }
-
- SPStop *next = NULL;
- next = sp_next_stop(stop);
- if (next != NULL ) {
- adj->upper = next->offset;
- } else {
- isEndStop = true;
- adj->upper = 1.0;
- }
-
- //fixme: does this work on all possible input gradients?
- if (!isEndStop) {
- gtk_widget_set_sensitive (offslide, TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (offspin), TRUE);
- } else {
- gtk_widget_set_sensitive (offslide, FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (offspin), FALSE);
- }
-
- gtk_adjustment_set_value (adj, stop->offset);
-
- gtk_adjustment_changed (adj);
-
- blocked = FALSE;
+ SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(tbl), "gradient");
+
+ GObject *item = G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu))));
+ SPStop *stop = SP_STOP (g_object_get_data (item, "stop"));
+ if (!stop) return;
+
+ blocked = TRUE;
+
+ SPColorSelector *csel = (SPColorSelector*)g_object_get_data (G_OBJECT (tbl), "cselector");
+ guint32 const c = sp_stop_get_rgba32(stop);
+ csel->base->setAlpha(SP_RGBA32_A_F (c));
+ SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) );
+ // set its color, from the stored array
+ csel->base->setColor( color );
+ GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offspn"));
+ GtkWidget *offslide =GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offslide"));
+
+ GtkAdjustment *adj = (GtkAdjustment*)gtk_object_get_data (GTK_OBJECT (tbl), "offset");
+
+ bool isEndStop = false;
+
+ SPStop *prev = NULL;
+ prev = sp_prev_stop(stop, gradient);
+ if (prev != NULL ) {
+ adj->lower = prev->offset;
+ } else {
+ isEndStop = true;
+ adj->lower = 0;
+ }
+
+ SPStop *next = NULL;
+ next = sp_next_stop(stop);
+ if (next != NULL ) {
+ adj->upper = next->offset;
+ } else {
+ isEndStop = true;
+ adj->upper = 1.0;
+ }
+
+ //fixme: does this work on all possible input gradients?
+ if (!isEndStop) {
+ gtk_widget_set_sensitive (offslide, TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (offspin), TRUE);
+ } else {
+ gtk_widget_set_sensitive (offslide, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (offspin), FALSE);
+ }
+
+ gtk_adjustment_set_value (adj, stop->offset);
+
+ gtk_adjustment_changed (adj);
+
+ blocked = FALSE;
}
static void
offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb)
{
- if (blocked)
- return;
+ if (blocked)
+ return;
- blocked = TRUE;
+ blocked = TRUE;
GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu");
if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return;
sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
sp_document_done (SP_OBJECT_DOCUMENT (stop), SP_VERB_CONTEXT_GRADIENT,
- _("Change gradient stop offset"));
+ _("Change gradient stop offset"));
- blocked = FALSE;
+ blocked = FALSE;
}
guint32
sp_average_color (guint32 c1, guint32 c2, gdouble p = 0.5)
{
- guint32 r = (guint32) (SP_RGBA32_R_U (c1) * p + SP_RGBA32_R_U (c2) * (1 - p));
- guint32 g = (guint32) (SP_RGBA32_G_U (c1) * p + SP_RGBA32_G_U (c2) * (1 - p));
- guint32 b = (guint32) (SP_RGBA32_B_U (c1) * p + SP_RGBA32_B_U (c2) * (1 - p));
- guint32 a = (guint32) (SP_RGBA32_A_U (c1) * p + SP_RGBA32_A_U (c2) * (1 - p));
+ guint32 r = (guint32) (SP_RGBA32_R_U (c1) * p + SP_RGBA32_R_U (c2) * (1 - p));
+ guint32 g = (guint32) (SP_RGBA32_G_U (c1) * p + SP_RGBA32_G_U (c2) * (1 - p));
+ guint32 b = (guint32) (SP_RGBA32_B_U (c1) * p + SP_RGBA32_B_U (c2) * (1 - p));
+ guint32 a = (guint32) (SP_RGBA32_A_U (c1) * p + SP_RGBA32_A_U (c2) * (1 - p));
- return SP_RGBA32_U_COMPOSE (r, g, b, a);
+ return SP_RGBA32_U_COMPOSE (r, g, b, a);
}
static void
sp_grd_ed_add_stop (GtkWidget *widget, GtkWidget *vb)
{
- SPGradient *gradient = (SPGradient *) g_object_get_data (G_OBJECT(vb), "gradient");
- verify_grad (gradient);
- GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu");
-
- SPStop *stop = (SPStop *) g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop");
-
- if (stop == NULL)
- return;
-
- Inkscape::XML::Node *new_stop_repr = NULL;
-
- SPStop *next = sp_next_stop (stop);
-
- if (next == NULL) {
- SPStop *prev = sp_prev_stop (stop, gradient);
- if (prev != NULL) {
- next = stop;
- stop = prev;
- }
- }
-
- if (next != NULL) {
- new_stop_repr = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
- SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop));
- } else {
- next = stop;
- new_stop_repr = SP_OBJECT_REPR(sp_prev_stop(stop, gradient))->duplicate(SP_OBJECT_REPR(gradient)->document());
- SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(sp_prev_stop(stop, gradient)));
- }
-
- SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(gradient)->getObjectByRepr(new_stop_repr);
-
- newstop->offset = (stop->offset + next->offset) * 0.5 ;
-
- guint32 const c1 = sp_stop_get_rgba32(stop);
- guint32 const c2 = sp_stop_get_rgba32(next);
- guint32 cnew = sp_average_color (c1, c2);
-
- Inkscape::CSSOStringStream os;
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), cnew);
- gdouble opacity = (gdouble) SP_RGBA32_A_F (cnew);
- os << "stop-color:" << c << ";stop-opacity:" << opacity <<";";
- SP_OBJECT_REPR (newstop)->setAttribute("style", os.str().c_str());
+ SPGradient *gradient = (SPGradient *) g_object_get_data (G_OBJECT(vb), "gradient");
+ verify_grad (gradient);
+ GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu");
+
+ SPStop *stop = (SPStop *) g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop");
+
+ if (stop == NULL)
+ return;
+
+ Inkscape::XML::Node *new_stop_repr = NULL;
+
+ SPStop *next = sp_next_stop (stop);
+
+ if (next == NULL) {
+ SPStop *prev = sp_prev_stop (stop, gradient);
+ if (prev != NULL) {
+ next = stop;
+ stop = prev;
+ }
+ }
+
+ if (next != NULL) {
+ new_stop_repr = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
+ SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop));
+ } else {
+ next = stop;
+ new_stop_repr = SP_OBJECT_REPR(sp_prev_stop(stop, gradient))->duplicate(SP_OBJECT_REPR(gradient)->document());
+ SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(sp_prev_stop(stop, gradient)));
+ }
+
+ SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(gradient)->getObjectByRepr(new_stop_repr);
+
+ newstop->offset = (stop->offset + next->offset) * 0.5 ;
+
+ guint32 const c1 = sp_stop_get_rgba32(stop);
+ guint32 const c2 = sp_stop_get_rgba32(next);
+ guint32 cnew = sp_average_color (c1, c2);
+
+ Inkscape::CSSOStringStream os;
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), cnew);
+ gdouble opacity = (gdouble) SP_RGBA32_A_F (cnew);
+ os << "stop-color:" << c << ";stop-opacity:" << opacity <<";";
+ SP_OBJECT_REPR (newstop)->setAttribute("style", os.str().c_str());
sp_repr_set_css_double( SP_OBJECT_REPR(newstop), "offset", (double)newstop->offset);
- sp_gradient_vector_widget_load_gradient (vb, gradient);
- Inkscape::GC::release(new_stop_repr);
- update_stop_list(GTK_WIDGET(mnu), gradient, newstop);
- GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (vb), "offspn"));
- GtkWidget *offslide =GTK_WIDGET (g_object_get_data (G_OBJECT (vb), "offslide"));
- gtk_widget_set_sensitive (offslide, TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (offspin), TRUE);
- sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
- _("Add gradient stop"));
+ sp_gradient_vector_widget_load_gradient (vb, gradient);
+ Inkscape::GC::release(new_stop_repr);
+ update_stop_list(GTK_WIDGET(mnu), gradient, newstop);
+ GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (vb), "offspn"));
+ GtkWidget *offslide =GTK_WIDGET (g_object_get_data (G_OBJECT (vb), "offslide"));
+ gtk_widget_set_sensitive (offslide, TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (offspin), TRUE);
+ sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
+ _("Add gradient stop"));
}
static void
sp_grd_ed_del_stop (GtkWidget *widget, GtkWidget *vb)
{
- SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient");
-
- GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu");
- if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return;
- SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
- if (gradient->vector.stops.size() > 2) { // 2 is the minimum
-
- // if we delete first or last stop, move the next/previous to the edge
- if (stop->offset == 0) {
- SPStop *next = sp_next_stop (stop);
- if (next) {
- next->offset = 0;
- sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0);
- }
- } else if (stop->offset == 1) {
- SPStop *prev = sp_prev_stop (stop, gradient);
- if (prev) {
- prev->offset = 1;
- sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1);
- }
- }
-
- SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
- sp_gradient_vector_widget_load_gradient (vb, gradient);
- update_stop_list(GTK_WIDGET(mnu), gradient, NULL);
- sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
- _("Delete gradient stop"));
- }
+ SPGradient *gradient = (SPGradient *)g_object_get_data (G_OBJECT(vb), "gradient");
+
+ GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(vb), "stopmenu");
+ if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return;
+ SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
+ if (gradient->vector.stops.size() > 2) { // 2 is the minimum
+
+ // if we delete first or last stop, move the next/previous to the edge
+ if (stop->offset == 0) {
+ SPStop *next = sp_next_stop (stop);
+ if (next) {
+ next->offset = 0;
+ sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0);
+ }
+ } else if (stop->offset == 1) {
+ SPStop *prev = sp_prev_stop (stop, gradient);
+ if (prev) {
+ prev->offset = 1;
+ sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1);
+ }
+ }
+
+ SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
+ sp_gradient_vector_widget_load_gradient (vb, gradient);
+ update_stop_list(GTK_WIDGET(mnu), gradient, NULL);
+ sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT,
+ _("Delete gradient stop"));
+ }
}
static GtkWidget *
sp_gradient_vector_widget_new (SPGradient *gradient, SPStop *select_stop)
{
- GtkWidget *vb, *w, *f, *csel;
-
- g_return_val_if_fail (!gradient || SP_IS_GRADIENT (gradient), NULL);
-
- vb = gtk_vbox_new (FALSE, PAD);
- g_signal_connect (G_OBJECT (vb), "destroy", G_CALLBACK (sp_gradient_vector_widget_destroy), NULL);
-
- w = sp_gradient_image_new (gradient);
- g_object_set_data (G_OBJECT (vb), "preview", w);
- gtk_widget_show (w);
- gtk_box_pack_start (GTK_BOX (vb), w, TRUE, TRUE, PAD);
-
- gtk_object_set_data (GTK_OBJECT (vb), "gradient", gradient);
- sp_repr_add_listener (SP_OBJECT_REPR(gradient), &grad_edit_dia_repr_events, vb);
- GtkTooltips *tt = gtk_tooltips_new ();
-
- /* Stop list */
- GtkWidget *mnu = gtk_option_menu_new ();
- /* Create new menu widget */
- update_stop_list (GTK_WIDGET(mnu), gradient, NULL);
- gtk_signal_connect (GTK_OBJECT (mnu), "changed", GTK_SIGNAL_FUNC (sp_grad_edit_select), vb);
- gtk_widget_show (mnu);
- gtk_object_set_data (GTK_OBJECT (vb), "stopmenu", mnu);
- gtk_box_pack_start (GTK_BOX (vb), mnu, FALSE, FALSE, 0);
-
- /* Add and Remove buttons */
- GtkWidget *hb = gtk_hbox_new (FALSE, 1);
- // TRANSLATORS: "Stop" means: a "phase" of a gradient
- GtkWidget *b = gtk_button_new_with_label (_("Add stop"));
- gtk_widget_show (b);
- gtk_container_add (GTK_CONTAINER (hb), b);
- gtk_tooltips_set_tip (tt, b, _("Add another control stop to gradient"), NULL);
- gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_add_stop), vb);
- b = gtk_button_new_with_label (_("Delete stop"));
- gtk_widget_show (b);
- gtk_container_add (GTK_CONTAINER (hb), b);
- gtk_tooltips_set_tip (tt, b, _("Delete current control stop from gradient"), NULL);
- gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_del_stop), vb);
-
- gtk_widget_show (hb);
- gtk_box_pack_start (GTK_BOX (vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
-
-
- /* Offset Slider and stuff */
- hb = gtk_hbox_new (FALSE, 0);
-
- /* Label */
- GtkWidget *l = gtk_label_new (_("Offset:"));
- gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
- gtk_widget_show (l);
-
- /* Adjustment */
- GtkAdjustment *Offset_adj = NULL;
- Offset_adj= (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.01, 0.0);
- gtk_object_set_data (GTK_OBJECT (vb), "offset", Offset_adj);
- GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu (GTK_OPTION_MENU(mnu)));
- SPStop *stop = SP_STOP (g_object_get_data (G_OBJECT (gtk_menu_get_active (m)), "stop"));
- gtk_adjustment_set_value (Offset_adj, stop->offset);
-
- /* Slider */
- GtkWidget *slider = gtk_hscale_new(Offset_adj);
- gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE );
- gtk_widget_show (slider);
- gtk_box_pack_start (GTK_BOX (hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);
- gtk_object_set_data (GTK_OBJECT (vb), "offslide", slider);
-
- /* Spinbutton */
- GtkWidget *sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (Offset_adj), 0.01, 2);
- sp_dialog_defocus_on_enter (sbtn);
- gtk_widget_show (sbtn);
- gtk_box_pack_start (GTK_BOX (hb),sbtn, FALSE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);
- gtk_object_set_data (GTK_OBJECT (vb), "offspn", sbtn);
-
- if (stop->offset>0 && stop->offset<1) {
- gtk_widget_set_sensitive (slider, TRUE);
- gtk_widget_set_sensitive (GTK_WIDGET (sbtn), TRUE);
- } else {
- gtk_widget_set_sensitive (slider, FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (sbtn), FALSE);
- }
-
-
- /* Signals */
- gtk_signal_connect (GTK_OBJECT (Offset_adj), "value_changed",
- GTK_SIGNAL_FUNC (offadjustmentChanged), vb);
-
- // gtk_signal_connect (GTK_OBJECT (slider), "changed", GTK_SIGNAL_FUNC (offsliderChanged), vb);
- gtk_widget_show (hb);
- gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, PAD);
-
- // TRANSLATORS: "Stop" means: a "phase" of a gradient
- f = gtk_frame_new (_("Stop Color"));
- gtk_widget_show (f);
- gtk_box_pack_start (GTK_BOX (vb), f, TRUE, TRUE, PAD);
- csel = (GtkWidget*)sp_color_selector_new (SP_TYPE_COLOR_NOTEBOOK);
- g_object_set_data (G_OBJECT (vb), "cselector", csel);
- gtk_widget_show (csel);
- gtk_container_add (GTK_CONTAINER (f), csel);
- g_signal_connect (G_OBJECT (csel), "dragged", G_CALLBACK (sp_gradient_vector_color_dragged), vb);
- g_signal_connect (G_OBJECT (csel), "changed", G_CALLBACK (sp_gradient_vector_color_changed), vb);
-
- gtk_widget_show (vb);
-
- sp_gradient_vector_widget_load_gradient (vb, gradient);
-
- if (select_stop)
- select_stop_in_list (GTK_WIDGET(mnu), gradient, select_stop);
-
- return vb;
+ GtkWidget *vb, *w, *f, *csel;
+
+ g_return_val_if_fail (!gradient || SP_IS_GRADIENT (gradient), NULL);
+
+ vb = gtk_vbox_new (FALSE, PAD);
+ g_signal_connect (G_OBJECT (vb), "destroy", G_CALLBACK (sp_gradient_vector_widget_destroy), NULL);
+
+ w = sp_gradient_image_new (gradient);
+ g_object_set_data (G_OBJECT (vb), "preview", w);
+ gtk_widget_show (w);
+ gtk_box_pack_start (GTK_BOX (vb), w, TRUE, TRUE, PAD);
+
+ gtk_object_set_data (GTK_OBJECT (vb), "gradient", gradient);
+ sp_repr_add_listener (SP_OBJECT_REPR(gradient), &grad_edit_dia_repr_events, vb);
+ GtkTooltips *tt = gtk_tooltips_new ();
+
+ /* Stop list */
+ GtkWidget *mnu = gtk_option_menu_new ();
+ /* Create new menu widget */
+ update_stop_list (GTK_WIDGET(mnu), gradient, NULL);
+ gtk_signal_connect (GTK_OBJECT (mnu), "changed", GTK_SIGNAL_FUNC (sp_grad_edit_select), vb);
+ gtk_widget_show (mnu);
+ gtk_object_set_data (GTK_OBJECT (vb), "stopmenu", mnu);
+ gtk_box_pack_start (GTK_BOX (vb), mnu, FALSE, FALSE, 0);
+
+ /* Add and Remove buttons */
+ GtkWidget *hb = gtk_hbox_new (FALSE, 1);
+ // TRANSLATORS: "Stop" means: a "phase" of a gradient
+ GtkWidget *b = gtk_button_new_with_label (_("Add stop"));
+ gtk_widget_show (b);
+ gtk_container_add (GTK_CONTAINER (hb), b);
+ gtk_tooltips_set_tip (tt, b, _("Add another control stop to gradient"), NULL);
+ gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_add_stop), vb);
+ b = gtk_button_new_with_label (_("Delete stop"));
+ gtk_widget_show (b);
+ gtk_container_add (GTK_CONTAINER (hb), b);
+ gtk_tooltips_set_tip (tt, b, _("Delete current control stop from gradient"), NULL);
+ gtk_signal_connect (GTK_OBJECT (b), "clicked", GTK_SIGNAL_FUNC (sp_grd_ed_del_stop), vb);
+
+ gtk_widget_show (hb);
+ gtk_box_pack_start (GTK_BOX (vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
+
+
+ /* Offset Slider and stuff */
+ hb = gtk_hbox_new (FALSE, 0);
+
+ /* Label */
+ GtkWidget *l = gtk_label_new (_("Offset:"));
+ gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS);
+ gtk_widget_show (l);
+
+ /* Adjustment */
+ GtkAdjustment *Offset_adj = NULL;
+ Offset_adj= (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.01, 0.0);
+ gtk_object_set_data (GTK_OBJECT (vb), "offset", Offset_adj);
+ GtkMenu *m = GTK_MENU(gtk_option_menu_get_menu (GTK_OPTION_MENU(mnu)));
+ SPStop *stop = SP_STOP (g_object_get_data (G_OBJECT (gtk_menu_get_active (m)), "stop"));
+ gtk_adjustment_set_value (Offset_adj, stop->offset);
+
+ /* Slider */
+ GtkWidget *slider = gtk_hscale_new(Offset_adj);
+ gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE );
+ gtk_widget_show (slider);
+ gtk_box_pack_start (GTK_BOX (hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);
+ gtk_object_set_data (GTK_OBJECT (vb), "offslide", slider);
+
+ /* Spinbutton */
+ GtkWidget *sbtn = gtk_spin_button_new (GTK_ADJUSTMENT (Offset_adj), 0.01, 2);
+ sp_dialog_defocus_on_enter (sbtn);
+ gtk_widget_show (sbtn);
+ gtk_box_pack_start (GTK_BOX (hb),sbtn, FALSE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);
+ gtk_object_set_data (GTK_OBJECT (vb), "offspn", sbtn);
+
+ if (stop->offset>0 && stop->offset<1) {
+ gtk_widget_set_sensitive (slider, TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (sbtn), TRUE);
+ } else {
+ gtk_widget_set_sensitive (slider, FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (sbtn), FALSE);
+ }
+
+
+ /* Signals */
+ gtk_signal_connect (GTK_OBJECT (Offset_adj), "value_changed",
+ GTK_SIGNAL_FUNC (offadjustmentChanged), vb);
+
+ // gtk_signal_connect (GTK_OBJECT (slider), "changed", GTK_SIGNAL_FUNC (offsliderChanged), vb);
+ gtk_widget_show (hb);
+ gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, PAD);
+
+ // TRANSLATORS: "Stop" means: a "phase" of a gradient
+ f = gtk_frame_new (_("Stop Color"));
+ gtk_widget_show (f);
+ gtk_box_pack_start (GTK_BOX (vb), f, TRUE, TRUE, PAD);
+ csel = (GtkWidget*)sp_color_selector_new (SP_TYPE_COLOR_NOTEBOOK);
+ g_object_set_data (G_OBJECT (vb), "cselector", csel);
+ gtk_widget_show (csel);
+ gtk_container_add (GTK_CONTAINER (f), csel);
+ g_signal_connect (G_OBJECT (csel), "dragged", G_CALLBACK (sp_gradient_vector_color_dragged), vb);
+ g_signal_connect (G_OBJECT (csel), "changed", G_CALLBACK (sp_gradient_vector_color_changed), vb);
+
+ gtk_widget_show (vb);
+
+ sp_gradient_vector_widget_load_gradient (vb, gradient);
+
+ if (select_stop)
+ select_stop_in_list (GTK_WIDGET(mnu), gradient, select_stop);
+
+ return vb;
}
if (y<0) y=0;
if (x != 0 || y != 0)
- gtk_window_move ((GtkWindow *) dlg, x, y);
+ gtk_window_move ((GtkWindow *) dlg, x, y);
else
- gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
+ gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
if (w && h) gtk_window_resize ((GtkWindow *) dlg, w, h);
sp_transientize (dlg);
wd.win = dlg;
static void
sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient)
{
- blocked = TRUE;
-
- SPGradient *old;
-
- old = (SPGradient*)g_object_get_data (G_OBJECT (widget), "gradient");
-
- if (old != gradient) {
- sigc::connection *release_connection;
- sigc::connection *modified_connection;
-
- release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_release_connection");
- modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_modified_connection");
-
- if (old) {
- g_assert( release_connection != NULL );
- g_assert( modified_connection != NULL );
- release_connection->disconnect();
- modified_connection->disconnect();
- sp_signal_disconnect_by_data (old, widget);
- }
-
- if (gradient) {
- if (!release_connection) {
- release_connection = new sigc::connection();
- }
- if (!modified_connection) {
- modified_connection = new sigc::connection();
- }
- *release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_vector_gradient_release), widget));
- *modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_vector_gradient_modified), widget));
- } else {
- if (release_connection) {
- delete release_connection;
- release_connection = NULL;
- }
- if (modified_connection) {
- delete modified_connection;
- modified_connection = NULL;
- }
- }
-
- g_object_set_data(G_OBJECT(widget), "gradient_release_connection", release_connection);
- g_object_set_data(G_OBJECT(widget), "gradient_modified_connection", modified_connection);
- }
-
- g_object_set_data (G_OBJECT (widget), "gradient", gradient);
-
- if (gradient) {
- sp_gradient_ensure_vector (gradient);
-
- GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(widget), "stopmenu");
- SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
- guint32 const c = sp_stop_get_rgba32(stop);
-
- /// get the color selector
- SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data (G_OBJECT (widget), "cselector"));
- // set alpha
- csel->base->setAlpha(SP_RGBA32_A_F (c));
- SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) );
- // set color
- csel->base->setColor( color );
- }
-
- /* Fill preview */
- GtkWidget *w = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(widget), "preview"));
- sp_gradient_image_set_gradient (SP_GRADIENT_IMAGE (w), gradient);
-
- GtkWidget *mnu = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(widget), "stopmenu"));
- update_stop_list (GTK_WIDGET(mnu), gradient, NULL);
-
- // Once the user edits a gradient, it stops being auto-collectable
- if (SP_OBJECT_REPR(gradient)->attribute("inkscape:collect")) {
- SPDocument *document = SP_OBJECT_DOCUMENT (gradient);
- bool saved = sp_document_get_undo_sensitive(document);
- sp_document_set_undo_sensitive (document, false);
- SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL);
- sp_document_set_undo_sensitive (document, saved);
- }
-
- blocked = FALSE;
+ blocked = TRUE;
+
+ SPGradient *old;
+
+ old = (SPGradient*)g_object_get_data (G_OBJECT (widget), "gradient");
+
+ if (old != gradient) {
+ sigc::connection *release_connection;
+ sigc::connection *modified_connection;
+
+ release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_release_connection");
+ modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_modified_connection");
+
+ if (old) {
+ g_assert( release_connection != NULL );
+ g_assert( modified_connection != NULL );
+ release_connection->disconnect();
+ modified_connection->disconnect();
+ sp_signal_disconnect_by_data (old, widget);
+ }
+
+ if (gradient) {
+ if (!release_connection) {
+ release_connection = new sigc::connection();
+ }
+ if (!modified_connection) {
+ modified_connection = new sigc::connection();
+ }
+ *release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_vector_gradient_release), widget));
+ *modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_vector_gradient_modified), widget));
+ } else {
+ if (release_connection) {
+ delete release_connection;
+ release_connection = NULL;
+ }
+ if (modified_connection) {
+ delete modified_connection;
+ modified_connection = NULL;
+ }
+ }
+
+ g_object_set_data(G_OBJECT(widget), "gradient_release_connection", release_connection);
+ g_object_set_data(G_OBJECT(widget), "gradient_modified_connection", modified_connection);
+ }
+
+ g_object_set_data (G_OBJECT (widget), "gradient", gradient);
+
+ if (gradient) {
+ sp_gradient_ensure_vector (gradient);
+
+ GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(widget), "stopmenu");
+ SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
+ guint32 const c = sp_stop_get_rgba32(stop);
+
+ /// get the color selector
+ SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data (G_OBJECT (widget), "cselector"));
+ // set alpha
+ csel->base->setAlpha(SP_RGBA32_A_F (c));
+ SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) );
+ // set color
+ csel->base->setColor( color );
+ }
+
+ /* Fill preview */
+ GtkWidget *w = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(widget), "preview"));
+ sp_gradient_image_set_gradient (SP_GRADIENT_IMAGE (w), gradient);
+
+ GtkWidget *mnu = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(widget), "stopmenu"));
+ update_stop_list (GTK_WIDGET(mnu), gradient, NULL);
+
+ // Once the user edits a gradient, it stops being auto-collectable
+ if (SP_OBJECT_REPR(gradient)->attribute("inkscape:collect")) {
+ SPDocument *document = SP_OBJECT_DOCUMENT (gradient);
+ bool saved = sp_document_get_undo_sensitive(document);
+ sp_document_set_undo_sensitive (document, false);
+ SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL);
+ sp_document_set_undo_sensitive (document, saved);
+ }
+
+ blocked = FALSE;
}
static void
sp_gradient_vector_dialog_destroy (GtkObject *object, gpointer data)
{
- sp_signal_disconnect_by_data (INKSCAPE, dlg);
- wd.win = dlg = NULL;
- wd.stop = 0;
+ sp_signal_disconnect_by_data (INKSCAPE, dlg);
+ wd.win = dlg = NULL;
+ wd.stop = 0;
}
static gboolean
@@ -1072,53 +1070,53 @@ sp_gradient_vector_dialog_delete (GtkWidget *widget, GdkEvent *event, GtkWidget
static void
sp_gradient_vector_widget_destroy (GtkObject *object, gpointer data)
{
- GObject *gradient;
+ GObject *gradient;
- gradient = (GObject*)g_object_get_data (G_OBJECT (object), "gradient");
+ gradient = (GObject*)g_object_get_data (G_OBJECT (object), "gradient");
- if (gradient && SP_OBJECT_REPR(gradient)) {
- /* Remove signals connected to us */
- /* fixme: may use _connect_while_alive as well */
- sp_signal_disconnect_by_data (gradient, object);
- sp_repr_remove_listener_by_data (SP_OBJECT_REPR(gradient), object);
- }
+ if (gradient && SP_OBJECT_REPR(gradient)) {
+ /* Remove signals connected to us */
+ /* fixme: may use _connect_while_alive as well */
+ sp_signal_disconnect_by_data (gradient, object);
+ sp_repr_remove_listener_by_data (SP_OBJECT_REPR(gradient), object);
+ }
}
static void
sp_gradient_vector_gradient_release (SPObject *object, GtkWidget *widget)
{
- sp_gradient_vector_widget_load_gradient (widget, NULL);
+ sp_gradient_vector_widget_load_gradient (widget, NULL);
}
static void
sp_gradient_vector_gradient_modified (SPObject *object, guint flags, GtkWidget *widget)
{
- SPGradient *gradient=SP_GRADIENT(object);
- if (!blocked) {
- blocked = TRUE;
- sp_gradient_vector_widget_load_gradient (widget, gradient);
- blocked = FALSE;
- }
+ SPGradient *gradient=SP_GRADIENT(object);
+ if (!blocked) {
+ blocked = TRUE;
+ sp_gradient_vector_widget_load_gradient (widget, gradient);
+ blocked = FALSE;
+ }
}
static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *object)
{
- SPGradient *gradient, *ngr;
+ SPGradient *gradient, *ngr;
- if (blocked) return;
+ if (blocked) return;
- gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient");
- if (!gradient) return;
+ gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient");
+ if (!gradient) return;
- blocked = TRUE;
+ blocked = TRUE;
- ngr = sp_gradient_ensure_vector_normalized (gradient);
- if (ngr != gradient) {
- /* Our master gradient has changed */
- sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr);
- }
+ ngr = sp_gradient_ensure_vector_normalized (gradient);
+ if (ngr != gradient) {
+ /* Our master gradient has changed */
+ sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr);
+ }
- sp_gradient_ensure_vector (ngr);
+ sp_gradient_ensure_vector (ngr);
GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(object), "stopmenu");
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
@@ -1133,52 +1131,52 @@ static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *o
static void
sp_gradient_vector_color_changed (SPColorSelector *csel, GtkObject *object)
{
- SPColor color;
- float alpha;
- guint32 rgb;
+ SPColor color;
+ float alpha;
+ guint32 rgb;
- if (blocked) return;
+ if (blocked) return;
- SPGradient *gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient");
- if (!gradient) return;
+ SPGradient *gradient = (SPGradient*)g_object_get_data (G_OBJECT (object), "gradient");
+ if (!gradient) return;
- blocked = TRUE;
+ blocked = TRUE;
- SPGradient *ngr = sp_gradient_ensure_vector_normalized (gradient);
- if (ngr != gradient) {
- /* Our master gradient has changed */
- sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr);
- }
+ SPGradient *ngr = sp_gradient_ensure_vector_normalized (gradient);
+ if (ngr != gradient) {
+ /* Our master gradient has changed */
+ sp_gradient_vector_widget_load_gradient (GTK_WIDGET (object), ngr);
+ }
- sp_gradient_ensure_vector (ngr);
+ sp_gradient_ensure_vector (ngr);
- /* Set start parameters */
- /* We rely on normalized vector, i.e. stops HAVE to exist */
- g_return_if_fail (sp_first_stop(ngr) != NULL);
+ /* Set start parameters */
+ /* We rely on normalized vector, i.e. stops HAVE to exist */
+ g_return_if_fail (sp_first_stop(ngr) != NULL);
- GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(object), "stopmenu");
- SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
+ GtkOptionMenu *mnu = (GtkOptionMenu *)g_object_get_data (G_OBJECT(object), "stopmenu");
+ SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
- csel = (SPColorSelector*)g_object_get_data (G_OBJECT (object), "cselector");
- csel->base->getColorAlpha( color, &alpha );
- rgb = color.toRGBA32( 0x00 );
+ csel = (SPColorSelector*)g_object_get_data (G_OBJECT (object), "cselector");
+ csel->base->getColorAlpha( color, &alpha );
+ rgb = color.toRGBA32( 0x00 );
- sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset);
- Inkscape::CSSOStringStream os;
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), rgb);
- os << "stop-color:" << c << ";stop-opacity:" << (gdouble) alpha <<";";
- SP_OBJECT_REPR (stop)->setAttribute("style", os.str().c_str());
- // g_snprintf (c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, (gdouble) alpha);
- //SP_OBJECT_REPR (stop)->setAttribute("style", c);
+ sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset);
+ Inkscape::CSSOStringStream os;
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), rgb);
+ os << "stop-color:" << c << ";stop-opacity:" << (gdouble) alpha <<";";
+ SP_OBJECT_REPR (stop)->setAttribute("style", os.str().c_str());
+ // g_snprintf (c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, (gdouble) alpha);
+ //SP_OBJECT_REPR (stop)->setAttribute("style", c);
- sp_document_done (SP_OBJECT_DOCUMENT (ngr), SP_VERB_CONTEXT_GRADIENT,
- _("Change gradient stop color"));
+ sp_document_done (SP_OBJECT_DOCUMENT (ngr), SP_VERB_CONTEXT_GRADIENT,
+ _("Change gradient stop color"));
- blocked = FALSE;
+ blocked = FALSE;
- SPColorPreview *cpv = (SPColorPreview *)g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "preview");
- sp_color_preview_set_rgba32(cpv, sp_stop_get_rgba32(stop));
+ SPColorPreview *cpv = (SPColorPreview *)g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "preview");
+ sp_color_preview_set_rgba32(cpv, sp_stop_get_rgba32(stop));
}
/*
index be3ed62eb38ac6c0976217822418a044758d82f1..bac85177700fdfd0c7658d471443f60c909f95b9 100644 (file)
-#ifndef __SP_GRADIENT_VECTOR_H__
-#define __SP_GRADIENT_VECTOR_H__
+#ifndef SEEN_GRADIENT_VECTOR_H
+#define SEEN_GRADIENT_VECTOR_H
/*
* Gradient vector selection widget
#define SP_IS_GRADIENT_VECTOR_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_VECTOR_SELECTOR))
struct SPGradientVectorSelector {
- GtkVBox vbox;
+ GtkVBox vbox;
- guint idlabel : 1;
+ guint idlabel : 1;
- SPDocument *doc;
- SPGradient *gr;
+ SPDocument *doc;
+ SPGradient *gr;
- /* Vector menu */
- GtkWidget *menu;
+ /* Vector menu */
+ GtkWidget *menu;
- sigc::connection gradient_release_connection;
- sigc::connection defs_release_connection;
- sigc::connection defs_modified_connection;
+ sigc::connection gradient_release_connection;
+ sigc::connection defs_release_connection;
+ sigc::connection defs_modified_connection;
};
struct SPGradientVectorSelectorClass {
- GtkVBoxClass parent_class;
+ GtkVBoxClass parent_class;
- void (* vector_set) (SPGradientVectorSelector *gvs, SPGradient *gr);
+ void (* vector_set) (SPGradientVectorSelector *gvs, SPGradient *gr);
};
GtkType sp_gradient_vector_selector_get_type (void);
-#endif
+#endif // SEEN_GRADIENT_VECTOR_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :