Commit 7c19953c authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added GimpProgress::pulse.

2005-02-12  Sven Neumann  <sven@gimp.org>

	* app/core/gimpprogress.[ch]: added GimpProgress::pulse.

	* app/display/gimpdisplay.c
	* app/display/gimpstatusbar.c
	* app/widgets/gimpfiledialog.c
	* app/widgets/gimpprogressbox.c
	* app/widgets/gimpprogressdialog.c
	* app/widgets/gimpthumbbox.c: implement it in the classes that
	implement the GimpProgress interface.

	* app/plug-in/plug-in-progress.[ch]: allow plug-ins to pulse their
	progress.

	* tools/pdbgen/pdb/progress.pdb: added a procedure for the new
	functionality.

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

	* libgimp/gimp.def: updated.
parent 5766da03
2005-02-12 Sven Neumann <sven@gimp.org>
* app/core/gimpprogress.[ch]: added GimpProgress::pulse.
* app/display/gimpdisplay.c
* app/display/gimpstatusbar.c
* app/widgets/gimpfiledialog.c
* app/widgets/gimpprogressbox.c
* app/widgets/gimpprogressdialog.c
* app/widgets/gimpthumbbox.c: implement it in the classes that
implement the GimpProgress interface.
* app/plug-in/plug-in-progress.[ch]: allow plug-ins to pulse their
progress.
* tools/pdbgen/pdb/progress.pdb: added a procedure for the new
functionality.
* app/pdb/internal_procs.c
* app/pdb/progress_cmds.c
* libgimp/gimpprogress_pdb.[ch]: regenerated.
* libgimp/gimp.def: updated.
2005-02-11 Sven Neumann <sven@gimp.org>
* app/base/pixel-processor.[ch]: code cleanup. Removed unused code,
......
......@@ -190,6 +190,18 @@ gimp_progress_get_value (GimpProgress *progress)
return 0.0;
}
void
gimp_progress_pulse (GimpProgress *progress)
{
GimpProgressInterface *progress_iface;
g_return_if_fail (GIMP_IS_PROGRESS (progress));
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
if (progress_iface->pulse)
progress_iface->pulse (progress);
}
void
gimp_progress_message (GimpProgress *progress,
......
......@@ -47,6 +47,7 @@ struct _GimpProgressInterface
void (* set_value) (GimpProgress *progress,
gdouble percentage);
gdouble (* get_value) (GimpProgress *progress);
void (* pulse) (GimpProgress *progress);
void (* message) (GimpProgress *progress,
Gimp *gimp,
......@@ -71,6 +72,7 @@ void gimp_progress_set_text (GimpProgress *progress,
void gimp_progress_set_value (GimpProgress *progress,
gdouble percentage);
gdouble gimp_progress_get_value (GimpProgress *progress);
void gimp_progress_pulse (GimpProgress *progress);
void gimp_progress_message (GimpProgress *progress,
Gimp *gimp,
......
......@@ -75,6 +75,7 @@ static void gimp_display_progress_set_text (GimpProgress *progress,
static void gimp_display_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_display_progress_get_value (GimpProgress *progress);
static void gimp_display_progress_pulse (GimpProgress *progress);
static void gimp_display_progress_canceled (GimpProgress *progress,
GimpDisplay *display);
......@@ -174,6 +175,7 @@ gimp_display_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->set_text = gimp_display_progress_set_text;
progress_iface->set_value = gimp_display_progress_set_value;
progress_iface->get_value = gimp_display_progress_get_value;
progress_iface->pulse = gimp_display_progress_pulse;
}
static void
......@@ -309,6 +311,20 @@ gimp_display_progress_get_value (GimpProgress *progress)
return gimp_progress_get_value (GIMP_PROGRESS (shell->statusbar));
}
static void
gimp_display_progress_pulse (GimpProgress *progress)
{
GimpDisplay *display = GIMP_DISPLAY (progress);
GimpDisplayShell *shell;
if (! display->shell)
return;
shell = GIMP_DISPLAY_SHELL (display->shell);
gimp_progress_pulse (GIMP_PROGRESS (shell->statusbar));
}
static void
gimp_display_progress_canceled (GimpProgress *progress,
GimpDisplay *display)
......
......@@ -73,6 +73,7 @@ static void gimp_statusbar_progress_set_text (GimpProgress *progress,
static void gimp_statusbar_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_statusbar_progress_get_value (GimpProgress *progress);
static void gimp_statusbar_progress_pulse (GimpProgress *progress);
static void gimp_statusbar_progress_canceled (GtkWidget *button,
GimpStatusbar *statusbar);
......@@ -251,6 +252,7 @@ gimp_statusbar_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->set_text = gimp_statusbar_progress_set_text;
progress_iface->set_value = gimp_statusbar_progress_set_value;
progress_iface->get_value = gimp_statusbar_progress_get_value;
progress_iface->pulse = gimp_statusbar_progress_pulse;
}
static void
......@@ -379,6 +381,22 @@ gimp_statusbar_progress_get_value (GimpProgress *progress)
return 0.0;
}
static void
gimp_statusbar_progress_pulse (GimpProgress *progress)
{
GimpStatusbar *statusbar = GIMP_STATUSBAR (progress);
if (statusbar->progress_active)
{
GtkWidget *bar = statusbar->progressbar;
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (bar));
if (GTK_WIDGET_DRAWABLE (bar))
gdk_window_process_updates (bar->window, TRUE);
}
}
static void
gimp_statusbar_progress_canceled (GtkWidget *button,
GimpStatusbar *statusbar)
......
......@@ -74,7 +74,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 449 procedures registered total */
/* 450 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -110,7 +110,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Drawable procedures"), 0.187);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.263);
(* status_callback) (NULL, _("Transformation procedures"), 0.262);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.298);
......@@ -119,88 +119,88 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("File Operations"), 0.318);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.341);
(* status_callback) (NULL, _("Floating selections"), 0.34);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.354);
(* status_callback) (NULL, _("Font UI"), 0.353);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.361);
(* status_callback) (NULL, _("Fonts"), 0.36);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.365);
(* status_callback) (NULL, _("Gimprc procedures"), 0.364);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.379);
(* status_callback) (NULL, _("Gradient"), 0.378);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.445);
(* status_callback) (NULL, _("Gradient UI"), 0.444);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.452);
(* status_callback) (NULL, _("Gradients"), 0.451);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.463);
(* status_callback) (NULL, _("Guide procedures"), 0.462);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.477);
(* status_callback) (NULL, _("Help procedures"), 0.476);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.479);
(* status_callback) (NULL, _("Image"), 0.478);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.617);
(* status_callback) (NULL, _("Layer"), 0.616);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.677);
(* status_callback) (NULL, _("Message procedures"), 0.676);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.684);
(* status_callback) (NULL, _("Miscellaneous"), 0.682);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.688);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.687);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.722);
(* status_callback) (NULL, _("Palette"), 0.72);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.748);
(* status_callback) (NULL, _("Palette UI"), 0.747);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.755);
(* status_callback) (NULL, _("Palettes"), 0.753);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.764);
(* status_callback) (NULL, _("Parasite procedures"), 0.762);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.791);
(* status_callback) (NULL, _("Paths"), 0.789);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.824);
(* status_callback) (NULL, _("Pattern"), 0.822);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.829);
(* status_callback) (NULL, _("Pattern UI"), 0.827);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.835);
(* status_callback) (NULL, _("Patterns"), 0.833);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.844);
(* status_callback) (NULL, _("Plug-in"), 0.842);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.855);
(* status_callback) (NULL, _("Procedural database"), 0.853);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.875);
(* status_callback) (NULL, _("Progress"), 0.873);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.886);
(* status_callback) (NULL, _("Image mask"), 0.887);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.924);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.935);
(* status_callback) (NULL, _("Text procedures"), 0.936);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.944);
......
......@@ -32,6 +32,7 @@
static ProcRecord progress_init_proc;
static ProcRecord progress_update_proc;
static ProcRecord progress_pulse_proc;
static ProcRecord progress_install_proc;
static ProcRecord progress_uninstall_proc;
static ProcRecord progress_cancel_proc;
......@@ -41,6 +42,7 @@ register_progress_procs (Gimp *gimp)
{
procedural_db_register (gimp, &progress_init_proc);
procedural_db_register (gimp, &progress_update_proc);
procedural_db_register (gimp, &progress_pulse_proc);
procedural_db_register (gimp, &progress_install_proc);
procedural_db_register (gimp, &progress_uninstall_proc);
procedural_db_register (gimp, &progress_cancel_proc);
......@@ -155,6 +157,40 @@ static ProcRecord progress_update_proc =
{ { progress_update_invoker } }
};
static Argument *
progress_pulse_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_pulse (gimp->current_plug_in);
}
else
success = FALSE;
return procedural_db_return_args (&progress_pulse_proc, success);
}
static ProcRecord progress_pulse_proc =
{
"gimp_progress_pulse",
"Pulses the progress bar for the current plug-in.",
"Updates the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in. Use this function instead of gimp_progress_update() if you cannot tell how much progress has been made. This usually causes the the progress bar to enter \"activity mode\", where a block bounces back and forth.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005",
NULL,
GIMP_INTERNAL,
0,
NULL,
0,
NULL,
{ { progress_pulse_invoker } }
};
static Argument *
progress_install_invoker (Gimp *gimp,
GimpContext *context,
......
......@@ -109,6 +109,26 @@ plug_in_progress_update (PlugIn *plug_in,
gimp_progress_set_value (proc_frame->progress, percentage);
}
void
plug_in_progress_pulse (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, -1);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
gimp_progress_pulse (proc_frame->progress);
}
void
plug_in_progress_end (PlugIn *plug_in)
{
......
......@@ -27,6 +27,7 @@ void plug_in_progress_start (PlugIn *plug_in,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_pulse (PlugIn *plug_in);
void plug_in_progress_end (PlugIn *plug_in);
gboolean plug_in_progress_install (PlugIn *plug_in,
......
......@@ -109,6 +109,26 @@ plug_in_progress_update (PlugIn *plug_in,
gimp_progress_set_value (proc_frame->progress, percentage);
}
void
plug_in_progress_pulse (PlugIn *plug_in)
{
PlugInProcFrame *proc_frame;
g_return_if_fail (plug_in != NULL);
proc_frame = plug_in_get_proc_frame (plug_in);
if (! proc_frame->progress ||
! gimp_progress_is_active (proc_frame->progress) ||
! proc_frame->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, -1);
}
if (proc_frame->progress && gimp_progress_is_active (proc_frame->progress))
gimp_progress_pulse (proc_frame->progress);
}
void
plug_in_progress_end (PlugIn *plug_in)
{
......
......@@ -27,6 +27,7 @@ void plug_in_progress_start (PlugIn *plug_in,
gint display_ID);
void plug_in_progress_update (PlugIn *plug_in,
gdouble percentage);
void plug_in_progress_pulse (PlugIn *plug_in);
void plug_in_progress_end (PlugIn *plug_in);
gboolean plug_in_progress_install (PlugIn *plug_in,
......
......@@ -70,6 +70,7 @@ static void gimp_file_dialog_progress_set_text (GimpProgress *progress,
static void gimp_file_dialog_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_file_dialog_progress_get_value (GimpProgress *progress);
static void gimp_file_dialog_progress_pulse (GimpProgress *progress);
static void gimp_file_dialog_add_preview (GimpFileDialog *dialog,
Gimp *gimp);
......@@ -156,6 +157,7 @@ gimp_file_dialog_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->set_text = gimp_file_dialog_progress_set_text;
progress_iface->set_value = gimp_file_dialog_progress_set_value;
progress_iface->get_value = gimp_file_dialog_progress_get_value;
progress_iface->pulse = gimp_file_dialog_progress_pulse;
}
static gboolean
......@@ -275,6 +277,19 @@ gimp_file_dialog_progress_get_value (GimpProgress *progress)
return 0.0;
}
static void
gimp_file_dialog_progress_pulse (GimpProgress *progress)
{
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
if (dialog->progress_active)
{
GtkProgressBar *bar = GTK_PROGRESS_BAR (dialog->progress);
gtk_progress_bar_pulse (bar);
}
}
/* public functions */
......
......@@ -47,6 +47,7 @@ static void gimp_progress_box_progress_set_text (GimpProgress *progress,
static void gimp_progress_box_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_progress_box_progress_get_value (GimpProgress *progress);
static void gimp_progress_box_progress_pulse (GimpProgress *progress);
......@@ -97,6 +98,7 @@ gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->set_text = gimp_progress_box_progress_set_text;
progress_iface->set_value = gimp_progress_box_progress_set_value;
progress_iface->get_value = gimp_progress_box_progress_get_value;
progress_iface->pulse = gimp_progress_box_progress_pulse;
}
static GimpProgress *
......@@ -191,6 +193,22 @@ gimp_progress_box_progress_get_value (GimpProgress *progress)
return 0.0;
}
static void
gimp_progress_box_progress_pulse (GimpProgress *progress)
{
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
if (box->active)
{
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
gtk_progress_bar_pulse (bar);
if (GTK_WIDGET_DRAWABLE (box->progress))
gdk_window_process_updates (box->progress->window, TRUE);
}
}
GtkWidget *
gimp_progress_box_new (void)
{
......
......@@ -53,6 +53,7 @@ static void gimp_progress_dialog_progress_set_text (GimpProgress *progress,
static void gimp_progress_dialog_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_progress_dialog_progress_get_value (GimpProgress *progress);
static void gimp_progress_dialog_progress_pulse (GimpProgress *progress);
static GimpDialogClass *parent_class = NULL;
......@@ -132,6 +133,7 @@ gimp_progress_dialog_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->set_text = gimp_progress_dialog_progress_set_text;
progress_iface->set_value = gimp_progress_dialog_progress_set_value;
progress_iface->get_value = gimp_progress_dialog_progress_get_value;
progress_iface->pulse = gimp_progress_dialog_progress_pulse;
}
static void
......@@ -232,6 +234,17 @@ gimp_progress_dialog_progress_get_value (GimpProgress *progress)
return gimp_progress_get_value (GIMP_PROGRESS (dialog->box));
}
static void
gimp_progress_dialog_progress_pulse (GimpProgress *progress)
{
GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);
if (! dialog->box)
return;
gimp_progress_pulse (GIMP_PROGRESS (dialog->box));
}
GtkWidget *
gimp_progress_dialog_new (void)
{
......
......@@ -66,6 +66,7 @@ static gboolean gimp_thumb_box_progress_is_active (GimpProgress *progress);
static void gimp_thumb_box_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_thumb_box_progress_get_value (GimpProgress *progress);
static void gimp_thumb_box_progress_pulse (GimpProgress *progress);
static void gimp_thumb_box_progress_message (GimpProgress *progress,
Gimp *gimp,
......@@ -165,7 +166,7 @@ gimp_thumb_box_progress_iface_init (GimpProgressInterface *progress_iface)
progress_iface->is_active = gimp_thumb_box_progress_is_active;
progress_iface->set_value = gimp_thumb_box_progress_set_value;
progress_iface->get_value = gimp_thumb_box_progress_get_value;
progress_iface->pulse = gimp_thumb_box_progress_pulse;
progress_iface->message = gimp_thumb_box_progress_message;
}
......@@ -294,6 +295,19 @@ gimp_thumb_box_progress_get_value (GimpProgress *progress)
return 0.0;
}
static void
gimp_thumb_box_progress_pulse (GimpProgress *progress)
{
GimpThumbBox *box = GIMP_THUMB_BOX (progress);
if (box->progress_active)
{
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
gtk_progress_bar_pulse (bar);
}
}
static void
gimp_thumb_box_progress_message (GimpProgress *progress,
Gimp *gimp,
......
......@@ -480,6 +480,7 @@ EXPORTS
gimp_progress_cancel
gimp_progress_init
gimp_progress_install
gimp_progress_pulse
gimp_progress_uninstall
gimp_progress_update
gimp_quit
......
......@@ -87,6 +87,39 @@ gimp_progress_update (gdouble percentage)
return success;
}
/**
* gimp_progress_pulse:
*
* Pulses the progress bar for the current plug-in.
*
* Updates the progress bar for the current plug-in. It is only valid
* to call this procedure from a plug-in. Use this function instead of
* gimp_progress_update() if you cannot tell how much progress has been
* made. This usually causes the the progress bar to enter \"activity
* mode\", where a block bounces back and forth.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_progress_pulse (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_progress_pulse",
&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_install:
* @progress_callback: The callback PDB proc to call.
......
......@@ -31,6 +31,7 @@ G_BEGIN_DECLS
gboolean gimp_progress_init (const gchar *message);
gboolean gimp_progress_update (gdouble percentage);
gboolean gimp_progress_pulse (void);
gboolean _gimp_progress_install (const gchar *progress_callback);
gboolean _gimp_progress_uninstall (const gchar *progress_callback);
gboolean gimp_progress_cancel (const gchar *progress_callback);
......
......@@ -88,6 +88,37 @@ CODE
);
}
sub progress_pulse {
$blurb = 'Pulses the progress bar for the current plug-in.';
$help = <<'HELP';
Updates the progress bar for the current plug-in. It is only valid to
call this procedure from a plug-in. Use this function instead of
gimp_progress_update() if you cannot tell how much progress has been
made. This usually causes the the progress bar to enter "activity
mode", where a block bounces back and forth.
HELP
$author = 'Sven Neumann <sven@gimp.org>';
$copyright = 'Sven Neumann';
$date = '2005';
$since = '2.4';
%invoke = (
code => <<'CODE'
{
if (gimp->current_plug_in && gimp->current_plug_in->open)
{
if (! gimp->no_interface)
plug_in_progress_pulse (gimp->current_plug_in);
}
else
success = FALSE;
}
CODE
);
}
sub progress_install {
$blurb = 'Installs a progress callback for the current plug-in.';
......@@ -176,7 +207,7 @@ CODE
@headers = qw("core/gimp.h" "plug-in/plug-in.h" "plug-in/plug-in-progress.h");
@procs = qw(progress_init progress_update
@procs = qw(progress_init progress_update progress_pulse
progress_install progress_uninstall progress_cancel);
%exports = (app => [@procs], lib => [@procs]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment