[gimp/gtk3-port: 188/243] libgimpwidgets: move all GimpColorHexEntry members to a private struct
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 188/243] libgimpwidgets: move all GimpColorHexEntry members to a private struct
- Date: Mon, 11 Apr 2011 17:22:57 +0000 (UTC)
commit 606bac6c52ee7d2a9524f507709b1067c08cdead
Author: Michael Natterer <mitch gimp org>
Date: Sun Jan 2 01:29:39 2011 +0100
libgimpwidgets: move all GimpColorHexEntry members to a private struct
libgimpwidgets/gimpcolorhexentry.c | 56 ++++++++++++++++++++++++++---------
libgimpwidgets/gimpcolorhexentry.h | 4 +--
2 files changed, 42 insertions(+), 18 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorhexentry.c b/libgimpwidgets/gimpcolorhexentry.c
index e5885d7..07b047b 100644
--- a/libgimpwidgets/gimpcolorhexentry.c
+++ b/libgimpwidgets/gimpcolorhexentry.c
@@ -57,6 +57,18 @@ enum
};
+typedef struct _GimpColorHexEntryPrivate GimpColorHexEntryPrivate;
+
+struct _GimpColorHexEntryPrivate
+{
+ GimpRGB color;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ GIMP_TYPE_COLOR_HEX_ENTRY, \
+ GimpColorHexEntryPrivate))
+
+
static gboolean gimp_color_hex_entry_events (GtkWidget *widget,
GdkEvent *event);
@@ -76,6 +88,8 @@ static guint entry_signals[LAST_SIGNAL] = { 0 };
static void
gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
entry_signals[COLOR_CHANGED] =
g_signal_new ("color-changed",
G_TYPE_FROM_CLASS (klass),
@@ -86,20 +100,23 @@ gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
G_TYPE_NONE, 0);
klass->color_changed = NULL;
+
+ g_type_class_add_private (object_class, sizeof (GimpColorHexEntryPrivate));
}
static void
gimp_color_hex_entry_init (GimpColorHexEntry *entry)
{
- GtkEntryCompletion *completion;
- GtkCellRenderer *cell;
- GtkListStore *store;
- GimpRGB *colors;
- const gchar **names;
- gint num_colors;
- gint i;
+ GimpColorHexEntryPrivate *private = GET_PRIVATE (entry);
+ GtkEntryCompletion *completion;
+ GtkCellRenderer *cell;
+ GtkListStore *store;
+ GimpRGB *colors;
+ const gchar **names;
+ gint num_colors;
+ gint i;
- gimp_rgba_set (&entry->color, 0.0, 0.0, 0.0, 1.0);
+ gimp_rgba_set (&private->color, 0.0, 0.0, 0.0, 1.0);
store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, GIMP_TYPE_RGB);
@@ -177,18 +194,22 @@ void
gimp_color_hex_entry_set_color (GimpColorHexEntry *entry,
const GimpRGB *color)
{
+ GimpColorHexEntryPrivate *private;
+
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
g_return_if_fail (color != NULL);
- if (gimp_rgb_distance (&entry->color, color) > 0.0)
+ private = GET_PRIVATE (entry);
+
+ if (gimp_rgb_distance (&private->color, color) > 0.0)
{
gchar buffer[8];
guchar r, g, b;
- gimp_rgb_set (&entry->color, color->r, color->g, color->b);
- gimp_rgb_clamp (&entry->color);
+ gimp_rgb_set (&private->color, color->r, color->g, color->b);
+ gimp_rgb_clamp (&private->color);
- gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
+ gimp_rgb_get_uchar (&private->color, &r, &g, &b);
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
gtk_entry_set_text (GTK_ENTRY (entry), buffer);
@@ -213,17 +234,22 @@ void
gimp_color_hex_entry_get_color (GimpColorHexEntry *entry,
GimpRGB *color)
{
+ GimpColorHexEntryPrivate *private;
+
g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry));
g_return_if_fail (color != NULL);
- *color = entry->color;
+ private = GET_PRIVATE (entry);
+
+ *color = private->color;
}
static gboolean
gimp_color_hex_entry_events (GtkWidget *widget,
GdkEvent *event)
{
- GimpColorHexEntry *entry = GIMP_COLOR_HEX_ENTRY (widget);
+ GimpColorHexEntry *entry = GIMP_COLOR_HEX_ENTRY (widget);
+ GimpColorHexEntryPrivate *private = GET_PRIVATE (entry);
switch (event->type)
{
@@ -246,7 +272,7 @@ gimp_color_hex_entry_events (GtkWidget *widget,
text = gtk_entry_get_text (GTK_ENTRY (widget));
- gimp_rgb_get_uchar (&entry->color, &r, &g, &b);
+ gimp_rgb_get_uchar (&private->color, &r, &g, &b);
g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b);
if (g_ascii_strcasecmp (buffer, text) != 0)
diff --git a/libgimpwidgets/gimpcolorhexentry.h b/libgimpwidgets/gimpcolorhexentry.h
index 8d5a5a6..8ff496f 100644
--- a/libgimpwidgets/gimpcolorhexentry.h
+++ b/libgimpwidgets/gimpcolorhexentry.h
@@ -37,9 +37,7 @@ typedef struct _GimpColorHexEntryClass GimpColorHexEntryClass;
struct _GimpColorHexEntry
{
- GtkEntry parent_instance;
-
- GimpRGB color;
+ GtkEntry parent_instance;
};
struct _GimpColorHexEntryClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]