[gtk+/wip/colorchooser-v2: 18/40] Make color chooser always come up with palette
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/colorchooser-v2: 18/40] Make color chooser always come up with palette
- Date: Tue, 7 Feb 2012 17:45:59 +0000 (UTC)
commit 6959d8b7d20d3254ce9797d547d41eea941c5ba5
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 1 01:53:08 2012 -0500
Make color chooser always come up with palette
gtk/gtkcolorchooser.c | 1 +
gtk/gtkcolorchooser.h | 16 ++++++++--------
gtk/gtkcolorchooserdialog.c | 29 +++++++++++++++++++++++++----
gtk/gtkcolorchooserwidget.c | 23 ++++++++++++++++++++++-
4 files changed, 56 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkcolorchooser.c b/gtk/gtkcolorchooser.c
index 42e0e97..9013d2c 100644
--- a/gtk/gtkcolorchooser.c
+++ b/gtk/gtkcolorchooser.c
@@ -52,6 +52,7 @@ gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
P_("Whether alpha should be shown"),
TRUE,
GTK_PARAM_READWRITE));
+
/**
* GtkColorChooser::color-activated:
* @self: the object which received the signal
diff --git a/gtk/gtkcolorchooser.h b/gtk/gtkcolorchooser.h
index 23db338..3d38c0f 100644
--- a/gtk/gtkcolorchooser.h
+++ b/gtk/gtkcolorchooser.h
@@ -55,15 +55,15 @@ struct _GtkColorChooserInterface
gpointer padding[12];
};
-GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
+GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
-void gtk_color_chooser_get_color (GtkColorChooser *chooser,
- GdkRGBA *color);
-void gtk_color_chooser_set_color (GtkColorChooser *chooser,
- const GdkRGBA *color);
-gboolean gtk_color_chooser_get_show_alpha (GtkColorChooser *chooser);
-void gtk_color_chooser_set_show_alpha (GtkColorChooser *chooser,
- gboolean show_alpha);
+void gtk_color_chooser_get_color (GtkColorChooser *chooser,
+ GdkRGBA *color);
+void gtk_color_chooser_set_color (GtkColorChooser *chooser,
+ const GdkRGBA *color);
+gboolean gtk_color_chooser_get_show_alpha (GtkColorChooser *chooser);
+void gtk_color_chooser_set_show_alpha (GtkColorChooser *chooser,
+ gboolean show_alpha);
G_END_DECLS
diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c
index 8d2c229..32e77cc 100644
--- a/gtk/gtkcolorchooserdialog.c
+++ b/gtk/gtkcolorchooserdialog.c
@@ -22,6 +22,7 @@
#include "gtkdialog.h"
#include "gtkstock.h"
#include "gtkbox.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkcolorchooserprivate.h"
@@ -41,7 +42,8 @@ enum
{
PROP_ZERO,
PROP_COLOR,
- PROP_SHOW_ALPHA
+ PROP_SHOW_ALPHA,
+ PROP_SHOW_EDITOR
};
static void gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface);
@@ -133,6 +135,9 @@ gtk_color_chooser_dialog_response (GtkDialog *dialog,
gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (dialog), &color);
gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (dialog), &color);
}
+
+ g_object_set (GTK_COLOR_CHOOSER_DIALOG (dialog)->priv->color_chooser,
+ "show-editor", FALSE, NULL);
}
static void
@@ -153,10 +158,17 @@ gtk_color_chooser_dialog_get_property (GObject *object,
gtk_color_chooser_get_color (cc, &color);
g_value_set_boxed (value, &color);
}
- break;
+ break;
case PROP_SHOW_ALPHA:
g_value_set_boolean (value, gtk_color_chooser_get_show_alpha (GTK_COLOR_CHOOSER (cd->priv->color_chooser)));
break;
+ case PROP_SHOW_EDITOR:
+ {
+ gboolean show_editor;
+ g_object_get (cd->priv->color_chooser, "show-editor", &show_editor, NULL);
+ g_value_set_boolean (value, show_editor);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -176,10 +188,15 @@ gtk_color_chooser_dialog_set_property (GObject *object,
{
case PROP_COLOR:
gtk_color_chooser_set_color (cc, g_value_get_boxed (value));
- break;
+ break;
case PROP_SHOW_ALPHA:
gtk_color_chooser_set_show_alpha (GTK_COLOR_CHOOSER (cd->priv->color_chooser), g_value_get_boolean (value));
- break;
+ break;
+ case PROP_SHOW_EDITOR:
+ g_object_set (cd->priv->color_chooser,
+ "show-editor", g_value_get_boolean (value),
+ NULL);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -199,6 +216,10 @@ gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class)
g_object_class_override_property (object_class, PROP_COLOR, "color");
g_object_class_override_property (object_class, PROP_SHOW_ALPHA, "show-alpha");
+ g_object_class_install_property (object_class, PROP_SHOW_EDITOR,
+ g_param_spec_boolean ("show-editor", P_("Show editor"), P_("Show editor"),
+ FALSE, GTK_PARAM_READWRITE));
+
g_type_class_add_private (class, sizeof (GtkColorChooserDialogPrivate));
}
diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c
index c54181b..04ac168 100644
--- a/gtk/gtkcolorchooserwidget.c
+++ b/gtk/gtkcolorchooserwidget.c
@@ -29,6 +29,7 @@
#include "gtkhsv.h"
#include "gtklabel.h"
#include "gtkorientable.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
struct _GtkColorChooserWidgetPrivate
@@ -51,7 +52,8 @@ enum
{
PROP_ZERO,
PROP_COLOR,
- PROP_SHOW_ALPHA
+ PROP_SHOW_ALPHA,
+ PROP_SHOW_EDITOR
};
static void gtk_color_chooser_widget_iface_init (GtkColorChooserInterface *iface);
@@ -348,6 +350,9 @@ gtk_color_chooser_widget_get_property (GObject *object,
case PROP_SHOW_ALPHA:
g_value_set_boolean (value, cw->priv->show_alpha);
break;
+ case PROP_SHOW_EDITOR:
+ g_value_set_boolean (value, gtk_widget_get_visible (cw->priv->editor));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -385,6 +390,14 @@ gtk_color_chooser_widget_set_show_alpha (GtkColorChooserWidget *cc,
}
static void
+gtk_color_chooser_widget_set_show_editor (GtkColorChooserWidget *cc,
+ gboolean show_editor)
+{
+ gtk_widget_set_visible (cc->priv->editor, show_editor);
+ gtk_widget_set_visible (cc->priv->palette, !show_editor);
+}
+
+static void
gtk_color_chooser_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -402,6 +415,10 @@ gtk_color_chooser_widget_set_property (GObject *object,
gtk_color_chooser_widget_set_show_alpha (cc,
g_value_get_boolean (value));
break;
+ case PROP_SHOW_EDITOR:
+ gtk_color_chooser_widget_set_show_editor (cc,
+ g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -430,6 +447,10 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class)
g_object_class_override_property (object_class, PROP_COLOR, "color");
g_object_class_override_property (object_class, PROP_SHOW_ALPHA, "show-alpha");
+ g_object_class_install_property (object_class, PROP_SHOW_EDITOR,
+ g_param_spec_boolean ("show-editor", P_("Show editor"), P_("Show editor"),
+ FALSE, GTK_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (GtkColorChooserWidgetPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]