mirror of https://github.com/GNOME/gimp.git
plug-ins/script-fu/script-fu-interface.[ch]
2006-10-19 Sven Neumann <sven@gimp.org> * plug-ins/script-fu/script-fu-interface.[ch] * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-types.h: don't look at the menu path to see if a script is image-based. Instead check the passed and the expected parameter types. * plug-ins/script-fu/scripts/tileblur.scm: global variables won't work with tiny-scheme.
This commit is contained in:
parent
f2a2afaf5d
commit
c97fc7a7a5
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-10-19 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/script-fu-interface.[ch]
|
||||
* plug-ins/script-fu/script-fu-scripts.c
|
||||
* plug-ins/script-fu/script-fu-types.h: don't look at the menu path
|
||||
to see if a script is image-based. Instead check the passed and the
|
||||
expected parameter types.
|
||||
|
||||
* plug-ins/script-fu/scripts/tileblur.scm: global variables won't
|
||||
work with tiny-scheme.
|
||||
|
||||
2006-10-19 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* plug-ins/script-fu/tinyscheme/scheme.c
|
||||
|
|
|
@ -154,7 +154,8 @@ script_fu_interface_report_cc (const gchar *command)
|
|||
}
|
||||
|
||||
void
|
||||
script_fu_interface (SFScript *script)
|
||||
script_fu_interface (SFScript *script,
|
||||
gint start_arg)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *menu;
|
||||
|
@ -201,6 +202,7 @@ script_fu_interface (SFScript *script)
|
|||
|
||||
/* strip the first part of the menupath if it contains _("/Script-Fu/") */
|
||||
tmp = strstr (gettext (script->menu_path), _("/Script-Fu/"));
|
||||
|
||||
if (tmp)
|
||||
sf_interface->title = g_strdup (tmp + strlen (_("/Script-Fu/")));
|
||||
else
|
||||
|
@ -259,10 +261,7 @@ script_fu_interface (SFScript *script)
|
|||
gtk_widget_show (vbox);
|
||||
|
||||
/* The argument table */
|
||||
if (script->image_based)
|
||||
sf_interface->table = gtk_table_new (script->num_args - 1, 3, FALSE);
|
||||
else
|
||||
sf_interface->table = gtk_table_new (script->num_args + 1, 3, FALSE);
|
||||
sf_interface->table = gtk_table_new (script->num_args - start_arg, 3, FALSE);
|
||||
|
||||
gtk_table_set_col_spacings (GTK_TABLE (sf_interface->table), 6);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (sf_interface->table), 6);
|
||||
|
@ -271,7 +270,7 @@ script_fu_interface (SFScript *script)
|
|||
|
||||
group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
for (i = script->image_based ? 2 : 0; i < script->num_args; i++)
|
||||
for (i = start_arg; i < script->num_args; i++)
|
||||
{
|
||||
GtkWidget *widget = NULL;
|
||||
GtkObject *adj;
|
||||
|
@ -279,15 +278,13 @@ script_fu_interface (SFScript *script)
|
|||
gfloat label_yalign = 0.5;
|
||||
gint *ID_ptr = NULL;
|
||||
gint row = i;
|
||||
gboolean left_align = FALSE;
|
||||
gboolean left_align = FALSE;
|
||||
|
||||
if (script->image_based)
|
||||
row -= 2;
|
||||
row -= start_arg;
|
||||
|
||||
/* we add a colon after the label;
|
||||
some languages want an extra space here */
|
||||
label_text = g_strdup_printf (_("%s:"),
|
||||
gettext (script->arg_labels[i]));
|
||||
label_text = g_strdup_printf (_("%s:"), gettext (script->arg_labels[i]));
|
||||
|
||||
switch (script->arg_types[i])
|
||||
{
|
||||
|
@ -365,39 +362,39 @@ script_fu_interface (SFScript *script)
|
|||
script->arg_values[i].sfa_value);
|
||||
break;
|
||||
|
||||
case SF_TEXT:
|
||||
{
|
||||
GtkWidget *view;
|
||||
GtkTextBuffer *buffer;
|
||||
case SF_TEXT:
|
||||
{
|
||||
GtkWidget *view;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
widget = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_size_request (widget, TEXT_WIDTH, -1);
|
||||
widget = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_set_size_request (widget, TEXT_WIDTH, -1);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (widget), view);
|
||||
gtk_widget_show (view);
|
||||
view = gtk_text_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (widget), view);
|
||||
gtk_widget_show (view);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE);
|
||||
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
script->arg_values[i].sfa_value, -1);
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
script->arg_values[i].sfa_value, -1);
|
||||
|
||||
label_yalign = 0.0;
|
||||
}
|
||||
break;
|
||||
label_yalign = 0.0;
|
||||
}
|
||||
break;
|
||||
|
||||
case SF_ADJUSTMENT:
|
||||
switch (script->arg_defaults[i].sfa_adjustment.type)
|
||||
{
|
||||
case SF_SLIDER:
|
||||
script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *)
|
||||
gimp_scale_entry_new (GTK_TABLE (sf_interface->table),
|
||||
gimp_scale_entry_new (GTK_TABLE (sf_interface->table),
|
||||
0, row,
|
||||
label_text, SLIDER_WIDTH, -1,
|
||||
script->arg_values[i].sfa_adjustment.value,
|
||||
|
@ -898,12 +895,12 @@ script_fu_reset (SFScript *script)
|
|||
case SF_COLOR:
|
||||
gimp_color_button_set_color (GIMP_COLOR_BUTTON (widget),
|
||||
&script->arg_defaults[i].sfa_color);
|
||||
break;
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
|
||||
script->arg_defaults[i].sfa_toggle);
|
||||
break;
|
||||
break;
|
||||
|
||||
case SF_VALUE:
|
||||
case SF_STRING:
|
||||
|
@ -950,7 +947,7 @@ script_fu_reset (SFScript *script)
|
|||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
gimp_pattern_select_button_set_pattern (GIMP_PATTERN_SELECT_BUTTON (widget),
|
||||
gimp_pattern_select_button_set_pattern (GIMP_PATTERN_SELECT_BUTTON (widget),
|
||||
script->arg_defaults[i].sfa_pattern);
|
||||
break;
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
#define __SCRIPT_FU_INTERFACE_H__
|
||||
|
||||
|
||||
void script_fu_interface (SFScript *script);
|
||||
void script_fu_interface (SFScript *script,
|
||||
gint start_arg);
|
||||
void script_fu_interface_report_cc (const gchar *command);
|
||||
gboolean script_fu_interface_is_active (void);
|
||||
|
||||
|
|
|
@ -167,10 +167,6 @@ script_fu_add_script (scheme *sc, pointer a)
|
|||
/* Find the script menu_path */
|
||||
val = sc->vptr->string_value (sc->vptr->pair_car (a));
|
||||
script->menu_path = g_strdup (val);
|
||||
if (strncmp (script->menu_path, "<Image>", 7) == 0)
|
||||
script->image_based = TRUE;
|
||||
else
|
||||
script->image_based = FALSE;
|
||||
a = sc->vptr->pair_cdr (a);
|
||||
|
||||
/* Find the script blurb */
|
||||
|
@ -765,7 +761,7 @@ script_fu_script_proc (const gchar *name,
|
|||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
GimpRunMode run_mode;
|
||||
SFScript *script;
|
||||
gint min_args;
|
||||
gint min_args = 0;
|
||||
|
||||
run_mode = params[0].data.d_int32;
|
||||
|
||||
|
@ -782,26 +778,25 @@ script_fu_script_proc (const gchar *name,
|
|||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Determine whether the script is image based (runs on an image).
|
||||
* When being called from an image, nparams is 3, otherwise it's 1.
|
||||
*/
|
||||
if (nparams == 3 && script->num_args >= 2)
|
||||
if (nparams > 1 && params[1].type == GIMP_PDB_IMAGE &&
|
||||
script->num_args > 0 && script->arg_types[0] == SF_IMAGE)
|
||||
{
|
||||
script->arg_values[0].sfa_image = params[1].data.d_image;
|
||||
script->arg_values[1].sfa_drawable = params[2].data.d_drawable;
|
||||
script->image_based = TRUE;
|
||||
script->arg_values[0].sfa_image = params[1].data.d_image;
|
||||
min_args++;
|
||||
}
|
||||
else
|
||||
|
||||
if (nparams > 2 && params[2].type == GIMP_PDB_DRAWABLE &&
|
||||
script->num_args > 1 && script->arg_types[1] == SF_DRAWABLE)
|
||||
{
|
||||
script->image_based = FALSE;
|
||||
script->arg_values[1].sfa_drawable = params[2].data.d_drawable;
|
||||
min_args++;
|
||||
}
|
||||
|
||||
/* First acquire information with a dialog */
|
||||
/* Skip this part if the script takes no parameters */
|
||||
min_args = (script->image_based) ? 2 : 0;
|
||||
if (script->num_args > min_args)
|
||||
{
|
||||
script_fu_interface (script);
|
||||
script_fu_interface (script, min_args);
|
||||
break;
|
||||
}
|
||||
/* else fallthrough */
|
||||
|
|
|
@ -94,7 +94,6 @@ typedef struct
|
|||
gchar **arg_labels;
|
||||
SFArgValue *arg_defaults;
|
||||
SFArgValue *arg_values;
|
||||
gboolean image_based;
|
||||
GimpParamDef *args; /* used only temporary until installed */
|
||||
} SFScript;
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
(define (script-fu-tile-blur inImage inLayer inRadius inVert inHoriz inType)
|
||||
|
||||
(define (cjg-pasteat xoff yoff)
|
||||
(let ( (theFloat (car (gimp-edit-paste theLayer 0))) )
|
||||
(gimp-layer-set-offsets theFloat (* xoff theWidth) (* yoff theHeight) )
|
||||
(define (tile-blur-paste-at layer width height xoff yoff)
|
||||
(let ( (theFloat (car (gimp-edit-paste layer 0))) )
|
||||
(gimp-layer-set-offsets theFloat (* xoff width) (* yoff height) )
|
||||
(gimp-floating-sel-anchor theFloat)
|
||||
)
|
||||
)
|
||||
|
@ -41,9 +41,15 @@
|
|||
(gimp-selection-none theImage)
|
||||
(gimp-layer-set-offsets theLayer theWidth theHeight)
|
||||
|
||||
(cjg-pasteat 1 1) (cjg-pasteat 1 2) (cjg-pasteat 1 3)
|
||||
(cjg-pasteat 2 1) (cjg-pasteat 2 2) (cjg-pasteat 2 3)
|
||||
(cjg-pasteat 3 1) (cjg-pasteat 3 2) (cjg-pasteat 3 3)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 1 1)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 1 2)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 1 3)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 2 1)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 2 2)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 2 3)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 3 1)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 3 2)
|
||||
(tile-blur-paste-at theLayer theWidth theHeight 3 3)
|
||||
|
||||
(gimp-selection-none theImage)
|
||||
(if (= inType 0)
|
||||
|
|
Loading…
Reference in New Issue