summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d40e214)
raw | patch | inline | side by side (parent: d40e214)
author | Jon A. Cruz <jon@joncruz.org> | |
Wed, 7 Jul 2010 05:03:34 +0000 (22:03 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Wed, 7 Jul 2010 05:03:34 +0000 (22:03 -0700) |
index 77defa5c9d4290b483924e648ea13189c85dd771..5b663c49302a284fbd02ce79d98ba2d1cad94930 100644 (file)
object_class->destroy = sp_gradient_selector_destroy;
}
-static void
-sp_gradient_selector_init (SPGradientSelector *sel)
+static void sp_gradient_selector_init(SPGradientSelector *sel)
{
- GtkWidget *hb, *m, *mi;
+ sel->safelyInit = true;
+ new (&sel->nonsolid) std::vector<GtkWidget*>();
sel->mode = SPGradientSelector::MODE_LINEAR;
g_signal_connect (G_OBJECT (sel->vectors), "vector_set", G_CALLBACK (sp_gradient_selector_vector_set), sel);
/* Create box for buttons */
- hb = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (sel), hb, FALSE, FALSE, 0);
+ GtkWidget *hb = gtk_hbox_new( FALSE, 0 );
+ sel->nonsolid.push_back(hb);
+ gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
GtkTooltips *ttips = gtk_tooltips_new ();
sel->add = gtk_button_new_with_label (_("Duplicate"));
+ sel->nonsolid.push_back(sel->add);
gtk_box_pack_start (GTK_BOX (hb), sel->add, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (sel->add), "clicked", G_CALLBACK (sp_gradient_selector_add_vector_clicked), sel);
gtk_widget_set_sensitive (sel->add, FALSE);
sel->edit = gtk_button_new_with_label (_("Edit..."));
+ sel->nonsolid.push_back(sel->edit);
gtk_box_pack_start (GTK_BOX (hb), sel->edit, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (sel->edit), "clicked", G_CALLBACK (sp_gradient_selector_edit_vector_clicked), sel);
gtk_widget_set_sensitive (sel->edit, FALSE);
- gtk_widget_show_all (hb);
+ gtk_widget_show_all(hb);
/* Spread selector */
- hb = gtk_hbox_new (FALSE, 0);
- gtk_widget_show (hb);
- gtk_box_pack_start (GTK_BOX (sel), hb, FALSE, FALSE, 0);
-
- sel->spread = gtk_option_menu_new ();
- gtk_widget_show (sel->spread);
- gtk_box_pack_end (GTK_BOX (hb), sel->spread, FALSE, FALSE, 0);
- gtk_tooltips_set_tip (ttips, sel->spread,
+ hb = gtk_hbox_new( FALSE, 0 );
+ sel->nonsolid.push_back(hb);
+ gtk_widget_show(hb);
+ gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 );
+
+ sel->spread = gtk_option_menu_new();
+ sel->nonsolid.push_back(sel->spread);
+ gtk_widget_show(sel->spread);
+ gtk_box_pack_end( GTK_BOX(hb), sel->spread, FALSE, FALSE, 0 );
+ gtk_tooltips_set_tip( ttips, sel->spread,
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute
_("Whether to fill with flat color beyond the ends of the gradient vector "
"(spreadMethod=\"pad\"), or repeat the gradient in the same direction "
"(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite "
"directions (spreadMethod=\"reflect\")"), NULL);
- m = gtk_menu_new ();
- mi = gtk_menu_item_new_with_label (_("none"));
+ GtkWidget *m = gtk_menu_new();
+ GtkWidget *mi = gtk_menu_item_new_with_label(_("none"));
gtk_menu_append (GTK_MENU (m), mi);
g_object_set_data (G_OBJECT (mi), "gradientSpread", GUINT_TO_POINTER (SP_GRADIENT_SPREAD_PAD));
g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (sp_gradient_selector_spread_activate), sel);
gtk_menu_append (GTK_MENU (m), mi);
gtk_widget_show_all (m);
- gtk_option_menu_set_menu (GTK_OPTION_MENU (sel->spread), m);
+ gtk_option_menu_set_menu( GTK_OPTION_MENU(sel->spread), m );
- sel->spreadLbl = gtk_label_new (_("Repeat:"));
- gtk_widget_show(sel->spreadLbl);
- gtk_box_pack_end(GTK_BOX(hb), sel->spreadLbl, FALSE, FALSE, 4);
+ sel->spreadLbl = gtk_label_new( _("Repeat:") );
+ sel->nonsolid.push_back(sel->spreadLbl);
+ gtk_widget_show( sel->spreadLbl );
+ gtk_box_pack_end( GTK_BOX(hb), sel->spreadLbl, FALSE, FALSE, 4 );
}
-static void
-sp_gradient_selector_destroy (GtkObject *object)
+static void sp_gradient_selector_destroy(GtkObject *object)
{
- SPGradientSelector *sel;
+ SPGradientSelector *sel = SP_GRADIENT_SELECTOR( object );
- sel = SP_GRADIENT_SELECTOR (object);
+ if ( sel->safelyInit ) {
+ sel->safelyInit = false;
+ using std::vector;
+ sel->nonsolid.~vector<GtkWidget*>();
+ }
- if (((GtkObjectClass *) (parent_class))->destroy)
+ if (((GtkObjectClass *) (parent_class))->destroy) {
(* ((GtkObjectClass *) (parent_class))->destroy) (object);
+ }
}
GtkWidget *
return (GtkWidget *) sel;
}
-static void removeWidget( GtkWidget *& widget )
-{
- if (widget) {
- GtkWidget *parent = gtk_widget_get_parent(widget);
- if (parent) {
- gtk_container_remove(GTK_CONTAINER(parent), widget);
- widget = 0;
- }
- }
-}
-
void SPGradientSelector::setMode(SelectorMode mode)
{
if (mode != this->mode) {
this->mode = mode;
if (mode == MODE_SWATCH) {
- removeWidget(add);
- removeWidget(edit);
- removeWidget(spread);
- removeWidget(spreadLbl);
+ for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ {
+ gtk_widget_hide(*it);
+ }
SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors);
vs->setSwatched();
sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(vectors), doc, vector);
if (vector) {
+ if ( (mode == MODE_SWATCH) && vector->isSwatch() ) {
+ if ( vector->isSolid() ) {
+ for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ {
+ gtk_widget_hide(*it);
+ }
+ } else {
+ for (std::vector<GtkWidget*>::iterator it = nonsolid.begin(); it != nonsolid.end(); ++it)
+ {
+ gtk_widget_show_all(*it);
+ }
+ }
+ }
+
if (edit) {
gtk_widget_set_sensitive(edit, TRUE);
}
index 25f561a6e9875a0c38a1c237128e69fe8b5e888d..860804ec6b4f981e18ff3e080fb09d45665d61a9 100644 (file)
#include <glib.h>
#include <gtk/gtkvbox.h>
+#include <vector>
#include "sp-gradient.h"
#include "sp-gradient-spread.h"
#include "sp-gradient-units.h"
GtkWidget *spread;
GtkWidget *spreadLbl;
+ bool safelyInit;
+ std::vector<GtkWidget*> nonsolid;
+
void setMode(SelectorMode mode);
void setUnits(SPGradientUnits units);
void setSpread(SPGradientSpread spread);
index 454c120015364949d684eade3245f17907b15d13..c49d9e06f0685427023ec6d585f5927c7d65a8a0 100644 (file)
void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr)
{
+// g_message("sp_gradient_vector_selector_set_gradient(%p, %p, %p) [%s] %d %d", gvs, doc, gr,
+// (gr ? gr->getId():"N/A"),
+// (gr ? gr->isSwatch() : -1),
+// (gr ? gr->isSolid() : -1));
static gboolean suppress = FALSE;
g_return_if_fail(gvs != NULL);
@@ -337,6 +341,7 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
/* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
//g_print("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID(gr));
+ //g_message("Setting to gradient %p swatch:%d solid:%d", gr, gr->isSwatch(), gr->isSolid());
norm = sp_gradient_ensure_vector_normalized(gr);
if (norm != gr) {
index a569d00bb7126f0ea4777b568244709d6cea865e..cf6a04a3c6cc0c6cd1b15c8eab54ab0342a2b99b 100644 (file)
@@ -1082,11 +1082,10 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele
SwatchSelector *swatchsel = 0;
if (psel->mode == SPPaintSelector::MODE_SWATCH){
- /* Already have pattern menu */
swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
} else {
sp_paint_selector_clear_frame(psel);
- /* Create new gradient selector */
+ // Create new gradient selector
SwatchSelector *swatchsel = new SwatchSelector();
swatchsel->show();
index ce0f8a810ae366f69ce3c3558b843fa4a1bd59e2..88abca358ab218c59bd6084998f480cb3cc18924 100644 (file)
void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector)
{
//GtkVBox * box = gobj();
-
_gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
- if (vector) {
+ if ( vector && vector->isSolid() ) {
SPStop* stop = vector->getFirstStop();
guint32 const colorVal = sp_stop_get_rgba32(stop);
SPColor color( SP_RGBA32_R_F(colorVal), SP_RGBA32_G_F(colorVal), SP_RGBA32_B_F(colorVal) );
// set its color, from the stored array
_csel->base->setColor( color );
+ gtk_widget_show_all( GTK_WIDGET(_csel) );
+ } else {
+ gtk_widget_hide( GTK_WIDGET(_csel) );
}
/*