Commit 0c686e02 authored by Sven Neumann's avatar Sven Neumann
Browse files

The scripf-fu dialog now remembers your last settings and has a

"Reset to Defaults" button. Still no font-selector though, might be the
next thing I add ...


--Sven
parent 99d563c7
Sun Aug 9 14:15:42 MEST 1998 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-scripts.c: The scripf-fu dialog
now remembers your last settings and has a "Reset to Defaults"
button.
1998-08-07 Raja R Harinath <harinath@cs.umn.edu> 1998-08-07 Raja R Harinath <harinath@cs.umn.edu>
* plug-ins/script-fu/Makefile.am (INCLUDES): * plug-ins/script-fu/Makefile.am (INCLUDES):
......
...@@ -66,7 +66,6 @@ typedef union ...@@ -66,7 +66,6 @@ typedef union
SFColor sfa_color; SFColor sfa_color;
gint32 sfa_toggle; gint32 sfa_toggle;
gchar * sfa_value; gchar * sfa_value;
gchar * sfa_string;
SFAdjustment sfa_adjustment; SFAdjustment sfa_adjustment;
} SFArgValue; } SFArgValue;
...@@ -121,6 +120,8 @@ static void script_fu_ok_callback (GtkWidget *widget, ...@@ -121,6 +120,8 @@ static void script_fu_ok_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void script_fu_close_callback (GtkWidget *widget, static void script_fu_close_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void script_fu_reset_callback (GtkWidget *widget,
gpointer data);
static void script_fu_menu_callback (gint32 id, static void script_fu_menu_callback (gint32 id,
gpointer data); gpointer data);
static void script_fu_toggle_update (GtkWidget *widget, static void script_fu_toggle_update (GtkWidget *widget,
...@@ -462,6 +463,7 @@ script_fu_add_script (LISP a) ...@@ -462,6 +463,7 @@ script_fu_add_script (LISP a)
if (!TYPEP (car (a), tc_string)) if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: value defaults must be string values", NIL); return my_err ("script-fu-register: value defaults must be string values", NIL);
script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a))); script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a)));
script->arg_values[i].sfa_value = g_strdup (script->arg_defaults[i].sfa_value);
args[i + 1].type = PARAM_STRING; args[i + 1].type = PARAM_STRING;
args[i + 1].name = "value"; args[i + 1].name = "value";
...@@ -471,7 +473,8 @@ script_fu_add_script (LISP a) ...@@ -471,7 +473,8 @@ script_fu_add_script (LISP a)
case SF_STRING: case SF_STRING:
if (!TYPEP (car (a), tc_string)) if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: string defaults must be string values", NIL); return my_err ("script-fu-register: string defaults must be string values", NIL);
script->arg_defaults[i].sfa_string = g_strdup (get_c_string (car (a))); script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a)));
script->arg_values[i].sfa_value = g_strdup (script->arg_defaults[i].sfa_value);
args[i + 1].type = PARAM_STRING; args[i + 1].type = PARAM_STRING;
args[i + 1].name = "string"; args[i + 1].name = "string";
...@@ -773,10 +776,9 @@ script_fu_free_script (SFScript *script) ...@@ -773,10 +776,9 @@ script_fu_free_script (SFScript *script)
case SF_COLOR: case SF_COLOR:
break; break;
case SF_VALUE: case SF_VALUE:
case SF_STRING:
g_free (script->arg_defaults[i].sfa_value); g_free (script->arg_defaults[i].sfa_value);
break; g_free (script->arg_values[i].sfa_value);
case SF_STRING:
g_free (script->arg_defaults[i].sfa_string);
break; break;
case SF_ADJUSTMENT: case SF_ADJUSTMENT:
break; break;
...@@ -891,7 +893,7 @@ script_fu_interface (SFScript *script) ...@@ -891,7 +893,7 @@ script_fu_interface (SFScript *script)
gtk_widget_show (label); gtk_widget_show (label);
/* The argument table */ /* The argument table */
table = gtk_table_new (script->num_args, 2, FALSE); table = gtk_table_new (script->num_args + 1, 2, FALSE);
gtk_container_border_width (GTK_CONTAINER (table), 4); gtk_container_border_width (GTK_CONTAINER (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
...@@ -919,22 +921,22 @@ script_fu_interface (SFScript *script) ...@@ -919,22 +921,22 @@ script_fu_interface (SFScript *script)
case SF_IMAGE: case SF_IMAGE:
menu = gimp_image_menu_new (NULL, script_fu_menu_callback, menu = gimp_image_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_image, &script->arg_values[i].sfa_image,
script->arg_defaults[i].sfa_image); script->arg_values[i].sfa_image);
break; break;
case SF_DRAWABLE: case SF_DRAWABLE:
menu = gimp_drawable_menu_new (NULL, script_fu_menu_callback, menu = gimp_drawable_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_drawable, &script->arg_values[i].sfa_drawable,
script->arg_defaults[i].sfa_drawable); script->arg_values[i].sfa_drawable);
break; break;
case SF_LAYER: case SF_LAYER:
menu = gimp_layer_menu_new (NULL, script_fu_menu_callback, menu = gimp_layer_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_layer, &script->arg_values[i].sfa_layer,
script->arg_defaults[i].sfa_layer); script->arg_values[i].sfa_layer);
break; break;
case SF_CHANNEL: case SF_CHANNEL:
menu = gimp_channel_menu_new (NULL, script_fu_menu_callback, menu = gimp_channel_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_channel, &script->arg_values[i].sfa_channel,
script->arg_defaults[i].sfa_channel); script->arg_values[i].sfa_channel);
break; break;
default: default:
menu = NULL; menu = NULL;
...@@ -946,7 +948,7 @@ script_fu_interface (SFScript *script) ...@@ -946,7 +948,7 @@ script_fu_interface (SFScript *script)
case SF_COLOR: case SF_COLOR:
script->args_widgets[i] = gtk_button_new(); script->args_widgets[i] = gtk_button_new();
script->arg_values[i].sfa_color.preview = gtk_preview_new(GTK_PREVIEW_COLOR); script->arg_values[i].sfa_color.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview), gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview),
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT); COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT);
gtk_container_add (GTK_CONTAINER (script->args_widgets[i]), gtk_container_add (GTK_CONTAINER (script->args_widgets[i]),
...@@ -972,17 +974,11 @@ script_fu_interface (SFScript *script) ...@@ -972,17 +974,11 @@ script_fu_interface (SFScript *script)
break; break;
case SF_VALUE: case SF_VALUE:
script->args_widgets[i] = gtk_entry_new ();
gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0);
gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]),
script->arg_defaults[i].sfa_value);
break;
case SF_STRING: case SF_STRING:
script->args_widgets[i] = gtk_entry_new (); script->args_widgets[i] = gtk_entry_new ();
gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0); gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0);
gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]), gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]),
script->arg_defaults[i].sfa_string); script->arg_values[i].sfa_value);
break; break;
case SF_ADJUSTMENT: case SF_ADJUSTMENT:
...@@ -1022,20 +1018,34 @@ script_fu_interface (SFScript *script) ...@@ -1022,20 +1018,34 @@ script_fu_interface (SFScript *script)
break; break;
} }
hbox = gtk_hbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), script->args_widgets[i], gtk_box_pack_start (GTK_BOX (hbox), script->args_widgets[i],
((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), ((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)),
((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), 0); ((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), 0);
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_table_attach (GTK_TABLE (table), hbox, /* script->args_widgets[i], */ gtk_table_attach (GTK_TABLE (table), hbox, /* script->args_widgets[i], */
1, 2, i, i + 1, 1, 2, i, i + 1,
GTK_FILL | ((script->arg_types[i] == SF_VALUE) ? GTK_FILL | (((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING))
GTK_EXPAND : 0), ? GTK_EXPAND : 0),
GTK_FILL, 4, 2); GTK_FILL, 4, 2);
gtk_widget_show (script->args_widgets[i]); gtk_widget_show (script->args_widgets[i]);
} }
gtk_widget_show (table); gtk_widget_show (table);
/* Reset to defaults */
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox), 4);
button = gtk_button_new_with_label (" Reset to Defaults ");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) script_fu_reset_callback,
NULL);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
gtk_widget_show (hbox);
/* Action area */ /* Action area */
hbox = gtk_hbox_new (0, 2); hbox = gtk_hbox_new (0, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
...@@ -1188,9 +1198,13 @@ script_fu_ok_callback (GtkWidget *widget, ...@@ -1188,9 +1198,13 @@ script_fu_ok_callback (GtkWidget *widget,
break; break;
case SF_VALUE: case SF_VALUE:
text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i])); text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i]));
g_free (script->arg_values[i].sfa_value);
script->arg_values[i].sfa_value = g_strdup (text);
break; break;
case SF_STRING: case SF_STRING:
text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i])); text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i]));
g_free (script->arg_values[i].sfa_value);
script->arg_values[i].sfa_value = g_strdup (text);
g_snprintf (buffer, MAX_STRING_LENGTH, "\"%s\"", text); g_snprintf (buffer, MAX_STRING_LENGTH, "\"%s\"", text);
text = buffer; text = buffer;
break; break;
...@@ -1198,13 +1212,13 @@ script_fu_ok_callback (GtkWidget *widget, ...@@ -1198,13 +1212,13 @@ script_fu_ok_callback (GtkWidget *widget,
switch (script->arg_defaults[i].sfa_adjustment.type) switch (script->arg_defaults[i].sfa_adjustment.type)
{ {
case SF_SLIDER: case SF_SLIDER:
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.adj->value); script->arg_values[i].sfa_adjustment.value = script->arg_values[i].sfa_adjustment.adj->value;
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value);
text = buffer; text = buffer;
break; break;
case SF_SPINNER: case SF_SPINNER:
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (script->args_widgets[i]));
gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (script->args_widgets[i]))); g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value); text = buffer;
text = buffer;
break; break;
default: default:
break; break;
...@@ -1248,6 +1262,55 @@ script_fu_close_callback (GtkWidget *widget, ...@@ -1248,6 +1262,55 @@ script_fu_close_callback (GtkWidget *widget,
gtk_main_quit (); gtk_main_quit ();
} }
static void
script_fu_reset_callback (GtkWidget *widget,
gpointer data)
{
SFScript *script;
int i,j;
if ((script = sf_interface.script) == NULL)
return;
for (i = 0; i < script->num_args; i++)
switch (script->arg_types[i])
{
case SF_IMAGE:
case SF_DRAWABLE:
case SF_LAYER:
case SF_CHANNEL:
break;
case SF_COLOR:
for (j = 0; j < 4; j++)
{
script->arg_values[i].sfa_color.color[j] = script->arg_defaults[i].sfa_color.color[j];
}
script_fu_color_preview (script->arg_values[i].sfa_color.preview,
script->arg_values[i].sfa_color.color);
break;
case SF_TOGGLE:
script->arg_values[i].sfa_toggle = script->arg_defaults[i].sfa_toggle;
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (script->args_widgets[i]),
script->arg_values[i].sfa_toggle);
break;
case SF_VALUE:
case SF_STRING:
g_free (script->arg_values[i].sfa_value);
script->arg_values[i].sfa_value = g_strdup (script->arg_defaults[i].sfa_value);
gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]),
script->arg_values[i].sfa_value);
break;
case SF_ADJUSTMENT:
script->arg_values[i].sfa_adjustment.value = script->arg_defaults[i].sfa_adjustment.value;
gtk_adjustment_set_value (script->arg_values[i].sfa_adjustment.adj,
script->arg_values[i].sfa_adjustment.value);
break;
default:
break;
}
}
static void static void
script_fu_menu_callback (gint32 id, script_fu_menu_callback (gint32 id,
gpointer data) gpointer data)
......
...@@ -66,7 +66,6 @@ typedef union ...@@ -66,7 +66,6 @@ typedef union
SFColor sfa_color; SFColor sfa_color;
gint32 sfa_toggle; gint32 sfa_toggle;
gchar * sfa_value; gchar * sfa_value;
gchar * sfa_string;
SFAdjustment sfa_adjustment; SFAdjustment sfa_adjustment;
} SFArgValue; } SFArgValue;
...@@ -121,6 +120,8 @@ static void script_fu_ok_callback (GtkWidget *widget, ...@@ -121,6 +120,8 @@ static void script_fu_ok_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void script_fu_close_callback (GtkWidget *widget, static void script_fu_close_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void script_fu_reset_callback (GtkWidget *widget,
gpointer data);
static void script_fu_menu_callback (gint32 id, static void script_fu_menu_callback (gint32 id,
gpointer data); gpointer data);
static void script_fu_toggle_update (GtkWidget *widget, static void script_fu_toggle_update (GtkWidget *widget,
...@@ -462,6 +463,7 @@ script_fu_add_script (LISP a) ...@@ -462,6 +463,7 @@ script_fu_add_script (LISP a)
if (!TYPEP (car (a), tc_string)) if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: value defaults must be string values", NIL); return my_err ("script-fu-register: value defaults must be string values", NIL);
script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a))); script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a)));
script->arg_values[i].sfa_value = g_strdup (script->arg_defaults[i].sfa_value);
args[i + 1].type = PARAM_STRING; args[i + 1].type = PARAM_STRING;
args[i + 1].name = "value"; args[i + 1].name = "value";
...@@ -471,7 +473,8 @@ script_fu_add_script (LISP a) ...@@ -471,7 +473,8 @@ script_fu_add_script (LISP a)
case SF_STRING: case SF_STRING:
if (!TYPEP (car (a), tc_string)) if (!TYPEP (car (a), tc_string))
return my_err ("script-fu-register: string defaults must be string values", NIL); return my_err ("script-fu-register: string defaults must be string values", NIL);
script->arg_defaults[i].sfa_string = g_strdup (get_c_string (car (a))); script->arg_defaults[i].sfa_value = g_strdup (get_c_string (car (a)));
script->arg_values[i].sfa_value = g_strdup (script->arg_defaults[i].sfa_value);
args[i + 1].type = PARAM_STRING; args[i + 1].type = PARAM_STRING;
args[i + 1].name = "string"; args[i + 1].name = "string";
...@@ -773,10 +776,9 @@ script_fu_free_script (SFScript *script) ...@@ -773,10 +776,9 @@ script_fu_free_script (SFScript *script)
case SF_COLOR: case SF_COLOR:
break; break;
case SF_VALUE: case SF_VALUE:
case SF_STRING:
g_free (script->arg_defaults[i].sfa_value); g_free (script->arg_defaults[i].sfa_value);
break; g_free (script->arg_values[i].sfa_value);
case SF_STRING:
g_free (script->arg_defaults[i].sfa_string);
break; break;
case SF_ADJUSTMENT: case SF_ADJUSTMENT:
break; break;
...@@ -891,7 +893,7 @@ script_fu_interface (SFScript *script) ...@@ -891,7 +893,7 @@ script_fu_interface (SFScript *script)
gtk_widget_show (label); gtk_widget_show (label);
/* The argument table */ /* The argument table */
table = gtk_table_new (script->num_args, 2, FALSE); table = gtk_table_new (script->num_args + 1, 2, FALSE);
gtk_container_border_width (GTK_CONTAINER (table), 4); gtk_container_border_width (GTK_CONTAINER (table), 4);
gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);
...@@ -919,22 +921,22 @@ script_fu_interface (SFScript *script) ...@@ -919,22 +921,22 @@ script_fu_interface (SFScript *script)
case SF_IMAGE: case SF_IMAGE:
menu = gimp_image_menu_new (NULL, script_fu_menu_callback, menu = gimp_image_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_image, &script->arg_values[i].sfa_image,
script->arg_defaults[i].sfa_image); script->arg_values[i].sfa_image);
break; break;
case SF_DRAWABLE: case SF_DRAWABLE:
menu = gimp_drawable_menu_new (NULL, script_fu_menu_callback, menu = gimp_drawable_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_drawable, &script->arg_values[i].sfa_drawable,
script->arg_defaults[i].sfa_drawable); script->arg_values[i].sfa_drawable);
break; break;
case SF_LAYER: case SF_LAYER:
menu = gimp_layer_menu_new (NULL, script_fu_menu_callback, menu = gimp_layer_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_layer, &script->arg_values[i].sfa_layer,
script->arg_defaults[i].sfa_layer); script->arg_values[i].sfa_layer);
break; break;
case SF_CHANNEL: case SF_CHANNEL:
menu = gimp_channel_menu_new (NULL, script_fu_menu_callback, menu = gimp_channel_menu_new (NULL, script_fu_menu_callback,
&script->arg_values[i].sfa_channel, &script->arg_values[i].sfa_channel,
script->arg_defaults[i].sfa_channel); script->arg_values[i].sfa_channel);
break; break;
default: default:
menu = NULL; menu = NULL;
...@@ -946,7 +948,7 @@ script_fu_interface (SFScript *script) ...@@ -946,7 +948,7 @@ script_fu_interface (SFScript *script)
case SF_COLOR: case SF_COLOR:
script->args_widgets[i] = gtk_button_new(); script->args_widgets[i] = gtk_button_new();
script->arg_values[i].sfa_color.preview = gtk_preview_new(GTK_PREVIEW_COLOR); script->arg_values[i].sfa_color.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview), gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview),
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT); COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT);
gtk_container_add (GTK_CONTAINER (script->args_widgets[i]), gtk_container_add (GTK_CONTAINER (script->args_widgets[i]),
...@@ -972,17 +974,11 @@ script_fu_interface (SFScript *script) ...@@ -972,17 +974,11 @@ script_fu_interface (SFScript *script)
break; break;
case SF_VALUE: case SF_VALUE:
script->args_widgets[i] = gtk_entry_new ();
gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0);
gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]),
script->arg_defaults[i].sfa_value);
break;
case SF_STRING: case SF_STRING:
script->args_widgets[i] = gtk_entry_new (); script->args_widgets[i] = gtk_entry_new ();
gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0); gtk_widget_set_usize (script->args_widgets[i], TEXT_WIDTH, 0);
gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]), gtk_entry_set_text (GTK_ENTRY (script->args_widgets[i]),
script->arg_defaults[i].sfa_string); script->arg_values[i].sfa_value);
break; break;
case SF_ADJUSTMENT: case SF_ADJUSTMENT:
...@@ -1022,20 +1018,34 @@ script_fu_interface (SFScript *script) ...@@ -1022,20 +1018,34 @@ script_fu_interface (SFScript *script)
break; break;
} }
hbox = gtk_hbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX(hbox), script->args_widgets[i], gtk_box_pack_start (GTK_BOX (hbox), script->args_widgets[i],
((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), ((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)),
((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), 0); ((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING)), 0);
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_table_attach (GTK_TABLE (table), hbox, /* script->args_widgets[i], */ gtk_table_attach (GTK_TABLE (table), hbox, /* script->args_widgets[i], */
1, 2, i, i + 1, 1, 2, i, i + 1,
GTK_FILL | ((script->arg_types[i] == SF_VALUE) ? GTK_FILL | (((script->arg_types[i] == SF_VALUE) || (script->arg_types[i] == SF_STRING))
GTK_EXPAND : 0), ? GTK_EXPAND : 0),
GTK_FILL, 4, 2); GTK_FILL, 4, 2);
gtk_widget_show (script->args_widgets[i]); gtk_widget_show (script->args_widgets[i]);
} }
gtk_widget_show (table); gtk_widget_show (table);
/* Reset to defaults */
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox), 4);
button = gtk_button_new_with_label (" Reset to Defaults ");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) script_fu_reset_callback,
NULL);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
gtk_widget_show (hbox);
/* Action area */ /* Action area */
hbox = gtk_hbox_new (0, 2); hbox = gtk_hbox_new (0, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
...@@ -1188,9 +1198,13 @@ script_fu_ok_callback (GtkWidget *widget, ...@@ -1188,9 +1198,13 @@ script_fu_ok_callback (GtkWidget *widget,
break; break;
case SF_VALUE: case SF_VALUE:
text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i])); text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i]));
g_free (script->arg_values[i].sfa_value);
script->arg_values[i].sfa_value = g_strdup (text);
break; break;
case SF_STRING: case SF_STRING:
text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i])); text = gtk_entry_get_text (GTK_ENTRY (script->args_widgets[i]));
g_free (script->arg_values[i].sfa_value);
script->arg_values[i].sfa_value = g_strdup (text);
g_snprintf (buffer, MAX_STRING_LENGTH, "\"%s\"", text); g_snprintf (buffer, MAX_STRING_LENGTH, "\"%s\"", text);
text = buffer; text = buffer;
break; break;
...@@ -1198,13 +1212,13 @@ script_fu_ok_callback (GtkWidget *widget, ...@@ -1198,13 +1212,13 @@ script_fu_ok_callback (GtkWidget *widget,
switch (script->arg_defaults[i].sfa_adjustment.type) switch (script->arg_defaults[i].sfa_adjustment.type)
{ {
case SF_SLIDER: case SF_SLIDER:
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.adj->value); script->arg_values[i].sfa_adjustment.value = script->arg_values[i].sfa_adjustment.adj->value;
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value);
text = buffer; text = buffer;
break; break;
case SF_SPINNER: case SF_SPINNER:
g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (script->args_widgets[i]));
gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (script->args_widgets[i]))); g_snprintf (buffer, 24, "%f", script->arg_values[i].sfa_adjustment.value); text = buffer;
text = buffer;
break; break;
default: default:
break;