PIKApp/app/pdb/progress-cmds.c

510 lines
21 KiB
C

/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include "stamp-pdbgen.h"
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libpikabase/pikabase.h"
#include "pdb-types.h"
#include "core/pika.h"
#include "core/pikaparamspecs.h"
#include "plug-in/pikaplugin-progress.h"
#include "plug-in/pikaplugin.h"
#include "plug-in/pikapluginmanager.h"
#include "pikapdb.h"
#include "pikaprocedure.h"
#include "internal-procs.h"
static PikaValueArray *
progress_init_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *message;
PikaDisplay *gdisplay;
message = g_value_get_string (pika_value_array_index (args, 0));
gdisplay = g_value_get_object (pika_value_array_index (args, 1));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_start (plug_in, message, gdisplay);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_update_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
gdouble percentage;
percentage = g_value_get_double (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_set_value (plug_in, percentage);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_pulse_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_pulse (plug_in);
}
else
success = FALSE;
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_set_text_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *message;
message = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
pika_plug_in_progress_set_text (plug_in, message);
}
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_end_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
PikaPlugInProcFrame *proc_frame = pika_plug_in_get_proc_frame (plug_in);
pika_plug_in_progress_end (plug_in, proc_frame);
}
else
success = FALSE;
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_get_window_handle_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
PikaValueArray *return_vals;
GBytes *handle = NULL;
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
{
if (! pika->no_interface)
handle = pika_plug_in_progress_get_window_id (plug_in);
}
else
success = FALSE;
return_vals = pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_take_boxed (pika_value_array_index (return_vals, 1), handle);
return return_vals;
}
static PikaValueArray *
progress_install_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_install (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_uninstall_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_uninstall (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static PikaValueArray *
progress_cancel_invoker (PikaProcedure *procedure,
Pika *pika,
PikaContext *context,
PikaProgress *progress,
const PikaValueArray *args,
GError **error)
{
gboolean success = TRUE;
const gchar *progress_callback;
progress_callback = g_value_get_string (pika_value_array_index (args, 0));
if (success)
{
PikaPlugIn *plug_in = pika->plug_in_manager->current_plug_in;
if (plug_in && plug_in->open)
success = pika_plug_in_progress_cancel (plug_in, progress_callback);
else
success = FALSE;
}
return pika_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_progress_procs (PikaPDB *pdb)
{
PikaProcedure *procedure;
/*
* pika-progress-init
*/
procedure = pika_procedure_new (progress_init_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-init");
pika_procedure_set_static_help (procedure,
"Initializes the progress bar for the current plug-in.",
"Initializes the progress bar for the current plug-in. It is only valid to call this procedure from a plug-in.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("message",
"message",
"Message to use in the progress dialog",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_procedure_add_argument (procedure,
pika_param_spec_display ("gdisplay",
"gdisplay",
"PikaDisplay to update progressbar in, or %NULL for a separate window",
TRUE,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-update
*/
procedure = pika_procedure_new (progress_update_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-update");
pika_procedure_set_static_help (procedure,
"Updates 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.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996");
pika_procedure_add_argument (procedure,
g_param_spec_double ("percentage",
"percentage",
"Percentage of progress completed which must be between 0.0 and 1.0",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-pulse
*/
procedure = pika_procedure_new (progress_pulse_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-pulse");
pika_procedure_set_static_help (procedure,
"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 'pika-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.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-set-text
*/
procedure = pika_procedure_new (progress_set_text_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-set-text");
pika_procedure_set_static_help (procedure,
"Changes the text in the progress bar for the current plug-in.",
"This function changes the text in the progress bar for the current plug-in. Unlike 'pika-progress-init' it does not change the displayed value.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("message",
"message",
"Message to use in the progress dialog",
FALSE, TRUE, FALSE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-end
*/
procedure = pika_procedure_new (progress_end_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-end");
pika_procedure_set_static_help (procedure,
"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.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2007");
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-get-window-handle
*/
procedure = pika_procedure_new (progress_get_window_handle_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-get-window-handle");
pika_procedure_set_static_help (procedure,
"Returns the native handle of the toplevel window this plug-in's progress is displayed in.",
"This function returns the native handle allowing to identify the toplevel window this plug-in's progress is displayed in.\n"
"This handle can be of various types (integer, string, etc.) depending on the platform you are running on which is why it returns a GBytes. There are usually no reasons to call this directly.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_return_value (procedure,
g_param_spec_boxed ("handle",
"handle",
"The progress bar's toplevel window's handle",
G_TYPE_BYTES,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-install
*/
procedure = pika_procedure_new (progress_install_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-install");
pika_procedure_set_static_help (procedure,
"Installs a progress callback for the current plug-in.",
"This function installs a temporary PDB procedure which will handle all progress calls made by this plug-in and any procedure it calls. Calling this function multiple times simply replaces the old progress callbacks.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The callback PDB proc to call",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-uninstall
*/
procedure = pika_procedure_new (progress_uninstall_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-uninstall");
pika_procedure_set_static_help (procedure,
"Uninstalls the progress callback for the current plug-in.",
"This function uninstalls any progress callback installed with 'pika-progress-install' before.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The name of the callback registered for this progress",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* pika-progress-cancel
*/
procedure = pika_procedure_new (progress_cancel_invoker);
pika_object_set_static_name (PIKA_OBJECT (procedure),
"pika-progress-cancel");
pika_procedure_set_static_help (procedure,
"Cancels a running progress.",
"This function cancels the currently running progress.",
NULL);
pika_procedure_set_static_attribution (procedure,
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2004");
pika_procedure_add_argument (procedure,
pika_param_spec_string ("progress-callback",
"progress callback",
"The name of the callback registered for this progress",
FALSE, FALSE, TRUE,
NULL,
PIKA_PARAM_READWRITE));
pika_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}