libgimpbase/Makefile.am libgimpbase/gimpbase-private.[ch] new files
2003-11-15 Michael Natterer <mitch@gimp.org> * libgimpbase/Makefile.am * libgimpbase/gimpbase-private.[ch] * libgimpbase/gimpunit.c: new files implementing GimpUnitVTable (formerly known as GimpWidgetsVTable). Now the unit functions finally live in the same library as their header declarations. * libgimpbase/gimpunit.h: removed comment about being a header for two different files. * libgimpwidgets/gimpwidgets-private.[ch]: removed GimpWidgetsVTable. * libgimpwidgets/gimpsizeentry.c * libgimpwidgets/gimpunitmenu.c * libgimpwidgets/gimpwidgets.c: use normal gimp_unit functions again. * libgimp/gimpui.c * app/gui/gui.c: removed GimpWidgetVTable stuff. * libgimp/Makefile.am * libgimp/gimpunitcache.[ch]: new files. * libgimp/gimpunit.c: removed (moved to gimpunitcache.c). * libgimp/gimp.c (gimp_main): initialize GimpUnitVTable using the gimp_unit_cache functions. * app/Makefile.am * app/units.[ch]: new files implementing GimpUnitVTable. * app/libgimp_glue.[ch]: removed. * app/app_procs.[ch]: made "the_gimp" a static variable. Call units_init(). * app/main.c: changed accordingly.
This commit is contained in:

committed by
Michael Natterer

parent
f7d599851c
commit
5221d4daa6
40
ChangeLog
40
ChangeLog
@ -1,3 +1,43 @@
|
||||
2003-11-15 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpbase/Makefile.am
|
||||
* libgimpbase/gimpbase-private.[ch]
|
||||
* libgimpbase/gimpunit.c: new files implementing GimpUnitVTable
|
||||
(formerly known as GimpWidgetsVTable). Now the unit functions
|
||||
finally live in the same library as their header declarations.
|
||||
|
||||
* libgimpbase/gimpunit.h: removed comment about being a header for
|
||||
two different files.
|
||||
|
||||
* libgimpwidgets/gimpwidgets-private.[ch]: removed
|
||||
GimpWidgetsVTable.
|
||||
|
||||
* libgimpwidgets/gimpsizeentry.c
|
||||
* libgimpwidgets/gimpunitmenu.c
|
||||
* libgimpwidgets/gimpwidgets.c: use normal gimp_unit functions
|
||||
again.
|
||||
|
||||
* libgimp/gimpui.c
|
||||
* app/gui/gui.c: removed GimpWidgetVTable stuff.
|
||||
|
||||
* libgimp/Makefile.am
|
||||
* libgimp/gimpunitcache.[ch]: new files.
|
||||
|
||||
* libgimp/gimpunit.c: removed (moved to gimpunitcache.c).
|
||||
|
||||
* libgimp/gimp.c (gimp_main): initialize GimpUnitVTable using the
|
||||
gimp_unit_cache functions.
|
||||
|
||||
* app/Makefile.am
|
||||
* app/units.[ch]: new files implementing GimpUnitVTable.
|
||||
|
||||
* app/libgimp_glue.[ch]: removed.
|
||||
|
||||
* app/app_procs.[ch]: made "the_gimp" a static variable. Call
|
||||
units_init().
|
||||
|
||||
* app/main.c: changed accordingly.
|
||||
|
||||
2003-11-15 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimp.def
|
||||
|
@ -34,9 +34,9 @@ gimp_1_3_SOURCES = \
|
||||
batch.h \
|
||||
errors.c \
|
||||
errors.h \
|
||||
gimp-intl.h \
|
||||
libgimp_glue.c \
|
||||
libgimp_glue.h
|
||||
units.c \
|
||||
units.h \
|
||||
gimp-intl.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
makefile.msc \
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "app_procs.h"
|
||||
#include "batch.h"
|
||||
#include "errors.h"
|
||||
#include "units.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
@ -64,9 +65,9 @@ static gboolean app_exit_after_callback (Gimp *gimp,
|
||||
gboolean kill_it);
|
||||
|
||||
|
||||
/* global variables */
|
||||
/* private variables */
|
||||
|
||||
Gimp *the_gimp = NULL;
|
||||
static Gimp *the_gimp = NULL;
|
||||
|
||||
|
||||
/* public functions */
|
||||
@ -174,6 +175,8 @@ app_init (const gchar *full_prog_name,
|
||||
gimp_error_log_func,
|
||||
&the_gimp);
|
||||
|
||||
units_init (the_gimp);
|
||||
|
||||
/* Check if the user's gimp_directory exists
|
||||
*/
|
||||
if (! g_file_test (gimp_directory (), G_FILE_TEST_IS_DIR))
|
||||
|
@ -24,11 +24,6 @@
|
||||
#error You must not #include "app_procs.h" from an app/ subdir
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this is a temp hack
|
||||
*/
|
||||
extern Gimp *the_gimp;
|
||||
|
||||
|
||||
gboolean app_gui_libs_init (gint *gimp_argc,
|
||||
gchar ***gimp_argv);
|
||||
|
@ -119,7 +119,6 @@ gboolean
|
||||
gui_libs_init (gint *argc,
|
||||
gchar ***argv)
|
||||
{
|
||||
GimpWidgetsVTable vtable;
|
||||
const gchar *mismatch;
|
||||
|
||||
g_return_val_if_fail (argc != NULL, FALSE);
|
||||
@ -128,19 +127,7 @@ gui_libs_init (gint *argc,
|
||||
if (!gtk_init_check (argc, argv))
|
||||
return FALSE;
|
||||
|
||||
/* Initialize the eeky vtable needed by libgimpwidgets */
|
||||
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,
|
||||
gui_help_func,
|
||||
gimp_widgets_init (gui_help_func,
|
||||
gui_get_foreground_func,
|
||||
gui_get_background_func,
|
||||
NULL);
|
||||
|
@ -1,118 +0,0 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core/core-types.h"
|
||||
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
|
||||
#define __LIBGIMP_GLUE_C__
|
||||
#include "libgimp_glue.h"
|
||||
|
||||
|
||||
gint
|
||||
gimp_unit_get_number_of_units (void)
|
||||
{
|
||||
return _gimp_unit_get_number_of_units (the_gimp);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_unit_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
gimp_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
return _gimp_unit_new (the_gimp,
|
||||
identifier,
|
||||
factor,
|
||||
digits,
|
||||
symbol,
|
||||
abbreviation,
|
||||
singular,
|
||||
plural);
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_deletion_flag (the_gimp, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
_gimp_unit_set_deletion_flag (the_gimp, unit, deletion_flag);
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_factor (the_gimp, unit);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_digits (the_gimp, unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_identifier (the_gimp, unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_symbol (the_gimp, unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_abbreviation (the_gimp, unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_singular (the_gimp, unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_plural (the_gimp, unit);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LIBGIMP_GLUE_H__
|
||||
#define __LIBGIMP_GLUE_H__
|
||||
|
||||
#ifndef __LIBGIMP_GLUE_C__
|
||||
#error You must not #include "libgimp_glue.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* This files lets various libgimp files link against the application.
|
||||
*
|
||||
* NEVER include this header, it's only here for documentation.
|
||||
*/
|
||||
|
||||
|
||||
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,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural);
|
||||
gboolean gimp_unit_get_deletion_flag (GimpUnit unit);
|
||||
void gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag);
|
||||
gdouble gimp_unit_get_factor (GimpUnit unit);
|
||||
gint gimp_unit_get_digits (GimpUnit unit);
|
||||
const gchar * gimp_unit_get_identifier (GimpUnit unit);
|
||||
const gchar * gimp_unit_get_symbol (GimpUnit unit);
|
||||
const gchar * gimp_unit_get_abbreviation (GimpUnit unit);
|
||||
const gchar * gimp_unit_get_singular (GimpUnit unit);
|
||||
const gchar * gimp_unit_get_plural (GimpUnit unit);
|
||||
|
||||
|
||||
#endif /* __LIBGIMP_GLUE_H__ */
|
@ -176,7 +176,7 @@ main (int argc,
|
||||
if (format)
|
||||
{
|
||||
g_type_init ();
|
||||
the_gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
|
||||
g_object_new (GIMP_TYPE_GIMP, NULL);
|
||||
|
||||
gimp_text_console_exit (gimp_config_dump (format) ?
|
||||
EXIT_SUCCESS : EXIT_FAILURE);
|
||||
|
147
app/units.c
Normal file
147
app/units.c
Normal file
@ -0,0 +1,147 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpbase/gimpbase-private.h"
|
||||
|
||||
#include "core/core-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "units.h"
|
||||
|
||||
|
||||
static Gimp *the_unit_gimp = NULL;
|
||||
|
||||
|
||||
static gint
|
||||
units_get_number_of_units (void)
|
||||
{
|
||||
return _gimp_unit_get_number_of_units (the_unit_gimp);
|
||||
}
|
||||
|
||||
static gint
|
||||
units_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
static GimpUnit
|
||||
units_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
return _gimp_unit_new (the_unit_gimp,
|
||||
identifier,
|
||||
factor,
|
||||
digits,
|
||||
symbol,
|
||||
abbreviation,
|
||||
singular,
|
||||
plural);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
units_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_deletion_flag (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static void
|
||||
units_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
_gimp_unit_set_deletion_flag (the_unit_gimp, unit, deletion_flag);
|
||||
}
|
||||
|
||||
static gdouble
|
||||
units_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_factor (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static gint
|
||||
units_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_digits (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
units_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_identifier (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
units_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_symbol (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
units_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_abbreviation (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
units_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_singular (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
units_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_plural (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
void
|
||||
units_init (Gimp *gimp)
|
||||
{
|
||||
GimpUnitVTable vtable;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (the_unit_gimp == NULL);
|
||||
|
||||
the_unit_gimp = gimp;
|
||||
|
||||
vtable.unit_get_number_of_units = units_get_number_of_units;
|
||||
vtable.unit_get_number_of_built_in_units = units_get_number_of_built_in_units;
|
||||
vtable.unit_new = units_unit_new;
|
||||
vtable.unit_get_deletion_flag = units_unit_get_deletion_flag;
|
||||
vtable.unit_set_deletion_flag = units_unit_set_deletion_flag;
|
||||
vtable.unit_get_factor = units_unit_get_factor;
|
||||
vtable.unit_get_digits = units_unit_get_digits;
|
||||
vtable.unit_get_identifier = units_unit_get_identifier;
|
||||
vtable.unit_get_symbol = units_unit_get_symbol;
|
||||
vtable.unit_get_abbreviation = units_unit_get_abbreviation;
|
||||
vtable.unit_get_singular = units_unit_get_singular;
|
||||
vtable.unit_get_plural = units_unit_get_plural;
|
||||
|
||||
gimp_base_init (&vtable);
|
||||
}
|
31
app/units.h
Normal file
31
app/units.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __UNITS_H__
|
||||
#define __UNITS_H__
|
||||
|
||||
|
||||
#ifndef GIMP_APP_GLUE_COMPILATION
|
||||
#error You must not #include "units.h" from an app/ subdir
|
||||
#endif
|
||||
|
||||
|
||||
void units_init (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __UNITS_H__ */
|
@ -187,7 +187,8 @@ libgimp_1_3_la_SOURCES = \
|
||||
gimpselection.h \
|
||||
gimptile.c \
|
||||
gimptile.h \
|
||||
gimpunit.c \
|
||||
gimpunitcache.c \
|
||||
gimpunitcache.h \
|
||||
stdplugins-intl.h \
|
||||
libgimp-intl.h
|
||||
|
||||
|
@ -87,11 +87,13 @@
|
||||
|
||||
#include "libgimpbase/gimpbasetypes.h"
|
||||
|
||||
#include "libgimpbase/gimpbase-private.h"
|
||||
#include "libgimpbase/gimpenv.h"
|
||||
#include "libgimpbase/gimpprotocol.h"
|
||||
#include "libgimpbase/gimpwire.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpunitcache.h"
|
||||
|
||||
|
||||
/* Maybe this should go in a public header if we add other things to it */
|
||||
@ -346,6 +348,27 @@ gimp_main (const GimpPlugInInfo *info,
|
||||
wire_set_flusher (gimp_flush);
|
||||
|
||||
|
||||
/* initialize units */
|
||||
{
|
||||
GimpUnitVTable vtable;
|
||||
|
||||
vtable.unit_get_number_of_units = _gimp_unit_cache_get_number_of_units;
|
||||
vtable.unit_get_number_of_built_in_units = _gimp_unit_cache_get_number_of_built_in_units;
|
||||
vtable.unit_new = _gimp_unit_cache_new;
|
||||
vtable.unit_get_deletion_flag = _gimp_unit_cache_get_deletion_flag;
|
||||
vtable.unit_set_deletion_flag = _gimp_unit_cache_set_deletion_flag;
|
||||
vtable.unit_get_factor = _gimp_unit_cache_get_factor;
|
||||
vtable.unit_get_digits = _gimp_unit_cache_get_digits;
|
||||
vtable.unit_get_identifier = _gimp_unit_cache_get_identifier;
|
||||
vtable.unit_get_symbol = _gimp_unit_cache_get_symbol;
|
||||
vtable.unit_get_abbreviation = _gimp_unit_cache_get_abbreviation;
|
||||
vtable.unit_get_singular = _gimp_unit_cache_get_singular;
|
||||
vtable.unit_get_plural = _gimp_unit_cache_get_plural;
|
||||
|
||||
gimp_base_init (&vtable);
|
||||
}
|
||||
|
||||
|
||||
/* initialize i18n support */
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
@ -62,8 +62,6 @@ gimp_ui_init (const gchar *prog_name,
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
GimpWidgetsVTable vtable;
|
||||
|
||||
const gchar *display_name;
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
@ -109,19 +107,7 @@ gimp_ui_init (const gchar *prog_name,
|
||||
screen = gdk_screen_get_default ();
|
||||
gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen));
|
||||
|
||||
/* Initialize the eeky vtable needed by libgimpwidgets */
|
||||
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,
|
||||
gimp_ui_help_func,
|
||||
gimp_widgets_init (gimp_ui_help_func,
|
||||
gimp_palette_get_foreground,
|
||||
gimp_palette_get_background,
|
||||
gimp_ensure_modules);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunit.c
|
||||
* gimpunitcache.c
|
||||
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -28,6 +28,7 @@
|
||||
|
||||
#include "libgimpbase/gimpunit.h"
|
||||
|
||||
#include "gimpunitcache.h"
|
||||
#include "gimpunit_pdb.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
@ -96,63 +97,29 @@ gimp_unit_def_init (GimpUnitDef *unit_def,
|
||||
unit_def->symbol = _gimp_unit_get_symbol (unit);
|
||||
unit_def->abbreviation = _gimp_unit_get_abbreviation (unit);
|
||||
unit_def->singular = _gimp_unit_get_singular (unit);
|
||||
unit_def->plural = _gimp_unit_get_plural (unit);
|
||||
unit_def->plural = _gimp_unit_get_plural (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_units:
|
||||
*
|
||||
* Returns the number of units which are known to the #GimpUnit system.
|
||||
*
|
||||
* Returns: The number of defined units.
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_units (void)
|
||||
_gimp_unit_cache_get_number_of_units (void)
|
||||
{
|
||||
return _gimp_unit_get_number_of_units ();
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_built_in_units:
|
||||
*
|
||||
* Returns the number of #GimpUnit's which are hardcoded in the unit system
|
||||
* (UNIT_INCH, UNIT_MM, UNIT_POINT, UNIT_PICA and the two "pseudo unit"
|
||||
* UNIT_PIXEL).
|
||||
*
|
||||
* Returns: The number of built-in units.
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_number_of_built_in_units (void)
|
||||
_gimp_unit_cache_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_new:
|
||||
* @identifier: The unit's identifier string.
|
||||
* @factor: The unit's factor (how many units are in one inch).
|
||||
* @digits: The unit's suggested number of digits (see gimp_unit_get_digits()).
|
||||
* @symbol: The symbol of the unit (e.g. "''" for inch).
|
||||
* @abbreviation: The abbreviation of the unit.
|
||||
* @singular: The singular form of the unit.
|
||||
* @plural: The plural form of the unit.
|
||||
*
|
||||
* Returns the integer ID of the new #GimpUnit.
|
||||
*
|
||||
* Note that a new unit is always created with it's deletion flag
|
||||
* set to %TRUE. You will have to set it to %FALSE with
|
||||
* gimp_unit_set_deletion_flag() to make the unit definition persistent.
|
||||
*
|
||||
* Returns: The ID of the new unit.
|
||||
*/
|
||||
GimpUnit
|
||||
gimp_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
_gimp_unit_cache_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
return _gimp_unit_new (identifier,
|
||||
factor,
|
||||
@ -163,14 +130,8 @@ gimp_unit_new (gchar *identifier,
|
||||
plural);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_deletion_flag:
|
||||
* @unit: The unit you want to know the @deletion_flag of.
|
||||
*
|
||||
* Returns: The unit's @deletion_flag.
|
||||
*/
|
||||
gboolean
|
||||
gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
_gimp_unit_cache_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE);
|
||||
|
||||
@ -180,21 +141,9 @@ gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
return _gimp_unit_get_deletion_flag (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_set_deletion_flag:
|
||||
* @unit: The unit you want to set the @deletion_flag for.
|
||||
* @deletion_flag: The new deletion_flag.
|
||||
*
|
||||
* Sets a #GimpUnit's @deletion_flag. If the @deletion_flag of a unit is
|
||||
* %TRUE when GIMP exits, this unit will not be saved in the uses's
|
||||
* "unitrc" file.
|
||||
*
|
||||
* Trying to change the @deletion_flag of a built-in unit will be silently
|
||||
* ignored.
|
||||
*/
|
||||
void
|
||||
gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
_gimp_unit_cache_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
g_return_if_fail (unit >= GIMP_UNIT_PIXEL);
|
||||
|
||||
@ -205,20 +154,8 @@ gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
deletion_flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_factor:
|
||||
* @unit: The unit you want to know the factor of.
|
||||
*
|
||||
* A #GimpUnit's @factor is defined to be:
|
||||
*
|
||||
* distance_in_units == (@factor * distance_in_inches)
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The unit's factor.
|
||||
*/
|
||||
gdouble
|
||||
gimp_unit_get_factor (GimpUnit unit)
|
||||
_gimp_unit_cache_get_factor (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0);
|
||||
|
||||
@ -231,19 +168,8 @@ gimp_unit_get_factor (GimpUnit unit)
|
||||
return gimp_unit_defs[unit].factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_digits:
|
||||
* @unit: The unit you want to know the digits.
|
||||
*
|
||||
* Returns the number of digits an entry field should provide to get
|
||||
* approximately the same accuracy as an inch input field with two digits.
|
||||
*
|
||||
* Returns 0 for @unit == GIMP_UNIT_PIXEL.
|
||||
*
|
||||
* Returns: The suggested number of digits.
|
||||
*/
|
||||
gint
|
||||
gimp_unit_get_digits (GimpUnit unit)
|
||||
_gimp_unit_cache_get_digits (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 0);
|
||||
|
||||
@ -256,16 +182,8 @@ gimp_unit_get_digits (GimpUnit unit)
|
||||
return gimp_unit_defs[unit].digits;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_identifier:
|
||||
* @unit: The unit you want to know the identifier of.
|
||||
*
|
||||
* This is an unstranslated string and must not be changed or freed.
|
||||
*
|
||||
* Returns: The unit's identifier.
|
||||
*/
|
||||
const gchar *
|
||||
gimp_unit_get_identifier (GimpUnit unit)
|
||||
const gchar *
|
||||
_gimp_unit_cache_get_identifier (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
|
||||
@ -278,18 +196,8 @@ gimp_unit_get_identifier (GimpUnit unit)
|
||||
return gimp_unit_defs[unit].identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_symbol:
|
||||
* @unit: The unit you want to know the symbol of.
|
||||
*
|
||||
* This is e.g. "''" for UNIT_INCH.
|
||||
*
|
||||
* NOTE: This string must not be changed or freed.
|
||||
*
|
||||
* Returns: The unit's symbol.
|
||||
*/
|
||||
const gchar *
|
||||
gimp_unit_get_symbol (GimpUnit unit)
|
||||
_gimp_unit_cache_get_symbol (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
|
||||
@ -302,19 +210,8 @@ gimp_unit_get_symbol (GimpUnit unit)
|
||||
return gimp_unit_defs[unit].symbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_abbreviation:
|
||||
* @unit: The unit you want to know the abbreviation of.
|
||||
*
|
||||
* For built-in units, this function returns the translated abbreviation
|
||||
* of the unit.
|
||||
*
|
||||
* NOTE: This string must not be changed or freed.
|
||||
*
|
||||
* Returns: The unit's abbreviation.
|
||||
*/
|
||||
const gchar *
|
||||
gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
_gimp_unit_cache_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
|
||||
@ -327,19 +224,8 @@ gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
return gimp_unit_defs[unit].abbreviation;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_singular:
|
||||
* @unit: The unit you want to know the singular form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated singular form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string must not be changed or freed.
|
||||
*
|
||||
* Returns: The unit's singular form.
|
||||
*/
|
||||
const gchar *
|
||||
gimp_unit_get_singular (GimpUnit unit)
|
||||
_gimp_unit_cache_get_singular (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
|
||||
@ -352,20 +238,8 @@ gimp_unit_get_singular (GimpUnit unit)
|
||||
return gettext (gimp_unit_defs[unit].singular);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_plural:
|
||||
* @unit: The unit you want to know the plural form of.
|
||||
*
|
||||
* For built-in units, this function returns the translated plural form
|
||||
* of the unit's name.
|
||||
*
|
||||
* NOTE: This string must not be changed or freed.
|
||||
*
|
||||
* Returns: The unit's plural form.
|
||||
*
|
||||
*/
|
||||
const gchar *
|
||||
gimp_unit_get_plural (GimpUnit unit)
|
||||
_gimp_unit_cache_get_plural (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
|
||||
|
49
libgimp/gimpunitcache.h
Normal file
49
libgimp/gimpunitcache.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunitcache.c
|
||||
* Copyright (C) 2003 Michael Natterer <mitch@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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_UNIT_CACHE_H__
|
||||
#define __GIMP_UNIT_CACHE_H__
|
||||
|
||||
|
||||
gint _gimp_unit_cache_get_number_of_units (void);
|
||||
gint _gimp_unit_cache_get_number_of_built_in_units (void);
|
||||
|
||||
GimpUnit _gimp_unit_cache_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural);
|
||||
gboolean _gimp_unit_cache_get_deletion_flag (GimpUnit unit);
|
||||
void _gimp_unit_cache_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag);
|
||||
gdouble _gimp_unit_cache_get_factor (GimpUnit unit);
|
||||
gint _gimp_unit_cache_get_digits (GimpUnit unit);
|
||||
const gchar * _gimp_unit_cache_get_identifier (GimpUnit unit);
|
||||
const gchar * _gimp_unit_cache_get_symbol (GimpUnit unit);
|
||||
const gchar * _gimp_unit_cache_get_abbreviation (GimpUnit unit);
|
||||
const gchar * _gimp_unit_cache_get_singular (GimpUnit unit);
|
||||
const gchar * _gimp_unit_cache_get_plural (GimpUnit unit);
|
||||
|
||||
|
||||
#endif /* __GIMP_UNIT_CACHE_H__ */
|
@ -69,9 +69,10 @@ libgimpbase_1_3_la_SOURCES = \
|
||||
gimpbase.h \
|
||||
gimpbasetypes.h \
|
||||
gimplimits.h \
|
||||
gimpunit.h \
|
||||
gimpversion.h \
|
||||
\
|
||||
gimpbase-private.c \
|
||||
gimpbase-private.h \
|
||||
gimpdatafiles.c \
|
||||
gimpdatafiles.h \
|
||||
gimpenv.c \
|
||||
@ -84,6 +85,8 @@ libgimpbase_1_3_la_SOURCES = \
|
||||
gimpprotocol.h \
|
||||
gimpsignal.c \
|
||||
gimpsignal.h \
|
||||
gimpunit.c \
|
||||
gimpunit.h \
|
||||
gimputils.c \
|
||||
gimputils.h \
|
||||
gimpwin32-io.h \
|
||||
@ -94,15 +97,15 @@ libgimpbaseinclude_HEADERS = \
|
||||
gimpbase.h \
|
||||
gimpbasetypes.h \
|
||||
gimplimits.h \
|
||||
gimpunit.h \
|
||||
gimputils.h \
|
||||
gimpversion.h \
|
||||
\
|
||||
gimpdatafiles.h \
|
||||
gimpenv.h \
|
||||
gimpparasite.h \
|
||||
gimpparasiteio.h \
|
||||
gimpsignal.h
|
||||
gimpsignal.h \
|
||||
gimpunit.h \
|
||||
gimputils.h
|
||||
|
||||
libgimpbase_1_3_la_LDFLAGS = \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
|
||||
|
50
libgimpbase/gimpbase-private.c
Normal file
50
libgimpbase/gimpbase-private.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpbase-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 <glib.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "gimpbasetypes.h"
|
||||
|
||||
#include "gimpbase-private.h"
|
||||
|
||||
|
||||
GimpUnitVTable _gimp_unit_vtable = { NULL, };
|
||||
|
||||
|
||||
void
|
||||
gimp_base_init (GimpUnitVTable *vtable)
|
||||
{
|
||||
static gboolean gimp_base_initialized = FALSE;
|
||||
|
||||
g_return_if_fail (vtable != NULL);
|
||||
|
||||
if (gimp_base_initialized)
|
||||
g_error ("gimp_base_init() must only be called once!");
|
||||
|
||||
_gimp_unit_vtable = *vtable;
|
||||
|
||||
gimp_base_initialized = TRUE;
|
||||
}
|
69
libgimpbase/gimpbase-private.h
Normal file
69
libgimpbase/gimpbase-private.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpbase-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_BASE_PRIVATE_H__
|
||||
#define __GIMP_BASE_PRIVATE_H__
|
||||
|
||||
|
||||
typedef struct _GimpUnitVTable GimpUnitVTable;
|
||||
|
||||
struct _GimpUnitVTable
|
||||
{
|
||||
gint (* unit_get_number_of_units) (void);
|
||||
gint (* unit_get_number_of_built_in_units) (void);
|
||||
|
||||
GimpUnit (* unit_new) (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural);
|
||||
gboolean (* unit_get_deletion_flag) (GimpUnit unit);
|
||||
void (* unit_set_deletion_flag) (GimpUnit unit,
|
||||
gboolean deletion_flag);
|
||||
|
||||
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 GimpUnitVTable _gimp_unit_vtable;
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gimp_base_init (GimpUnitVTable *vtable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_BASE_PRIVATE_H__ */
|
@ -2,7 +2,7 @@
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunit.c
|
||||
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -12,7 +12,7 @@
|
||||
* 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.
|
||||
* 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
|
||||
@ -24,80 +24,11 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "libgimpbase/gimpbasetypes.h"
|
||||
#include "gimpbasetypes.h"
|
||||
|
||||
#include "libgimpbase/gimpunit.h"
|
||||
#include "gimpbase-private.h"
|
||||
#include "gimpunit.h"
|
||||
|
||||
#include "gimpunit_pdb.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
/* internal structures */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gdouble factor;
|
||||
gint digits;
|
||||
const gchar *identifier;
|
||||
const gchar *symbol;
|
||||
const gchar *abbreviation;
|
||||
const gchar *singular;
|
||||
const gchar *plural;
|
||||
} GimpUnitDef;
|
||||
|
||||
|
||||
static GimpUnitDef * gimp_unit_defs = NULL;
|
||||
static GimpUnit gimp_units_initialized = 0;
|
||||
|
||||
/* not a unit at all but kept here to have the strings in one place
|
||||
*/
|
||||
static GimpUnitDef gimp_unit_percent =
|
||||
{
|
||||
0.0, 0, "percent", "%", "%", N_("percent"), N_("percent")
|
||||
};
|
||||
|
||||
|
||||
static void gimp_unit_def_init (GimpUnitDef *unit_def,
|
||||
GimpUnit unit);
|
||||
|
||||
|
||||
static gboolean
|
||||
gimp_unit_init (GimpUnit unit)
|
||||
{
|
||||
gint i, n;
|
||||
|
||||
if (unit < gimp_units_initialized)
|
||||
return TRUE;
|
||||
|
||||
n = _gimp_unit_get_number_of_units ();
|
||||
|
||||
if (unit >= n)
|
||||
return FALSE;
|
||||
|
||||
gimp_unit_defs = g_renew (GimpUnitDef, gimp_unit_defs, n);
|
||||
|
||||
for (i = gimp_units_initialized; i < n; i++)
|
||||
{
|
||||
gimp_unit_def_init (&gimp_unit_defs[i], i);
|
||||
}
|
||||
|
||||
gimp_units_initialized = n;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_unit_def_init (GimpUnitDef *unit_def,
|
||||
GimpUnit unit)
|
||||
{
|
||||
unit_def->factor = _gimp_unit_get_factor (unit);
|
||||
unit_def->digits = _gimp_unit_get_digits (unit);
|
||||
unit_def->identifier = _gimp_unit_get_identifier (unit);
|
||||
unit_def->symbol = _gimp_unit_get_symbol (unit);
|
||||
unit_def->abbreviation = _gimp_unit_get_abbreviation (unit);
|
||||
unit_def->singular = _gimp_unit_get_singular (unit);
|
||||
unit_def->plural = _gimp_unit_get_plural (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_get_number_of_units:
|
||||
@ -109,7 +40,10 @@ gimp_unit_def_init (GimpUnitDef *unit_def,
|
||||
gint
|
||||
gimp_unit_get_number_of_units (void)
|
||||
{
|
||||
return _gimp_unit_get_number_of_units ();
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_number_of_units != NULL,
|
||||
GIMP_UNIT_END);
|
||||
|
||||
return _gimp_unit_vtable.unit_get_number_of_units ();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,7 +58,10 @@ gimp_unit_get_number_of_units (void)
|
||||
gint
|
||||
gimp_unit_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_number_of_built_in_units
|
||||
!= NULL, GIMP_UNIT_END);
|
||||
|
||||
return _gimp_unit_vtable.unit_get_number_of_built_in_units ();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,20 +84,17 @@ gimp_unit_get_number_of_built_in_units (void)
|
||||
*/
|
||||
GimpUnit
|
||||
gimp_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
return _gimp_unit_new (identifier,
|
||||
factor,
|
||||
digits,
|
||||
symbol,
|
||||
abbreviation,
|
||||
singular,
|
||||
plural);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_new != NULL, GIMP_UNIT_INCH);
|
||||
|
||||
return _gimp_unit_vtable.unit_new (identifier, factor, digits,
|
||||
symbol, abbreviation, singular, plural);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,12 +106,9 @@ gimp_unit_new (gchar *identifier,
|
||||
gboolean
|
||||
gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, TRUE);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_deletion_flag != NULL, FALSE);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return FALSE;
|
||||
|
||||
return _gimp_unit_get_deletion_flag (unit);
|
||||
return _gimp_unit_vtable.unit_get_deletion_flag (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,15 +125,11 @@ gimp_unit_get_deletion_flag (GimpUnit unit)
|
||||
*/
|
||||
void
|
||||
gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
g_return_if_fail (unit >= GIMP_UNIT_PIXEL);
|
||||
g_return_if_fail (_gimp_unit_vtable.unit_set_deletion_flag != NULL);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return;
|
||||
|
||||
_gimp_unit_set_deletion_flag (unit,
|
||||
deletion_flag);
|
||||
_gimp_unit_vtable.unit_set_deletion_flag (unit, deletion_flag);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,15 +147,9 @@ gimp_unit_set_deletion_flag (GimpUnit unit,
|
||||
gdouble
|
||||
gimp_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 1.0);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_factor != NULL, 1.0);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.factor;
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return 1.0;
|
||||
|
||||
return gimp_unit_defs[unit].factor;
|
||||
return _gimp_unit_vtable.unit_get_factor (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,15 +166,9 @@ gimp_unit_get_factor (GimpUnit unit)
|
||||
gint
|
||||
gimp_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_INCH, 0);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_digits != NULL, 2);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.digits;
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return 0;
|
||||
|
||||
return gimp_unit_defs[unit].digits;
|
||||
return _gimp_unit_vtable.unit_get_digits (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -264,18 +179,12 @@ gimp_unit_get_digits (GimpUnit unit)
|
||||
*
|
||||
* Returns: The unit's identifier.
|
||||
*/
|
||||
const gchar *
|
||||
const gchar *
|
||||
gimp_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_identifier != NULL, NULL);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.identifier;
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return NULL;
|
||||
|
||||
return gimp_unit_defs[unit].identifier;
|
||||
return _gimp_unit_vtable.unit_get_identifier (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,15 +200,9 @@ gimp_unit_get_identifier (GimpUnit unit)
|
||||
const gchar *
|
||||
gimp_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_symbol != NULL, NULL);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.symbol;
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return NULL;
|
||||
|
||||
return gimp_unit_defs[unit].symbol;
|
||||
return _gimp_unit_vtable.unit_get_symbol (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,15 +219,9 @@ gimp_unit_get_symbol (GimpUnit unit)
|
||||
const gchar *
|
||||
gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_abbreviation != NULL, NULL);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.abbreviation;
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return NULL;
|
||||
|
||||
return gimp_unit_defs[unit].abbreviation;
|
||||
return _gimp_unit_vtable.unit_get_abbreviation (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -341,15 +238,9 @@ gimp_unit_get_abbreviation (GimpUnit unit)
|
||||
const gchar *
|
||||
gimp_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_singular != NULL, NULL);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gettext (gimp_unit_percent.singular);
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return NULL;
|
||||
|
||||
return gettext (gimp_unit_defs[unit].singular);
|
||||
return _gimp_unit_vtable.unit_get_singular (unit);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,13 +258,7 @@ gimp_unit_get_singular (GimpUnit unit)
|
||||
const gchar *
|
||||
gimp_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit >= GIMP_UNIT_PIXEL, NULL);
|
||||
g_return_val_if_fail (_gimp_unit_vtable.unit_get_plural != NULL, NULL);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gettext (gimp_unit_percent.plural);
|
||||
|
||||
if (!gimp_unit_init (unit))
|
||||
return NULL;
|
||||
|
||||
return gettext (gimp_unit_defs[unit].plural);
|
||||
return _gimp_unit_vtable.unit_get_plural (unit);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunit.h
|
||||
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
||||
* Copyright (C) 1999-2003 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,13 +20,6 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE:
|
||||
*
|
||||
* This file serves as header for both app/gimpunit.c and libgimp/gimpunit.c
|
||||
* because the unit functions are needed by widgets which are used by both
|
||||
* the gimp app and plugins.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_UNIT_H__
|
||||
#define __GIMP_UNIT_H__
|
||||
|
||||
|
@ -31,12 +31,11 @@
|
||||
|
||||
#include "gimpsizeentry.h"
|
||||
#include "gimpunitmenu.h"
|
||||
#include "gimpwidgets-private.h"
|
||||
|
||||
|
||||
#define SIZE_MAX_VALUE 500000.0
|
||||
|
||||
#define GIMP_SIZE_ENTRY_DIGITS(unit) (MIN (_gimp_eek.unit_get_digits (unit), 5) + 1)
|
||||
#define GIMP_SIZE_ENTRY_DIGITS(unit) (MIN (gimp_unit_get_digits (unit), 5) + 1)
|
||||
|
||||
|
||||
enum
|
||||
@ -664,10 +663,10 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
|
||||
gimp_size_entry_set_refval_boundaries (gse, field,
|
||||
gsef->min_value *
|
||||
gsef->resolution /
|
||||
_gimp_eek.unit_get_factor (gse->unit),
|
||||
gimp_unit_get_factor (gse->unit),
|
||||
gsef->max_value *
|
||||
gsef->resolution /
|
||||
_gimp_eek.unit_get_factor (gse->unit));
|
||||
gimp_unit_get_factor (gse->unit));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -675,9 +674,9 @@ gimp_size_entry_set_value_boundaries (GimpSizeEntry *gse,
|
||||
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
|
||||
gimp_size_entry_set_refval_boundaries (gse, field,
|
||||
gsef->min_value *
|
||||
_gimp_eek.unit_get_factor (gse->unit),
|
||||
gimp_unit_get_factor (gse->unit),
|
||||
gsef->max_value *
|
||||
_gimp_eek.unit_get_factor (gse->unit));
|
||||
gimp_unit_get_factor (gse->unit));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -746,7 +745,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
|
||||
default:
|
||||
gsef->refval =
|
||||
CLAMP (value * gsef->resolution /
|
||||
_gimp_eek.unit_get_factor (gsef->gse->unit),
|
||||
gimp_unit_get_factor (gsef->gse->unit),
|
||||
gsef->min_refval, gsef->max_refval);
|
||||
break;
|
||||
}
|
||||
@ -757,7 +756,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
|
||||
|
||||
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
|
||||
gsef->refval =
|
||||
CLAMP (value * _gimp_eek.unit_get_factor (gsef->gse->unit),
|
||||
CLAMP (value * gimp_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),
|
||||
@ -887,10 +886,10 @@ gimp_size_entry_set_refval_boundaries (GimpSizeEntry *gse,
|
||||
default:
|
||||
gimp_size_entry_set_value_boundaries (gse, field,
|
||||
gsef->min_refval *
|
||||
_gimp_eek.unit_get_factor (gse->unit) /
|
||||
gimp_unit_get_factor (gse->unit) /
|
||||
gsef->resolution,
|
||||
gsef->max_refval *
|
||||
_gimp_eek.unit_get_factor (gse->unit) /
|
||||
gimp_unit_get_factor (gse->unit) /
|
||||
gsef->resolution);
|
||||
break;
|
||||
}
|
||||
@ -899,9 +898,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_eek.unit_get_factor (gse->unit),
|
||||
gimp_unit_get_factor (gse->unit),
|
||||
gsef->max_refval /
|
||||
_gimp_eek.unit_get_factor (gse->unit));
|
||||
gimp_unit_get_factor (gse->unit));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1005,7 +1004,7 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
|
||||
break;
|
||||
default:
|
||||
gsef->value =
|
||||
CLAMP (refval * _gimp_eek.unit_get_factor (gsef->gse->unit) /
|
||||
CLAMP (refval * gimp_unit_get_factor (gsef->gse->unit) /
|
||||
gsef->resolution,
|
||||
gsef->min_value, gsef->max_value);
|
||||
break;
|
||||
@ -1016,7 +1015,7 @@ gimp_size_entry_update_refval (GimpSizeEntryField *gsef,
|
||||
|
||||
case GIMP_SIZE_ENTRY_UPDATE_RESOLUTION:
|
||||
gsef->value =
|
||||
CLAMP (refval / _gimp_eek.unit_get_factor (gsef->gse->unit),
|
||||
CLAMP (refval / gimp_unit_get_factor (gsef->gse->unit),
|
||||
gsef->min_value, gsef->max_value);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment),
|
||||
gsef->value);
|
||||
@ -1125,8 +1124,8 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
||||
}
|
||||
else if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION)
|
||||
{
|
||||
digits = (_gimp_eek.unit_get_digits (GIMP_UNIT_INCH) -
|
||||
_gimp_eek.unit_get_digits (unit));
|
||||
digits = (gimp_unit_get_digits (GIMP_UNIT_INCH) -
|
||||
gimp_unit_get_digits (unit));
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
|
||||
MAX (3 + digits, 3));
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "gimphelpui.h"
|
||||
#include "gimpunitmenu.h"
|
||||
#include "gimpwidgets.h"
|
||||
#include "gimpwidgets-private.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
@ -210,10 +209,10 @@ gimp_unit_menu_new (const gchar *format,
|
||||
GimpUnit u;
|
||||
|
||||
g_return_val_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
|
||||
(unit < _gimp_eek.unit_get_number_of_units ())) ||
|
||||
(unit < gimp_unit_get_number_of_units ())) ||
|
||||
(unit == GIMP_UNIT_PERCENT), NULL);
|
||||
|
||||
if ((unit >= _gimp_eek.unit_get_number_of_built_in_units ()) &&
|
||||
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
|
||||
(unit != GIMP_UNIT_PERCENT))
|
||||
show_custom = TRUE;
|
||||
|
||||
@ -225,7 +224,7 @@ gimp_unit_menu_new (const gchar *format,
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
for (u = show_pixels ? GIMP_UNIT_PIXEL : GIMP_UNIT_INCH;
|
||||
u < _gimp_eek.unit_get_number_of_built_in_units ();
|
||||
u < gimp_unit_get_number_of_built_in_units ();
|
||||
u++)
|
||||
{
|
||||
/* special cases "pixels" and "percent" */
|
||||
@ -267,7 +266,7 @@ gimp_unit_menu_new (const gchar *format,
|
||||
unit_menu);
|
||||
}
|
||||
|
||||
if ((unit >= _gimp_eek.unit_get_number_of_built_in_units ()) &&
|
||||
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
|
||||
(unit != GIMP_UNIT_PERCENT))
|
||||
{
|
||||
menuitem = gtk_menu_item_new ();
|
||||
@ -340,7 +339,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_eek.unit_get_number_of_units ())) ||
|
||||
(unit < gimp_unit_get_number_of_units ())) ||
|
||||
((unit == GIMP_UNIT_PERCENT) && menu->show_percent));
|
||||
|
||||
if (unit == menu->unit)
|
||||
@ -510,27 +509,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_eek.unit_get_factor (unit));
|
||||
gimp_unit_get_factor (unit));
|
||||
break;
|
||||
|
||||
case 'y': /* symbol ("''" for inch) */
|
||||
i += print (buffer, sizeof (buffer), i, "%s",
|
||||
_gimp_eek.unit_get_symbol (unit));
|
||||
gimp_unit_get_symbol (unit));
|
||||
break;
|
||||
|
||||
case 'a': /* abbreviation */
|
||||
i += print (buffer, sizeof (buffer), i, "%s",
|
||||
_gimp_eek.unit_get_abbreviation (unit));
|
||||
gimp_unit_get_abbreviation (unit));
|
||||
break;
|
||||
|
||||
case 's': /* singular */
|
||||
i += print (buffer, sizeof (buffer), i, "%s",
|
||||
_gimp_eek.unit_get_singular (unit));
|
||||
gimp_unit_get_singular (unit));
|
||||
break;
|
||||
|
||||
case 'p': /* plural */
|
||||
i += print (buffer, sizeof (buffer), i, "%s",
|
||||
_gimp_eek.unit_get_plural (unit));
|
||||
gimp_unit_get_plural (unit));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -662,7 +661,7 @@ gimp_unit_menu_create_selection (GimpUnitMenu *menu)
|
||||
"text", FACTOR_COLUMN, NULL);
|
||||
|
||||
/* the unit lines */
|
||||
num_units = _gimp_eek.unit_get_number_of_units ();
|
||||
num_units = gimp_unit_get_number_of_units ();
|
||||
for (unit = GIMP_UNIT_END; unit < num_units; unit++)
|
||||
{
|
||||
gtk_list_store_append (list, &iter);
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "themes/Default/images/gimp-wilber-pixbufs.h"
|
||||
|
||||
|
||||
GimpWidgetsVTable _gimp_eek = { NULL, };
|
||||
GimpHelpFunc _gimp_standard_help_func = NULL;
|
||||
GimpGetColorFunc _gimp_get_foreground_func = NULL;
|
||||
GimpGetColorFunc _gimp_get_background_func = NULL;
|
||||
@ -43,8 +42,7 @@ GimpEnsureModulesFunc _gimp_ensure_modules_func = NULL;
|
||||
|
||||
|
||||
void
|
||||
gimp_widgets_init (GimpWidgetsVTable *vtable,
|
||||
GimpHelpFunc standard_help_func,
|
||||
gimp_widgets_init (GimpHelpFunc standard_help_func,
|
||||
GimpGetColorFunc get_foreground_func,
|
||||
GimpGetColorFunc get_background_func,
|
||||
GimpEnsureModulesFunc ensure_modules_func)
|
||||
@ -63,13 +61,11 @@ gimp_widgets_init (GimpWidgetsVTable *vtable,
|
||||
stock_wilber_64
|
||||
};
|
||||
|
||||
g_return_if_fail (vtable != NULL);
|
||||
g_return_if_fail (standard_help_func != NULL);
|
||||
|
||||
if (gimp_widgets_initialized)
|
||||
g_error ("gimp_widgets_init() must only be called once!");
|
||||
|
||||
_gimp_eek = *vtable;
|
||||
_gimp_standard_help_func = standard_help_func;
|
||||
_gimp_get_foreground_func = get_foreground_func;
|
||||
_gimp_get_background_func = get_background_func;
|
||||
@ -92,5 +88,3 @@ gimp_widgets_init (GimpWidgetsVTable *vtable,
|
||||
|
||||
gimp_widgets_initialized = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,28 +28,6 @@ typedef gboolean (* GimpGetColorFunc) (GimpRGB *color);
|
||||
typedef void (* GimpEnsureModulesFunc) (void);
|
||||
|
||||
|
||||
typedef struct _GimpWidgetsVTable GimpWidgetsVTable;
|
||||
|
||||
struct _GimpWidgetsVTable
|
||||
{
|
||||
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;
|
||||
extern GimpHelpFunc _gimp_standard_help_func;
|
||||
extern GimpGetColorFunc _gimp_get_foreground_func;
|
||||
extern GimpGetColorFunc _gimp_get_background_func;
|
||||
@ -59,8 +37,7 @@ extern GimpEnsureModulesFunc _gimp_ensure_modules_func;
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
void gimp_widgets_init (GimpWidgetsVTable *vtable,
|
||||
GimpHelpFunc standard_help_func,
|
||||
void gimp_widgets_init (GimpHelpFunc standard_help_func,
|
||||
GimpGetColorFunc get_foreground_func,
|
||||
GimpGetColorFunc get_background_func,
|
||||
GimpEnsureModulesFunc ensure_modules_func);
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "gimpsizeentry.h"
|
||||
#include "gimpunitmenu.h"
|
||||
#include "gimpwidgets.h"
|
||||
#include "gimpwidgets-private.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
||||
@ -1760,7 +1759,7 @@ gimp_unit_menu_update (GtkWidget *widget,
|
||||
|
||||
digits = ((*val == GIMP_UNIT_PIXEL) ? 0 :
|
||||
((*val == GIMP_UNIT_PERCENT) ? 2 :
|
||||
(MIN (6, MAX (3, _gimp_eek.unit_get_digits (*val))))));
|
||||
(MIN (6, MAX (3, gimp_unit_get_digits (*val))))));
|
||||
|
||||
digits += gimp_unit_menu_get_pixel_digits (GIMP_UNIT_MENU (widget));
|
||||
|
||||
|
Reference in New Issue
Block a user