Brought the PDB progress into a working state. Fixes bug #6010, addressed

2004-08-30  Michael Natterer  <mitch@gimp.org>

	Brought the PDB progress into a working state. Fixes bug #6010,
	addressed bugs #97266 and #135185 and unfortunately reopens bug
	#150194 (will fix that later).

	* libgimpbase/gimpbaseenums.h: added enum GimpProgressCommand.

	* app/core/gimppdbprogress.c
	* libgimp/gimpprogress.c: use the enum instead of integer
	constants for the different progress commands. Cleanup.

	* app/plug-in/plug-in-progress.c
	* app/plug-in/plug-in-run.c
	* app/plug-in/plug-in.c: switch bach to real refcouting for
	plug_in->progress (reopens bug #150194) and enabled the PDB
	progress code.

	* plug-ins/script-fu/script-fu-scripts.c: cleaned up the
	progress stuff and the script-fu interface a bit.

	* plug-ins/pygimp/gimpenums.py
	* plug-ins/script-fu/script-fu-constants.c
	* tools/pdbgen/enums.pl: regenerated.
This commit is contained in:
Michael Natterer 2004-08-30 14:57:24 +00:00 committed by Michael Natterer
parent 1c4395c5c7
commit 509b88e815
16 changed files with 237 additions and 157 deletions

View File

@ -1,3 +1,28 @@
2004-08-30 Michael Natterer <mitch@gimp.org>
Brought the PDB progress into a working state. Fixes bug #6010,
addressed bugs #97266 and #135185 and unfortunately reopens bug
#150194 (will fix that later).
* libgimpbase/gimpbaseenums.h: added enum GimpProgressCommand.
* app/core/gimppdbprogress.c
* libgimp/gimpprogress.c: use the enum instead of integer
constants for the different progress commands. Cleanup.
* app/plug-in/plug-in-progress.c
* app/plug-in/plug-in-run.c
* app/plug-in/plug-in.c: switch bach to real refcouting for
plug_in->progress (reopens bug #150194) and enabled the PDB
progress code.
* plug-ins/script-fu/script-fu-scripts.c: cleaned up the
progress stuff and the script-fu interface a bit.
* plug-ins/pygimp/gimpenums.py
* plug-ins/script-fu/script-fu-constants.c
* tools/pdbgen/enums.pl: regenerated.
2004-08-29 Manish Singh <yosh@gimp.org>
* app/plug-in/plug-in.c (plug_in_open): set can_recurse on the

View File

@ -232,10 +232,10 @@ gimp_pdb_progress_set_property (GObject *object,
}
static void
gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
gint command,
const gchar *text,
gdouble value)
gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
GimpProgressCommand command,
const gchar *text,
gdouble value)
{
if (! progress->callback_busy)
{
@ -244,9 +244,6 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
progress->callback_busy = TRUE;
g_print ("%s: command = %d, text = %s, value = %f\n",
G_STRFUNC, command, text, value);
return_vals = procedural_db_run_proc (progress->context->gimp,
progress->context,
NULL,
@ -268,8 +265,6 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
if (return_vals)
procedural_db_destroy_args (return_vals, n_return_vals);
g_print ("%s: callback finished\n", G_STRFUNC);
progress->callback_busy = FALSE;
}
}
@ -283,7 +278,9 @@ gimp_pdb_progress_progress_start (GimpProgress *progress,
if (! pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress, 0, message, 0.0);
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_START,
message, 0.0);
pdb_progress->active = TRUE;
pdb_progress->value = 0.0;
@ -301,7 +298,9 @@ gimp_pdb_progress_progress_end (GimpProgress *progress)
if (pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress, 1, NULL, 0.0);
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_END,
NULL, 0.0);
pdb_progress->active = FALSE;
pdb_progress->value = 0.0;
@ -323,7 +322,9 @@ gimp_pdb_progress_progress_set_text (GimpProgress *progress,
GimpPdbProgress *pdb_progress = GIMP_PDB_PROGRESS (progress);
if (pdb_progress->active)
gimp_pdb_progress_run_callback (pdb_progress, 2, message, 0.0);
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_SET_TEXT,
message, 0.0);
}
static void
@ -334,7 +335,9 @@ gimp_pdb_progress_progress_set_value (GimpProgress *progress,
if (pdb_progress->active)
{
gimp_pdb_progress_run_callback (pdb_progress, 3, NULL, percentage);
gimp_pdb_progress_run_callback (pdb_progress,
GIMP_PROGRESS_COMMAND_SET_VALUE,
NULL, percentage);
pdb_progress->value = percentage;
}
}

View File

@ -53,14 +53,12 @@ plug_in_progress_start (PlugIn *plug_in,
if (! plug_in->progress)
{
plug_in->progress = gimp_new_progress (plug_in->gimp, display_ID);
plug_in->progress_cancel_id = 0;
if (plug_in->progress)
{
plug_in->progress_created = TRUE;
g_object_add_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_ref (plug_in->progress);
}
}
@ -121,6 +119,7 @@ plug_in_progress_end (PlugIn *plug_in)
if (plug_in->progress_created)
{
gimp_free_progress (plug_in->gimp, plug_in->progress);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
}
@ -133,25 +132,21 @@ plug_in_progress_install (PlugIn *plug_in,
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
#if 0
if (plug_in->progress)
{
plug_in_progress_end (plug_in);
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
g_object_unref (plug_in->progress);
else
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
plug_in->progress = NULL;
if (plug_in->progress)
{
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
}
plug_in->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", plug_in->context,
"callback-name", progress_callback,
NULL);
#endif
}
void
@ -161,14 +156,12 @@ plug_in_progress_uninstall (PlugIn *plug_in,
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
#if 0
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
{
plug_in_progress_end (plug_in);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
#endif
}
void

View File

@ -318,8 +318,7 @@ plug_in_unref (PlugIn *plug_in)
plug_in_progress_end (plug_in);
if (plug_in->progress)
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_unref (plug_in->progress);
g_object_unref (plug_in->context);
@ -621,8 +620,7 @@ plug_in_close (PlugIn *plug_in,
if (plug_in->progress)
{
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}

View File

@ -101,12 +101,7 @@ plug_in_run (Gimp *gimp,
}
if (progress)
{
plug_in->progress = progress;
g_object_add_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
}
plug_in->progress = g_object_ref (progress);
config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH;

View File

@ -101,12 +101,7 @@ plug_in_run (Gimp *gimp,
}
if (progress)
{
plug_in->progress = progress;
g_object_add_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
}
plug_in->progress = g_object_ref (progress);
config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH;

View File

@ -53,14 +53,12 @@ plug_in_progress_start (PlugIn *plug_in,
if (! plug_in->progress)
{
plug_in->progress = gimp_new_progress (plug_in->gimp, display_ID);
plug_in->progress_cancel_id = 0;
if (plug_in->progress)
{
plug_in->progress_created = TRUE;
g_object_add_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_ref (plug_in->progress);
}
}
@ -121,6 +119,7 @@ plug_in_progress_end (PlugIn *plug_in)
if (plug_in->progress_created)
{
gimp_free_progress (plug_in->gimp, plug_in->progress);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
}
@ -133,25 +132,21 @@ plug_in_progress_install (PlugIn *plug_in,
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
#if 0
if (plug_in->progress)
{
plug_in_progress_end (plug_in);
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
g_object_unref (plug_in->progress);
else
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
plug_in->progress = NULL;
if (plug_in->progress)
{
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
}
plug_in->progress = g_object_new (GIMP_TYPE_PDB_PROGRESS,
"context", plug_in->context,
"callback-name", progress_callback,
NULL);
#endif
}
void
@ -161,14 +156,12 @@ plug_in_progress_uninstall (PlugIn *plug_in,
g_return_if_fail (plug_in != NULL);
g_return_if_fail (progress_callback != NULL);
#if 0
if (GIMP_IS_PDB_PROGRESS (plug_in->progress))
{
plug_in_progress_end (plug_in);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}
#endif
}
void

View File

@ -101,12 +101,7 @@ plug_in_run (Gimp *gimp,
}
if (progress)
{
plug_in->progress = progress;
g_object_add_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
}
plug_in->progress = g_object_ref (progress);
config.version = GIMP_PROTOCOL_VERSION;
config.tile_width = TILE_WIDTH;

View File

@ -318,8 +318,7 @@ plug_in_unref (PlugIn *plug_in)
plug_in_progress_end (plug_in);
if (plug_in->progress)
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_unref (plug_in->progress);
g_object_unref (plug_in->context);
@ -621,8 +620,7 @@ plug_in_close (PlugIn *plug_in,
if (plug_in->progress)
{
g_object_remove_weak_pointer (G_OBJECT (plug_in->progress),
(gpointer *) &plug_in->progress);
g_object_unref (plug_in->progress);
plug_in->progress = NULL;
}

View File

@ -29,9 +29,6 @@ typedef struct _GimpProgressData GimpProgressData;
struct _GimpProgressData
{
gchar *progress_callback;
#if 0
guint idle_id;
#endif
GimpProgressStartCallback start_callback;
GimpProgressEndCallback end_callback;
GimpProgressTextCallback text_callback;
@ -142,11 +139,6 @@ gimp_progress_uninstall (const gchar *progress_callback)
return;
}
#if 0
if (progress_data->idle_id)
g_source_remove (progress_data->idle_id);
#endif
_gimp_progress_uninstall (progress_callback);
gimp_uninstall_temp_proc (progress_callback);
@ -174,37 +166,26 @@ gimp_temp_progress_run (const gchar *name,
}
else
{
#if 0
if (! progress_data->idle_id)
progress_data->idle_id =
g_idle_add ((GSourceFunc) gimp_temp_progress_run_idle,
progress_data);
#endif
GimpProgressCommand command = param[0].data.d_int32;
g_print ("%s: command = %d, text = %s, value = %f\n",
G_STRFUNC,
param[0].data.d_int32,
param[1].data.d_string,
param[2].data.d_float);
switch (param[0].data.d_int32)
switch (command)
{
case 0:
case GIMP_PROGRESS_COMMAND_START:
progress_data->start_callback (param[1].data.d_string,
param[2].data.d_float != 0.0,
progress_data->data);
break;
case 1:
case GIMP_PROGRESS_COMMAND_END:
progress_data->end_callback (progress_data->data);
break;
case 2:
case GIMP_PROGRESS_COMMAND_SET_TEXT:
progress_data->text_callback (param[1].data.d_string,
progress_data->data);
break;
case 3:
case GIMP_PROGRESS_COMMAND_SET_VALUE:
progress_data->value_callback (param[2].data.d_float,
progress_data->data);
break;
@ -215,38 +196,9 @@ gimp_temp_progress_run (const gchar *name,
}
}
g_print ("%s: callback finished\n", G_STRFUNC);
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
}
#if 0
static gboolean
gimp_temp_progress_run_idle (GimpProgressData *progress_data)
{
progress_data->idle_id = 0;
if (progress_data->callback)
progress_data->callback (progress_data->progress_name,
progress_data->closing,
progress_data->data);
if (progress_data->closing)
{
gchar *progress_callback = progress_data->progress_callback;
progress_data->progress_callback = NULL;
gimp_progress_select_destroy (progress_callback);
}
return FALSE;
}
#endif

View File

@ -133,6 +133,14 @@ typedef enum /*< skip >*/
GIMP_STACK_TRACE_ALWAYS
} GimpStackTraceMode;
typedef enum /*< skip >*/
{
GIMP_PROGRESS_COMMAND_START,
GIMP_PROGRESS_COMMAND_END,
GIMP_PROGRESS_COMMAND_SET_TEXT,
GIMP_PROGRESS_COMMAND_SET_VALUE
} GimpProgressCommand;
G_END_DECLS

View File

@ -257,6 +257,12 @@ PDB_CANCEL = 4
PAINT_CONSTANT = 0
PAINT_INCREMENTAL = 1
# GimpProgressCommand
PROGRESS_COMMAND_START = 0
PROGRESS_COMMAND_END = 1
PROGRESS_COMMAND_SET_TEXT = 2
PROGRESS_COMMAND_SET_VALUE = 3
# GimpRepeatMode
REPEAT_NONE = 0
REPEAT_SAWTOOTH = 1

View File

@ -216,6 +216,11 @@ init_generated_constants (void)
setvar (cintern ("PAINT-CONSTANT"), flocons (0), NIL);
setvar (cintern ("PAINT-INCREMENTAL"), flocons (1), NIL);
setvar (cintern ("PROGRESS-COMMAND-START"), flocons (0), NIL);
setvar (cintern ("PROGRESS-COMMAND-END"), flocons (1), NIL);
setvar (cintern ("PROGRESS-COMMAND-SET-TEXT"), flocons (2), NIL);
setvar (cintern ("PROGRESS-COMMAND-SET-VALUE"), flocons (3), NIL);
setvar (cintern ("REPEAT-NONE"), flocons (0), NIL);
setvar (cintern ("REPEAT-SAWTOOTH"), flocons (1), NIL);
setvar (cintern ("REPEAT-TRIANGULAR"), flocons (2), NIL);

View File

@ -128,11 +128,18 @@ typedef struct
typedef struct
{
GtkWidget *dialog;
GtkWidget **args_widgets;
GtkWidget *status;
GtkWidget *about_dialog;
GtkWidget *args_table;
GtkWidget **args_widgets;
GtkWidget *progress_label;
GtkWidget *progress;
const gchar *progress_callback;
GtkWidget *about_dialog;
gchar *title;
gchar *last_command;
gint command_count;
@ -664,13 +671,13 @@ script_fu_report_cc (gchar *command)
new_command = g_strdup_printf ("%s <%d>",
command, sf_interface->command_count);
gtk_label_set_text (GTK_LABEL (sf_interface->status), new_command);
gtk_label_set_text (GTK_LABEL (sf_interface->progress_label), new_command);
g_free (new_command);
}
else
{
sf_interface->command_count = 1;
gtk_label_set_text (GTK_LABEL (sf_interface->status), command);
gtk_label_set_text (GTK_LABEL (sf_interface->progress_label), command);
g_free (sf_interface->last_command);
sf_interface->last_command = g_strdup (command);
}
@ -806,7 +813,8 @@ script_fu_script_proc (const gchar *name,
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != (script->num_args + 1))
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
{
guchar color[3];
@ -967,9 +975,9 @@ script_fu_script_proc (const gchar *name,
}
*nreturn_vals = 1;
*return_vals = values;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
@ -1105,6 +1113,10 @@ script_fu_progress_start (const gchar *message,
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress),
message ? message : " ");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (sf_interface->progress), 0.0);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1114,6 +1126,10 @@ script_fu_progress_end (gpointer user_data)
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress), " ");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (sf_interface->progress), 0.0);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1124,6 +1140,10 @@ script_fu_progress_text (const gchar *message,
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress),
message ? message : " ");
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1136,7 +1156,8 @@ script_fu_progress_value (gdouble percentage,
percentage);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
gdk_window_process_updates (sf_interface->progress->window, TRUE);
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1146,8 +1167,8 @@ script_fu_interface (SFScript *script)
GtkWidget *frame;
GtkWidget *button;
GtkWidget *menu;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *hbox;
GSList *list;
gchar *title;
@ -1246,11 +1267,15 @@ script_fu_interface (SFScript *script)
gtk_widget_show (frame);
/* The argument table */
table = gtk_table_new (script->num_args + 1, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
if (script->image_based)
sf_interface->args_table = gtk_table_new (script->num_args - 1, 3, FALSE);
else
sf_interface->args_table = gtk_table_new (script->num_args + 1, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (sf_interface->args_table), 6);
gtk_table_set_row_spacings (GTK_TABLE (sf_interface->args_table), 6);
gtk_container_add (GTK_CONTAINER (frame), sf_interface->args_table);
gtk_widget_show (sf_interface->args_table);
start_args = (script->image_based) ? 2 : 0;
@ -1261,6 +1286,10 @@ script_fu_interface (SFScript *script)
gfloat label_yalign = 0.5;
gboolean leftalign = FALSE;
gint *ID_ptr = NULL;
gint row = i;
if (script->image_based)
row -= 2;
/* we add a colon after the label;
some languages want an extra space here */
@ -1344,7 +1373,8 @@ script_fu_interface (SFScript *script)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *)
gimp_scale_entry_new (GTK_TABLE (table), 0, i,
gimp_scale_entry_new (GTK_TABLE (sf_interface->args_table),
0, row,
label_text, SLIDER_WIDTH, -1,
script->arg_values[i].sfa_adjustment.value,
script->arg_defaults[i].sfa_adjustment.lower,
@ -1454,14 +1484,16 @@ script_fu_interface (SFScript *script)
{
if (label_text)
{
gimp_table_attach_aligned (GTK_TABLE (table), 0, i,
gimp_table_attach_aligned (GTK_TABLE (sf_interface->args_table),
0, row,
label_text, 0.0, label_yalign,
widget, 2, leftalign);
g_free (label_text);
}
else
{
gtk_table_attach (GTK_TABLE (table), widget, 0, 3, i, i+1,
gtk_table_attach (GTK_TABLE (sf_interface->args_table),
widget, 0, 3, row, row + 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (widget);
}
@ -1470,9 +1502,24 @@ script_fu_interface (SFScript *script)
sf_interface->args_widgets[i] = widget;
}
/* the script progress frame */
frame = gimp_frame_new (_("Script Progress"));
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
vbox2 = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_widget_show (vbox2);
sf_interface->progress_label = gtk_label_new (_("(none)"));
gtk_misc_set_alignment (GTK_MISC (sf_interface->progress_label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress_label,
FALSE, FALSE, 0);
gtk_widget_show (sf_interface->progress_label);
sf_interface->progress = gtk_progress_bar_new ();
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress), " ");
gtk_box_pack_start (GTK_BOX (vbox), sf_interface->progress, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress, FALSE, FALSE, 0);
gtk_widget_show (sf_interface->progress);
sf_interface->progress_callback =
@ -1625,6 +1672,10 @@ script_fu_response (GtkWidget *widget,
break;
case GTK_RESPONSE_OK:
gtk_widget_set_sensitive (sf_interface->args_table, FALSE);
gtk_widget_set_sensitive (GTK_DIALOG (sf_interface->dialog)->action_area,
FALSE);
script_fu_ok (script);
/* fallthru */

View File

@ -128,11 +128,18 @@ typedef struct
typedef struct
{
GtkWidget *dialog;
GtkWidget **args_widgets;
GtkWidget *status;
GtkWidget *about_dialog;
GtkWidget *args_table;
GtkWidget **args_widgets;
GtkWidget *progress_label;
GtkWidget *progress;
const gchar *progress_callback;
GtkWidget *about_dialog;
gchar *title;
gchar *last_command;
gint command_count;
@ -664,13 +671,13 @@ script_fu_report_cc (gchar *command)
new_command = g_strdup_printf ("%s <%d>",
command, sf_interface->command_count);
gtk_label_set_text (GTK_LABEL (sf_interface->status), new_command);
gtk_label_set_text (GTK_LABEL (sf_interface->progress_label), new_command);
g_free (new_command);
}
else
{
sf_interface->command_count = 1;
gtk_label_set_text (GTK_LABEL (sf_interface->status), command);
gtk_label_set_text (GTK_LABEL (sf_interface->progress_label), command);
g_free (sf_interface->last_command);
sf_interface->last_command = g_strdup (command);
}
@ -806,7 +813,8 @@ script_fu_script_proc (const gchar *name,
case GIMP_RUN_NONINTERACTIVE:
/* Make sure all the arguments are there! */
if (nparams != (script->num_args + 1))
status = GIMP_PDB_CALLING_ERROR;
status = GIMP_PDB_CALLING_ERROR;
if (status == GIMP_PDB_SUCCESS)
{
guchar color[3];
@ -967,9 +975,9 @@ script_fu_script_proc (const gchar *name,
}
*nreturn_vals = 1;
*return_vals = values;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
}
@ -1105,6 +1113,10 @@ script_fu_progress_start (const gchar *message,
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress),
message ? message : " ");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (sf_interface->progress), 0.0);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1114,6 +1126,10 @@ script_fu_progress_end (gpointer user_data)
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress), " ");
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (sf_interface->progress), 0.0);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1124,6 +1140,10 @@ script_fu_progress_text (const gchar *message,
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress),
message ? message : " ");
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1136,7 +1156,8 @@ script_fu_progress_value (gdouble percentage,
percentage);
if (GTK_WIDGET_DRAWABLE (sf_interface->progress))
gdk_window_process_updates (sf_interface->progress->window, TRUE);
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1146,8 +1167,8 @@ script_fu_interface (SFScript *script)
GtkWidget *frame;
GtkWidget *button;
GtkWidget *menu;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *hbox;
GSList *list;
gchar *title;
@ -1246,11 +1267,15 @@ script_fu_interface (SFScript *script)
gtk_widget_show (frame);
/* The argument table */
table = gtk_table_new (script->num_args + 1, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
if (script->image_based)
sf_interface->args_table = gtk_table_new (script->num_args - 1, 3, FALSE);
else
sf_interface->args_table = gtk_table_new (script->num_args + 1, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (sf_interface->args_table), 6);
gtk_table_set_row_spacings (GTK_TABLE (sf_interface->args_table), 6);
gtk_container_add (GTK_CONTAINER (frame), sf_interface->args_table);
gtk_widget_show (sf_interface->args_table);
start_args = (script->image_based) ? 2 : 0;
@ -1261,6 +1286,10 @@ script_fu_interface (SFScript *script)
gfloat label_yalign = 0.5;
gboolean leftalign = FALSE;
gint *ID_ptr = NULL;
gint row = i;
if (script->image_based)
row -= 2;
/* we add a colon after the label;
some languages want an extra space here */
@ -1344,7 +1373,8 @@ script_fu_interface (SFScript *script)
{
case SF_SLIDER:
script->arg_values[i].sfa_adjustment.adj = (GtkAdjustment *)
gimp_scale_entry_new (GTK_TABLE (table), 0, i,
gimp_scale_entry_new (GTK_TABLE (sf_interface->args_table),
0, row,
label_text, SLIDER_WIDTH, -1,
script->arg_values[i].sfa_adjustment.value,
script->arg_defaults[i].sfa_adjustment.lower,
@ -1454,14 +1484,16 @@ script_fu_interface (SFScript *script)
{
if (label_text)
{
gimp_table_attach_aligned (GTK_TABLE (table), 0, i,
gimp_table_attach_aligned (GTK_TABLE (sf_interface->args_table),
0, row,
label_text, 0.0, label_yalign,
widget, 2, leftalign);
g_free (label_text);
}
else
{
gtk_table_attach (GTK_TABLE (table), widget, 0, 3, i, i+1,
gtk_table_attach (GTK_TABLE (sf_interface->args_table),
widget, 0, 3, row, row + 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (widget);
}
@ -1470,9 +1502,24 @@ script_fu_interface (SFScript *script)
sf_interface->args_widgets[i] = widget;
}
/* the script progress frame */
frame = gimp_frame_new (_("Script Progress"));
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
vbox2 = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_widget_show (vbox2);
sf_interface->progress_label = gtk_label_new (_("(none)"));
gtk_misc_set_alignment (GTK_MISC (sf_interface->progress_label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress_label,
FALSE, FALSE, 0);
gtk_widget_show (sf_interface->progress_label);
sf_interface->progress = gtk_progress_bar_new ();
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (sf_interface->progress), " ");
gtk_box_pack_start (GTK_BOX (vbox), sf_interface->progress, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), sf_interface->progress, FALSE, FALSE, 0);
gtk_widget_show (sf_interface->progress);
sf_interface->progress_callback =
@ -1625,6 +1672,10 @@ script_fu_response (GtkWidget *widget,
break;
case GTK_RESPONSE_OK:
gtk_widget_set_sensitive (sf_interface->args_table, FALSE);
gtk_widget_set_sensitive (GTK_DIALOG (sf_interface->dialog)->action_area,
FALSE);
script_fu_ok (script);
/* fallthru */

View File

@ -128,6 +128,18 @@ package Gimp::CodeGen::enums;
GIMP_STACK_TRACE_QUERY => '1',
GIMP_STACK_TRACE_ALWAYS => '2' }
},
GimpProgressCommand =>
{ contig => 1,
header => 'libgimpbase/gimpbaseenums.h',
symbols => [ qw(GIMP_PROGRESS_COMMAND_START
GIMP_PROGRESS_COMMAND_END
GIMP_PROGRESS_COMMAND_SET_TEXT
GIMP_PROGRESS_COMMAND_SET_VALUE) ],
mapping => { GIMP_PROGRESS_COMMAND_START => '0',
GIMP_PROGRESS_COMMAND_END => '1',
GIMP_PROGRESS_COMMAND_SET_TEXT => '2',
GIMP_PROGRESS_COMMAND_SET_VALUE => '3' }
},
GimpHistogramChannel =>
{ contig => 1,
header => 'base/base-enums.h',