hardcode the built-in units. Dynamically constructing the constants using
2007-06-20 Sven Neumann <sven@gimp.org> * plug-ins/script-fu/scheme-wrapper.c (init_constants): hardcode the built-in units. Dynamically constructing the constants using gimp_unit_get_singular() doesn't work because it returns a translated string. svn path=/trunk/; revision=22804
This commit is contained in:

committed by
Sven Neumann

parent
c622b604d7
commit
1140960d35
@ -1,3 +1,10 @@
|
|||||||
|
2007-06-20 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/script-fu/scheme-wrapper.c (init_constants): hardcode
|
||||||
|
the built-in units. Dynamically constructing the constants using
|
||||||
|
gimp_unit_get_singular() doesn't work because it returns a
|
||||||
|
translated string.
|
||||||
|
|
||||||
2007-06-20 Sven Neumann <sven@gimp.org>
|
2007-06-20 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/script-fu/script-fu-console.c (script_fu_cc_key_function):
|
* plug-ins/script-fu/script-fu-console.c (script_fu_cc_key_function):
|
||||||
|
@ -51,10 +51,10 @@ static int ts_console_mode;
|
|||||||
|
|
||||||
#undef cons
|
#undef cons
|
||||||
|
|
||||||
struct
|
struct named_constant
|
||||||
named_constant {
|
{
|
||||||
const char *name;
|
const gchar *name;
|
||||||
int value;
|
gint value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct named_constant const script_constants[] =
|
struct named_constant const script_constants[] =
|
||||||
@ -69,6 +69,13 @@ struct named_constant const script_constants[] =
|
|||||||
{ "TRUE", TRUE },
|
{ "TRUE", TRUE },
|
||||||
{ "FALSE", FALSE },
|
{ "FALSE", FALSE },
|
||||||
|
|
||||||
|
/* Builtin units */
|
||||||
|
{ "UNIT-PIXEL", GIMP_UNIT_PIXEL },
|
||||||
|
{ "UNIT-INCH", GIMP_UNIT_INCH },
|
||||||
|
{ "UNIT-MM", GIMP_UNIT_MM },
|
||||||
|
{ "UNIT-POINT", GIMP_UNIT_POINT },
|
||||||
|
{ "UNIT-PICA", GIMP_UNIT_PICA },
|
||||||
|
|
||||||
/* Script-Fu types */
|
/* Script-Fu types */
|
||||||
{ "SF-IMAGE", SF_IMAGE },
|
{ "SF-IMAGE", SF_IMAGE },
|
||||||
{ "SF-DRAWABLE", SF_DRAWABLE },
|
{ "SF-DRAWABLE", SF_DRAWABLE },
|
||||||
@ -372,7 +379,6 @@ init_constants (void)
|
|||||||
const gchar **enum_type_names;
|
const gchar **enum_type_names;
|
||||||
gint n_enum_type_names;
|
gint n_enum_type_names;
|
||||||
gint i;
|
gint i;
|
||||||
GimpUnit unit;
|
|
||||||
pointer symbol;
|
pointer symbol;
|
||||||
|
|
||||||
symbol = sc.vptr->mk_symbol (&sc, "gimp-directory");
|
symbol = sc.vptr->mk_symbol (&sc, "gimp-directory");
|
||||||
@ -430,32 +436,13 @@ init_constants (void)
|
|||||||
g_type_class_unref (enum_class);
|
g_type_class_unref (enum_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unit = GIMP_UNIT_PIXEL;
|
|
||||||
unit < gimp_unit_get_number_of_built_in_units ();
|
|
||||||
unit++)
|
|
||||||
{
|
|
||||||
gchar *tmp;
|
|
||||||
gchar *scheme_name;
|
|
||||||
|
|
||||||
/* FIXME: gimp_unit_get_singular() returns a translated string */
|
|
||||||
tmp = g_ascii_strup (gimp_unit_get_singular (unit), -1);
|
|
||||||
scheme_name = g_strconcat ("UNIT-", tmp, NULL);
|
|
||||||
g_free (tmp);
|
|
||||||
|
|
||||||
symbol = sc.vptr->mk_symbol (&sc, scheme_name);
|
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
|
||||||
sc.vptr->mk_integer (&sc, unit));
|
|
||||||
sc.vptr->setimmutable(symbol);
|
|
||||||
|
|
||||||
g_free (scheme_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Constants used in the register block of scripts */
|
/* Constants used in the register block of scripts */
|
||||||
for (i = 0; script_constants[i].name != NULL; ++i)
|
for (i = 0; script_constants[i].name != NULL; ++i)
|
||||||
{
|
{
|
||||||
symbol = sc.vptr->mk_symbol (&sc, script_constants[i].name);
|
symbol = sc.vptr->mk_symbol (&sc, script_constants[i].name);
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
||||||
sc.vptr->mk_integer (&sc, script_constants[i].value));
|
sc.vptr->mk_integer (&sc,
|
||||||
|
script_constants[i].value));
|
||||||
sc.vptr->setimmutable(symbol);
|
sc.vptr->setimmutable(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +472,8 @@ init_constants (void)
|
|||||||
{
|
{
|
||||||
symbol = sc.vptr->mk_symbol (&sc, old_constants[i].name);
|
symbol = sc.vptr->mk_symbol (&sc, old_constants[i].name);
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
||||||
sc.vptr->mk_integer (&sc, old_constants[i].value));
|
sc.vptr->mk_integer (&sc,
|
||||||
|
old_constants[i].value));
|
||||||
sc.vptr->setimmutable(symbol);
|
sc.vptr->setimmutable(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,12 +506,14 @@ init_procedures (void)
|
|||||||
|
|
||||||
symbol = sc.vptr->mk_symbol (&sc, "script-fu-register");
|
symbol = sc.vptr->mk_symbol (&sc, "script-fu-register");
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
||||||
sc.vptr->mk_foreign_func (&sc, script_fu_register_call));
|
sc.vptr->mk_foreign_func (&sc,
|
||||||
|
script_fu_register_call));
|
||||||
sc.vptr->setimmutable(symbol);
|
sc.vptr->setimmutable(symbol);
|
||||||
|
|
||||||
symbol = sc.vptr->mk_symbol (&sc, "script-fu-menu-register");
|
symbol = sc.vptr->mk_symbol (&sc, "script-fu-menu-register");
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
||||||
sc.vptr->mk_foreign_func (&sc, script_fu_menu_register_call));
|
sc.vptr->mk_foreign_func (&sc,
|
||||||
|
script_fu_menu_register_call));
|
||||||
sc.vptr->setimmutable(symbol);
|
sc.vptr->setimmutable(symbol);
|
||||||
|
|
||||||
symbol = sc.vptr->mk_symbol (&sc, "script-fu-quit");
|
symbol = sc.vptr->mk_symbol (&sc, "script-fu-quit");
|
||||||
@ -534,7 +524,8 @@ init_procedures (void)
|
|||||||
/* register the database execution procedure */
|
/* register the database execution procedure */
|
||||||
symbol = sc.vptr->mk_symbol (&sc, "gimp-proc-db-call");
|
symbol = sc.vptr->mk_symbol (&sc, "gimp-proc-db-call");
|
||||||
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
sc.vptr->scheme_define (&sc, sc.global_env, symbol,
|
||||||
sc.vptr->mk_foreign_func (&sc, marshall_proc_db_call));
|
sc.vptr->mk_foreign_func (&sc,
|
||||||
|
marshall_proc_db_call));
|
||||||
sc.vptr->setimmutable(symbol);
|
sc.vptr->setimmutable(symbol);
|
||||||
|
|
||||||
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
gimp_procedural_db_query (".*", ".*", ".*", ".*", ".*", ".*", ".*",
|
||||||
@ -558,14 +549,14 @@ init_procedures (void)
|
|||||||
/* The Scheme statement was suggested by Simon Budig */
|
/* The Scheme statement was suggested by Simon Budig */
|
||||||
if (nparams == 0)
|
if (nparams == 0)
|
||||||
{
|
{
|
||||||
buff = g_strdup_printf (
|
buff = g_strdup_printf (" (define (%s)"
|
||||||
" (define (%s) (gimp-proc-db-call \"%s\"))",
|
" (gimp-proc-db-call \"%s\"))",
|
||||||
proc_list[i], proc_list[i]);
|
proc_list[i], proc_list[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buff = g_strdup_printf (
|
buff = g_strdup_printf (" (define %s (lambda x"
|
||||||
" (define %s (lambda x (apply gimp-proc-db-call (cons \"%s\" x))))",
|
" (apply gimp-proc-db-call (cons \"%s\" x))))",
|
||||||
proc_list[i], proc_list[i]);
|
proc_list[i], proc_list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,6 +571,7 @@ init_procedures (void)
|
|||||||
g_free (proc_author);
|
g_free (proc_author);
|
||||||
g_free (proc_copyright);
|
g_free (proc_copyright);
|
||||||
g_free (proc_date);
|
g_free (proc_date);
|
||||||
|
|
||||||
gimp_destroy_paramdefs (params, nparams);
|
gimp_destroy_paramdefs (params, nparams);
|
||||||
gimp_destroy_paramdefs (return_vals, nreturn_vals);
|
gimp_destroy_paramdefs (return_vals, nreturn_vals);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user