[gimp/gtk3-port: 198/247] libgimpwidgets: move all GimpColorNotebook members to a private struct.
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 198/247] libgimpwidgets: move all GimpColorNotebook members to a private struct.
- Date: Sat, 5 Mar 2011 20:48:50 +0000 (UTC)
commit 35cfb6fae7765c9c97cbe0a50f6cf99ee0268ef3
Author: Michael Natterer <mitch gimp org>
Date: Sun Jan 2 02:20:09 2011 +0100
libgimpwidgets: move all GimpColorNotebook members to a private struct.
app/widgets/gimpcolordialog.c | 5 +-
app/widgets/gimpcoloreditor.c | 17 ++-
libgimpwidgets/gimpcolorbutton.c | 5 +-
libgimpwidgets/gimpcolornotebook.c | 212 +++++++++++++++++++++++------------
libgimpwidgets/gimpcolornotebook.h | 17 ++--
libgimpwidgets/gimpcolorselection.c | 8 +-
6 files changed, 173 insertions(+), 91 deletions(-)
---
diff --git a/app/widgets/gimpcolordialog.c b/app/widgets/gimpcolordialog.c
index e238280..e990d15 100644
--- a/app/widgets/gimpcolordialog.c
+++ b/app/widgets/gimpcolordialog.c
@@ -361,11 +361,14 @@ gimp_color_dialog_help_func (const gchar *help_id,
{
GimpColorDialog *dialog = GIMP_COLOR_DIALOG (help_data);
GimpColorNotebook *notebook;
+ GimpColorSelector *current;
notebook =
GIMP_COLOR_NOTEBOOK (GIMP_COLOR_SELECTION (dialog->selection)->notebook);
- help_id = GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->help_id;
+ current = gimp_color_notebook_get_current_selector (notebook);
+
+ help_id = GIMP_COLOR_SELECTOR_GET_CLASS (current)->help_id;
gimp_standard_help_func (help_id, NULL);
}
diff --git a/app/widgets/gimpcoloreditor.c b/app/widgets/gimpcoloreditor.c
index dd85c8a..e2085ec 100644
--- a/app/widgets/gimpcoloreditor.c
+++ b/app/widgets/gimpcoloreditor.c
@@ -183,7 +183,7 @@ gimp_color_editor_init (GimpColorEditor *editor)
G_CALLBACK (gimp_color_editor_color_changed),
editor);
- notebook = GIMP_COLOR_NOTEBOOK (editor->notebook)->notebook;
+ notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
@@ -193,7 +193,7 @@ gimp_color_editor_init (GimpColorEditor *editor)
group = NULL;
- for (list = GIMP_COLOR_NOTEBOOK (editor->notebook)->selectors;
+ for (list = gimp_color_notebook_get_selectors (GIMP_COLOR_NOTEBOOK (editor->notebook));
list;
list = g_list_next (list))
{
@@ -340,9 +340,11 @@ gimp_color_editor_set_aux_info (GimpDocked *docked,
GList *aux_info)
{
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
- GtkWidget *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook)->notebook;
+ GtkWidget *notebook;
GList *list;
+ notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
+
parent_docked_iface->set_aux_info (docked, aux_info);
for (list = aux_info; list; list = g_list_next (list))
@@ -382,16 +384,19 @@ gimp_color_editor_get_aux_info (GimpDocked *docked)
{
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook);
+ GimpColorSelector *current;
GList *aux_info;
aux_info = parent_docked_iface->get_aux_info (docked);
- if (notebook->cur_page)
+ current = gimp_color_notebook_get_current_selector (notebook);
+
+ if (current)
{
GimpSessionInfoAux *aux;
aux = gimp_session_info_aux_new (AUX_INFO_CURRENT_PAGE,
- G_OBJECT_TYPE_NAME (notebook->cur_page));
+ G_OBJECT_TYPE_NAME (current));
aux_info = g_list_append (aux_info, aux);
}
@@ -589,7 +594,7 @@ gimp_color_editor_tab_toggled (GtkWidget *widget,
GtkWidget *notebook;
gint page_num;
- notebook = GIMP_COLOR_NOTEBOOK (editor->notebook)->notebook;
+ notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), selector);
diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c
index de4ac39..410d70b 100644
--- a/libgimpwidgets/gimpcolorbutton.c
+++ b/libgimpwidgets/gimpcolorbutton.c
@@ -1008,12 +1008,15 @@ gimp_color_button_help_func (const gchar *help_id,
{
GimpColorSelection *selection;
GimpColorNotebook *notebook;
+ GimpColorSelector *current;
selection = g_object_get_data (G_OBJECT (help_data), COLOR_SELECTION_KEY);
notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
- help_id = GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->help_id;
+ current = gimp_color_notebook_get_current_selector (notebook);
+
+ help_id = GIMP_COLOR_SELECTOR_GET_CLASS (current)->help_id;
gimp_standard_help_func (help_id, NULL);
}
diff --git a/libgimpwidgets/gimpcolornotebook.c b/libgimpwidgets/gimpcolornotebook.c
index 2e76cd1..5c31fd2 100644
--- a/libgimpwidgets/gimpcolornotebook.c
+++ b/libgimpwidgets/gimpcolornotebook.c
@@ -52,6 +52,21 @@
#define DEFAULT_TAB_ICON_SIZE GTK_ICON_SIZE_BUTTON
+typedef struct _GimpColorNotebookPrivate GimpColorNotebookPrivate;
+
+struct _GimpColorNotebookPrivate
+{
+ GtkWidget *notebook;
+
+ GList *selectors;
+ GimpColorSelector *cur_page;
+};
+
+#define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
+ GIMP_TYPE_COLOR_NOTEBOOK, \
+ GimpColorNotebookPrivate))
+
+
static void gimp_color_notebook_finalize (GObject *object);
static void gimp_color_notebook_style_updated (GtkWidget *widget);
@@ -128,22 +143,25 @@ gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
GTK_TYPE_ICON_SIZE,
DEFAULT_TAB_ICON_SIZE,
G_PARAM_READABLE));
+
+ g_type_class_add_private (object_class, sizeof (GimpColorNotebookPrivate));
}
static void
gimp_color_notebook_init (GimpColorNotebook *notebook)
{
- GType *selector_types;
- guint n_selector_types;
- guint i;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (notebook);
+ GType *selector_types;
+ guint n_selector_types;
+ guint i;
- notebook->notebook = gtk_notebook_new ();
- gtk_box_pack_start (GTK_BOX (notebook), notebook->notebook, TRUE, TRUE, 0);
- gtk_widget_show (notebook->notebook);
+ private->notebook = gtk_notebook_new ();
+ gtk_box_pack_start (GTK_BOX (notebook), private->notebook, TRUE, TRUE, 0);
+ gtk_widget_show (private->notebook);
- gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook->notebook));
+ gtk_notebook_popup_enable (GTK_NOTEBOOK (private->notebook));
- g_signal_connect (notebook->notebook, "switch-page",
+ g_signal_connect (private->notebook, "switch-page",
G_CALLBACK (gimp_color_notebook_switch_page),
notebook);
@@ -152,8 +170,8 @@ gimp_color_notebook_init (GimpColorNotebook *notebook)
if (n_selector_types == 2)
{
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook->notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook->notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (private->notebook), FALSE);
}
for (i = 0; i < n_selector_types; i++)
@@ -175,12 +193,12 @@ gimp_color_notebook_init (GimpColorNotebook *notebook)
static void
gimp_color_notebook_finalize (GObject *object)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (object);
+ GimpColorNotebookPrivate *private = GET_PRIVATE (object);
- if (notebook->selectors)
+ if (private->selectors)
{
- g_list_free (notebook->selectors);
- notebook->selectors = NULL;
+ g_list_free (private->selectors);
+ private->selectors = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -189,10 +207,10 @@ gimp_color_notebook_finalize (GObject *object)
static void
gimp_color_notebook_style_updated (GtkWidget *widget)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (widget);
- GList *list;
- gint tab_border;
- GtkIconSize icon_size;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (widget);
+ GList *list;
+ gint tab_border;
+ GtkIconSize icon_size;
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
@@ -201,11 +219,11 @@ gimp_color_notebook_style_updated (GtkWidget *widget)
"tab-icon_size", &icon_size,
NULL);
- g_object_set (notebook->notebook,
+ g_object_set (private->notebook,
"tab-border", tab_border,
NULL);
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelectorClass *selector_class;
GtkWidget *image;
@@ -214,7 +232,7 @@ gimp_color_notebook_style_updated (GtkWidget *widget)
image = gtk_image_new_from_stock (selector_class->stock_id, icon_size);
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook->notebook),
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (private->notebook),
GTK_WIDGET (list->data),
image);
}
@@ -224,10 +242,10 @@ static void
gimp_color_notebook_togg_visible (GimpColorSelector *selector,
gboolean visible)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
- GList *list;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
+ GList *list;
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelector *child = list->data;
@@ -239,10 +257,10 @@ static void
gimp_color_notebook_togg_sensitive (GimpColorSelector *selector,
gboolean sensitive)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
- GList *list;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
+ GList *list;
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelector *child = list->data;
@@ -254,10 +272,10 @@ static void
gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
gboolean show_alpha)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
- GList *list;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
+ GList *list;
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelector *child = list->data;
@@ -270,44 +288,44 @@ gimp_color_notebook_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
- g_signal_handlers_block_by_func (notebook->cur_page,
+ g_signal_handlers_block_by_func (private->cur_page,
gimp_color_notebook_color_changed,
- notebook);
+ selector);
- gimp_color_selector_set_color (notebook->cur_page, rgb, hsv);
+ gimp_color_selector_set_color (private->cur_page, rgb, hsv);
- g_signal_handlers_unblock_by_func (notebook->cur_page,
+ g_signal_handlers_unblock_by_func (private->cur_page,
gimp_color_notebook_color_changed,
- notebook);
+ selector);
}
static void
gimp_color_notebook_set_channel (GimpColorSelector *selector,
GimpColorSelectorChannel channel)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
- g_signal_handlers_block_by_func (notebook->cur_page,
+ g_signal_handlers_block_by_func (private->cur_page,
gimp_color_notebook_channel_changed,
- notebook);
+ selector);
- gimp_color_selector_set_channel (notebook->cur_page, channel);
+ gimp_color_selector_set_channel (private->cur_page, channel);
- g_signal_handlers_unblock_by_func (notebook->cur_page,
+ g_signal_handlers_unblock_by_func (private->cur_page,
gimp_color_notebook_channel_changed,
- notebook);
+ selector);
}
static void
gimp_color_notebook_set_config (GimpColorSelector *selector,
GimpColorConfig *config)
{
- GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
- GList *list;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
+ GList *list;
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelector *child = list->data;
@@ -321,30 +339,31 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
guint page_num,
GimpColorNotebook *notebook)
{
- GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
- GtkWidget *page_widget;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (notebook);
+ GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
+ GtkWidget *page_widget;
page_widget = gtk_notebook_get_nth_page (gtk_notebook, page_num);
- notebook->cur_page = GIMP_COLOR_SELECTOR (page_widget);
+ private->cur_page = GIMP_COLOR_SELECTOR (page_widget);
- g_signal_handlers_block_by_func (notebook->cur_page,
+ g_signal_handlers_block_by_func (private->cur_page,
gimp_color_notebook_color_changed,
notebook);
- g_signal_handlers_block_by_func (notebook->cur_page,
+ g_signal_handlers_block_by_func (private->cur_page,
gimp_color_notebook_channel_changed,
notebook);
- gimp_color_selector_set_color (notebook->cur_page,
+ gimp_color_selector_set_color (private->cur_page,
&selector->rgb,
&selector->hsv);
- gimp_color_selector_set_channel (notebook->cur_page,
+ gimp_color_selector_set_channel (private->cur_page,
selector->channel);
- g_signal_handlers_unblock_by_func (notebook->cur_page,
+ g_signal_handlers_unblock_by_func (private->cur_page,
gimp_color_notebook_color_changed,
notebook);
- g_signal_handlers_unblock_by_func (notebook->cur_page,
+ g_signal_handlers_unblock_by_func (private->cur_page,
gimp_color_notebook_channel_changed,
notebook);
}
@@ -379,12 +398,13 @@ static GtkWidget *
gimp_color_notebook_add_page (GimpColorNotebook *notebook,
GType page_type)
{
- GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
- GimpColorSelectorClass *selector_class;
- GtkWidget *page;
- GtkWidget *menu_widget;
- GtkWidget *image;
- GtkWidget *label;
+ GimpColorNotebookPrivate *private = GET_PRIVATE (notebook);
+ GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
+ GimpColorSelectorClass *selector_class;
+ GtkWidget *page;
+ GtkWidget *menu_widget;
+ GtkWidget *image;
+ GtkWidget *label;
page = gimp_color_selector_new (page_type,
&selector->rgb,
@@ -413,13 +433,13 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
image = gtk_image_new_from_stock (selector_class->stock_id,
DEFAULT_TAB_ICON_SIZE);
- gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook->notebook),
+ gtk_notebook_append_page_menu (GTK_NOTEBOOK (private->notebook),
page, image, menu_widget);
- if (! notebook->cur_page)
- notebook->cur_page = GIMP_COLOR_SELECTOR (page);
+ if (! private->cur_page)
+ private->cur_page = GIMP_COLOR_SELECTOR (page);
- notebook->selectors = g_list_append (notebook->selectors, page);
+ private->selectors = g_list_append (private->selectors, page);
gtk_widget_show (page);
@@ -451,8 +471,9 @@ gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
GType page_type,
gboolean has_page)
{
- GimpColorSelector *selector;
- GList *list;
+ GimpColorNotebookPrivate *private;
+ GimpColorSelector *selector;
+ GList *list;
g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
g_return_val_if_fail (g_type_is_a (page_type, GIMP_TYPE_COLOR_SELECTOR),
@@ -460,9 +481,10 @@ gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
g_return_val_if_fail (! g_type_is_a (page_type, GIMP_TYPE_COLOR_NOTEBOOK),
NULL);
+ private = GET_PRIVATE (notebook);
selector = GIMP_COLOR_SELECTOR (notebook);
- for (list = notebook->selectors; list; list = g_list_next (list))
+ for (list = private->selectors; list; list = g_list_next (list))
{
GimpColorSelector *page = list->data;
@@ -471,12 +493,12 @@ gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
if (has_page)
return GTK_WIDGET (page);
- gtk_container_remove (GTK_CONTAINER (notebook->notebook),
+ gtk_container_remove (GTK_CONTAINER (private->notebook),
GTK_WIDGET (page));
- notebook->selectors = g_list_remove (notebook->selectors, page);
+ private->selectors = g_list_remove (private->selectors, page);
- if (! notebook->selectors)
- notebook->cur_page = NULL;
+ if (! private->selectors)
+ private->cur_page = NULL;
return NULL;
}
@@ -487,3 +509,51 @@ gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
return gimp_color_notebook_add_page (notebook, page_type);
}
+
+/**
+ * gimp_color_notebook_get_notebook:
+ * @notebook: A #GimpColorNotebook widget.
+ *
+ * Return value: The #GtkNotebook inside.
+ *
+ * Since: GIMP 3.0
+ **/
+GtkWidget *
+gimp_color_notebook_get_notebook (GimpColorNotebook *notebook)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
+
+ return GET_PRIVATE (notebook)->notebook;
+}
+
+/**
+ * gimp_color_notebook_get_selectors:
+ * @notebook: A #GimpColorNotebook widget.
+ *
+ * Return value: The notebook's list of #GimpColorSelector's.
+ *
+ * Since: GIMP 3.0
+ **/
+GList *
+gimp_color_notebook_get_selectors (GimpColorNotebook *notebook)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
+
+ return GET_PRIVATE (notebook)->selectors;
+}
+
+/**
+ * gimp_color_notebook_get_current_selector:
+ * @notebook: A #GimpColorNotebook widget.
+ *
+ * Return value: The active page's #GimpColorSelector.
+ *
+ * Since: GIMP 3.0
+ **/
+GimpColorSelector *
+gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
+
+ return GET_PRIVATE (notebook)->cur_page;
+}
diff --git a/libgimpwidgets/gimpcolornotebook.h b/libgimpwidgets/gimpcolornotebook.h
index a48fa22..9295eeb 100644
--- a/libgimpwidgets/gimpcolornotebook.h
+++ b/libgimpwidgets/gimpcolornotebook.h
@@ -43,11 +43,6 @@ typedef struct _GimpColorNotebookClass GimpColorNotebookClass;
struct _GimpColorNotebook
{
GimpColorSelector parent_instance;
-
- GtkWidget *notebook;
-
- GList *selectors;
- GimpColorSelector *cur_page;
};
struct _GimpColorNotebookClass
@@ -62,11 +57,15 @@ struct _GimpColorNotebookClass
};
-GType gimp_color_notebook_get_type (void) G_GNUC_CONST;
+GType gimp_color_notebook_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
+ GType page_type,
+ gboolean has_page);
-GtkWidget * gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
- GType page_type,
- gboolean has_page);
+GtkWidget * gimp_color_notebook_get_notebook (GimpColorNotebook *notebook);
+GList * gimp_color_notebook_get_selectors (GimpColorNotebook *notebook);
+GimpColorSelector * gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook);
G_END_DECLS
diff --git a/libgimpwidgets/gimpcolorselection.c b/libgimpwidgets/gimpcolorselection.c
index 876ad4c..1308a46 100644
--- a/libgimpwidgets/gimpcolorselection.c
+++ b/libgimpwidgets/gimpcolorselection.c
@@ -202,7 +202,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
g_signal_connect (selection->notebook, "color-changed",
G_CALLBACK (gimp_color_selection_notebook_changed),
selection);
- g_signal_connect (GIMP_COLOR_NOTEBOOK (selection->notebook)->notebook,
+ g_signal_connect (gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (selection->notebook)),
"switch-page",
G_CALLBACK (gimp_color_selection_switch_page),
selection);
@@ -547,10 +547,12 @@ gimp_color_selection_switch_page (GtkWidget *widget,
GimpColorSelection *selection)
{
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selection->notebook);
+ GimpColorSelector *current;
gboolean sensitive;
- sensitive =
- (GIMP_COLOR_SELECTOR_GET_CLASS (notebook->cur_page)->set_channel != NULL);
+ current = gimp_color_notebook_get_current_selector (notebook);
+
+ sensitive = (GIMP_COLOR_SELECTOR_GET_CLASS (current)->set_channel != NULL);
gimp_color_selector_set_toggles_sensitive
(GIMP_COLOR_SELECTOR (selection->scales), sensitive);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]