added new procedure gimp-progress-end.

2007-07-25  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/progress.pdb: added new procedure gimp-progress-end.

	* app/pdb/progress_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpprogress_pdb.[ch]: regenerated.

	* plug-ins/print/print.[ch]
	* plug-ins/print/print-settings.[ch]: end the progress and save
	the settings from the "end-print" handler. The plug-in then
	appears finished but keeps running in the background until it has
	finished the print operation.

svn path=/trunk/; revision=22994
This commit is contained in:
Sven Neumann 2007-07-25 10:48:25 +00:00 committed by Sven Neumann
parent b7e345a06c
commit 7e4e919152
10 changed files with 131 additions and 51 deletions

View file

@ -1,3 +1,17 @@
2007-07-25 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/progress.pdb: added new procedure gimp-progress-end.
* app/pdb/progress_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpprogress_pdb.[ch]: regenerated.
* plug-ins/print/print.[ch]
* plug-ins/print/print-settings.[ch]: end the progress and save
the settings from the "end-print" handler. The plug-in then
appears finished but keeps running in the background until it has
finished the print operation.
2007-07-25 Sven Neumann <sven@gimp.org>
* plug-ins/print/print.c: delete the export image from the

View file

@ -29,7 +29,7 @@
#include "internal_procs.h"
/* 549 procedures registered total */
/* 550 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View file

@ -143,6 +143,28 @@ progress_set_text_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
progress_end_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
{
gboolean success = TRUE;
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
GimpPlugInProcFrame *proc_frame = gimp_plug_in_get_proc_frame (plug_in);
gimp_plug_in_progress_end (plug_in, proc_frame);
}
else
success = FALSE;
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
progress_get_window_handle_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -342,6 +364,22 @@ register_progress_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-progress-end
*/
procedure = gimp_procedure_new (progress_end_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-progress-end");
gimp_procedure_set_static_strings (procedure,
"gimp-progress-end",
"Ends the progress bar for the current plug-in.",
"Ends the progress display for the current plug-in. Most plug-ins don't need to call this, they just exit when the work is done. It is only valid to call this procedure from a plug-in.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2007",
NULL);
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-progress-get-window-handle
*/

View file

@ -154,6 +154,37 @@ gimp_progress_set_text (const gchar *message)
return success;
}
/**
* gimp_progress_end:
*
* Ends the progress bar for the current plug-in.
*
* Ends the progress display for the current plug-in. Most plug-ins
* don't need to call this, they just exit when the work is done. It is
* only valid to call this procedure from a plug-in.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_progress_end (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-progress-end",
&nreturn_vals,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_progress_get_window_handle:
*

View file

@ -34,6 +34,7 @@ G_GNUC_INTERNAL gboolean _gimp_progress_init (const gchar *message,
G_GNUC_INTERNAL gboolean _gimp_progress_update (gdouble percentage);
gboolean gimp_progress_pulse (void);
gboolean gimp_progress_set_text (const gchar *message);
gboolean gimp_progress_end (void);
gint gimp_progress_get_window_handle (void);
G_GNUC_INTERNAL gboolean _gimp_progress_install (const gchar *progress_callback);
G_GNUC_INTERNAL gboolean _gimp_progress_uninstall (const gchar *progress_callback);

View file

@ -54,10 +54,9 @@ static GKeyFile * check_version (GKeyFile
* file of the same name
*/
gboolean
load_print_settings (PrintData *data,
gint32 image_ID)
load_print_settings (PrintData *data)
{
GKeyFile *key_file = print_settings_key_file_from_parasite (image_ID);
GKeyFile *key_file = print_settings_key_file_from_parasite (data->image_id);
if (! key_file)
key_file = print_settings_key_file_from_resource_file ();
@ -77,8 +76,7 @@ load_print_settings (PrintData *data,
* and as an image parasite
*/
void
save_print_settings (PrintData *data,
gint32 image_ID)
save_print_settings (PrintData *data)
{
GKeyFile *key_file;
@ -93,7 +91,8 @@ save_print_settings (PrintData *data,
g_key_file_set_double (key_file, "image-setup", "x-offset", data->offset_x);
g_key_file_set_double (key_file, "image-setup", "y-offset", data->offset_y);
save_print_settings_as_parasite (key_file, image_ID);
if (gimp_image_is_valid (data->image_id))
save_print_settings_as_parasite (key_file, data->image_id);
g_key_file_free (key_file);
}

View file

@ -16,7 +16,5 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
gboolean load_print_settings (PrintData *data,
gint32 image_ID);
void save_print_settings (PrintData *data,
gint32 image_ID);
gboolean load_print_settings (PrintData *data);
void save_print_settings (PrintData *data);

View file

@ -59,7 +59,6 @@ static void draw_page (GtkPrintOperation *print,
GtkPrintContext *context,
gint page_nr,
PrintData *data);
static void status_changed (GtkPrintOperation *operation);
static GtkWidget * create_custom_widget (GtkPrintOperation *operation,
PrintData *data);
@ -174,6 +173,7 @@ print_image (gint32 image_ID,
/* fill in the PrintData struct */
data.num_pages = 1;
data.image_id = orig_image_ID;
data.drawable_id = drawable_ID;
data.unit = gimp_get_default_unit ();
data.image_unit = gimp_image_get_unit (image_ID);
@ -184,7 +184,7 @@ print_image (gint32 image_ID,
gimp_image_get_resolution (image_ID, &data.xres, &data.yres);
load_print_settings (&data, orig_image_ID);
load_print_settings (&data);
if (export != GIMP_EXPORT_EXPORT)
image_ID = -1;
@ -199,13 +199,11 @@ print_image (gint32 image_ID,
G_CALLBACK (end_print),
&image_ID);
g_signal_connect (operation, "status-changed",
G_CALLBACK (status_changed),
NULL);
if (interactive)
{
GtkPrintOperationResult result;
g_signal_connect_swapped (operation, "end-print",
G_CALLBACK (save_print_settings),
&data);
g_signal_connect (operation, "create-custom-widget",
G_CALLBACK (create_custom_widget),
@ -213,21 +211,9 @@ print_image (gint32 image_ID,
gtk_print_operation_set_custom_tab_label (operation, _("Image"));
result = gtk_print_operation_run (operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error);
switch (result)
{
case GTK_PRINT_OPERATION_RESULT_APPLY:
case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
save_print_settings (&data, orig_image_ID);
break;
case GTK_PRINT_OPERATION_RESULT_ERROR:
case GTK_PRINT_OPERATION_RESULT_CANCEL:
break;
}
gtk_print_operation_run (operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error);
}
else
{
@ -238,10 +224,6 @@ print_image (gint32 image_ID,
g_object_unref (operation);
/* The export image should have been deleted already from the
* "status-changed" handler, but better make sure that it isn't
* left behind.
*/
if (gimp_image_is_valid (image_ID))
gimp_image_delete (image_ID);
@ -298,26 +280,14 @@ end_print (GtkPrintOperation *operation,
GtkPrintContext *context,
gint32 *image_ID)
{
gimp_progress_update (1.0);
/* we don't need the export image any longer, delete it */
if (gimp_image_is_valid (*image_ID))
{
gimp_image_delete (*image_ID);
*image_ID = -1;
}
}
static void
status_changed (GtkPrintOperation *operation)
{
const gchar *status = gtk_print_operation_get_status_string (operation);
if (status && strlen (status))
{
/* display status of the print operation in the status bar */
gimp_progress_set_text_printf (_("Print: %s"), status);
}
gimp_progress_end ();
}
static void

View file

@ -19,6 +19,7 @@
typedef struct
{
gint num_pages;
gint32 image_id;
gint32 drawable_id;
GimpUnit unit;
gboolean show_info_header;

View file

@ -148,6 +148,34 @@ CODE
);
}
sub progress_end {
$blurb = 'Ends the progress bar for the current plug-in.';
$help = <<'HELP';
Ends the progress display for the current plug-in. Most plug-ins don't need to call this, they just exit when the work is done. It is only valid to call this
procedure from a plug-in.
HELP
&neo_pdb_misc('2007', '2.4');
%invoke = (
code => <<'CODE'
{
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
GimpPlugInProcFrame *proc_frame = gimp_plug_in_get_proc_frame (plug_in);
gimp_plug_in_progress_end (plug_in, proc_frame);
}
else
success = FALSE;
}
CODE
);
}
sub progress_get_window_handle {
$blurb = 'Returns the native window ID of the toplevel window this plug-in\'s progress is displayed in.';
@ -275,7 +303,7 @@ CODE
"plug-in/gimppluginmanager.h");
@procs = qw(progress_init progress_update progress_pulse progress_set_text
progress_get_window_handle
progress_end progress_get_window_handle
progress_install progress_uninstall progress_cancel);
%exports = (app => [@procs], lib => [@procs]);