From ac2b6c870250c445e817bddeb66fb68335f42787 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 25 May 2003 14:23:43 +0000 Subject: [PATCH] changed again to take no paramaters and use _gimp_standard_help_func from 2003-05-25 Michael Natterer * libgimpwidgets/gimphelpui.[ch] (_gimp_help_init): changed again to take no paramaters and use _gimp_standard_help_func from gimpwidgets-private. * libgimpwidgets/gimpwidgets-private.[ch]: removed the palette functions from GimpWidgetVTable. Instead, pass them as GimpGetColorFunc to gimp_widgets_init() and make them available as _gimp_get_foreground_func and _gimp_get_background_func. * libgimpwidgets/gimpcolorbutton.c * libgimp/gimpui.c: changed accordingly. * app/libgimp_glue.[ch]: removed the palette functions. * app/gui/gui.c: added gui_get_foreground_func() and gui_get_background_func() and pass them to gimp_widgets_init(). --- ChangeLog | 19 +++++++++++ app/gui/gui.c | 34 ++++++++++++++----- app/libgimp_glue.c | 49 ++-------------------------- app/libgimp_glue.h | 5 --- libgimp/gimpui.c | 7 ++-- libgimpwidgets/gimpcolorbutton.c | 11 ++++--- libgimpwidgets/gimphelpui.c | 25 +++++++------- libgimpwidgets/gimphelpui.h | 2 +- libgimpwidgets/gimpwidgets-private.c | 16 ++++++--- libgimpwidgets/gimpwidgets-private.h | 14 +++++--- 10 files changed, 92 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9a123893a..598dcd288f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-05-25 Michael Natterer + + * libgimpwidgets/gimphelpui.[ch] (_gimp_help_init): changed again + to take no paramaters and use _gimp_standard_help_func from + gimpwidgets-private. + + * libgimpwidgets/gimpwidgets-private.[ch]: removed the palette + functions from GimpWidgetVTable. Instead, pass them as + GimpGetColorFunc to gimp_widgets_init() and make them available as + _gimp_get_foreground_func and _gimp_get_background_func. + + * libgimpwidgets/gimpcolorbutton.c + * libgimp/gimpui.c: changed accordingly. + + * app/libgimp_glue.[ch]: removed the palette functions. + + * app/gui/gui.c: added gui_get_foreground_func() and + gui_get_background_func() and pass them to gimp_widgets_init(). + 2003-05-25 Michael Natterer * libgimpwidgets/gimphelpui.[ch]: added a GimpHelpFunc parameter to diff --git a/app/gui/gui.c b/app/gui/gui.c index c9c40bd997..8f63c69300 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -66,6 +66,8 @@ /* local function prototypes */ static void gui_help_func (const gchar *help_data); +static gboolean gui_get_background_func (GimpRGB *color); +static gboolean gui_get_foreground_func (GimpRGB *color); static void gui_threads_enter (Gimp *gimp); static void gui_threads_leave (Gimp *gimp); @@ -103,10 +105,6 @@ static GHashTable *themes_hash = NULL; static GimpItemFactory *toolbox_item_factory = NULL; static GimpItemFactory *image_item_factory = NULL; -/* forward declarations to avoid inclusion of libgimp-glue.h */ -gboolean gimp_palette_get_background (GimpRGB *color); -gboolean gimp_palette_get_foreground (GimpRGB *color); - /* public functions */ @@ -123,9 +121,6 @@ gui_libs_init (gint *argc, return FALSE; /* Initialize the eeky vtable needed by libgimpwidgets */ - vtable.palette_get_background = gimp_palette_get_background; - vtable.palette_get_foreground = gimp_palette_get_foreground; - vtable.unit_get_number_of_units = gimp_unit_get_number_of_units; vtable.unit_get_number_of_built_in_units = gimp_unit_get_number_of_built_in_units; vtable.unit_get_factor = gimp_unit_get_factor; @@ -136,7 +131,10 @@ gui_libs_init (gint *argc, vtable.unit_get_singular = gimp_unit_get_singular; vtable.unit_get_plural = gimp_unit_get_plural; - gimp_widgets_init (&vtable, gui_help_func); + gimp_widgets_init (&vtable, + gui_help_func, + gui_get_foreground_func, + gui_get_background_func); g_type_class_ref (GIMP_TYPE_COLOR_SELECT); @@ -406,6 +404,26 @@ gui_help_func (const gchar *help_data) gimp_help (the_gimp, NULL, help_data); } +static gboolean +gui_get_foreground_func (GimpRGB *color) +{ + g_return_val_if_fail (color != NULL, FALSE); + + gimp_context_get_foreground (gimp_get_user_context (the_gimp), color); + + return TRUE; +} + +static gboolean +gui_get_background_func (GimpRGB *color) +{ + g_return_val_if_fail (color != NULL, FALSE); + + gimp_context_get_background (gimp_get_user_context (the_gimp), color); + + return TRUE; +} + static void gui_threads_enter (Gimp *gimp) { diff --git a/app/libgimp_glue.c b/app/libgimp_glue.c index 917e0359f7..caa3dc27a4 100644 --- a/app/libgimp_glue.c +++ b/app/libgimp_glue.c @@ -18,14 +18,10 @@ #include "config.h" -#include +#include -#include "libgimpcolor/gimpcolor.h" +#include "core/core-types.h" -#include "widgets/widgets-types.h" - -#include "core/gimp.h" -#include "core/gimpcontext.h" #include "core/gimpunit.h" #include "app_procs.h" @@ -34,47 +30,6 @@ #include "libgimp_glue.h" -gboolean -gimp_palette_set_foreground (const GimpRGB *color) -{ - g_return_val_if_fail (color != NULL, FALSE); - - gimp_context_set_foreground (gimp_get_user_context (the_gimp), color); - - return TRUE; -} - -gboolean -gimp_palette_get_foreground (GimpRGB *color) -{ - g_return_val_if_fail (color != NULL, FALSE); - - gimp_context_get_foreground (gimp_get_user_context (the_gimp), color); - - return TRUE; -} - -gboolean -gimp_palette_set_background (const GimpRGB *color) -{ - g_return_val_if_fail (color != NULL, FALSE); - - gimp_context_set_background (gimp_get_user_context (the_gimp), color); - - return TRUE; -} - -gboolean -gimp_palette_get_background (GimpRGB *color) -{ - g_return_val_if_fail (color != NULL, FALSE); - - gimp_context_get_background (gimp_get_user_context (the_gimp), color); - - return TRUE; -} - - gint gimp_unit_get_number_of_units (void) { diff --git a/app/libgimp_glue.h b/app/libgimp_glue.h index adc76fb149..75586226d8 100644 --- a/app/libgimp_glue.h +++ b/app/libgimp_glue.h @@ -30,11 +30,6 @@ */ -gboolean gimp_palette_set_foreground (const GimpRGB *color); -gboolean gimp_palette_get_foreground (GimpRGB *color); -gboolean gimp_palette_set_background (const GimpRGB *color); -gboolean gimp_palette_get_background (GimpRGB *color); - gint gimp_unit_get_number_of_units (void); gint gimp_unit_get_number_of_built_in_units (void) G_GNUC_CONST; GimpUnit gimp_unit_new (gchar *identifier, diff --git a/libgimp/gimpui.c b/libgimp/gimpui.c index c27e98152e..624f5ffe95 100644 --- a/libgimp/gimpui.c +++ b/libgimp/gimpui.c @@ -90,8 +90,6 @@ gimp_ui_init (const gchar *prog_name, gtk_preview_set_gamma (gimp_gamma ()); /* Initialize the eeky vtable needed by libgimpwidgets */ - vtable.palette_get_background = gimp_palette_get_background; - vtable.palette_get_foreground = gimp_palette_get_foreground; vtable.unit_get_number_of_units = gimp_unit_get_number_of_units; vtable.unit_get_number_of_built_in_units = gimp_unit_get_number_of_built_in_units; vtable.unit_get_factor = gimp_unit_get_factor; @@ -102,7 +100,10 @@ gimp_ui_init (const gchar *prog_name, vtable.unit_get_singular = gimp_unit_get_singular; vtable.unit_get_plural = gimp_unit_get_plural; - gimp_widgets_init (&vtable, gimp_ui_help_func); + gimp_widgets_init (&vtable, + gimp_ui_help_func, + gimp_palette_get_foreground, + gimp_palette_get_background); if (! gimp_show_tool_tips ()) gimp_help_disable_tooltips (); diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c index 94b06948c3..46af96fa71 100644 --- a/libgimpwidgets/gimpcolorbutton.c +++ b/libgimpwidgets/gimpcolorbutton.c @@ -207,9 +207,8 @@ gimp_color_button_destroy (GtkObject *object) gtk_widget_destroy (button->color_area); button->color_area = NULL; } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); + + GTK_OBJECT_CLASS (parent_class)->destroy (object); } static gboolean @@ -464,10 +463,12 @@ gimp_color_button_use_color (gpointer callback_data, switch (type) { case GIMP_COLOR_BUTTON_COLOR_FG: - _gimp_eek.palette_get_foreground (&color); + if (_gimp_get_foreground_func) + _gimp_get_foreground_func (&color); break; case GIMP_COLOR_BUTTON_COLOR_BG: - _gimp_eek.palette_get_background (&color); + if (_gimp_get_background_func) + _gimp_get_background_func (&color); break; case GIMP_COLOR_BUTTON_COLOR_BLACK: gimp_rgb_set (&color, 0.0, 0.0, 0.0); diff --git a/libgimpwidgets/gimphelpui.c b/libgimpwidgets/gimphelpui.c index 9747750b37..bb5eb7ca3b 100644 --- a/libgimpwidgets/gimphelpui.c +++ b/libgimpwidgets/gimphelpui.c @@ -39,6 +39,7 @@ #include "gimpdialog.h" #include "gimphelpui.h" +#include "gimpwidgets-private.h" typedef enum @@ -66,9 +67,8 @@ static gboolean gimp_help_tips_query_idle_start (gpointer tips_query /* local variables */ -static GimpHelpFunc the_help_func = NULL; -static GtkTooltips *tool_tips = NULL; -static GtkWidget *tips_query = NULL; +static GtkTooltips *tool_tips = NULL; +static GtkWidget *tips_query = NULL; /* public functions */ @@ -84,14 +84,13 @@ static GtkWidget *tips_query = NULL; * Nota that this function is called automatically by gimp_widgets_init(). **/ void -_gimp_help_init (GimpHelpFunc standard_help_func) +_gimp_help_init (void) { - g_return_if_fail (standard_help_func != NULL); - - if (the_help_func) - g_error ("_gimp_help_init() must only be called once!"); - - the_help_func = standard_help_func; + if (tool_tips) + { + g_warning ("_gimp_help_init() must only be called once!"); + return; + } tool_tips = gtk_tooltips_new (); @@ -125,14 +124,14 @@ gimp_help_disable_tooltips (void) void gimp_standard_help_func (const gchar *help_data) { - if (! the_help_func) + if (! _gimp_standard_help_func) { - g_warning ("gimp_standard_help_func(): you must call _gimp_help_init() " + g_warning ("gimp_standard_help_func(): you must call gimp_widgets_init() " "before using the help system"); return; } - (* the_help_func) (help_data); + (* _gimp_standard_help_func) (help_data); } /** diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h index 76d1bcd816..f3bf94bd24 100644 --- a/libgimpwidgets/gimphelpui.h +++ b/libgimpwidgets/gimphelpui.h @@ -28,7 +28,7 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -void _gimp_help_init (GimpHelpFunc standard_help_func); +void _gimp_help_init (void); void gimp_help_enable_tooltips (void); void gimp_help_disable_tooltips (void); diff --git a/libgimpwidgets/gimpwidgets-private.c b/libgimpwidgets/gimpwidgets-private.c index e59429a62a..779aae98a9 100644 --- a/libgimpwidgets/gimpwidgets-private.c +++ b/libgimpwidgets/gimpwidgets-private.c @@ -35,12 +35,17 @@ #include "themes/Default/images/gimp-wilber-pixbufs.h" -GimpWidgetsVTable _gimp_eek; +GimpWidgetsVTable _gimp_eek = { NULL, }; +GimpHelpFunc _gimp_standard_help_func = NULL; +GimpGetColorFunc _gimp_get_foreground_func = NULL; +GimpGetColorFunc _gimp_get_background_func = NULL; void gimp_widgets_init (GimpWidgetsVTable *vtable, - GimpHelpFunc standard_help_func) + GimpHelpFunc standard_help_func, + GimpGetColorFunc get_foreground_func, + GimpGetColorFunc get_background_func) { static gboolean gimp_widgets_initialized = FALSE; @@ -62,7 +67,10 @@ gimp_widgets_init (GimpWidgetsVTable *vtable, if (gimp_widgets_initialized) g_error ("gimp_widgets_init() must only be called once!"); - _gimp_eek = *vtable; + _gimp_eek = *vtable; + _gimp_standard_help_func = standard_help_func; + _gimp_get_foreground_func = get_foreground_func; + _gimp_get_background_func = get_background_func; gimp_stock_init (); @@ -77,7 +85,7 @@ gimp_widgets_init (GimpWidgetsVTable *vtable, g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); - _gimp_help_init (standard_help_func); + _gimp_help_init (); gimp_widgets_initialized = TRUE; } diff --git a/libgimpwidgets/gimpwidgets-private.h b/libgimpwidgets/gimpwidgets-private.h index fef4b9aba8..ac975581b6 100644 --- a/libgimpwidgets/gimpwidgets-private.h +++ b/libgimpwidgets/gimpwidgets-private.h @@ -24,13 +24,13 @@ #define __GIMP_WIDGETS_PRIVATE_H__ +typedef gboolean (* GimpGetColorFunc) (GimpRGB *color); + + typedef struct _GimpWidgetsVTable GimpWidgetsVTable; struct _GimpWidgetsVTable { - gboolean (* palette_get_background) (GimpRGB *background); - gboolean (* palette_get_foreground) (GimpRGB *background); - gint (* unit_get_number_of_units) (void); gint (* unit_get_number_of_built_in_units) (void); gdouble (* unit_get_factor) (GimpUnit unit); @@ -47,14 +47,20 @@ struct _GimpWidgetsVTable void (* _reserved_4) (void); }; + extern GimpWidgetsVTable _gimp_eek; +extern GimpHelpFunc _gimp_standard_help_func; +extern GimpGetColorFunc _gimp_get_foreground_func; +extern GimpGetColorFunc _gimp_get_background_func; G_BEGIN_DECLS void gimp_widgets_init (GimpWidgetsVTable *vtable, - GimpHelpFunc standard_help_func); + GimpHelpFunc standard_help_func, + GimpGetColorFunc get_foreground_func, + GimpGetColorFunc get_background_func); G_END_DECLS