summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0d4337d)
raw | patch | inline | side by side (parent: 0d4337d)
author | Jon A. Cruz <jon@joncruz.org> | |
Thu, 17 Jun 2010 07:49:02 +0000 (00:49 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Thu, 17 Jun 2010 07:49:02 +0000 (00:49 -0700) |
src/widgets/gradient-selector.cpp | patch | blob | history |
index bc2413730e66d8fbe11f082d4ec2bb1b905f528b..9aa72164bc68ca04f145e0d49d6eff86f4e2149b 100644 (file)
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) {
- if (spread) {
- GtkWidget *parent = gtk_widget_get_parent(spread);
- if (parent) {
- gtk_container_remove(GTK_CONTAINER(parent), spread);
- spread = 0;
- }
- }
- if (spreadLbl) {
- GtkWidget *parent = gtk_widget_get_parent(spreadLbl);
- if (parent) {
- gtk_container_remove(GTK_CONTAINER(parent), spreadLbl);
- spreadLbl = 0;
- }
- }
+ removeWidget(add);
+ removeWidget(edit);
+ removeWidget(spread);
+ removeWidget(spreadLbl);
SPGradientVectorSelector* vs = SP_GRADIENT_VECTOR_SELECTOR(vectors);
vs->setSwatched();
sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(vectors), doc, vector);
if (vector) {
- gtk_widget_set_sensitive(edit, TRUE);
- gtk_widget_set_sensitive(add, TRUE);
+ if (edit) {
+ gtk_widget_set_sensitive(edit, TRUE);
+ }
+ if (add) {
+ gtk_widget_set_sensitive(add, TRUE);
+ }
} else {
- gtk_widget_set_sensitive(edit, FALSE);
- gtk_widget_set_sensitive(add, (doc != NULL));
+ if (edit) {
+ gtk_widget_set_sensitive(edit, FALSE);
+ }
+ if (add) {
+ gtk_widget_set_sensitive(add, (doc != NULL));
+ }
}
}