gimp/app/config/gimpconfig-types.c
Hans Breuer de5f8b5f43 #define GETTEXT_PACKAGE
2001-03-28  Hans Breuer  <hans@breuer.org>

	* config.h.win32 : #define GETTEXT_PACKAGE

	* makefile.msc : add theme rule

	* app/makefile.msc : gimp.exe depends on all the libs
	and general update

	* app/base/makefile.msc : updated

	* app/config/gimpconfig-serialize.c : #include <io.h> for win32
	* app/config/gimpconfig-types.c : #include <string.h>

	* app/core/gimpcontext.c app/core/gimpcontainer.c
	  app/core/gimptoolinfo.c : #include <string.h>

	* app/core/gimpdocuments.c (gimp_documents_save_func) :
	need to g_strescape() the filename to not make
	backslashes vanish during de-serialization

	* app/core/gimpimagefile.c : #define S_ISREG for G_OS_WIN32

	* app/core/makefile.msc : add -DGIMP_COMPILATION
	required for cpercep.c build

	* app/display/gimpdisplayshell.c : #include <string.h>

	* app/display/makefile.msc : -FImsvc_recommended_pragmas.h,
	G_LOG_DOMAIN definition and object file update

	* app/file/makefile.msc : -FImsvc_recommended_pragmas.h,
	G_LOG_DOMAIN definition

	* app/file/file-open.c (file_open_with_proc_and_display) :
	use absolute filename for gimp_documents_add()

	* app/gui/channel-commands.c app/gui/colormap-editor-commands.c
	  app/gui/edit-commands.c app/gui/vectors-commands.c :
	#include <string.h>

	* app/gui/makefile.msc : updated

	* app/gui/menus.c : use g_file_test() instead of access()
	to avoid inclusion <unistd.h>

	* app/paint/makefile.msc : updated

	* app/plug-in/plug-in-params.c : #include <string.h>

	* app/plug-in/makefile.msc : updated

	* app/plug-in/plug-in-def.h : #include <time.h> for time_t

	* app/plug-in/plug-in.c : remove definition of S_IFREG

	* app/plug-in/gap/gap_arr_dialog.c : include <config.h>
	before including libgimp/libgimp-intl.h

	* app/tools/makefile.msc : updated

	* app/vectors/makefile.msc : new file

	* app/widgets/makefile.msc : updated

	* libgimp/gimp.def : updated externals

	* libgimpwidgets/gimpwidgets.def : updated externals

	* modules/makefile.msc : updated and disabled colorsel_gtk.

	* plug-in/makefile.msc : don't define GETTEXT_PACKAGE

	* themes/Default/images/makefile.msc : moved makefile.msc from ..
	and adapted pathes to images
2002-03-28 00:10:56 +00:00

215 lines
5.1 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* ParamSpecs for config objects
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "gimpconfig-types.h"
static void memsize_to_string (const GValue *src_value,
GValue *dest_value);
static void string_to_memsize (const GValue *src_value,
GValue *dest_value);
static void unit_to_string (const GValue *src_value,
GValue *dest_value);
static void string_to_unit (const GValue *src_value,
GValue *dest_value);
GType
gimp_memsize_get_type (void)
{
static GType memsize_type = 0;
if (!memsize_type)
{
static const GTypeInfo type_info = { 0, };
memsize_type = g_type_register_static (G_TYPE_UINT, "GimpMemsize",
&type_info, 0);
g_value_register_transform_func (memsize_type, G_TYPE_STRING,
memsize_to_string);
g_value_register_transform_func (G_TYPE_STRING, memsize_type,
string_to_memsize);
}
return memsize_type;
}
GType
gimp_path_get_type (void)
{
static GType path_type = 0;
if (!path_type)
{
static const GTypeInfo type_info = { 0, };
path_type = g_type_register_static (G_TYPE_STRING, "GimpPath",
&type_info, 0);
}
return path_type;
}
GType
gimp_unit_get_type (void)
{
static GType unit_type = 0;
if (!unit_type)
{
static const GTypeInfo type_info = { 0, };
unit_type = g_type_register_static (G_TYPE_INT, "GimpUnit",
&type_info, 0);
g_value_register_transform_func (unit_type, G_TYPE_STRING,
unit_to_string);
g_value_register_transform_func (G_TYPE_STRING, unit_type,
string_to_unit);
}
return unit_type;
}
static void
memsize_to_string (const GValue *src_value,
GValue *dest_value)
{
guint size;
gchar *str;
size = g_value_get_uint (src_value);
if (size > (1 << 30) && size % (1 << 30) == 0)
str = g_strdup_printf ("%uG", size >> 30);
else if (size > (1 << 20) && size % (1 << 20) == 0)
str = g_strdup_printf ("%uM", size >> 20);
else if (size > (1 << 10) && size % (1 << 10) == 0)
str = g_strdup_printf ("%uk", size >> 10);
else
str = g_strdup_printf ("%u", size);
g_value_set_string_take_ownership (dest_value, str);
};
static void
string_to_memsize (const GValue *src_value,
GValue *dest_value)
{
const gchar *str;
gchar *end;
guint size;
str = g_value_get_string (src_value);
if (!str || !*str)
goto error;
size = strtoul (str, &end, 0);
if (size == ULONG_MAX)
goto error;
if (end && *end)
{
guint shift;
switch (g_ascii_tolower (*end))
{
case 'b':
shift = 0;
break;
case 'k':
shift = 10;
break;
case 'm':
shift = 20;
break;
case 'g':
shift = 30;
break;
default:
goto error;
}
size <<= shift;
}
g_value_set_uint (dest_value, size);
return;
error:
g_warning ("Can't convert string to GimpMemsize.");
};
static void
unit_to_string (const GValue *src_value,
GValue *dest_value)
{
GimpUnit unit;
unit = (GimpUnit) g_value_get_int (src_value);
g_value_set_string (dest_value, gimp_unit_get_identifier (unit));
};
static void
string_to_unit (const GValue *src_value,
GValue *dest_value)
{
const gchar *str;
gint num_units;
gint i;
str = g_value_get_string (src_value);
if (!str || !*str)
goto error;
num_units = gimp_unit_get_number_of_units ();
for (i = GIMP_UNIT_PIXEL; i < num_units; i++)
if (strcmp (str, gimp_unit_get_identifier (i)) == 0)
break;
if (i == num_units)
goto error;
g_value_set_int (dest_value, i);
return;
error:
g_warning ("Can't convert string to GimpUnit.");
};