Commit 57a3396d authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added virtual function gboolean GimpProgressInterface::is_active().

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

	* app/core/gimpprogress.[ch]: added virtual function
	gboolean GimpProgressInterface::is_active().

	* 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.

	* app/plug-in/plug-in.h: removed "gboolean progress_active" and
	added "gulong progress_cancel_id" instead.

	* app/plug-in/plug-in-progress.c: changed accordingly. Make sure
	we correctly handle the "cancel" connections of progress instances
	passed from other plug-ins.
parent 49dd42f6
2004-08-11 Michael Natterer <mitch@gimp.org>
* app/core/gimpprogress.[ch]: added virtual function
gboolean GimpProgressInterface::is_active().
* 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.
* app/plug-in/plug-in.h: removed "gboolean progress_active" and
added "gulong progress_cancel_id" instead.
* app/plug-in/plug-in-progress.c: changed accordingly. Make sure
we correctly handle the "cancel" connections of progress instances
passed from other plug-ins.
2004-08-11 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-message.c
......
......@@ -126,6 +126,21 @@ gimp_progress_end (GimpProgress *progress)
progress_iface->end (progress);
}
gboolean
gimp_progress_is_active (GimpProgress *progress)
{
GimpProgressInterface *progress_iface;
g_return_val_if_fail (GIMP_IS_PROGRESS (progress), FALSE);
progress_iface = GIMP_PROGRESS_GET_INTERFACE (progress);
if (progress_iface->is_active)
return progress_iface->is_active (progress);
return FALSE;
}
void
gimp_progress_set_text (GimpProgress *progress,
const gchar *message)
......
......@@ -40,6 +40,7 @@ struct _GimpProgressInterface
const gchar *message,
gboolean cancelable);
void (* end) (GimpProgress *progress);
gboolean (* is_active) (GimpProgress *progress);
void (* set_text) (GimpProgress *progress,
const gchar *message);
......@@ -58,6 +59,7 @@ GimpProgress * gimp_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
void gimp_progress_end (GimpProgress *progress);
gboolean gimp_progress_is_active (GimpProgress *progress);
void gimp_progress_set_text (GimpProgress *progress,
const gchar *message);
......
......@@ -51,39 +51,40 @@ enum
/* local function prototypes */
static void gimp_display_class_init (GimpDisplayClass *klass);
static void gimp_display_init (GimpDisplay *gdisp);
static void gimp_display_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_display_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_display_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_display_class_init (GimpDisplayClass *klass);
static void gimp_display_init (GimpDisplay *gdisp);
static void gimp_display_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_display_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_display_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpProgress *
gimp_display_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_display_progress_end (GimpProgress *progress);
static void gimp_display_progress_set_text (GimpProgress *progress,
const gchar *message);
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_canceled (GimpProgress *progress,
GimpDisplay *display);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_paint_area (GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h);
gimp_display_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_display_progress_end (GimpProgress *progress);
static gboolean gimp_display_progress_is_active (GimpProgress *progress);
static void gimp_display_progress_set_text (GimpProgress *progress,
const gchar *message);
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_canceled (GimpProgress *progress,
GimpDisplay *display);
static void gimp_display_flush_whenever (GimpDisplay *gdisp,
gboolean now);
static void gimp_display_paint_area (GimpDisplay *gdisp,
gint x,
gint y,
gint w,
gint h);
static GimpObjectClass *parent_class = NULL;
......@@ -169,6 +170,7 @@ gimp_display_progress_iface_init (GimpProgressInterface *progress_iface)
{
progress_iface->start = gimp_display_progress_start;
progress_iface->end = gimp_display_progress_end;
progress_iface->is_active = gimp_display_progress_is_active;
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;
......@@ -237,6 +239,14 @@ gimp_display_progress_end (GimpProgress *progress)
gimp_progress_end (GIMP_PROGRESS (shell->statusbar));
}
static gboolean
gimp_display_progress_is_active (GimpProgress *progress)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (progress)->shell);
return gimp_progress_is_active (GIMP_PROGRESS (shell->statusbar));
}
static void
gimp_display_progress_set_text (GimpProgress *progress,
const gchar *message)
......
......@@ -55,34 +55,35 @@ struct _GimpStatusbarMsg
#define CURSOR_LEN 256
static void gimp_statusbar_class_init (GimpStatusbarClass *klass);
static void gimp_statusbar_init (GimpStatusbar *statusbar);
static void gimp_statusbar_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_statusbar_class_init (GimpStatusbarClass *klass);
static void gimp_statusbar_init (GimpStatusbar *statusbar);
static void gimp_statusbar_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_statusbar_destroy (GtkObject *object);
static void gimp_statusbar_destroy (GtkObject *object);
static GimpProgress *
gimp_statusbar_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_statusbar_progress_end (GimpProgress *progress);
static void gimp_statusbar_progress_set_text (GimpProgress *progress,
const gchar *message);
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_canceled (GtkWidget *button,
GimpStatusbar *statusbar);
static void gimp_statusbar_update (GimpStatusbar *statusbar);
static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
GimpStatusbar *statusbar);
static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
const gchar *context);
gimp_statusbar_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_statusbar_progress_end (GimpProgress *progress);
static gboolean gimp_statusbar_progress_is_active (GimpProgress *progress);
static void gimp_statusbar_progress_set_text (GimpProgress *progress,
const gchar *message);
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_canceled (GtkWidget *button,
GimpStatusbar *statusbar);
static void gimp_statusbar_update (GimpStatusbar *statusbar);
static void gimp_statusbar_unit_changed (GimpUnitComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_scale_changed (GimpScaleComboBox *combo,
GimpStatusbar *statusbar);
static void gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
GimpStatusbar *statusbar);
static guint gimp_statusbar_get_context_id (GimpStatusbar *statusbar,
const gchar *context);
static GtkHBoxClass *parent_class = NULL;
......@@ -244,6 +245,7 @@ gimp_statusbar_progress_iface_init (GimpProgressInterface *progress_iface)
{
progress_iface->start = gimp_statusbar_progress_start;
progress_iface->end = gimp_statusbar_progress_end;
progress_iface->is_active = gimp_statusbar_progress_is_active;
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;
......@@ -318,6 +320,14 @@ gimp_statusbar_progress_end (GimpProgress *progress)
}
}
static gboolean
gimp_statusbar_progress_is_active (GimpProgress *progress)
{
GimpStatusbar *statusbar = GIMP_STATUSBAR (progress);
return statusbar->progress_active;
}
static void
gimp_statusbar_progress_set_text (GimpProgress *progress,
const gchar *message)
......
......@@ -59,25 +59,21 @@ plug_in_progress_start (PlugIn *plug_in,
if (plug_in->progress)
{
if (plug_in->progress_active)
if (! plug_in->progress_cancel_id)
plug_in->progress_cancel_id =
g_signal_connect (plug_in->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel),
plug_in);
if (gimp_progress_is_active (plug_in->progress))
{
gimp_progress_set_text (plug_in->progress, message);
gimp_progress_set_value (plug_in->progress, 0.0);
return;
}
if (! gimp_progress_start (plug_in->progress, message, TRUE))
else
{
gimp_progress_set_text (plug_in->progress, message);
gimp_progress_set_value (plug_in->progress, 0.0);
gimp_progress_start (plug_in->progress, message, TRUE);
}
g_signal_connect (plug_in->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel),
plug_in);
plug_in->progress_active = TRUE;
}
}
......@@ -87,10 +83,14 @@ plug_in_progress_update (PlugIn *plug_in,
{
g_return_if_fail (plug_in != NULL);
if (! (plug_in->progress && plug_in->progress_active))
plug_in_progress_start (plug_in, NULL, -1);
if (! plug_in->progress ||
! gimp_progress_is_active (plug_in->progress) ||
! plug_in->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, -1);
}
if (plug_in->progress && plug_in->progress_active)
if (plug_in->progress && gimp_progress_is_active (plug_in->progress))
gimp_progress_set_value (plug_in->progress, percentage);
}
......@@ -101,16 +101,16 @@ plug_in_progress_end (PlugIn *plug_in)
if (plug_in->progress)
{
if (plug_in->progress_active)
if (plug_in->progress_cancel_id)
{
g_signal_handlers_disconnect_by_func (plug_in->progress,
plug_in_progress_cancel,
plug_in);
gimp_progress_end (plug_in->progress);
plug_in->progress_active = FALSE;
g_signal_handler_disconnect (plug_in->progress,
plug_in->progress_cancel_id);
plug_in->progress_cancel_id = 0;
}
if (gimp_progress_is_active (plug_in->progress))
gimp_progress_end (plug_in->progress);
if (plug_in->progress_created)
{
gimp_free_progress (plug_in->gimp, plug_in->progress);
......
......@@ -67,8 +67,8 @@ struct _PlugIn
gint n_return_vals;
GimpProgress *progress; /* Progress dialog */
gboolean progress_active; /* Is the progress currently used */
gboolean progress_created; /* Was the progress created by the plug-in */
gulong progress_cancel_id;
PlugInDef *plug_in_def; /* Valid only during query() and init() */
};
......
......@@ -59,25 +59,21 @@ plug_in_progress_start (PlugIn *plug_in,
if (plug_in->progress)
{
if (plug_in->progress_active)
if (! plug_in->progress_cancel_id)
plug_in->progress_cancel_id =
g_signal_connect (plug_in->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel),
plug_in);
if (gimp_progress_is_active (plug_in->progress))
{
gimp_progress_set_text (plug_in->progress, message);
gimp_progress_set_value (plug_in->progress, 0.0);
return;
}
if (! gimp_progress_start (plug_in->progress, message, TRUE))
else
{
gimp_progress_set_text (plug_in->progress, message);
gimp_progress_set_value (plug_in->progress, 0.0);
gimp_progress_start (plug_in->progress, message, TRUE);
}
g_signal_connect (plug_in->progress, "cancel",
G_CALLBACK (plug_in_progress_cancel),
plug_in);
plug_in->progress_active = TRUE;
}
}
......@@ -87,10 +83,14 @@ plug_in_progress_update (PlugIn *plug_in,
{
g_return_if_fail (plug_in != NULL);
if (! (plug_in->progress && plug_in->progress_active))
plug_in_progress_start (plug_in, NULL, -1);
if (! plug_in->progress ||
! gimp_progress_is_active (plug_in->progress) ||
! plug_in->progress_cancel_id)
{
plug_in_progress_start (plug_in, NULL, -1);
}
if (plug_in->progress && plug_in->progress_active)
if (plug_in->progress && gimp_progress_is_active (plug_in->progress))
gimp_progress_set_value (plug_in->progress, percentage);
}
......@@ -101,16 +101,16 @@ plug_in_progress_end (PlugIn *plug_in)
if (plug_in->progress)
{
if (plug_in->progress_active)
if (plug_in->progress_cancel_id)
{
g_signal_handlers_disconnect_by_func (plug_in->progress,
plug_in_progress_cancel,
plug_in);
gimp_progress_end (plug_in->progress);
plug_in->progress_active = FALSE;
g_signal_handler_disconnect (plug_in->progress,
plug_in->progress_cancel_id);
plug_in->progress_cancel_id = 0;
}
if (gimp_progress_is_active (plug_in->progress))
gimp_progress_end (plug_in->progress);
if (plug_in->progress_created)
{
gimp_free_progress (plug_in->gimp, plug_in->progress);
......
......@@ -67,8 +67,8 @@ struct _PlugIn
gint n_return_vals;
GimpProgress *progress; /* Progress dialog */
gboolean progress_active; /* Is the progress currently used */
gboolean progress_created; /* Was the progress created by the plug-in */
gulong progress_cancel_id;
PlugInDef *plug_in_def; /* Valid only during query() and init() */
};
......
......@@ -54,43 +54,44 @@
static void gimp_file_dialog_class_init (GimpFileDialogClass *klass);
static void gimp_file_dialog_progress_iface_init (GimpProgressInterface *progress_iface);
static gboolean gimp_file_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event);
static void gimp_file_dialog_response (GtkDialog *dialog,
gint response_id);
static gboolean gimp_file_dialog_delete_event (GtkWidget *widget,
GdkEventAny *event);
static void gimp_file_dialog_response (GtkDialog *dialog,
gint response_id);
static GimpProgress *
gimp_file_dialog_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_file_dialog_progress_end (GimpProgress *progress);
static void gimp_file_dialog_progress_set_text (GimpProgress *progress,
const gchar *message);
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_add_preview (GimpFileDialog *dialog,
Gimp *gimp);
static void gimp_file_dialog_add_filters (GimpFileDialog *dialog,
Gimp *gimp,
GSList *file_procs);
static void gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog,
Gimp *gimp,
GSList *file_procs,
const gchar *automatic,
const gchar *automatic_help_id);
static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser,
GimpFileDialog *dialog);
static void gimp_file_dialog_update_preview (GtkFileChooser *chooser,
GimpFileDialog *dialog);
static void gimp_file_dialog_proc_changed (GimpFileProcView *view,
GimpFileDialog *dialog);
static void gimp_file_dialog_help_func (const gchar *help_id,
gpointer help_data);
gimp_file_dialog_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_file_dialog_progress_end (GimpProgress *progress);
static gboolean gimp_file_dialog_progress_is_active (GimpProgress *progress);
static void gimp_file_dialog_progress_set_text (GimpProgress *progress,
const gchar *message);
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_add_preview (GimpFileDialog *dialog,
Gimp *gimp);
static void gimp_file_dialog_add_filters (GimpFileDialog *dialog,
Gimp *gimp,
GSList *file_procs);
static void gimp_file_dialog_add_proc_selection (GimpFileDialog *dialog,
Gimp *gimp,
GSList *file_procs,
const gchar *automatic,
const gchar *automatic_help_id);
static void gimp_file_dialog_selection_changed (GtkFileChooser *chooser,
GimpFileDialog *dialog);
static void gimp_file_dialog_update_preview (GtkFileChooser *chooser,
GimpFileDialog *dialog);
static void gimp_file_dialog_proc_changed (GimpFileProcView *view,
GimpFileDialog *dialog);
static void gimp_file_dialog_help_func (const gchar *help_id,
gpointer help_data);
......@@ -148,6 +149,7 @@ gimp_file_dialog_progress_iface_init (GimpProgressInterface *progress_iface)
{
progress_iface->start = gimp_file_dialog_progress_start;
progress_iface->end = gimp_file_dialog_progress_end;
progress_iface->is_active = gimp_file_dialog_progress_is_active;
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;
......@@ -219,6 +221,14 @@ gimp_file_dialog_progress_end (GimpProgress *progress)
}
}
static gboolean
gimp_file_dialog_progress_is_active (GimpProgress *progress)
{
GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
return dialog->progress_active;
}
static void
gimp_file_dialog_progress_set_text (GimpProgress *progress,
const gchar *message)
......
......@@ -34,20 +34,21 @@
#include "gimp-intl.h"
static void gimp_progress_box_class_init (GimpProgressBoxClass *klass);
static void gimp_progress_box_init (GimpProgressBox *box);
static void gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_progress_box_class_init (GimpProgressBoxClass *klass);
static void gimp_progress_box_init (GimpProgressBox *box);
static void gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface);
static GimpProgress *
gimp_progress_box_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_progress_box_progress_end (GimpProgress *progress);
static void gimp_progress_box_progress_set_text (GimpProgress *progress,
const gchar *message);
static void gimp_progress_box_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_progress_box_progress_get_value (GimpProgress *progress);
gimp_progress_box_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_progress_box_progress_end (GimpProgress *progress);
static gboolean gimp_progress_box_progress_is_active (GimpProgress *progress);
static void gimp_progress_box_progress_set_text (GimpProgress *progress,
const gchar *message);
static void gimp_progress_box_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_progress_box_progress_get_value (GimpProgress *progress);
static GtkVBoxClass *parent_class = NULL;
......@@ -107,6 +108,7 @@ gimp_progress_box_progress_iface_init (GimpProgressInterface *progress_iface)
{
progress_iface->start = gimp_progress_box_progress_start;
progress_iface->end = gimp_progress_box_progress_end;
progress_iface->is_active = gimp_progress_box_progress_is_active;
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;
......@@ -152,6 +154,14 @@ gimp_progress_box_progress_end (GimpProgress *progress)
}
}
static gboolean
gimp_progress_box_progress_is_active (GimpProgress *progress)
{
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
return box->active;
}
static void
gimp_progress_box_progress_set_text (GimpProgress *progress,
const gchar *message)
......
......@@ -35,23 +35,24 @@
#include "gimp-intl.h"
static void gimp_progress_dialog_class_init (GimpProgressDialogClass *klass);
static void gimp_progress_dialog_init (GimpProgressDialog *dialog);
static void gimp_progress_dialog_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_progress_dialog_class_init (GimpProgressDialogClass *klass);
static void gimp_progress_dialog_init (GimpProgressDialog *dialog);
static void gimp_progress_dialog_progress_iface_init (GimpProgressInterface *progress_iface);
static void gimp_progress_dialog_response (GtkDialog *dialog,
gint response_id);
static void gimp_progress_dialog_response (GtkDialog *dialog,
gint response_id);
static GimpProgress *
gimp_progress_dialog_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_progress_dialog_progress_end (GimpProgress *progress);
static void gimp_progress_dialog_progress_set_text (GimpProgress *progress,
const gchar *message);
static void gimp_progress_dialog_progress_set_value (GimpProgress *progress,
gdouble percentage);
static gdouble gimp_progress_dialog_progress_get_value (GimpProgress *progress);
gimp_progress_dialog_progress_start (GimpProgress *progress,
const gchar *message,
gboolean cancelable);
static void gimp_progress_dialog_progress_end (GimpProgress *progress);
static gboolean gimp_progress_dialog_progress_is_active (GimpProgress *progress);
static void gimp_progress_dialog_progress_set_text (GimpProgress *progress,