[gimp/gtk3-port: 164/223] libgimpwidgets: move all GimpColorDisplayStack members to a private struct
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 164/223] libgimpwidgets: move all GimpColorDisplayStack members to a private struct
- Date: Thu, 3 Nov 2011 23:48:29 +0000 (UTC)
commit b7af6a28fc0949f6be7e1c6574be5a276be5f901
Author: Michael Natterer <mitch gimp org>
Date: Fri Dec 31 19:11:27 2010 +0100
libgimpwidgets: move all GimpColorDisplayStack members to a private struct
app/widgets/gimpcolordisplayeditor.c | 10 ++-
libgimpwidgets/gimpcolordisplaystack.c | 101 ++++++++++++++++++++++++--------
libgimpwidgets/gimpcolordisplaystack.h | 40 ++++++------
3 files changed, 104 insertions(+), 47 deletions(-)
---
diff --git a/app/widgets/gimpcolordisplayeditor.c b/app/widgets/gimpcolordisplayeditor.c
index 183dcd0..0e8d136 100644
--- a/app/widgets/gimpcolordisplayeditor.c
+++ b/app/widgets/gimpcolordisplayeditor.c
@@ -380,7 +380,9 @@ gimp_color_display_editor_new (GimpColorDisplayStack *stack)
g_free (display_types);
- for (list = stack->filters; list; list = g_list_next (list))
+ for (list = gimp_color_display_stack_get_filters (stack);
+ list;
+ list = g_list_next (list))
{
GimpColorDisplay *display = list->data;
GtkTreeIter iter;
@@ -670,6 +672,7 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack *stack,
if (display == display2)
{
+ GList *filters = gimp_color_display_stack_get_filters (stack);
GtkTreePath *path;
gint old_position;
@@ -680,7 +683,7 @@ gimp_color_display_editor_reordered (GimpColorDisplayStack *stack,
if (position == old_position)
return;
- if (position == -1 || position == g_list_length (stack->filters) - 1)
+ if (position == -1 || position == g_list_length (filters) - 1)
{
gtk_list_store_move_before (editor->dest, &iter, NULL);
}
@@ -781,11 +784,12 @@ gimp_color_display_editor_update_buttons (GimpColorDisplayEditor *editor)
if (gtk_tree_selection_get_selected (editor->dest_sel, &model, &iter))
{
+ GList *filters = gimp_color_display_stack_get_filters (editor->stack);
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
gint *indices = gtk_tree_path_get_indices (path);
up_sensitive = indices[0] > 0;
- down_sensitive = indices[0] < (g_list_length (editor->stack->filters) - 1);
+ down_sensitive = indices[0] < (g_list_length (filters) - 1);
gtk_tree_path_free (path);
}
diff --git a/libgimpwidgets/gimpcolordisplaystack.c b/libgimpwidgets/gimpcolordisplaystack.c
index bea266e..6c57108 100644
--- a/libgimpwidgets/gimpcolordisplaystack.c
+++ b/libgimpwidgets/gimpcolordisplaystack.c
@@ -53,6 +53,18 @@ enum
};
+typedef struct _GimpColorDisplayStackPrivate GimpColorDisplayStackPrivate;
+
+struct _GimpColorDisplayStackPrivate
+{
+ GList *filters;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ GIMP_TYPE_COLOR_DISPLAY_STACK, \
+ GimpColorDisplayStackPrivate))
+
+
static void gimp_color_display_stack_dispose (GObject *object);
static void gimp_color_display_stack_display_changed (GimpColorDisplay *display,
@@ -123,24 +135,29 @@ gimp_color_display_stack_class_init (GimpColorDisplayStackClass *klass)
klass->added = NULL;
klass->removed = NULL;
klass->reordered = NULL;
+
+ g_type_class_add_private (object_class, sizeof (GimpColorDisplayStackPrivate));
}
static void
gimp_color_display_stack_init (GimpColorDisplayStack *stack)
{
- stack->filters = NULL;
+ GimpColorDisplayStackPrivate *private = GET_PRIVATE (stack);
+
+ private->filters = NULL;
}
static void
gimp_color_display_stack_dispose (GObject *object)
{
- GimpColorDisplayStack *stack = GIMP_COLOR_DISPLAY_STACK (object);
+ GimpColorDisplayStack *stack = GIMP_COLOR_DISPLAY_STACK (object);
+ GimpColorDisplayStackPrivate *private = GET_PRIVATE (object);
- if (stack->filters)
+ if (private->filters)
{
GList *list;
- for (list = stack->filters; list; list = g_list_next (list))
+ for (list = private->filters; list; list = g_list_next (list))
{
GimpColorDisplay *display = list->data;
@@ -148,13 +165,16 @@ gimp_color_display_stack_dispose (GObject *object)
g_object_unref (display);
}
- g_list_free (stack->filters);
- stack->filters = NULL;
+ g_list_free (private->filters);
+ private->filters = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
+
+/* public functions */
+
GimpColorDisplayStack *
gimp_color_display_stack_new (void)
{
@@ -164,14 +184,17 @@ gimp_color_display_stack_new (void)
GimpColorDisplayStack *
gimp_color_display_stack_clone (GimpColorDisplayStack *stack)
{
- GimpColorDisplayStack *clone;
- GList *list;
+ GimpColorDisplayStackPrivate *private;
+ GimpColorDisplayStack *clone;
+ GList *list;
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack), NULL);
+ private = GET_PRIVATE (stack);
+
clone = g_object_new (GIMP_TYPE_COLOR_DISPLAY_STACK, NULL);
- for (list = stack->filters; list; list = g_list_next (list))
+ for (list = private->filters; list; list = g_list_next (list))
{
GimpColorDisplay *display;
@@ -192,15 +215,28 @@ gimp_color_display_stack_changed (GimpColorDisplayStack *stack)
g_signal_emit (stack, stack_signals[CHANGED], 0);
}
+GList *
+gimp_color_display_stack_get_filters (GimpColorDisplayStack *stack)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack), NULL);
+
+ return GET_PRIVATE (stack)->filters;
+}
+
void
gimp_color_display_stack_add (GimpColorDisplayStack *stack,
GimpColorDisplay *display)
{
+ GimpColorDisplayStackPrivate *private;
+
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
- g_return_if_fail (g_list_find (stack->filters, display) == NULL);
- stack->filters = g_list_append (stack->filters, g_object_ref (display));
+ private = GET_PRIVATE (stack);
+
+ g_return_if_fail (g_list_find (private->filters, display) == NULL);
+
+ private->filters = g_list_append (private->filters, g_object_ref (display));
g_signal_connect (display, "changed",
G_CALLBACK (gimp_color_display_stack_display_changed),
@@ -210,7 +246,7 @@ gimp_color_display_stack_add (GimpColorDisplayStack *stack,
G_OBJECT (stack));
g_signal_emit (stack, stack_signals[ADDED], 0,
- display, g_list_length (stack->filters) - 1);
+ display, g_list_length (private->filters) - 1);
gimp_color_display_stack_changed (stack);
}
@@ -219,13 +255,18 @@ void
gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
GimpColorDisplay *display)
{
+ GimpColorDisplayStackPrivate *private;
+
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
- g_return_if_fail (g_list_find (stack->filters, display) != NULL);
+
+ private = GET_PRIVATE (stack);
+
+ g_return_if_fail (g_list_find (private->filters, display) != NULL);
gimp_color_display_stack_disconnect (stack, display);
- stack->filters = g_list_remove (stack->filters, display);
+ private->filters = g_list_remove (private->filters, display);
g_signal_emit (stack, stack_signals[REMOVED], 0, display);
@@ -238,12 +279,15 @@ void
gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
GimpColorDisplay *display)
{
- GList *list;
+ GimpColorDisplayStackPrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
- list = g_list_find (stack->filters, display);
+ private = GET_PRIVATE (stack);
+
+ list = g_list_find (private->filters, display);
g_return_if_fail (list != NULL);
@@ -253,7 +297,7 @@ gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
list->prev->data = display;
g_signal_emit (stack, stack_signals[REORDERED], 0,
- display, g_list_position (stack->filters, list->prev));
+ display, g_list_position (private->filters, list->prev));
gimp_color_display_stack_changed (stack);
}
@@ -263,12 +307,15 @@ void
gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
GimpColorDisplay *display)
{
- GList *list;
+ GimpColorDisplayStackPrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
- list = g_list_find (stack->filters, display);
+ private = GET_PRIVATE (stack);
+
+ list = g_list_find (private->filters, display);
g_return_if_fail (list != NULL);
@@ -278,7 +325,7 @@ gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
list->next->data = display;
g_signal_emit (stack, stack_signals[REORDERED], 0,
- display, g_list_position (stack->filters, list->next));
+ display, g_list_position (private->filters, list->next));
gimp_color_display_stack_changed (stack);
}
@@ -297,14 +344,17 @@ void
gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
cairo_surface_t *surface)
{
- GList *list;
+ GimpColorDisplayStackPrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
g_return_if_fail (surface != NULL);
g_return_if_fail (cairo_surface_get_type (surface) ==
CAIRO_SURFACE_TYPE_IMAGE);
- for (list = stack->filters; list; list = g_list_next (list))
+ private = GET_PRIVATE (stack);
+
+ for (list = private->filters; list; list = g_list_next (list))
{
GimpColorDisplay *display = list->data;
@@ -333,11 +383,14 @@ gimp_color_display_stack_convert (GimpColorDisplayStack *stack,
gint bpp,
gint bpl)
{
- GList *list;
+ GimpColorDisplayStackPrivate *private;
+ GList *list;
g_return_if_fail (GIMP_IS_COLOR_DISPLAY_STACK (stack));
- for (list = stack->filters; list; list = g_list_next (list))
+ private = GET_PRIVATE (stack);
+
+ for (list = private->filters; list; list = g_list_next (list))
{
GimpColorDisplay *display = list->data;
diff --git a/libgimpwidgets/gimpcolordisplaystack.h b/libgimpwidgets/gimpcolordisplaystack.h
index 6bd1a9a..8c4d5f1 100644
--- a/libgimpwidgets/gimpcolordisplaystack.h
+++ b/libgimpwidgets/gimpcolordisplaystack.h
@@ -44,8 +44,6 @@ typedef struct _GimpColorDisplayStackClass GimpColorDisplayStackClass;
struct _GimpColorDisplayStack
{
GObject parent_instance;
-
- GList *filters;
};
struct _GimpColorDisplayStackClass
@@ -75,25 +73,27 @@ GType gimp_color_display_stack_get_type (void) G_GNUC_CONST;
GimpColorDisplayStack * gimp_color_display_stack_new (void);
GimpColorDisplayStack * gimp_color_display_stack_clone (GimpColorDisplayStack *stack);
-void gimp_color_display_stack_changed (GimpColorDisplayStack *stack);
-
-void gimp_color_display_stack_add (GimpColorDisplayStack *stack,
- GimpColorDisplay *display);
-void gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
- GimpColorDisplay *display);
-void gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
- GimpColorDisplay *display);
-void gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
- GimpColorDisplay *display);
-void gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
- cairo_surface_t *surface);
+void gimp_color_display_stack_changed (GimpColorDisplayStack *stack);
+
+GList * gimp_color_display_stack_get_filters (GimpColorDisplayStack *stack);
+
+void gimp_color_display_stack_add (GimpColorDisplayStack *stack,
+ GimpColorDisplay *display);
+void gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
+ GimpColorDisplay *display);
+void gimp_color_display_stack_reorder_up (GimpColorDisplayStack *stack,
+ GimpColorDisplay *display);
+void gimp_color_display_stack_reorder_down (GimpColorDisplayStack *stack,
+ GimpColorDisplay *display);
+void gimp_color_display_stack_convert_surface (GimpColorDisplayStack *stack,
+ cairo_surface_t *surface);
#ifndef GIMP_DISABLE_DEPRECATED
-void gimp_color_display_stack_convert (GimpColorDisplayStack *stack,
- guchar *buf,
- gint width,
- gint height,
- gint bpp,
- gint bpl);
+void gimp_color_display_stack_convert (GimpColorDisplayStack *stack,
+ guchar *buf,
+ gint width,
+ gint height,
+ gint bpp,
+ gint bpl);
#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]