libgimpwidgets/Makefile.am new files. Moved gimp_widgets_init() here and

2003-05-23  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/Makefile.am
	* libgimpwidgets/gimpwidgets-private.[ch]: new files. Moved
	gimp_widgets_init() here and added a vtable parameter. The vtable
	has entries for all the symbols that are either provided by libgimp
	or gimp itself depending on who is using the library.

	* libgimpwidgets/libgimp-glue.c: removed this file that uses to
	provide a Win32 only hack that is now not needed any longer.

	* libgimpwidgets/gimpcolorbutton.c
	* libgimpwidgets/gimphelpui.c
	* libgimpwidgets/gimpsizeentry.c
	* libgimpwidgets/gimpunitmenu.c
	* libgimpwidgets/gimpwidgets.[ch]: don't call the offending
	functions directly, but use the vtable entries. This is ugly but
	the ugliness is restricted to our code. There are plans to clean
	this up further... (Fixes #113410 once more.)

	* app/gui/gui.c (gui_libs_init)
	* libgimp/gimpui.c (gimp_ui_init): initialize libgimpwidgets with
	the proper vtable.
This commit is contained in:
Sven Neumann 2003-05-23 18:27:05 +00:00 committed by Sven Neumann
parent 31ad051308
commit 62dffea661
18 changed files with 1163 additions and 964 deletions

View File

@ -1,3 +1,27 @@
2003-05-23 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am
* libgimpwidgets/gimpwidgets-private.[ch]: new files. Moved
gimp_widgets_init() here and added a vtable parameter. The vtable
has entries for all the symbols that are either provided by libgimp
or gimp itself depending on who is using the library.
* libgimpwidgets/libgimp-glue.c: removed this file that uses to
provide a Win32 only hack that is now not needed any longer.
* libgimpwidgets/gimpcolorbutton.c
* libgimpwidgets/gimphelpui.c
* libgimpwidgets/gimpsizeentry.c
* libgimpwidgets/gimpunitmenu.c
* libgimpwidgets/gimpwidgets.[ch]: don't call the offending
functions directly, but use the vtable entries. This is ugly but
the ugliness is restricted to our code. There are plans to clean
this up further... (Fixes #113410 once more.)
* app/gui/gui.c (gui_libs_init)
* libgimp/gimpui.c (gimp_ui_init): initialize libgimpwidgets with
the proper vtable.
2003-05-23 Raphael Quinet <quinet@gamers.org>
* plug-ins/imagemap/Makefile.am: added rules for rebuilding the

View File

@ -25,6 +25,7 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "libgimpwidgets/gimpwidgets-private.h"
#include "gui-types.h"
@ -97,6 +98,10 @@ 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 */
@ -104,13 +109,31 @@ gboolean
gui_libs_init (gint *argc,
gchar ***argv)
{
GimpWidgetsVTable vtable;
g_return_val_if_fail (argc != NULL, FALSE);
g_return_val_if_fail (argv != NULL, FALSE);
if (!gtk_init_check (argc, argv))
return FALSE;
gimp_widgets_init ();
/* Initialize the eeky vtable needed by libgimpwidgets */
vtable.standard_help_func = gimp_standard_help_func;
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;
vtable.unit_get_digits = gimp_unit_get_digits;
vtable.unit_get_identifier = gimp_unit_get_identifier;
vtable.unit_get_symbol = gimp_unit_get_symbol;
vtable.unit_get_abbreviation = gimp_unit_get_abbreviation;
vtable.unit_get_singular = gimp_unit_get_singular;
vtable.unit_get_plural = gimp_unit_get_plural;
gimp_widgets_init (&vtable);
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);

View File

@ -1,3 +1,11 @@
2003-05-23 Sven Neumann <sven@gimp.org>
* libgimpwidgets/Makefile.am: ignore libgimpwidgets-private.h
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/tmpl/gimpwidgets.sgml: removed docs for
gimp_widgets_init().
2003-05-20 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-sections.txt

View File

@ -26,8 +26,8 @@ HFILE_GLOB = $(DOC_SOURCE_DIR)/*.h
CFILE_GLOB = $(DOC_SOURCE_DIR)/*.c
# Header files to ignore when scanning
IGNORE_HFILES =
IGNORE_HFILES = \
gimpwidgets-private.h
# Images to copy into HTML directory
IMAGES_DIR = $(top_srcdir)/themes/Default/images

View File

@ -414,7 +414,6 @@ GIMP_STOCK_WILBER_EEK
<SECTION>
<FILE>gimpwidgets</FILE>
<TITLE>GimpWidgets</TITLE>
gimp_widgets_init
gimp_option_menu_new
gimp_option_menu_new2
gimp_option_menu_set_history

View File

@ -15,13 +15,6 @@ helper functions.
</para>
<!-- ##### FUNCTION gimp_widgets_init ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_option_menu_new ##### -->
<para>

View File

@ -23,6 +23,7 @@
#include "gimpui.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "libgimpwidgets/gimpwidgets-private.h"
/**
* gimp_ui_init:
@ -45,12 +46,14 @@ void
gimp_ui_init (const gchar *prog_name,
gboolean preview)
{
static gboolean initialized = FALSE;
GimpWidgetsVTable vtable;
gint argc;
gchar **argv;
gchar *user_gtkrc;
static gboolean initialized = FALSE;
g_return_if_fail (prog_name != NULL);
if (initialized)
@ -78,7 +81,21 @@ gimp_ui_init (const gchar *prog_name,
if (preview)
gtk_preview_set_gamma (gimp_gamma ());
gimp_widgets_init ();
/* Initialize the eeky vtable needed by libgimpwidgets */
vtable.standard_help_func = gimp_standard_help_func;
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;
vtable.unit_get_digits = gimp_unit_get_digits;
vtable.unit_get_identifier = gimp_unit_get_identifier;
vtable.unit_get_symbol = gimp_unit_get_symbol;
vtable.unit_get_abbreviation = gimp_unit_get_abbreviation;
vtable.unit_get_singular = gimp_unit_get_singular;
vtable.unit_get_plural = gimp_unit_get_plural;
gimp_widgets_init (&vtable);
if (! gimp_show_tool_tips ())
gimp_help_disable_tooltips ();

View File

@ -105,7 +105,8 @@ libgimpwidgets_1_3_la_sources = \
gimpstock.h \
gimpunitmenu.c \
gimpunitmenu.h \
libgimp-glue.c
gimpwidgets-private.c \
gimpwidgets-private.h
libgimpwidgets_1_3_la_built_sources = \
gimpwidgetsmarshal.c \

View File

@ -30,8 +30,7 @@
#include "gimpcolorarea.h"
#include "gimpcolorbutton.h"
#include "libgimp/gimppalette_pdb.h"
#include "gimpwidgets-private.h"
#include "libgimp/libgimp-intl.h"
@ -465,10 +464,10 @@ gimp_color_button_use_color (gpointer callback_data,
switch (type)
{
case GIMP_COLOR_BUTTON_COLOR_FG:
gimp_palette_get_foreground (&color);
_gimp_eek.palette_get_foreground (&color);
break;
case GIMP_COLOR_BUTTON_COLOR_BG:
gimp_palette_get_background (&color);
_gimp_eek.palette_get_background (&color);
break;
case GIMP_COLOR_BUTTON_COLOR_BLACK:
gimp_rgb_set (&color, 0.0, 0.0, 0.0);

View File

@ -39,6 +39,7 @@
#include "gimpdialog.h"
#include "gimphelpui.h"
#include "gimpwidgets-private.h"
typedef enum
@ -335,13 +336,13 @@ gimp_help_tips_query_idle_show_help (gpointer data)
gchar *help_text;
help_text = g_strconcat (help_data, help_index, NULL);
gimp_standard_help_func (help_text);
_gimp_eek.standard_help_func (help_text);
g_free (help_text);
}
}
else
{
gimp_standard_help_func (help_data);
_gimp_eek.standard_help_func (help_data);
}
}

View File

@ -31,11 +31,12 @@
#include "gimpsizeentry.h"
#include "gimpunitmenu.h"
#include "gimpwidgets-private.h"
#define SIZE_MAX_VALUE 500000.0
#define GIMP_SIZE_ENTRY_DIGITS(unit) (MIN (gimp_unit_get_digits (unit), 5) + 1)
#define GIMP_SIZE_ENTRY_DIGITS(unit) (MIN (_gimp_eek.unit_get_digits (unit), 5) + 1)
enum
@ -658,19 +659,19 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_value *
gsef->resolution /
gimp_unit_get_factor (gse->unit),
_gimp_eek.unit_get_factor (gse->unit),
gsef->max_value *
gsef->resolution /
gimp_unit_get_factor (gse->unit));
_gimp_eek.unit_get_factor (gse->unit));
break;
}
break;
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gimp_size_entry_set_refval_boundaries (gse, field,
gsef->min_value *
gimp_unit_get_factor (gse->unit),
_gimp_eek.unit_get_factor (gse->unit),
gsef->max_value *
gimp_unit_get_factor (gse->unit));
_gimp_eek.unit_get_factor (gse->unit));
break;
default:
break;
@ -738,7 +739,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
default:
gsef->refval =
CLAMP (value * gsef->resolution /
gimp_unit_get_factor (gsef->gse->unit),
_gimp_eek.unit_get_factor (gsef->gse->unit),
gsef->min_refval, gsef->max_refval);
break;
}
@ -748,7 +749,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
break;
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gsef->refval =
CLAMP (value * gimp_unit_get_factor (gsef->gse->unit),
CLAMP (value * _gimp_eek.unit_get_factor (gsef->gse->unit),
gsef->min_refval, gsef->max_refval);
if (gsef->gse->show_refval)
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->refval_adjustment),
@ -880,10 +881,10 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
default:
gimp_size_entry_set_value_boundaries (gse, field,
gsef->min_refval *
gimp_unit_get_factor(gse->unit) /
_gimp_eek.unit_get_factor (gse->unit) /
gsef->resolution,
gsef->max_refval *
gimp_unit_get_factor(gse->unit) /
_gimp_eek.unit_get_factor (gse->unit) /
gsef->resolution);
break;
}
@ -891,9 +892,9 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gimp_size_entry_set_value_boundaries (gse, field,
gsef->min_refval /
gimp_unit_get_factor (gse->unit),
_gimp_eek.unit_get_factor (gse->unit),
gsef->max_refval /
gimp_unit_get_factor (gse->unit));
_gimp_eek.unit_get_factor (gse->unit));
break;
default:
@ -997,7 +998,7 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
break;
default:
gsef->value =
CLAMP (refval * gimp_unit_get_factor (gsef->gse->unit) /
CLAMP (refval * _gimp_eek.unit_get_factor (gsef->gse->unit) /
gsef->resolution,
gsef->min_value, gsef->max_value);
break;
@ -1007,7 +1008,7 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
break;
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
gsef->value =
CLAMP (refval / gimp_unit_get_factor (gsef->gse->unit),
CLAMP (refval / _gimp_eek.unit_get_factor (gsef->gse->unit),
gsef->min_value, gsef->max_value);
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment),
gsef->value);
@ -1118,7 +1119,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
else if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION)
{
digits =
-(gimp_unit_get_digits (unit) - gimp_unit_get_digits (GIMP_UNIT_INCH));
-(_gimp_eek.unit_get_digits (unit) - _gimp_eek.unit_get_digits (GIMP_UNIT_INCH));
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
MAX (3 + digits, 3));
}

View File

@ -31,6 +31,7 @@
#include "gimpdialog.h"
#include "gimphelpui.h"
#include "gimpunitmenu.h"
#include "gimpwidgets-private.h"
#include "libgimp/libgimp-intl.h"
@ -177,10 +178,10 @@ gimp_unit_menu_new (const gchar *format,
GimpUnit u;
g_return_val_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
(unit < gimp_unit_get_number_of_units ())) ||
(unit < _gimp_eek.unit_get_number_of_units ())) ||
(unit == GIMP_UNIT_PERCENT), NULL);
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
if ((unit >= _gimp_eek.unit_get_number_of_built_in_units ()) &&
(unit != GIMP_UNIT_PERCENT))
show_custom = TRUE;
@ -192,7 +193,7 @@ gimp_unit_menu_new (const gchar *format,
menu = gtk_menu_new ();
for (u = show_pixels ? GIMP_UNIT_PIXEL : GIMP_UNIT_INCH;
u < gimp_unit_get_number_of_built_in_units ();
u < _gimp_eek.unit_get_number_of_built_in_units ();
u++)
{
/* special cases "pixels" and "percent" */
@ -234,7 +235,7 @@ gimp_unit_menu_new (const gchar *format,
unit_menu);
}
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
if ((unit >= _gimp_eek.unit_get_number_of_built_in_units ()) &&
(unit != GIMP_UNIT_PERCENT))
{
menuitem = gtk_menu_item_new ();
@ -307,7 +308,7 @@ gimp_unit_menu_set_unit (GimpUnitMenu *menu,
g_return_if_fail (GIMP_IS_UNIT_MENU (menu));
g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
((unit > GIMP_UNIT_PIXEL) || menu->show_pixels) &&
(unit < gimp_unit_get_number_of_units ())) ||
(unit < _gimp_eek.unit_get_number_of_units ())) ||
((unit == GIMP_UNIT_PERCENT) && menu->show_percent));
if (unit == menu->unit)
@ -428,27 +429,27 @@ gimp_unit_menu_build_string (const gchar *format,
case 'f': /* factor (how many units make up an inch) */
i += print (buffer, sizeof (buffer), i, "%f",
gimp_unit_get_factor (unit));
_gimp_eek.unit_get_factor (unit));
break;
case 'y': /* symbol ("''" for inch) */
i += print (buffer, sizeof (buffer), i, "%s",
gimp_unit_get_symbol (unit));
_gimp_eek.unit_get_symbol (unit));
break;
case 'a': /* abbreviation */
i += print (buffer, sizeof (buffer), i, "%s",
gimp_unit_get_abbreviation (unit));
_gimp_eek.unit_get_abbreviation (unit));
break;
case 's': /* singular */
i += print (buffer, sizeof (buffer), i, "%s",
gimp_unit_get_singular (unit));
_gimp_eek.unit_get_singular (unit));
break;
case 'p': /* plural */
i += print (buffer, sizeof (buffer), i, "%s",
gimp_unit_get_plural (unit));
_gimp_eek.unit_get_plural (unit));
break;
default:
@ -524,7 +525,8 @@ gimp_unit_menu_create_selection (GimpUnitMenu *menu)
menu->selection =
gimp_dialog_new (_("Unit Selection"), "unit_selection",
gimp_standard_help_func, "dialogs/unit_selection.html",
_gimp_eek.standard_help_func,
"dialogs/unit_selection.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
@ -577,7 +579,7 @@ gimp_unit_menu_create_selection (GimpUnitMenu *menu)
"text", FACTOR_COLUMN, NULL);
/* the unit lines */
num_units = gimp_unit_get_number_of_units ();
num_units = _gimp_eek.unit_get_number_of_units ();
for (unit = GIMP_UNIT_END; unit < num_units; unit++)
{
gtk_list_store_append (list, &iter);

View File

@ -0,0 +1,86 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpwidgets-private.c
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "gimpwidgetstypes.h"
#include "gimphelpui.h"
#include "gimpstock.h"
#include "gimpwidgets-private.h"
#include "themes/Default/images/gimp-wilber-pixbufs.h"
GimpWidgetsVTable _gimp_eek;
void
gimp_widgets_init (GimpWidgetsVTable *vtable)
{
static gboolean gimp_widgets_initialized = FALSE;
GdkPixbuf *pixbuf;
GList *icon_list = NULL;
gint i;
const guint8 *inline_pixbufs[] =
{
stock_wilber_16,
stock_wilber_32,
stock_wilber_48,
stock_wilber_64
};
g_return_if_fail (vtable != NULL);
if (gimp_widgets_initialized)
{
g_error ("gimp_widgets_init() must only be called once!");
return;
}
_gimp_eek = *vtable;
gimp_stock_init ();
for (i = 0; i < G_N_ELEMENTS (inline_pixbufs); i++)
{
pixbuf = gdk_pixbuf_new_from_inline (-1, inline_pixbufs[i], FALSE, NULL);
icon_list = g_list_prepend (icon_list, pixbuf);
}
gtk_window_set_default_icon_list (icon_list);
g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
g_list_free (icon_list);
_gimp_help_init ();
gimp_widgets_initialized = TRUE;
}

View File

@ -0,0 +1,63 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpwidgets-private.h
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_WIDGETS_PRIVATE_H__
#define __GIMP_WIDGETS_PRIVATE_H__
typedef struct _GimpWidgetsVTable GimpWidgetsVTable;
struct _GimpWidgetsVTable
{
void (* standard_help_func) (const gchar *help_data);
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);
gint (* unit_get_digits) (GimpUnit unit);
const gchar * (* unit_get_identifier) (GimpUnit unit);
const gchar * (* unit_get_symbol) (GimpUnit unit);
const gchar * (* unit_get_abbreviation) (GimpUnit unit);
const gchar * (* unit_get_singular) (GimpUnit unit);
const gchar * (* unit_get_plural) (GimpUnit unit);
void (* _reserved_1) (void);
void (* _reserved_2) (void);
void (* _reserved_3) (void);
void (* _reserved_4) (void);
};
extern GimpWidgetsVTable _gimp_eek;
G_BEGIN_DECLS
void gimp_widgets_init (GimpWidgetsVTable *vtable);
G_END_DECLS
#endif /* __GIMP_WIDGETS_PRIVATE_H__ */

View File

@ -33,49 +33,15 @@
#include "gimpwidgetstypes.h"
#include "gimpchainbutton.h"
#include "gimphelpui.h"
#include "gimppixmap.h"
#include "gimpsizeentry.h"
#include "gimpunitmenu.h"
#include "gimpwidgets.h"
#include "themes/Default/images/gimp-wilber-pixbufs.h"
#include "gimpwidgets-private.h"
#include "libgimp/libgimp-intl.h"
void
gimp_widgets_init (void)
{
GdkPixbuf *pixbuf;
GList *icon_list = NULL;
gint i;
const guint8 *inline_pixbufs[] =
{
stock_wilber_16,
stock_wilber_32,
stock_wilber_48,
stock_wilber_64
};
gimp_stock_init ();
for (i = 0; i < G_N_ELEMENTS (inline_pixbufs); i++)
{
pixbuf = gdk_pixbuf_new_from_inline (-1, inline_pixbufs[i], FALSE, NULL);
icon_list = g_list_prepend (icon_list, pixbuf);
}
gtk_window_set_default_icon_list (icon_list);
g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
g_list_free (icon_list);
_gimp_help_init ();
}
/*
* Widget Constructors
*/
@ -1480,7 +1446,7 @@ gimp_unit_menu_update (GtkWidget *widget,
digits = ((*val == GIMP_UNIT_PIXEL) ? 0 :
((*val == GIMP_UNIT_PERCENT) ? 2 :
(MIN (6, MAX (3, gimp_unit_get_digits (*val))))));
(MIN (6, MAX (3, _gimp_eek.unit_get_digits (*val))))));
spinbutton = g_object_get_data (G_OBJECT (widget), "set_digits");
while (spinbutton)

View File

@ -55,9 +55,6 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
void gimp_widgets_init (void);
/*
* Widget Constructors
*/

View File

@ -1,134 +0,0 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* libgimp-glue.c
* Copyright (C) 2001 Hans Breuer <Hans@Breuer.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Supports dynamic linking at run-time against
* libgimp (if used by a plug-in, or gimp.exe
* if used by gimp.exe itself)
*
gimp_palette_get_background
gimp_palette_get_foreground
gimp_standard_help_func
gimp_unit_get_abbreviation
gimp_unit_get_digits
gimp_unit_get_factor
gimp_unit_get_number_of_built_in_units
gimp_unit_get_number_of_units
gimp_unit_get_plural
gimp_unit_get_singular
gimp_unit_get_symbol
*/
#include <glib.h>
#ifdef G_OS_WIN32 /* Bypass whole file otherwise */
#include "libgimpcolor/gimpcolortypes.h"
#include "libgimpbase/gimpbasetypes.h"
#include "libgimpbase/gimpunit.h"
#include "libgimp/gimppalette_pdb.h"
/*
too much depencencies
#include "gimphelpui.h"
*/
#include <windows.h>
typedef int voidish;
/* function pointer prototypes */
typedef gboolean (* PFN_QueryColor) (GimpRGB *color);
typedef gchar* (* PFN_GetUnitStr) (GimpUnit);
typedef gdouble (* PFN_GetUnitInt) (GimpUnit);
typedef gdouble (* PFN_GetUnitDouble) (GimpUnit);
typedef gint (* PFN_GetNumber) (void);
typedef voidish (* PFN_Help) (const char*);
static FARPROC
dynamic_resolve (const gchar* name, HMODULE* hMod)
{
FARPROC fn = NULL;
*hMod = NULL; /* if != NULL, call FreeLibrary */
/* from application ? */
fn = GetProcAddress(GetModuleHandle(NULL), name);
if (!fn)
{
#if defined (LT_RELEASE) && defined (LT_CURRENT_MINUS_AGE)
/* First try the libtool style name */
*hMod = LoadLibrary ("libgimp-" LT_RELEASE "-" LT_CURRENT_MINUS_AGE ".dll");
#endif
/* If that didn't work, try the name style used by Hans Breuer */
if (!*hMod)
*hMod = LoadLibrary ("gimp-1.3.dll");
fn = GetProcAddress (*hMod, name);
}
if (!fn)
g_warning ("dynamic_resolve of %s failed!", name);
return fn;
}
#define ENTRY(type, name, parlist, defaultval, fntype, arglist) \
type \
name parlist \
{ \
HMODULE h = NULL; \
type ret = defaultval; \
fntype fn = (fntype) dynamic_resolve (#name, &h); \
if (fn) \
ret = fn arglist; \
\
if (h) \
FreeLibrary (h); \
return ret; \
}
ENTRY (gboolean, gimp_palette_get_foreground, (GimpRGB *color), FALSE, PFN_QueryColor, (color));
ENTRY (gboolean, gimp_palette_get_background, (GimpRGB *color), FALSE, PFN_QueryColor, (color));
ENTRY (voidish, gimp_standard_help_func, (const gchar *help_data), 0, PFN_Help, (help_data));
ENTRY (const gchar *, gimp_unit_get_abbreviation, (GimpUnit unit), NULL, PFN_GetUnitStr, (unit));
ENTRY (const gchar *, gimp_unit_get_singular, (GimpUnit unit), NULL, PFN_GetUnitStr, (unit));
ENTRY (const gchar *, gimp_unit_get_plural, (GimpUnit unit), NULL, PFN_GetUnitStr, (unit));
ENTRY (gint, gimp_unit_get_digits, (GimpUnit unit), 0, PFN_GetUnitInt, (unit));
ENTRY (gdouble, gimp_unit_get_factor, (GimpUnit unit), 0., PFN_GetUnitDouble, (unit));
ENTRY (gint, gimp_unit_get_number_of_built_in_units, (void), 0, PFN_GetNumber, ());
ENTRY (gint, gimp_unit_get_number_of_units, (void), 0, PFN_GetNumber, ());
ENTRY (const gchar *, gimp_unit_get_symbol, (GimpUnit unit), NULL, PFN_GetUnitStr, (unit));
#endif /* G_OS_WIN32 */

File diff suppressed because it is too large Load Diff